x-tql-session-service 1.19.4
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/README.md +24 -0
- package/fesm2022/x-tql-session-service.mjs +332 -0
- package/fesm2022/x-tql-session-service.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/tql-session-service-configuration.d.ts +24 -0
- package/lib/tql-session-service.component.d.ts +5 -0
- package/lib/tql-session-service.module.d.ts +14 -0
- package/lib/tql-session-timeout-dialog/tql-session-timeout-dialog.component.d.ts +16 -0
- package/lib/tql-session.service.d.ts +41 -0
- package/package.json +23 -0
- package/public-api.d.ts +4 -0
package/README.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# TqlSessionService
|
|
2
|
+
|
|
3
|
+
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 15.1.0.
|
|
4
|
+
|
|
5
|
+
## Code scaffolding
|
|
6
|
+
|
|
7
|
+
Run `ng generate component component-name --project tql-session-service` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project tql-session-service`.
|
|
8
|
+
> Note: Don't forget to add `--project tql-session-service` or else it will be added to the default project in your `angular.json` file.
|
|
9
|
+
|
|
10
|
+
## Build
|
|
11
|
+
|
|
12
|
+
Run `ng build tql-session-service` to build the project. The build artifacts will be stored in the `dist/` directory.
|
|
13
|
+
|
|
14
|
+
## Publishing
|
|
15
|
+
|
|
16
|
+
After building your library with `ng build tql-session-service`, go to the dist folder `cd dist/tql-session-service` and run `npm publish`.
|
|
17
|
+
|
|
18
|
+
## Running unit tests
|
|
19
|
+
|
|
20
|
+
Run `ng test tql-session-service` to execute the unit tests via [Karma](https://karma-runner.github.io).
|
|
21
|
+
|
|
22
|
+
## Further help
|
|
23
|
+
|
|
24
|
+
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
|
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Inject, Component, Injectable, NgModule } from '@angular/core';
|
|
3
|
+
import * as i3$1 from 'x-tql-service';
|
|
4
|
+
import { DefaultDialogComponent, TqlServiceModule } from 'x-tql-service';
|
|
5
|
+
import * as i1 from '@angular/material/dialog';
|
|
6
|
+
import { MAT_DIALOG_DATA } from '@angular/material/dialog';
|
|
7
|
+
import * as i2 from '@angular/material/button';
|
|
8
|
+
import * as i3 from '@angular/common';
|
|
9
|
+
import { CommonModule } from '@angular/common';
|
|
10
|
+
import { BehaviorSubject } from 'rxjs';
|
|
11
|
+
import * as i2$1 from '@angular/router';
|
|
12
|
+
import { MaterialsModule } from 'x-tql-theme';
|
|
13
|
+
|
|
14
|
+
class TqlSessionServiceConfiguration {
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
class TqlSessionTimeoutDialogComponent extends DefaultDialogComponent {
|
|
18
|
+
static { this.DEFAULT_WIDTH = '500px'; }
|
|
19
|
+
constructor(_MatDialogRef, dialogData) {
|
|
20
|
+
super(_MatDialogRef);
|
|
21
|
+
this._MatDialogRef = _MatDialogRef;
|
|
22
|
+
this.dialogData = dialogData;
|
|
23
|
+
this.data = dialogData?.dialog;
|
|
24
|
+
this.data.start();
|
|
25
|
+
}
|
|
26
|
+
ngOnInit() { }
|
|
27
|
+
onConfirm() {
|
|
28
|
+
this.onClose();
|
|
29
|
+
this.data.continue();
|
|
30
|
+
}
|
|
31
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: TqlSessionTimeoutDialogComponent, deps: [{ token: i1.MatDialogRef }, { token: MAT_DIALOG_DATA }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
32
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.17", type: TqlSessionTimeoutDialogComponent, isStandalone: false, selector: "lib-tql-session-timeout-dialog", usesInheritance: true, ngImport: i0, template: "<div class=\"dashboard-content ei-emission-source-create-dialog h-100 d-flex flex-column\">\n <div class=\"\">\n <div\n class=\"font-size-16px font-weight-medium d-flex align-items-center justify-content-between p-3\">\n <div class=\"color-black\">Session Expired</div>\n </div>\n </div>\n <div class=\"d-flex flex-shrink-1 flex-grow-1 overflow-hidden\">\n <div class=\"d-flex w-100\">\n <div class=\"p-20px flex-shrink-1 flex-grow-1 position-relative\">\n <div class=\"step-1 d-flex flex-column flex-gap-3\">\n <div class=\"color-black\">\n Your session is going to be expired in <span\n class=\"font-weight-bold\">{{ (data?.counter$ | async) / 1000 }}\n seconds</span>.\n </div>\n <div class=\"color-black\">Please click on the button below to extend your session.</div>\n </div>\n </div>\n\n </div>\n </div>\n <div class=\"py-3 px-20px d-flex flex-gap-3 justify-content-end\">\n <button mat-button class=\"btn btn-green color-white\" (click)=\"onConfirm()\">Continue Session</button>\n </div>\n</div>\n", styles: [""], dependencies: [{ kind: "component", type: i2.MatButton, selector: " button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button] ", exportAs: ["matButton"] }, { kind: "pipe", type: i3.AsyncPipe, name: "async" }] }); }
|
|
33
|
+
}
|
|
34
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: TqlSessionTimeoutDialogComponent, decorators: [{
|
|
35
|
+
type: Component,
|
|
36
|
+
args: [{ selector: 'lib-tql-session-timeout-dialog', standalone: false, template: "<div class=\"dashboard-content ei-emission-source-create-dialog h-100 d-flex flex-column\">\n <div class=\"\">\n <div\n class=\"font-size-16px font-weight-medium d-flex align-items-center justify-content-between p-3\">\n <div class=\"color-black\">Session Expired</div>\n </div>\n </div>\n <div class=\"d-flex flex-shrink-1 flex-grow-1 overflow-hidden\">\n <div class=\"d-flex w-100\">\n <div class=\"p-20px flex-shrink-1 flex-grow-1 position-relative\">\n <div class=\"step-1 d-flex flex-column flex-gap-3\">\n <div class=\"color-black\">\n Your session is going to be expired in <span\n class=\"font-weight-bold\">{{ (data?.counter$ | async) / 1000 }}\n seconds</span>.\n </div>\n <div class=\"color-black\">Please click on the button below to extend your session.</div>\n </div>\n </div>\n\n </div>\n </div>\n <div class=\"py-3 px-20px d-flex flex-gap-3 justify-content-end\">\n <button mat-button class=\"btn btn-green color-white\" (click)=\"onConfirm()\">Continue Session</button>\n </div>\n</div>\n" }]
|
|
37
|
+
}], ctorParameters: () => [{ type: i1.MatDialogRef }, { type: undefined, decorators: [{
|
|
38
|
+
type: Inject,
|
|
39
|
+
args: [MAT_DIALOG_DATA]
|
|
40
|
+
}] }] });
|
|
41
|
+
|
|
42
|
+
var _a;
|
|
43
|
+
class TqlSessionService {
|
|
44
|
+
#sessionTimeout;
|
|
45
|
+
#checkingIntervalValue = _a.DEFAULT_CHECKING_INTERVAL;
|
|
46
|
+
#checkingInterval;
|
|
47
|
+
// isSessionTimeoutDialogOpened$: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
|
|
48
|
+
#dialog = null;
|
|
49
|
+
#clickFn = () => {
|
|
50
|
+
this.#resetTimeout();
|
|
51
|
+
};
|
|
52
|
+
constructor(_TqlSessionServiceConfiguration, _Router, _TqlDialogControllerService) {
|
|
53
|
+
this._TqlSessionServiceConfiguration = _TqlSessionServiceConfiguration;
|
|
54
|
+
this._Router = _Router;
|
|
55
|
+
this._TqlDialogControllerService = _TqlDialogControllerService;
|
|
56
|
+
}
|
|
57
|
+
test() {
|
|
58
|
+
this.#openSessionTimeoutDialog();
|
|
59
|
+
}
|
|
60
|
+
start(isResetTimeout = true) {
|
|
61
|
+
if (!this._TqlSessionServiceConfiguration.expiredCallback) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
// this.#clearSession();
|
|
65
|
+
if (isResetTimeout) {
|
|
66
|
+
this.#resetTimeout();
|
|
67
|
+
}
|
|
68
|
+
this.#onClickToReset();
|
|
69
|
+
if (this.#checkingInterval) {
|
|
70
|
+
clearInterval(this.#checkingInterval);
|
|
71
|
+
}
|
|
72
|
+
this.#checkingInterval = setInterval(() => {
|
|
73
|
+
// console.log('checkingInterval');
|
|
74
|
+
try {
|
|
75
|
+
const localSession = this.#loadSession();
|
|
76
|
+
this.#sessionTimeout = localSession.currentSessionValue - this.#checkingIntervalValue;
|
|
77
|
+
if (this.#sessionTimeout <= 0) {
|
|
78
|
+
clearInterval(this.#checkingInterval);
|
|
79
|
+
this.#openSessionTimeoutDialog();
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
this.#saveSession({
|
|
83
|
+
expiredSessionValue: localSession.expiredSessionValue,
|
|
84
|
+
currentSessionValue: this.#sessionTimeout,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
catch (e) {
|
|
89
|
+
clearInterval(this.#checkingInterval);
|
|
90
|
+
this.#openSessionTimeoutDialog();
|
|
91
|
+
}
|
|
92
|
+
}, this.#checkingIntervalValue);
|
|
93
|
+
}
|
|
94
|
+
stop(shouldExecuteCallback = false) {
|
|
95
|
+
if (shouldExecuteCallback) {
|
|
96
|
+
this.#executeExpiredCallback();
|
|
97
|
+
}
|
|
98
|
+
this.#clearSession();
|
|
99
|
+
}
|
|
100
|
+
reset(isResetTimeout = true) {
|
|
101
|
+
this.start(isResetTimeout);
|
|
102
|
+
}
|
|
103
|
+
isRunning() {
|
|
104
|
+
return localStorage.getItem(_a.TQL_SESSION_SERVICE_CONFIG) !== null;
|
|
105
|
+
}
|
|
106
|
+
#openSessionTimeoutDialog() {
|
|
107
|
+
document.removeEventListener('click', this.#clickFn);
|
|
108
|
+
// this.isSessionTimeoutDialogOpened$.next(true);
|
|
109
|
+
this.#dialog = new _a.Dialog(this);
|
|
110
|
+
this._TqlDialogControllerService
|
|
111
|
+
.open(this._TqlSessionServiceConfiguration?.dialogTemplate || TqlSessionTimeoutDialogComponent, {
|
|
112
|
+
dialog: this.#dialog,
|
|
113
|
+
}, {
|
|
114
|
+
callback: (dialog) => {
|
|
115
|
+
this.#dialog.dialogObj = dialog;
|
|
116
|
+
},
|
|
117
|
+
})
|
|
118
|
+
.then((result) => {
|
|
119
|
+
// console.log('close', result);
|
|
120
|
+
// this.isSessionTimeoutDialogOpened$.next(false);
|
|
121
|
+
this.#dialog?.end();
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
#executeExpiredCallback() {
|
|
125
|
+
if (!!this._TqlSessionServiceConfiguration.expiredCallback) {
|
|
126
|
+
this._TqlSessionServiceConfiguration.expiredCallback(this._Router);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
#onClickToReset() {
|
|
130
|
+
// add listener click to any place in UI to reset session
|
|
131
|
+
// remove click listener before add
|
|
132
|
+
document.removeEventListener('click', this.#clickFn);
|
|
133
|
+
document.addEventListener('click', this.#clickFn);
|
|
134
|
+
}
|
|
135
|
+
#resetTimeout() {
|
|
136
|
+
// default 20 minutes
|
|
137
|
+
this.#sessionTimeout =
|
|
138
|
+
this._TqlSessionServiceConfiguration.timeout || _a.DEFAULT_SESSION_TIMEOUT;
|
|
139
|
+
this.#saveSession({ expiredSessionValue: this.#sessionTimeout, currentSessionValue: this.#sessionTimeout });
|
|
140
|
+
}
|
|
141
|
+
#saveSession(session) {
|
|
142
|
+
localStorage.setItem(_a.TQL_SESSION_SERVICE_CONFIG, JSON.stringify(session));
|
|
143
|
+
}
|
|
144
|
+
#loadSession() {
|
|
145
|
+
const session = localStorage.getItem(_a.TQL_SESSION_SERVICE_CONFIG);
|
|
146
|
+
if (session) {
|
|
147
|
+
return JSON.parse(session);
|
|
148
|
+
}
|
|
149
|
+
return {
|
|
150
|
+
expiredSessionValue: 0,
|
|
151
|
+
currentSessionValue: 0,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
#clearSession() {
|
|
155
|
+
if (this.#checkingInterval) {
|
|
156
|
+
clearInterval(this.#checkingInterval);
|
|
157
|
+
}
|
|
158
|
+
localStorage.removeItem(_a.TQL_SESSION_SERVICE_CONFIG);
|
|
159
|
+
}
|
|
160
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: TqlSessionService, deps: [{ token: TqlSessionServiceConfiguration }, { token: i2$1.Router }, { token: i3$1.TqlDialogControllerService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
161
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: TqlSessionService, providedIn: 'root' }); }
|
|
162
|
+
}
|
|
163
|
+
_a = TqlSessionService;
|
|
164
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: TqlSessionService, decorators: [{
|
|
165
|
+
type: Injectable,
|
|
166
|
+
args: [{
|
|
167
|
+
providedIn: 'root',
|
|
168
|
+
}]
|
|
169
|
+
}], ctorParameters: () => [{ type: TqlSessionServiceConfiguration }, { type: i2$1.Router }, { type: i3$1.TqlDialogControllerService }] });
|
|
170
|
+
(function (TqlSessionService) {
|
|
171
|
+
TqlSessionService.DEFAULT_SESSION_TIMEOUT = 1200000;
|
|
172
|
+
TqlSessionService.DEFAULT_CHECKING_INTERVAL = 30000;
|
|
173
|
+
TqlSessionService.TQL_SESSION_SERVICE_CONFIG = 'TQL_SESSION_SERVICE_CONFIG';
|
|
174
|
+
TqlSessionService.TQL_SESSION_TIMEOUT_DIALOG_CONFIG = 'TQL_SESSION_TIMEOUT_DIALOG_CONFIG';
|
|
175
|
+
TqlSessionService.DEFAULT_TIMEOUT_VALUE = 30000;
|
|
176
|
+
TqlSessionService.DEFAULT_INTERVAL = 1000;
|
|
177
|
+
class Dialog {
|
|
178
|
+
// dialog
|
|
179
|
+
#dialogTimeout;
|
|
180
|
+
#dialogTimeoutValue;
|
|
181
|
+
#dialogInterval;
|
|
182
|
+
#dialogIntervalValue;
|
|
183
|
+
constructor(_TqlSessionService) {
|
|
184
|
+
this._TqlSessionService = _TqlSessionService;
|
|
185
|
+
this.#dialogTimeoutValue = TqlSessionService.DEFAULT_TIMEOUT_VALUE;
|
|
186
|
+
this.#dialogIntervalValue = TqlSessionService.DEFAULT_INTERVAL;
|
|
187
|
+
this.counter$ = new BehaviorSubject(0);
|
|
188
|
+
}
|
|
189
|
+
start() {
|
|
190
|
+
this.#reset();
|
|
191
|
+
}
|
|
192
|
+
end() {
|
|
193
|
+
if (this.#dialogInterval) {
|
|
194
|
+
clearInterval(this.#dialogInterval);
|
|
195
|
+
}
|
|
196
|
+
this.#onClose();
|
|
197
|
+
}
|
|
198
|
+
continue() {
|
|
199
|
+
if (this.#dialogInterval) {
|
|
200
|
+
clearInterval(this.#dialogInterval);
|
|
201
|
+
}
|
|
202
|
+
this.#onClose();
|
|
203
|
+
this._TqlSessionService.reset();
|
|
204
|
+
}
|
|
205
|
+
#reset() {
|
|
206
|
+
if (this.#dialogInterval) {
|
|
207
|
+
clearInterval(this.#dialogInterval);
|
|
208
|
+
}
|
|
209
|
+
this.#setTimer();
|
|
210
|
+
}
|
|
211
|
+
#setTimer() {
|
|
212
|
+
this.#dialogTimeout = this.#dialogTimeoutValue;
|
|
213
|
+
this.counter$.next(this.#dialogTimeout);
|
|
214
|
+
this.#saveLocalSession({
|
|
215
|
+
expiredSessionValue: this.#dialogTimeoutValue,
|
|
216
|
+
currentSessionValue: this.#dialogTimeout,
|
|
217
|
+
});
|
|
218
|
+
this.#dialogInterval = setInterval(() => {
|
|
219
|
+
const continuous = this.#checkLocalStorage();
|
|
220
|
+
if (!continuous) {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
this.#dialogTimeout = this.#loadLocalSession().currentSessionValue;
|
|
224
|
+
this.#dialogTimeout -= this.#dialogIntervalValue;
|
|
225
|
+
this.counter$.next(this.#dialogTimeout);
|
|
226
|
+
this.#saveLocalSession({
|
|
227
|
+
expiredSessionValue: this.#dialogTimeoutValue,
|
|
228
|
+
currentSessionValue: this.#dialogTimeout,
|
|
229
|
+
});
|
|
230
|
+
if (this.#dialogTimeout <= 0) {
|
|
231
|
+
this.#onExpired();
|
|
232
|
+
}
|
|
233
|
+
}, this.#dialogIntervalValue);
|
|
234
|
+
}
|
|
235
|
+
#checkLocalStorage() {
|
|
236
|
+
if (!this._TqlSessionService.isRunning()) {
|
|
237
|
+
this.#onExpired();
|
|
238
|
+
return false;
|
|
239
|
+
}
|
|
240
|
+
if (localStorage.getItem(TqlSessionService.TQL_SESSION_TIMEOUT_DIALOG_CONFIG) === null) {
|
|
241
|
+
console.log('close');
|
|
242
|
+
this.#onClose();
|
|
243
|
+
this._TqlSessionService.reset(false);
|
|
244
|
+
return false;
|
|
245
|
+
}
|
|
246
|
+
return true;
|
|
247
|
+
}
|
|
248
|
+
#onExpired() {
|
|
249
|
+
console.log('expired');
|
|
250
|
+
this.#onClose();
|
|
251
|
+
this._TqlSessionService.stop(true);
|
|
252
|
+
}
|
|
253
|
+
#onClose() {
|
|
254
|
+
if (this.#dialogInterval) {
|
|
255
|
+
clearInterval(this.#dialogInterval);
|
|
256
|
+
}
|
|
257
|
+
this.#clearLocalSession();
|
|
258
|
+
// this._TqlSessionServiceService.isSessionTimeoutDialogOpened$.next(false);
|
|
259
|
+
this.dialogObj.close();
|
|
260
|
+
}
|
|
261
|
+
#saveLocalSession(session) {
|
|
262
|
+
localStorage.setItem(TqlSessionService.TQL_SESSION_TIMEOUT_DIALOG_CONFIG, JSON.stringify(session));
|
|
263
|
+
}
|
|
264
|
+
#loadLocalSession() {
|
|
265
|
+
const session = localStorage.getItem(TqlSessionService.TQL_SESSION_TIMEOUT_DIALOG_CONFIG);
|
|
266
|
+
if (session) {
|
|
267
|
+
return JSON.parse(session);
|
|
268
|
+
}
|
|
269
|
+
return {
|
|
270
|
+
expiredSessionValue: 0,
|
|
271
|
+
currentSessionValue: 0,
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
#clearLocalSession() {
|
|
275
|
+
localStorage.removeItem(TqlSessionService.TQL_SESSION_TIMEOUT_DIALOG_CONFIG);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
TqlSessionService.Dialog = Dialog;
|
|
279
|
+
})(TqlSessionService || (TqlSessionService = {}));
|
|
280
|
+
|
|
281
|
+
class TqlSessionServiceComponent {
|
|
282
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: TqlSessionServiceComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
283
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.17", type: TqlSessionServiceComponent, isStandalone: false, selector: "lib-tql-session-service", ngImport: i0, template: `
|
|
284
|
+
<p>
|
|
285
|
+
tql-session-service works!
|
|
286
|
+
</p>
|
|
287
|
+
`, isInline: true }); }
|
|
288
|
+
}
|
|
289
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: TqlSessionServiceComponent, decorators: [{
|
|
290
|
+
type: Component,
|
|
291
|
+
args: [{ selector: 'lib-tql-session-service', standalone: false, template: `
|
|
292
|
+
<p>
|
|
293
|
+
tql-session-service works!
|
|
294
|
+
</p>
|
|
295
|
+
` }]
|
|
296
|
+
}] });
|
|
297
|
+
|
|
298
|
+
class TqlSessionServiceModule {
|
|
299
|
+
static forRoot(libConfiguration) {
|
|
300
|
+
return {
|
|
301
|
+
ngModule: TqlSessionServiceModule,
|
|
302
|
+
providers: [
|
|
303
|
+
{
|
|
304
|
+
provide: TqlSessionServiceConfiguration,
|
|
305
|
+
useValue: libConfiguration,
|
|
306
|
+
},
|
|
307
|
+
],
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: TqlSessionServiceModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
311
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.17", ngImport: i0, type: TqlSessionServiceModule, declarations: [TqlSessionServiceComponent, TqlSessionTimeoutDialogComponent], imports: [TqlServiceModule, MaterialsModule, CommonModule], exports: [TqlSessionServiceComponent] }); }
|
|
312
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: TqlSessionServiceModule, imports: [TqlServiceModule, MaterialsModule, CommonModule] }); }
|
|
313
|
+
}
|
|
314
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: TqlSessionServiceModule, decorators: [{
|
|
315
|
+
type: NgModule,
|
|
316
|
+
args: [{
|
|
317
|
+
declarations: [TqlSessionServiceComponent, TqlSessionTimeoutDialogComponent],
|
|
318
|
+
imports: [TqlServiceModule, MaterialsModule, CommonModule],
|
|
319
|
+
exports: [TqlSessionServiceComponent],
|
|
320
|
+
}]
|
|
321
|
+
}] });
|
|
322
|
+
|
|
323
|
+
/*
|
|
324
|
+
* Public API Surface of tql-session-service
|
|
325
|
+
*/
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Generated bundle index. Do not edit.
|
|
329
|
+
*/
|
|
330
|
+
|
|
331
|
+
export { TqlSessionService, TqlSessionServiceComponent, TqlSessionServiceConfiguration, TqlSessionServiceModule };
|
|
332
|
+
//# sourceMappingURL=x-tql-session-service.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"x-tql-session-service.mjs","sources":["../../../projects/tql-session-service/src/lib/tql-session-service-configuration.ts","../../../projects/tql-session-service/src/lib/tql-session-timeout-dialog/tql-session-timeout-dialog.component.ts","../../../projects/tql-session-service/src/lib/tql-session-timeout-dialog/tql-session-timeout-dialog.component.html","../../../projects/tql-session-service/src/lib/tql-session.service.ts","../../../projects/tql-session-service/src/lib/tql-session-service.component.ts","../../../projects/tql-session-service/src/lib/tql-session-service.module.ts","../../../projects/tql-session-service/src/public-api.ts","../../../projects/tql-session-service/src/x-tql-session-service.ts"],"sourcesContent":["import { Router } from '@angular/router';\nimport { DefaultDialogComponent } from 'x-tql-service';\n\nexport class TqlSessionServiceConfiguration {\n /**\n * Timeout in milliseconds\n * @type {number}\n */\n timeout?: number;\n /**\n * title\n * @type {string}\n */\n title?: string;\n /**\n * Callback when session expired\n * @type {(router: Router) => void}\n */\n expiredCallback?: (router: Router) => void;\n\n /**\n * Template for confirm dialog\n * @type {Component}\n */\n dialogTemplate?: typeof DefaultDialogComponent;\n}\n","import { Component, Inject, OnInit } from '@angular/core';\nimport { DefaultDialogComponent } from 'x-tql-service';\nimport { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';\nimport { TqlSessionService } from '../tql-session.service';\n\n@Component({\n selector: 'lib-tql-session-timeout-dialog',\n standalone: false,\n templateUrl: './tql-session-timeout-dialog.component.html',\n styleUrls: ['./tql-session-timeout-dialog.component.css'],\n})\nexport class TqlSessionTimeoutDialogComponent extends DefaultDialogComponent implements OnInit {\n static override DEFAULT_WIDTH = '500px';\n data: TqlSessionService.Dialog;\n\n constructor(\n public _MatDialogRef: MatDialogRef<DefaultDialogComponent>,\n @Inject(MAT_DIALOG_DATA) public dialogData: any,\n ) {\n super(_MatDialogRef);\n this.data = dialogData?.dialog;\n this.data.start();\n }\n\n ngOnInit() {}\n\n onConfirm() {\n this.onClose();\n this.data.continue();\n }\n}\n","<div class=\"dashboard-content ei-emission-source-create-dialog h-100 d-flex flex-column\">\n <div class=\"\">\n <div\n class=\"font-size-16px font-weight-medium d-flex align-items-center justify-content-between p-3\">\n <div class=\"color-black\">Session Expired</div>\n </div>\n </div>\n <div class=\"d-flex flex-shrink-1 flex-grow-1 overflow-hidden\">\n <div class=\"d-flex w-100\">\n <div class=\"p-20px flex-shrink-1 flex-grow-1 position-relative\">\n <div class=\"step-1 d-flex flex-column flex-gap-3\">\n <div class=\"color-black\">\n Your session is going to be expired in <span\n class=\"font-weight-bold\">{{ (data?.counter$ | async) / 1000 }}\n seconds</span>.\n </div>\n <div class=\"color-black\">Please click on the button below to extend your session.</div>\n </div>\n </div>\n\n </div>\n </div>\n <div class=\"py-3 px-20px d-flex flex-gap-3 justify-content-end\">\n <button mat-button class=\"btn btn-green color-white\" (click)=\"onConfirm()\">Continue Session</button>\n </div>\n</div>\n","import { Injectable } from '@angular/core';\nimport { TqlSessionServiceConfiguration } from './tql-session-service-configuration';\nimport { Router } from '@angular/router';\nimport { TqlDialogControllerService } from 'x-tql-service';\nimport { TqlSessionTimeoutDialogComponent } from './tql-session-timeout-dialog/tql-session-timeout-dialog.component';\nimport { BehaviorSubject } from 'rxjs';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class TqlSessionService {\n #sessionTimeout: number;\n #checkingIntervalValue: number = TqlSessionService.DEFAULT_CHECKING_INTERVAL;\n #checkingInterval: any;\n\n // isSessionTimeoutDialogOpened$: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);\n\n #dialog: TqlSessionService.Dialog | null = null;\n\n #clickFn = () => {\n this.#resetTimeout();\n };\n\n constructor(\n private readonly _TqlSessionServiceConfiguration: TqlSessionServiceConfiguration,\n private _Router: Router,\n private _TqlDialogControllerService: TqlDialogControllerService,\n ) {}\n\n test() {\n this.#openSessionTimeoutDialog();\n }\n\n start(isResetTimeout: boolean = true) {\n if (!this._TqlSessionServiceConfiguration.expiredCallback) {\n return;\n }\n // this.#clearSession();\n\n if (isResetTimeout) {\n this.#resetTimeout();\n }\n\n this.#onClickToReset();\n\n if (this.#checkingInterval) {\n clearInterval(this.#checkingInterval);\n }\n\n this.#checkingInterval = setInterval(() => {\n // console.log('checkingInterval');\n try {\n const localSession = this.#loadSession();\n this.#sessionTimeout = localSession.currentSessionValue - this.#checkingIntervalValue;\n if (this.#sessionTimeout <= 0) {\n clearInterval(this.#checkingInterval);\n this.#openSessionTimeoutDialog();\n } else {\n this.#saveSession({\n expiredSessionValue: localSession.expiredSessionValue,\n currentSessionValue: this.#sessionTimeout,\n });\n }\n } catch (e) {\n clearInterval(this.#checkingInterval);\n this.#openSessionTimeoutDialog();\n }\n }, this.#checkingIntervalValue);\n }\n\n stop(shouldExecuteCallback: boolean = false) {\n if (shouldExecuteCallback) {\n this.#executeExpiredCallback();\n }\n this.#clearSession();\n }\n\n reset(isResetTimeout: boolean = true) {\n this.start(isResetTimeout);\n }\n\n isRunning() {\n return localStorage.getItem(TqlSessionService.TQL_SESSION_SERVICE_CONFIG) !== null;\n }\n\n #openSessionTimeoutDialog() {\n document.removeEventListener('click', this.#clickFn);\n // this.isSessionTimeoutDialogOpened$.next(true);\n this.#dialog = new TqlSessionService.Dialog(this);\n this._TqlDialogControllerService\n .open(\n this._TqlSessionServiceConfiguration?.dialogTemplate || TqlSessionTimeoutDialogComponent,\n {\n dialog: this.#dialog,\n },\n {\n callback: (dialog: any) => {\n this.#dialog!.dialogObj = dialog;\n },\n },\n )\n .then((result) => {\n // console.log('close', result);\n // this.isSessionTimeoutDialogOpened$.next(false);\n this.#dialog?.end();\n });\n }\n\n #executeExpiredCallback() {\n if (!!this._TqlSessionServiceConfiguration.expiredCallback) {\n this._TqlSessionServiceConfiguration.expiredCallback(this._Router);\n }\n }\n\n #onClickToReset() {\n // add listener click to any place in UI to reset session\n // remove click listener before add\n document.removeEventListener('click', this.#clickFn);\n document.addEventListener('click', this.#clickFn);\n }\n\n #resetTimeout() {\n // default 20 minutes\n this.#sessionTimeout =\n this._TqlSessionServiceConfiguration.timeout || TqlSessionService.DEFAULT_SESSION_TIMEOUT;\n this.#saveSession({ expiredSessionValue: this.#sessionTimeout, currentSessionValue: this.#sessionTimeout });\n }\n\n #saveSession(session: TqlSessionService.ISession) {\n localStorage.setItem(TqlSessionService.TQL_SESSION_SERVICE_CONFIG, JSON.stringify(session));\n }\n\n #loadSession(): TqlSessionService.ISession {\n const session = localStorage.getItem(TqlSessionService.TQL_SESSION_SERVICE_CONFIG);\n if (session) {\n return JSON.parse(session);\n }\n return {\n expiredSessionValue: 0,\n currentSessionValue: 0,\n };\n }\n\n #clearSession() {\n if (this.#checkingInterval) {\n clearInterval(this.#checkingInterval);\n }\n localStorage.removeItem(TqlSessionService.TQL_SESSION_SERVICE_CONFIG);\n }\n}\n\nexport namespace TqlSessionService {\n export const DEFAULT_SESSION_TIMEOUT = 1200000;\n export const DEFAULT_CHECKING_INTERVAL = 30000;\n export const TQL_SESSION_SERVICE_CONFIG = 'TQL_SESSION_SERVICE_CONFIG';\n\n export const TQL_SESSION_TIMEOUT_DIALOG_CONFIG = 'TQL_SESSION_TIMEOUT_DIALOG_CONFIG';\n export const DEFAULT_TIMEOUT_VALUE = 30000;\n export const DEFAULT_INTERVAL = 1000;\n\n export interface ISession {\n expiredSessionValue: number;\n currentSessionValue: number;\n }\n\n export class Dialog {\n // dialog\n #dialogTimeout: number;\n #dialogTimeoutValue: number = TqlSessionService.DEFAULT_TIMEOUT_VALUE;\n #dialogInterval: any;\n #dialogIntervalValue: number = TqlSessionService.DEFAULT_INTERVAL;\n\n dialogObj: any;\n\n counter$: BehaviorSubject<number> = new BehaviorSubject<number>(0);\n\n constructor(private _TqlSessionService: TqlSessionService) {}\n\n start() {\n this.#reset();\n }\n\n end() {\n if (this.#dialogInterval) {\n clearInterval(this.#dialogInterval);\n }\n this.#onClose();\n }\n\n continue() {\n if (this.#dialogInterval) {\n clearInterval(this.#dialogInterval);\n }\n this.#onClose();\n this._TqlSessionService.reset();\n }\n\n #reset() {\n if (this.#dialogInterval) {\n clearInterval(this.#dialogInterval);\n }\n this.#setTimer();\n }\n\n #setTimer() {\n this.#dialogTimeout = this.#dialogTimeoutValue;\n this.counter$.next(this.#dialogTimeout);\n this.#saveLocalSession({\n expiredSessionValue: this.#dialogTimeoutValue,\n currentSessionValue: this.#dialogTimeout,\n });\n this.#dialogInterval = setInterval(() => {\n const continuous = this.#checkLocalStorage();\n if (!continuous) {\n return;\n }\n this.#dialogTimeout = this.#loadLocalSession().currentSessionValue;\n this.#dialogTimeout -= this.#dialogIntervalValue;\n this.counter$.next(this.#dialogTimeout);\n this.#saveLocalSession({\n expiredSessionValue: this.#dialogTimeoutValue,\n currentSessionValue: this.#dialogTimeout,\n });\n if (this.#dialogTimeout <= 0) {\n this.#onExpired();\n }\n }, this.#dialogIntervalValue);\n }\n\n #checkLocalStorage() {\n if (!this._TqlSessionService.isRunning()) {\n this.#onExpired();\n return false;\n }\n if (localStorage.getItem(TqlSessionService.TQL_SESSION_TIMEOUT_DIALOG_CONFIG) === null) {\n console.log('close');\n this.#onClose();\n this._TqlSessionService.reset(false);\n return false;\n }\n return true;\n }\n\n #onExpired() {\n console.log('expired');\n this.#onClose();\n this._TqlSessionService.stop(true);\n }\n\n #onClose() {\n if (this.#dialogInterval) {\n clearInterval(this.#dialogInterval);\n }\n this.#clearLocalSession();\n // this._TqlSessionServiceService.isSessionTimeoutDialogOpened$.next(false);\n this.dialogObj.close();\n }\n\n #saveLocalSession(session: any) {\n localStorage.setItem(TqlSessionService.TQL_SESSION_TIMEOUT_DIALOG_CONFIG, JSON.stringify(session));\n }\n\n #loadLocalSession() {\n const session = localStorage.getItem(TqlSessionService.TQL_SESSION_TIMEOUT_DIALOG_CONFIG);\n if (session) {\n return JSON.parse(session);\n }\n return {\n expiredSessionValue: 0,\n currentSessionValue: 0,\n };\n }\n\n #clearLocalSession() {\n localStorage.removeItem(TqlSessionService.TQL_SESSION_TIMEOUT_DIALOG_CONFIG);\n }\n }\n}\n","import { Component } from '@angular/core';\n\n@Component({\n selector: 'lib-tql-session-service',\n standalone: false,\n template: `\n <p>\n tql-session-service works!\n </p>\n `,\n styles: [\n ]\n})\nexport class TqlSessionServiceComponent {\n\n}\n","import { ModuleWithProviders, NgModule } from '@angular/core';\nimport { TqlSessionServiceComponent } from './tql-session-service.component';\nimport { TqlSessionServiceConfiguration } from './tql-session-service-configuration';\nimport { TqlSessionTimeoutDialogComponent } from './tql-session-timeout-dialog/tql-session-timeout-dialog.component';\nimport { TqlServiceModule } from 'x-tql-service';\nimport { MaterialsModule } from 'x-tql-theme';\nimport { CommonModule } from '@angular/common';\n\n@NgModule({\n declarations: [TqlSessionServiceComponent, TqlSessionTimeoutDialogComponent],\n imports: [TqlServiceModule, MaterialsModule, CommonModule],\n exports: [TqlSessionServiceComponent],\n})\nexport class TqlSessionServiceModule {\n static forRoot(libConfiguration: TqlSessionServiceConfiguration): ModuleWithProviders<TqlSessionServiceModule> {\n return {\n ngModule: TqlSessionServiceModule,\n providers: [\n {\n provide: TqlSessionServiceConfiguration,\n useValue: libConfiguration,\n },\n ],\n };\n }\n}\n","/*\n * Public API Surface of tql-session-service\n */\nexport * from './lib/tql-session-service-configuration';\nexport * from './lib/tql-session.service';\nexport * from './lib/tql-session-service.component';\nexport * from './lib/tql-session-service.module';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i1.TqlSessionServiceConfiguration","i2","i3"],"mappings":";;;;;;;;;;;;;MAGa,8BAA8B,CAAA;AAsB1C;;ACdK,MAAO,gCAAiC,SAAQ,sBAAsB,CAAA;aACxD,IAAa,CAAA,aAAA,GAAG,OAAH,CAAW;IAGxC,WACW,CAAA,aAAmD,EAC1B,UAAe,EAAA;QAE/C,KAAK,CAAC,aAAa,CAAC;QAHb,IAAa,CAAA,aAAA,GAAb,aAAa;QACY,IAAU,CAAA,UAAA,GAAV,UAAU;AAG1C,QAAA,IAAI,CAAC,IAAI,GAAG,UAAU,EAAE,MAAM;AAC9B,QAAA,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;;AAGrB,IAAA,QAAQ;IAER,SAAS,GAAA;QACL,IAAI,CAAC,OAAO,EAAE;AACd,QAAA,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;;AAjBf,IAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,kBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,gCAAgC,8CAM7B,eAAe,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAA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
+
import { DefaultDialogComponent } from 'x-tql-service';
|
|
3
|
+
export declare class TqlSessionServiceConfiguration {
|
|
4
|
+
/**
|
|
5
|
+
* Timeout in milliseconds
|
|
6
|
+
* @type {number}
|
|
7
|
+
*/
|
|
8
|
+
timeout?: number;
|
|
9
|
+
/**
|
|
10
|
+
* title
|
|
11
|
+
* @type {string}
|
|
12
|
+
*/
|
|
13
|
+
title?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Callback when session expired
|
|
16
|
+
* @type {(router: Router) => void}
|
|
17
|
+
*/
|
|
18
|
+
expiredCallback?: (router: Router) => void;
|
|
19
|
+
/**
|
|
20
|
+
* Template for confirm dialog
|
|
21
|
+
* @type {Component}
|
|
22
|
+
*/
|
|
23
|
+
dialogTemplate?: typeof DefaultDialogComponent;
|
|
24
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
export declare class TqlSessionServiceComponent {
|
|
3
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<TqlSessionServiceComponent, never>;
|
|
4
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<TqlSessionServiceComponent, "lib-tql-session-service", never, {}, {}, never, never, false, never>;
|
|
5
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ModuleWithProviders } from '@angular/core';
|
|
2
|
+
import { TqlSessionServiceConfiguration } from './tql-session-service-configuration';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
import * as i1 from "./tql-session-service.component";
|
|
5
|
+
import * as i2 from "./tql-session-timeout-dialog/tql-session-timeout-dialog.component";
|
|
6
|
+
import * as i3 from "x-tql-service";
|
|
7
|
+
import * as i4 from "x-tql-theme";
|
|
8
|
+
import * as i5 from "@angular/common";
|
|
9
|
+
export declare class TqlSessionServiceModule {
|
|
10
|
+
static forRoot(libConfiguration: TqlSessionServiceConfiguration): ModuleWithProviders<TqlSessionServiceModule>;
|
|
11
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<TqlSessionServiceModule, never>;
|
|
12
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<TqlSessionServiceModule, [typeof i1.TqlSessionServiceComponent, typeof i2.TqlSessionTimeoutDialogComponent], [typeof i3.TqlServiceModule, typeof i4.MaterialsModule, typeof i5.CommonModule], [typeof i1.TqlSessionServiceComponent]>;
|
|
13
|
+
static ɵinj: i0.ɵɵInjectorDeclaration<TqlSessionServiceModule>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { OnInit } from '@angular/core';
|
|
2
|
+
import { DefaultDialogComponent } from 'x-tql-service';
|
|
3
|
+
import { MatDialogRef } from '@angular/material/dialog';
|
|
4
|
+
import { TqlSessionService } from '../tql-session.service';
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
6
|
+
export declare class TqlSessionTimeoutDialogComponent extends DefaultDialogComponent implements OnInit {
|
|
7
|
+
_MatDialogRef: MatDialogRef<DefaultDialogComponent>;
|
|
8
|
+
dialogData: any;
|
|
9
|
+
static DEFAULT_WIDTH: string;
|
|
10
|
+
data: TqlSessionService.Dialog;
|
|
11
|
+
constructor(_MatDialogRef: MatDialogRef<DefaultDialogComponent>, dialogData: any);
|
|
12
|
+
ngOnInit(): void;
|
|
13
|
+
onConfirm(): void;
|
|
14
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<TqlSessionTimeoutDialogComponent, never>;
|
|
15
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<TqlSessionTimeoutDialogComponent, "lib-tql-session-timeout-dialog", never, {}, {}, never, never, false, never>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { TqlSessionServiceConfiguration } from './tql-session-service-configuration';
|
|
2
|
+
import { Router } from '@angular/router';
|
|
3
|
+
import { TqlDialogControllerService } from 'x-tql-service';
|
|
4
|
+
import { BehaviorSubject } from 'rxjs';
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
6
|
+
export declare class TqlSessionService {
|
|
7
|
+
#private;
|
|
8
|
+
private readonly _TqlSessionServiceConfiguration;
|
|
9
|
+
private _Router;
|
|
10
|
+
private _TqlDialogControllerService;
|
|
11
|
+
constructor(_TqlSessionServiceConfiguration: TqlSessionServiceConfiguration, _Router: Router, _TqlDialogControllerService: TqlDialogControllerService);
|
|
12
|
+
test(): void;
|
|
13
|
+
start(isResetTimeout?: boolean): void;
|
|
14
|
+
stop(shouldExecuteCallback?: boolean): void;
|
|
15
|
+
reset(isResetTimeout?: boolean): void;
|
|
16
|
+
isRunning(): boolean;
|
|
17
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<TqlSessionService, never>;
|
|
18
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<TqlSessionService>;
|
|
19
|
+
}
|
|
20
|
+
export declare namespace TqlSessionService {
|
|
21
|
+
const DEFAULT_SESSION_TIMEOUT = 1200000;
|
|
22
|
+
const DEFAULT_CHECKING_INTERVAL = 30000;
|
|
23
|
+
const TQL_SESSION_SERVICE_CONFIG = "TQL_SESSION_SERVICE_CONFIG";
|
|
24
|
+
const TQL_SESSION_TIMEOUT_DIALOG_CONFIG = "TQL_SESSION_TIMEOUT_DIALOG_CONFIG";
|
|
25
|
+
const DEFAULT_TIMEOUT_VALUE = 30000;
|
|
26
|
+
const DEFAULT_INTERVAL = 1000;
|
|
27
|
+
interface ISession {
|
|
28
|
+
expiredSessionValue: number;
|
|
29
|
+
currentSessionValue: number;
|
|
30
|
+
}
|
|
31
|
+
class Dialog {
|
|
32
|
+
#private;
|
|
33
|
+
private _TqlSessionService;
|
|
34
|
+
dialogObj: any;
|
|
35
|
+
counter$: BehaviorSubject<number>;
|
|
36
|
+
constructor(_TqlSessionService: TqlSessionService);
|
|
37
|
+
start(): void;
|
|
38
|
+
end(): void;
|
|
39
|
+
continue(): void;
|
|
40
|
+
}
|
|
41
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "x-tql-session-service",
|
|
3
|
+
"version": "1.19.4",
|
|
4
|
+
"peerDependencies": {
|
|
5
|
+
"@angular/common": "^19.0.0",
|
|
6
|
+
"@angular/core": "^19.0.0"
|
|
7
|
+
},
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"tslib": "^2.3.0"
|
|
10
|
+
},
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"module": "fesm2022/x-tql-session-service.mjs",
|
|
13
|
+
"typings": "index.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
"./package.json": {
|
|
16
|
+
"default": "./package.json"
|
|
17
|
+
},
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./index.d.ts",
|
|
20
|
+
"default": "./fesm2022/x-tql-session-service.mjs"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
package/public-api.d.ts
ADDED