@noctuatech/uswds 1.4.6 → 1.4.7
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/package.json +1 -1
- package/src/lib/define.ts +49 -49
- package/src/lib/services/icon.service.element.test.ts +30 -0
- package/src/lib/services/icon.service.ts +7 -6
- package/target/lib/define.d.ts +49 -49
- package/target/lib/define.js +49 -49
- package/target/lib/services/icon.service.element.test.js +25 -0
- package/target/lib/services/icon.service.element.test.js.map +1 -1
- package/target/lib/services/icon.service.js +4 -3
- package/target/lib/services/icon.service.js.map +1 -1
package/package.json
CHANGED
package/src/lib/define.ts
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import
|
|
24
|
-
import
|
|
25
|
-
import
|
|
26
|
-
import
|
|
27
|
-
import
|
|
28
|
-
import
|
|
29
|
-
import
|
|
30
|
-
import
|
|
31
|
-
import
|
|
32
|
-
import
|
|
33
|
-
import
|
|
34
|
-
import
|
|
35
|
-
import
|
|
36
|
-
import
|
|
37
|
-
import
|
|
38
|
-
import
|
|
39
|
-
import
|
|
40
|
-
import
|
|
41
|
-
import
|
|
42
|
-
import
|
|
43
|
-
import
|
|
44
|
-
import
|
|
45
|
-
import
|
|
46
|
-
import
|
|
47
|
-
import
|
|
48
|
-
import
|
|
49
|
-
import
|
|
1
|
+
import './config/config.element.js';
|
|
2
|
+
import './alert/alert.element.js';
|
|
3
|
+
import './button/button.element.js';
|
|
4
|
+
import './checkbox/checkbox.element.js';
|
|
5
|
+
import './description/description.element.js';
|
|
6
|
+
import './file-input/file-input.element.js';
|
|
7
|
+
import './file-input/file-input-preview/file-input-preview.element.js';
|
|
8
|
+
import './icon/icon.element.js';
|
|
9
|
+
import './input/input.element.js';
|
|
10
|
+
import './input-mask/input-mask.element.js';
|
|
11
|
+
import './link/link.element.js';
|
|
12
|
+
import './radio/radio.element.js';
|
|
13
|
+
import './radio/radio-option/radio-option.element.js';
|
|
14
|
+
import './select/select.element.js';
|
|
15
|
+
import './select/select-option/select-option.element.js';
|
|
16
|
+
import './tag/tag.element.js';
|
|
17
|
+
import './accordion/accordion.element.js';
|
|
18
|
+
import './side-nav/side-nav.element.js';
|
|
19
|
+
import './side-nav/side-nav-item/side-nav-item.element.js';
|
|
20
|
+
import './summary-box/summary-box.element.js';
|
|
21
|
+
import './step-indicator/step-indicator.element.js';
|
|
22
|
+
import './step-indicator/step/step.element.js';
|
|
23
|
+
import './modal/modal.element.js';
|
|
24
|
+
import './modal/modal-close/modal-close.element.js';
|
|
25
|
+
import './modal/modal-heading/modal-heading.element.js';
|
|
26
|
+
import './card/card.element.js';
|
|
27
|
+
import './card/card-header/card-header.element.js';
|
|
28
|
+
import './card/card-body/card-body.element.js';
|
|
29
|
+
import './card/card-footer/card-footer.element.js';
|
|
30
|
+
import './card/card-media/card-media.element.js';
|
|
31
|
+
import './card/card-group/card-group.element.js';
|
|
32
|
+
import './textarea/textarea.element.js';
|
|
33
|
+
import './collection/collection.element.js';
|
|
34
|
+
import './collection/collection-item/collection-item.element.js';
|
|
35
|
+
import './checkbox/checkbox-group/checkbox-group.element.js';
|
|
36
|
+
import './range-slider/range-slider.element.js';
|
|
37
|
+
import './combo-box/combo-box.element.js';
|
|
38
|
+
import './combo-box/combo-box-option/combo-box-option.element.js';
|
|
39
|
+
import './search/search.element.js';
|
|
40
|
+
import './process-list/process-list.element.js';
|
|
41
|
+
import './process-list/process-list-item/process-list-item.element.js';
|
|
42
|
+
import './in-page-nav/in-page-nav.element.js';
|
|
43
|
+
import './in-page-nav/in-page-nav-item/in-page-nav-item.element.js';
|
|
44
|
+
import './button-group/button-group.element.js';
|
|
45
|
+
import './breadcrumbs/breadcrumbs.element.js';
|
|
46
|
+
import './breadcrumbs/breadcrumb/breadcrumb.element.js';
|
|
47
|
+
import './pagination/pagination.element.js';
|
|
48
|
+
import './pagination/pagination-item/pagination-item.element.js';
|
|
49
|
+
import './pagination/pagination-no/pagination-no.element.js';
|
|
@@ -60,4 +60,34 @@ describe('IconService', () => {
|
|
|
60
60
|
assert.equal(res.nodeName, 'svg');
|
|
61
61
|
assert.equal(callCount, 1);
|
|
62
62
|
});
|
|
63
|
+
|
|
64
|
+
it('should not fetch multiple times if the same icon is requested at the same time', async () => {
|
|
65
|
+
let callCount = 0;
|
|
66
|
+
|
|
67
|
+
const app = new Injector({
|
|
68
|
+
providers: [
|
|
69
|
+
[
|
|
70
|
+
HttpService,
|
|
71
|
+
{
|
|
72
|
+
use: class extends HttpService {
|
|
73
|
+
async fetch(): Promise<Response> {
|
|
74
|
+
callCount++;
|
|
75
|
+
return new Response('<svg></svg>');
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
],
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const icon = app.inject(IconService);
|
|
84
|
+
|
|
85
|
+
await Promise.all([
|
|
86
|
+
icon.getIcon('accessibility_new'),
|
|
87
|
+
icon.getIcon('accessibility_new'),
|
|
88
|
+
icon.getIcon('accessibility_new'),
|
|
89
|
+
]);
|
|
90
|
+
|
|
91
|
+
assert.equal(callCount, 1);
|
|
92
|
+
});
|
|
63
93
|
});
|
|
@@ -8,7 +8,7 @@ import { USAIcon } from '../icon/icon-types.js';
|
|
|
8
8
|
export class IconService {
|
|
9
9
|
#config = inject(USAConfig);
|
|
10
10
|
#http = inject(HttpService);
|
|
11
|
-
#iconCache: Map<USAIcon, HTMLTemplateElement
|
|
11
|
+
#iconCache: Map<USAIcon, Promise<HTMLTemplateElement>> = new Map();
|
|
12
12
|
|
|
13
13
|
async getIcon(icon: USAIcon, abortSignal?: AbortSignal): Promise<Node> {
|
|
14
14
|
const config = this.#config();
|
|
@@ -17,11 +17,13 @@ export class IconService {
|
|
|
17
17
|
const cached = this.#iconCache.get(icon);
|
|
18
18
|
|
|
19
19
|
if (cached) {
|
|
20
|
-
|
|
20
|
+
const res = await cached;
|
|
21
|
+
|
|
22
|
+
if (!res.content.firstElementChild) {
|
|
21
23
|
throw Error('cached value is not valid');
|
|
22
24
|
}
|
|
23
25
|
|
|
24
|
-
return
|
|
26
|
+
return res.content.firstElementChild.cloneNode(true);
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
const svg = http
|
|
@@ -39,12 +41,11 @@ export class IconService {
|
|
|
39
41
|
.then((res) => {
|
|
40
42
|
const template = document.createElement('template');
|
|
41
43
|
template.innerHTML = res;
|
|
42
|
-
|
|
43
|
-
this.#iconCache.set(icon, template);
|
|
44
|
-
|
|
45
44
|
return template;
|
|
46
45
|
});
|
|
47
46
|
|
|
47
|
+
this.#iconCache.set(icon, svg);
|
|
48
|
+
|
|
48
49
|
return svg.then((res) => {
|
|
49
50
|
if (!res.content.firstElementChild) {
|
|
50
51
|
throw Error('ICON is not valid');
|
package/target/lib/define.d.ts
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import
|
|
24
|
-
import
|
|
25
|
-
import
|
|
26
|
-
import
|
|
27
|
-
import
|
|
28
|
-
import
|
|
29
|
-
import
|
|
30
|
-
import
|
|
31
|
-
import
|
|
32
|
-
import
|
|
33
|
-
import
|
|
34
|
-
import
|
|
35
|
-
import
|
|
36
|
-
import
|
|
37
|
-
import
|
|
38
|
-
import
|
|
39
|
-
import
|
|
40
|
-
import
|
|
41
|
-
import
|
|
42
|
-
import
|
|
43
|
-
import
|
|
44
|
-
import
|
|
45
|
-
import
|
|
46
|
-
import
|
|
47
|
-
import
|
|
48
|
-
import
|
|
49
|
-
import
|
|
1
|
+
import './config/config.element.js';
|
|
2
|
+
import './alert/alert.element.js';
|
|
3
|
+
import './button/button.element.js';
|
|
4
|
+
import './checkbox/checkbox.element.js';
|
|
5
|
+
import './description/description.element.js';
|
|
6
|
+
import './file-input/file-input.element.js';
|
|
7
|
+
import './file-input/file-input-preview/file-input-preview.element.js';
|
|
8
|
+
import './icon/icon.element.js';
|
|
9
|
+
import './input/input.element.js';
|
|
10
|
+
import './input-mask/input-mask.element.js';
|
|
11
|
+
import './link/link.element.js';
|
|
12
|
+
import './radio/radio.element.js';
|
|
13
|
+
import './radio/radio-option/radio-option.element.js';
|
|
14
|
+
import './select/select.element.js';
|
|
15
|
+
import './select/select-option/select-option.element.js';
|
|
16
|
+
import './tag/tag.element.js';
|
|
17
|
+
import './accordion/accordion.element.js';
|
|
18
|
+
import './side-nav/side-nav.element.js';
|
|
19
|
+
import './side-nav/side-nav-item/side-nav-item.element.js';
|
|
20
|
+
import './summary-box/summary-box.element.js';
|
|
21
|
+
import './step-indicator/step-indicator.element.js';
|
|
22
|
+
import './step-indicator/step/step.element.js';
|
|
23
|
+
import './modal/modal.element.js';
|
|
24
|
+
import './modal/modal-close/modal-close.element.js';
|
|
25
|
+
import './modal/modal-heading/modal-heading.element.js';
|
|
26
|
+
import './card/card.element.js';
|
|
27
|
+
import './card/card-header/card-header.element.js';
|
|
28
|
+
import './card/card-body/card-body.element.js';
|
|
29
|
+
import './card/card-footer/card-footer.element.js';
|
|
30
|
+
import './card/card-media/card-media.element.js';
|
|
31
|
+
import './card/card-group/card-group.element.js';
|
|
32
|
+
import './textarea/textarea.element.js';
|
|
33
|
+
import './collection/collection.element.js';
|
|
34
|
+
import './collection/collection-item/collection-item.element.js';
|
|
35
|
+
import './checkbox/checkbox-group/checkbox-group.element.js';
|
|
36
|
+
import './range-slider/range-slider.element.js';
|
|
37
|
+
import './combo-box/combo-box.element.js';
|
|
38
|
+
import './combo-box/combo-box-option/combo-box-option.element.js';
|
|
39
|
+
import './search/search.element.js';
|
|
40
|
+
import './process-list/process-list.element.js';
|
|
41
|
+
import './process-list/process-list-item/process-list-item.element.js';
|
|
42
|
+
import './in-page-nav/in-page-nav.element.js';
|
|
43
|
+
import './in-page-nav/in-page-nav-item/in-page-nav-item.element.js';
|
|
44
|
+
import './button-group/button-group.element.js';
|
|
45
|
+
import './breadcrumbs/breadcrumbs.element.js';
|
|
46
|
+
import './breadcrumbs/breadcrumb/breadcrumb.element.js';
|
|
47
|
+
import './pagination/pagination.element.js';
|
|
48
|
+
import './pagination/pagination-item/pagination-item.element.js';
|
|
49
|
+
import './pagination/pagination-no/pagination-no.element.js';
|
package/target/lib/define.js
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import
|
|
24
|
-
import
|
|
25
|
-
import
|
|
26
|
-
import
|
|
27
|
-
import
|
|
28
|
-
import
|
|
29
|
-
import
|
|
30
|
-
import
|
|
31
|
-
import
|
|
32
|
-
import
|
|
33
|
-
import
|
|
34
|
-
import
|
|
35
|
-
import
|
|
36
|
-
import
|
|
37
|
-
import
|
|
38
|
-
import
|
|
39
|
-
import
|
|
40
|
-
import
|
|
41
|
-
import
|
|
42
|
-
import
|
|
43
|
-
import
|
|
44
|
-
import
|
|
45
|
-
import
|
|
46
|
-
import
|
|
47
|
-
import
|
|
48
|
-
import
|
|
49
|
-
import
|
|
1
|
+
import './config/config.element.js';
|
|
2
|
+
import './alert/alert.element.js';
|
|
3
|
+
import './button/button.element.js';
|
|
4
|
+
import './checkbox/checkbox.element.js';
|
|
5
|
+
import './description/description.element.js';
|
|
6
|
+
import './file-input/file-input.element.js';
|
|
7
|
+
import './file-input/file-input-preview/file-input-preview.element.js';
|
|
8
|
+
import './icon/icon.element.js';
|
|
9
|
+
import './input/input.element.js';
|
|
10
|
+
import './input-mask/input-mask.element.js';
|
|
11
|
+
import './link/link.element.js';
|
|
12
|
+
import './radio/radio.element.js';
|
|
13
|
+
import './radio/radio-option/radio-option.element.js';
|
|
14
|
+
import './select/select.element.js';
|
|
15
|
+
import './select/select-option/select-option.element.js';
|
|
16
|
+
import './tag/tag.element.js';
|
|
17
|
+
import './accordion/accordion.element.js';
|
|
18
|
+
import './side-nav/side-nav.element.js';
|
|
19
|
+
import './side-nav/side-nav-item/side-nav-item.element.js';
|
|
20
|
+
import './summary-box/summary-box.element.js';
|
|
21
|
+
import './step-indicator/step-indicator.element.js';
|
|
22
|
+
import './step-indicator/step/step.element.js';
|
|
23
|
+
import './modal/modal.element.js';
|
|
24
|
+
import './modal/modal-close/modal-close.element.js';
|
|
25
|
+
import './modal/modal-heading/modal-heading.element.js';
|
|
26
|
+
import './card/card.element.js';
|
|
27
|
+
import './card/card-header/card-header.element.js';
|
|
28
|
+
import './card/card-body/card-body.element.js';
|
|
29
|
+
import './card/card-footer/card-footer.element.js';
|
|
30
|
+
import './card/card-media/card-media.element.js';
|
|
31
|
+
import './card/card-group/card-group.element.js';
|
|
32
|
+
import './textarea/textarea.element.js';
|
|
33
|
+
import './collection/collection.element.js';
|
|
34
|
+
import './collection/collection-item/collection-item.element.js';
|
|
35
|
+
import './checkbox/checkbox-group/checkbox-group.element.js';
|
|
36
|
+
import './range-slider/range-slider.element.js';
|
|
37
|
+
import './combo-box/combo-box.element.js';
|
|
38
|
+
import './combo-box/combo-box-option/combo-box-option.element.js';
|
|
39
|
+
import './search/search.element.js';
|
|
40
|
+
import './process-list/process-list.element.js';
|
|
41
|
+
import './process-list/process-list-item/process-list-item.element.js';
|
|
42
|
+
import './in-page-nav/in-page-nav.element.js';
|
|
43
|
+
import './in-page-nav/in-page-nav-item/in-page-nav-item.element.js';
|
|
44
|
+
import './button-group/button-group.element.js';
|
|
45
|
+
import './breadcrumbs/breadcrumbs.element.js';
|
|
46
|
+
import './breadcrumbs/breadcrumb/breadcrumb.element.js';
|
|
47
|
+
import './pagination/pagination.element.js';
|
|
48
|
+
import './pagination/pagination-item/pagination-item.element.js';
|
|
49
|
+
import './pagination/pagination-no/pagination-no.element.js';
|
|
50
50
|
//# sourceMappingURL=define.js.map
|
|
@@ -48,5 +48,30 @@ describe('IconService', () => {
|
|
|
48
48
|
assert.equal(res.nodeName, 'svg');
|
|
49
49
|
assert.equal(callCount, 1);
|
|
50
50
|
});
|
|
51
|
+
it('should not fetch multiple times if the same icon is requested at the same time', async () => {
|
|
52
|
+
let callCount = 0;
|
|
53
|
+
const app = new Injector({
|
|
54
|
+
providers: [
|
|
55
|
+
[
|
|
56
|
+
HttpService,
|
|
57
|
+
{
|
|
58
|
+
use: class extends HttpService {
|
|
59
|
+
async fetch() {
|
|
60
|
+
callCount++;
|
|
61
|
+
return new Response('<svg></svg>');
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
],
|
|
67
|
+
});
|
|
68
|
+
const icon = app.inject(IconService);
|
|
69
|
+
await Promise.all([
|
|
70
|
+
icon.getIcon('accessibility_new'),
|
|
71
|
+
icon.getIcon('accessibility_new'),
|
|
72
|
+
icon.getIcon('accessibility_new'),
|
|
73
|
+
]);
|
|
74
|
+
assert.equal(callCount, 1);
|
|
75
|
+
});
|
|
51
76
|
});
|
|
52
77
|
//# sourceMappingURL=icon.service.element.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icon.service.element.test.js","sourceRoot":"","sources":["../../../src/lib/services/icon.service.element.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,EAAE,CAAC,mCAAmC,EAAE,KAAK,IAAI,EAAE;QACjD,IAAI,SAAS,GAAG,CAAC,CAAC;QAElB,MAAM,GAAG,GAAG,IAAI,QAAQ,CAAC;YACvB,SAAS,EAAE;gBACT;oBACE,WAAW;oBACX;wBACE,GAAG,EAAE,KAAM,SAAQ,WAAW;4BAC5B,KAAK,CAAC,KAAK;gCACT,SAAS,EAAE,CAAC;gCACZ,OAAO,IAAI,QAAQ,CAAC,aAAa,CAAC,CAAC;4BACrC,CAAC;yBACF;qBACF;iBACF;aACF;SACF,CAAC,CAAC;QAEH,MAAM,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAErC,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,MAAa,CAAC,CAAC;QAE9C,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QAClC,MAAM,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6DAA6D,EAAE,KAAK,IAAI,EAAE;QAC3E,IAAI,SAAS,GAAG,CAAC,CAAC;QAElB,MAAM,GAAG,GAAG,IAAI,QAAQ,CAAC;YACvB,SAAS,EAAE;gBACT;oBACE,WAAW;oBACX;wBACE,GAAG,EAAE,KAAM,SAAQ,WAAW;4BAC5B,KAAK,CAAC,KAAK;gCACT,SAAS,EAAE,CAAC;gCACZ,OAAO,IAAI,QAAQ,CAAC,aAAa,CAAC,CAAC;4BACrC,CAAC;yBACF;qBACF;iBACF;aACF;SACF,CAAC,CAAC;QAEH,MAAM,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAErC,MAAM,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;QAExC,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;QAEpD,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QAClC,MAAM,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"icon.service.element.test.js","sourceRoot":"","sources":["../../../src/lib/services/icon.service.element.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,EAAE,CAAC,mCAAmC,EAAE,KAAK,IAAI,EAAE;QACjD,IAAI,SAAS,GAAG,CAAC,CAAC;QAElB,MAAM,GAAG,GAAG,IAAI,QAAQ,CAAC;YACvB,SAAS,EAAE;gBACT;oBACE,WAAW;oBACX;wBACE,GAAG,EAAE,KAAM,SAAQ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QAC9F,IAAI,SAAS,GAAG,CAAC,CAAC;QAElB,MAAM,GAAG,GAAG,IAAI,QAAQ,CAAC;YACvB,SAAS,EAAE;gBACT;oBACE,WAAW;oBACX;wBACE,GAAG,EAAE,KAAM,SAAQ,WAAW;4BAC5B,KAAK,CAAC,KAAK;gCACT,SAAS,EAAE,CAAC;gCACZ,OAAO,IAAI,QAAQ,CAAC,aAAa,CAAC,CAAC;4BACrC,CAAC;yBACF;qBACF;iBACF;aACF;SACF,CAAC,CAAC;QAEH,MAAM,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAErC,MAAM,OAAO,CAAC,GAAG,CAAC;YAChB,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC;YACjC,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC;YACjC,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC;SAClC,CAAC,CAAC;QAEH,MAAM,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -24,10 +24,11 @@ let IconService = (() => {
|
|
|
24
24
|
const http = this.#http();
|
|
25
25
|
const cached = this.#iconCache.get(icon);
|
|
26
26
|
if (cached) {
|
|
27
|
-
|
|
27
|
+
const res = await cached;
|
|
28
|
+
if (!res.content.firstElementChild) {
|
|
28
29
|
throw Error('cached value is not valid');
|
|
29
30
|
}
|
|
30
|
-
return
|
|
31
|
+
return res.content.firstElementChild.cloneNode(true);
|
|
31
32
|
}
|
|
32
33
|
const svg = http
|
|
33
34
|
.fetch(`${config.iconPath}${icon}.svg`, {
|
|
@@ -43,9 +44,9 @@ let IconService = (() => {
|
|
|
43
44
|
.then((res) => {
|
|
44
45
|
const template = document.createElement('template');
|
|
45
46
|
template.innerHTML = res;
|
|
46
|
-
this.#iconCache.set(icon, template);
|
|
47
47
|
return template;
|
|
48
48
|
});
|
|
49
|
+
this.#iconCache.set(icon, svg);
|
|
49
50
|
return svg.then((res) => {
|
|
50
51
|
if (!res.content.firstElementChild) {
|
|
51
52
|
throw Error('ICON is not valid');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icon.service.js","sourceRoot":"","sources":["../../../src/lib/services/icon.service.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE/C,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;IAInC,WAAW;4BADvB,UAAU,EAAE;;;;;;;;YACb,
|
|
1
|
+
{"version":3,"file":"icon.service.js","sourceRoot":"","sources":["../../../src/lib/services/icon.service.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE/C,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;IAInC,WAAW;4BADvB,UAAU,EAAE;;;;;;;;YACb,6KAiDC;;;YAjDY,uDAAW;;QACtB,OAAO,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;QAC5B,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;QAC5B,UAAU,GAA+C,IAAI,GAAG,EAAE,CAAC;QAEnE,KAAK,CAAC,OAAO,CAAC,IAAa,EAAE,WAAyB;YACpD,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;YAC9B,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;YAE1B,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAEzC,IAAI,MAAM,EAAE,CAAC;gBACX,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC;gBAEzB,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,iBAAiB,EA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