@candy-kingdom/bonnie 0.1.1
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 +7 -0
- package/esm2022/candy-kingdom-bonnie.mjs +5 -0
- package/esm2022/index.mjs +9 -0
- package/esm2022/lib/core/MediaObjectFit.mjs +7 -0
- package/esm2022/lib/core/MediaStatus.mjs +8 -0
- package/esm2022/lib/core/device.service.base.mjs +3 -0
- package/esm2022/lib/core/device.service.mjs +14 -0
- package/esm2022/lib/core/index.mjs +8 -0
- package/esm2022/lib/core/intersection.component.mjs +69 -0
- package/esm2022/lib/core/src.directive.mjs +128 -0
- package/esm2022/lib/core/unsubscribe.service.mjs +19 -0
- package/esm2022/lib/core/utils.mjs +48 -0
- package/esm2022/lib/generated/bone.mjs +6 -0
- package/esm2022/lib/generated/file-meta.mjs +6 -0
- package/esm2022/lib/generated/file-src-base.mjs +6 -0
- package/esm2022/lib/generated/file-src.mjs +6 -0
- package/esm2022/lib/generated/i-equatable.mjs +6 -0
- package/esm2022/lib/generated/i-have-data-route-with-data.mjs +6 -0
- package/esm2022/lib/generated/i-have-data-route.mjs +6 -0
- package/esm2022/lib/generated/i-have-skeleton.mjs +6 -0
- package/esm2022/lib/generated/i-page.mjs +6 -0
- package/esm2022/lib/generated/image-meta.mjs +6 -0
- package/esm2022/lib/generated/image-source.mjs +6 -0
- package/esm2022/lib/generated/image.mjs +6 -0
- package/esm2022/lib/generated/index.mjs +34 -0
- package/esm2022/lib/generated/localized-object.mjs +6 -0
- package/esm2022/lib/generated/localized-string.mjs +6 -0
- package/esm2022/lib/generated/media-source-base.mjs +6 -0
- package/esm2022/lib/generated/media-source.mjs +6 -0
- package/esm2022/lib/generated/open-graph-data.mjs +6 -0
- package/esm2022/lib/generated/page-base.mjs +6 -0
- package/esm2022/lib/generated/page-data.mjs +6 -0
- package/esm2022/lib/generated/page.mjs +6 -0
- package/esm2022/lib/generated/pix-media.mjs +6 -0
- package/esm2022/lib/generated/pix-meta.mjs +6 -0
- package/esm2022/lib/generated/publish-status.mjs +12 -0
- package/esm2022/lib/generated/sizes-item.mjs +6 -0
- package/esm2022/lib/generated/sizes-width-unit.mjs +11 -0
- package/esm2022/lib/generated/video-meta.mjs +6 -0
- package/esm2022/lib/generated/video-source.mjs +6 -0
- package/esm2022/lib/generated/video.mjs +6 -0
- package/esm2022/lib/generated/view.mjs +6 -0
- package/esm2022/lib/localization/LocalizeServiceBase.mjs +19 -0
- package/esm2022/lib/localization/index.mjs +3 -0
- package/esm2022/lib/localization/localize.pipe.mjs +128 -0
- package/esm2022/lib/marcy-elements.module.mjs +98 -0
- package/esm2022/lib/marcy-image/IHtmlPictureSource.mjs +2 -0
- package/esm2022/lib/marcy-image/getDefaultSrc.mjs +17 -0
- package/esm2022/lib/marcy-image/imgsrc.directive.mjs +20 -0
- package/esm2022/lib/marcy-image/index.mjs +6 -0
- package/esm2022/lib/marcy-image/marcy-image.component.mjs +83 -0
- package/esm2022/lib/marcy-image/toHtmlSources.mjs +16 -0
- package/esm2022/lib/marcy-media/index.mjs +2 -0
- package/esm2022/lib/marcy-media/marcy-media.component.mjs +59 -0
- package/esm2022/lib/marcy-video/index.mjs +3 -0
- package/esm2022/lib/marcy-video/marcy-video.component.mjs +147 -0
- package/esm2022/lib/marcy-video/vidsrc.directive.mjs +20 -0
- package/esm2022/lib/skeleton/IBoneComponent.mjs +2 -0
- package/esm2022/lib/skeleton/bone.directive.mjs +41 -0
- package/esm2022/lib/skeleton/index.mjs +6 -0
- package/esm2022/lib/skeleton/skeleton-anchor.directive.mjs +17 -0
- package/esm2022/lib/skeleton/skeleton.component.mjs +53 -0
- package/esm2022/lib/skeleton/unknown-bone.component.mjs +25 -0
- package/fesm2022/candy-kingdom-bonnie.mjs +1107 -0
- package/fesm2022/candy-kingdom-bonnie.mjs.map +1 -0
- package/index.d.ts +8 -0
- package/lib/core/MediaObjectFit.d.ts +5 -0
- package/lib/core/MediaStatus.d.ts +6 -0
- package/lib/core/device.service.base.d.ts +4 -0
- package/lib/core/device.service.d.ts +8 -0
- package/lib/core/index.d.ts +7 -0
- package/lib/core/intersection.component.d.ts +20 -0
- package/lib/core/src.directive.d.ts +23 -0
- package/lib/core/unsubscribe.service.d.ts +10 -0
- package/lib/core/utils.d.ts +10 -0
- package/lib/generated/bone.d.ts +10 -0
- package/lib/generated/file-meta.d.ts +7 -0
- package/lib/generated/file-src-base.d.ts +8 -0
- package/lib/generated/file-src.d.ts +9 -0
- package/lib/generated/i-equatable.d.ts +6 -0
- package/lib/generated/i-have-data-route-with-data.d.ts +8 -0
- package/lib/generated/i-have-data-route.d.ts +7 -0
- package/lib/generated/i-have-skeleton.d.ts +8 -0
- package/lib/generated/i-page.d.ts +8 -0
- package/lib/generated/image-meta.d.ts +7 -0
- package/lib/generated/image-source.d.ts +10 -0
- package/lib/generated/image.d.ts +10 -0
- package/lib/generated/index.d.ts +33 -0
- package/lib/generated/localized-object.d.ts +7 -0
- package/lib/generated/localized-string.d.ts +7 -0
- package/lib/generated/media-source-base.d.ts +8 -0
- package/lib/generated/media-source.d.ts +11 -0
- package/lib/generated/open-graph-data.d.ts +11 -0
- package/lib/generated/page-base.d.ts +19 -0
- package/lib/generated/page-data.d.ts +7 -0
- package/lib/generated/page.d.ts +9 -0
- package/lib/generated/pix-media.d.ts +9 -0
- package/lib/generated/pix-meta.d.ts +10 -0
- package/lib/generated/publish-status.d.ts +10 -0
- package/lib/generated/sizes-item.d.ts +10 -0
- package/lib/generated/sizes-width-unit.d.ts +9 -0
- package/lib/generated/video-meta.d.ts +11 -0
- package/lib/generated/video-source.d.ts +8 -0
- package/lib/generated/video.d.ts +10 -0
- package/lib/generated/view.d.ts +9 -0
- package/lib/localization/LocalizeServiceBase.d.ts +9 -0
- package/lib/localization/index.d.ts +2 -0
- package/lib/localization/localize.pipe.d.ts +55 -0
- package/lib/marcy-elements.module.d.ts +19 -0
- package/lib/marcy-image/IHtmlPictureSource.d.ts +6 -0
- package/lib/marcy-image/getDefaultSrc.d.ts +2 -0
- package/lib/marcy-image/imgsrc.directive.d.ts +9 -0
- package/lib/marcy-image/index.d.ts +5 -0
- package/lib/marcy-image/marcy-image.component.d.ts +30 -0
- package/lib/marcy-image/toHtmlSources.d.ts +3 -0
- package/lib/marcy-media/index.d.ts +1 -0
- package/lib/marcy-media/marcy-media.component.d.ts +24 -0
- package/lib/marcy-video/index.d.ts +2 -0
- package/lib/marcy-video/marcy-video.component.d.ts +33 -0
- package/lib/marcy-video/vidsrc.directive.d.ts +9 -0
- package/lib/skeleton/IBoneComponent.d.ts +4 -0
- package/lib/skeleton/bone.directive.d.ts +17 -0
- package/lib/skeleton/index.d.ts +5 -0
- package/lib/skeleton/skeleton-anchor.directive.d.ts +8 -0
- package/lib/skeleton/skeleton.component.d.ts +18 -0
- package/lib/skeleton/unknown-bone.component.d.ts +14 -0
- package/package.json +25 -0
|
@@ -0,0 +1,1107 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Injectable, EventEmitter, Directive, Output, Component, Input, Pipe, Optional, ViewChild, ChangeDetectionStrategy, NgModule } from '@angular/core';
|
|
3
|
+
import { Subject, takeUntil, BehaviorSubject, NEVER, fromEvent, merge, filter } from 'rxjs';
|
|
4
|
+
import * as i2 from '@angular/platform-browser';
|
|
5
|
+
import * as i4 from '@angular/common';
|
|
6
|
+
import { CommonModule } from '@angular/common';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* This is a TypeGen auto-generated file.
|
|
10
|
+
* Any changes made to this file can be lost when this file is regenerated.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* This is a TypeGen auto-generated file.
|
|
15
|
+
* Any changes made to this file can be lost when this file is regenerated.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* This is a TypeGen auto-generated file.
|
|
20
|
+
* Any changes made to this file can be lost when this file is regenerated.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* This is a TypeGen auto-generated file.
|
|
25
|
+
* Any changes made to this file can be lost when this file is regenerated.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* This is a TypeGen auto-generated file.
|
|
30
|
+
* Any changes made to this file can be lost when this file is regenerated.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* This is a TypeGen auto-generated file.
|
|
35
|
+
* Any changes made to this file can be lost when this file is regenerated.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* This is a TypeGen auto-generated file.
|
|
40
|
+
* Any changes made to this file can be lost when this file is regenerated.
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* This is a TypeGen auto-generated file.
|
|
45
|
+
* Any changes made to this file can be lost when this file is regenerated.
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* This is a TypeGen auto-generated file.
|
|
50
|
+
* Any changes made to this file can be lost when this file is regenerated.
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* This is a TypeGen auto-generated file.
|
|
55
|
+
* Any changes made to this file can be lost when this file is regenerated.
|
|
56
|
+
*/
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* This is a TypeGen auto-generated file.
|
|
60
|
+
* Any changes made to this file can be lost when this file is regenerated.
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* This is a TypeGen auto-generated file.
|
|
65
|
+
* Any changes made to this file can be lost when this file is regenerated.
|
|
66
|
+
*/
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* This is a TypeGen auto-generated file.
|
|
70
|
+
* Any changes made to this file can be lost when this file is regenerated.
|
|
71
|
+
*/
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* This is a TypeGen auto-generated file.
|
|
75
|
+
* Any changes made to this file can be lost when this file is regenerated.
|
|
76
|
+
*/
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* This is a TypeGen auto-generated file.
|
|
80
|
+
* Any changes made to this file can be lost when this file is regenerated.
|
|
81
|
+
*/
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* This is a TypeGen auto-generated file.
|
|
85
|
+
* Any changes made to this file can be lost when this file is regenerated.
|
|
86
|
+
*/
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* This is a TypeGen auto-generated file.
|
|
90
|
+
* Any changes made to this file can be lost when this file is regenerated.
|
|
91
|
+
*/
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* This is a TypeGen auto-generated file.
|
|
95
|
+
* Any changes made to this file can be lost when this file is regenerated.
|
|
96
|
+
*/
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* This is a TypeGen auto-generated file.
|
|
100
|
+
* Any changes made to this file can be lost when this file is regenerated.
|
|
101
|
+
*/
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* This is a TypeGen auto-generated file.
|
|
105
|
+
* Any changes made to this file can be lost when this file is regenerated.
|
|
106
|
+
*/
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* This is a TypeGen auto-generated file.
|
|
110
|
+
* Any changes made to this file can be lost when this file is regenerated.
|
|
111
|
+
*/
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* This is a TypeGen auto-generated file.
|
|
115
|
+
* Any changes made to this file can be lost when this file is regenerated.
|
|
116
|
+
*/
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* This is a TypeGen auto-generated file.
|
|
120
|
+
* Any changes made to this file can be lost when this file is regenerated.
|
|
121
|
+
*/
|
|
122
|
+
var PublishStatus;
|
|
123
|
+
(function (PublishStatus) {
|
|
124
|
+
PublishStatus[PublishStatus["NotSet"] = 0] = "NotSet";
|
|
125
|
+
PublishStatus[PublishStatus["Draft"] = 1] = "Draft";
|
|
126
|
+
PublishStatus[PublishStatus["Published"] = 2] = "Published";
|
|
127
|
+
PublishStatus[PublishStatus["Archived"] = 3] = "Archived";
|
|
128
|
+
})(PublishStatus || (PublishStatus = {}));
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* This is a TypeGen auto-generated file.
|
|
132
|
+
* Any changes made to this file can be lost when this file is regenerated.
|
|
133
|
+
*/
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* This is a TypeGen auto-generated file.
|
|
137
|
+
* Any changes made to this file can be lost when this file is regenerated.
|
|
138
|
+
*/
|
|
139
|
+
var SizesWidthUnit;
|
|
140
|
+
(function (SizesWidthUnit) {
|
|
141
|
+
SizesWidthUnit["Px"] = "Px";
|
|
142
|
+
SizesWidthUnit["Em"] = "Em";
|
|
143
|
+
SizesWidthUnit["Vw"] = "Vw";
|
|
144
|
+
})(SizesWidthUnit || (SizesWidthUnit = {}));
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* This is a TypeGen auto-generated file.
|
|
148
|
+
* Any changes made to this file can be lost when this file is regenerated.
|
|
149
|
+
*/
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* This is a TypeGen auto-generated file.
|
|
153
|
+
* Any changes made to this file can be lost when this file is regenerated.
|
|
154
|
+
*/
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* This is a TypeGen auto-generated file.
|
|
158
|
+
* Any changes made to this file can be lost when this file is regenerated.
|
|
159
|
+
*/
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* This is a TypeGen auto-generated file.
|
|
163
|
+
* Any changes made to this file can be lost when this file is regenerated.
|
|
164
|
+
*/
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* This is a TypeGen auto-generated file.
|
|
168
|
+
* Any changes made to this file can be lost when this file is regenerated.
|
|
169
|
+
*/
|
|
170
|
+
|
|
171
|
+
// https://stackoverflow.com/questions/42136098/array-groupby-in-typescript
|
|
172
|
+
const groupBy = (arr, key) => arr.reduce((groups, item) => {
|
|
173
|
+
(groups[key(item)] ||= []).push(item);
|
|
174
|
+
return groups;
|
|
175
|
+
}, {});
|
|
176
|
+
function distinct(value, index, array) {
|
|
177
|
+
return array.indexOf(value) === index;
|
|
178
|
+
}
|
|
179
|
+
function ascending(a, b) {
|
|
180
|
+
return a - b;
|
|
181
|
+
}
|
|
182
|
+
function ascendingT(sel) {
|
|
183
|
+
return function (a, b) { return ascending(sel(a), sel(b)); };
|
|
184
|
+
}
|
|
185
|
+
function descending(a, b) {
|
|
186
|
+
return b - a;
|
|
187
|
+
}
|
|
188
|
+
function descendingT(sel) {
|
|
189
|
+
return function (a, b) { return descending(sel(a), sel(b)); };
|
|
190
|
+
}
|
|
191
|
+
function generateSizesString(sizes) {
|
|
192
|
+
const sizesString = sizes
|
|
193
|
+
.sort(x => x.width)
|
|
194
|
+
.map(x => `${x.mediaQuery} ${x.width}${x.unit}`)
|
|
195
|
+
.join(',');
|
|
196
|
+
return sizesString;
|
|
197
|
+
}
|
|
198
|
+
function matchesMediaQuery(mediaQuery) {
|
|
199
|
+
const isEmptyQuery = mediaQuery === null || mediaQuery === undefined || mediaQuery.trim().length === 0;
|
|
200
|
+
// work for SSR and browser
|
|
201
|
+
if (isEmptyQuery)
|
|
202
|
+
return true;
|
|
203
|
+
// other queries disallowed in SSR
|
|
204
|
+
if (typeof window === 'undefined')
|
|
205
|
+
return false;
|
|
206
|
+
const mediaQueryList = window.matchMedia(mediaQuery);
|
|
207
|
+
return mediaQueryList.matches;
|
|
208
|
+
}
|
|
209
|
+
function isLocalUrlString(url) {
|
|
210
|
+
if (url === undefined || url === null || url.trim().length === 0)
|
|
211
|
+
return true;
|
|
212
|
+
if (url.startsWith('//'))
|
|
213
|
+
return false;
|
|
214
|
+
if (url.startsWith('./') || url.startsWith('/'))
|
|
215
|
+
return true;
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
class UnsubscriberService {
|
|
220
|
+
constructor() {
|
|
221
|
+
this._destroy$ = new Subject();
|
|
222
|
+
this.takeUntilDestroy = (origin) => origin.pipe(takeUntil(this._destroy$));
|
|
223
|
+
}
|
|
224
|
+
ngOnDestroy() {
|
|
225
|
+
this._destroy$.next();
|
|
226
|
+
this._destroy$.complete();
|
|
227
|
+
}
|
|
228
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: UnsubscriberService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
229
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: UnsubscriberService }); }
|
|
230
|
+
}
|
|
231
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: UnsubscriberService, decorators: [{
|
|
232
|
+
type: Injectable
|
|
233
|
+
}] });
|
|
234
|
+
|
|
235
|
+
class SrcBaseDirective {
|
|
236
|
+
constructor(_u, cd) {
|
|
237
|
+
this._u = _u;
|
|
238
|
+
this.cd = cd;
|
|
239
|
+
this.ratioChange = new EventEmitter();
|
|
240
|
+
this.srcChange = new EventEmitter();
|
|
241
|
+
this._ratioSubject = new BehaviorSubject(0);
|
|
242
|
+
this._queryChangeClearSubject = new Subject();
|
|
243
|
+
console.log('SrcBaseDirective ctor');
|
|
244
|
+
this.cd.detach();
|
|
245
|
+
}
|
|
246
|
+
ngOnInit() {
|
|
247
|
+
console.log('SrcBaseDirective ngOnInit');
|
|
248
|
+
this._ratioSubject
|
|
249
|
+
.pipe(this._u.takeUntilDestroy)
|
|
250
|
+
.subscribe(x => {
|
|
251
|
+
this.ratioChange.next(x);
|
|
252
|
+
this.cd.detectChanges(); // todo: verify, do i need it here
|
|
253
|
+
});
|
|
254
|
+
this.cd.detectChanges();
|
|
255
|
+
}
|
|
256
|
+
get ratio() {
|
|
257
|
+
return this._ratioSubject.value;
|
|
258
|
+
}
|
|
259
|
+
get data() {
|
|
260
|
+
return this._data;
|
|
261
|
+
}
|
|
262
|
+
set data(val) {
|
|
263
|
+
console.log('set data', val);
|
|
264
|
+
if (val !== undefined && val !== null && val.sources.length === 0) {
|
|
265
|
+
console.warn(`image should have sources!`);
|
|
266
|
+
val = undefined;
|
|
267
|
+
}
|
|
268
|
+
this._data = val;
|
|
269
|
+
console.log('calling src change ', this._data);
|
|
270
|
+
// clear mediaQuery subscriptions
|
|
271
|
+
this._queryChangeClearSubject.next();
|
|
272
|
+
// ratio
|
|
273
|
+
this._ratioSubject.next(0);
|
|
274
|
+
this.srcChange.next(this._data);
|
|
275
|
+
if (this._data === undefined || this._data.sources.length === 0) {
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
const allRatios = this._data.sources
|
|
279
|
+
.flatMap(x => x.srcSet)
|
|
280
|
+
.map(x => x.meta.ratio)
|
|
281
|
+
.filter(distinct);
|
|
282
|
+
if (allRatios.length === 1) {
|
|
283
|
+
// same ratio for all
|
|
284
|
+
this._ratioSubject.next(allRatios[0]);
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
this.watchMediaQueries()
|
|
288
|
+
.subscribe(() => { this.calcRatio(); console.log('watchMediaQueries calcRatio'); });
|
|
289
|
+
this.calcRatio();
|
|
290
|
+
}
|
|
291
|
+
calcRatio() {
|
|
292
|
+
if (this._data === undefined || this._data === null || this._data.sources.length === 0)
|
|
293
|
+
return;
|
|
294
|
+
for (let i = 0; i < this._data.sources.length; i++) {
|
|
295
|
+
const source = this._data.sources[i];
|
|
296
|
+
const srcRatios = source.srcSet
|
|
297
|
+
.sort(descendingT(x => x.meta.width))
|
|
298
|
+
.map(x => x.meta.ratio)
|
|
299
|
+
.filter(distinct);
|
|
300
|
+
if (srcRatios.length === 0) {
|
|
301
|
+
// console.warn(`each source should have srcSet with same ratio. founded: ${srcRatios.join(', ')}`);
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
if (srcRatios.length > 1) {
|
|
305
|
+
console.warn(`each source should have srcSet with same ratio. founded: ${srcRatios.join(', ')}`);
|
|
306
|
+
}
|
|
307
|
+
const ratio = srcRatios[0]; // most accurate ratio in biggest image
|
|
308
|
+
if (source.mediaQuery.length === 0) {
|
|
309
|
+
this._ratioSubject.next(ratio);
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
if (typeof window === 'undefined' || typeof window.matchMedia === 'undefined')
|
|
313
|
+
return;
|
|
314
|
+
const mediaQueryList = window.matchMedia(source.mediaQuery);
|
|
315
|
+
if (mediaQueryList.matches) {
|
|
316
|
+
this._ratioSubject.next(ratio);
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
watchMediaQueries() {
|
|
322
|
+
console.log('watchMediaQueries');
|
|
323
|
+
if (this._data === undefined
|
|
324
|
+
|| this._data === null
|
|
325
|
+
|| typeof window === 'undefined'
|
|
326
|
+
|| typeof window.matchMedia === 'undefined')
|
|
327
|
+
return NEVER.pipe(this._u.takeUntilDestroy, takeUntil(this._queryChangeClearSubject));
|
|
328
|
+
const mediaQueries = this._data.sources
|
|
329
|
+
.map(x => x.mediaQuery)
|
|
330
|
+
.filter(distinct)
|
|
331
|
+
.filter(x => x.length > 0);
|
|
332
|
+
console.log('watchMediaQueries mediaQueries', mediaQueries);
|
|
333
|
+
const queryObservables = mediaQueries.map(media => {
|
|
334
|
+
const queryList = window.matchMedia(media);
|
|
335
|
+
const observable = fromEvent(queryList, 'change')
|
|
336
|
+
.pipe(this._u.takeUntilDestroy, takeUntil(this._queryChangeClearSubject));
|
|
337
|
+
return observable;
|
|
338
|
+
});
|
|
339
|
+
const combinedObservable = merge(...queryObservables);
|
|
340
|
+
return combinedObservable;
|
|
341
|
+
}
|
|
342
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: SrcBaseDirective, deps: [{ token: UnsubscriberService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
343
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.0.8", type: SrcBaseDirective, selector: "[bonSrcBase]", outputs: { ratioChange: "ratioChange", srcChange: "srcChange" }, providers: [UnsubscriberService], ngImport: i0 }); }
|
|
344
|
+
}
|
|
345
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: SrcBaseDirective, decorators: [{
|
|
346
|
+
type: Directive,
|
|
347
|
+
args: [{
|
|
348
|
+
selector: '[bonSrcBase]',
|
|
349
|
+
providers: [UnsubscriberService]
|
|
350
|
+
}]
|
|
351
|
+
}], ctorParameters: () => [{ type: UnsubscriberService }, { type: i0.ChangeDetectorRef }], propDecorators: { ratioChange: [{
|
|
352
|
+
type: Output
|
|
353
|
+
}], srcChange: [{
|
|
354
|
+
type: Output
|
|
355
|
+
}] } });
|
|
356
|
+
|
|
357
|
+
var MediaStatus;
|
|
358
|
+
(function (MediaStatus) {
|
|
359
|
+
MediaStatus["NotSet"] = "NotSet";
|
|
360
|
+
MediaStatus["NotLoaded"] = "NotLoaded";
|
|
361
|
+
MediaStatus["Loading"] = "Loading";
|
|
362
|
+
MediaStatus["Loaded"] = "Loaded";
|
|
363
|
+
})(MediaStatus || (MediaStatus = {}));
|
|
364
|
+
|
|
365
|
+
var MediaObjectFit;
|
|
366
|
+
(function (MediaObjectFit) {
|
|
367
|
+
MediaObjectFit["Original"] = "Original";
|
|
368
|
+
MediaObjectFit["Cover"] = "Cover";
|
|
369
|
+
MediaObjectFit["Contain"] = "Contain";
|
|
370
|
+
})(MediaObjectFit || (MediaObjectFit = {}));
|
|
371
|
+
|
|
372
|
+
class DeviceService {
|
|
373
|
+
constructor() {
|
|
374
|
+
this.devicePixelRatio = typeof window === 'undefined' ? 1 : window.devicePixelRatio;
|
|
375
|
+
this.isSSR = typeof window === 'undefined';
|
|
376
|
+
}
|
|
377
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: DeviceService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
378
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: DeviceService }); }
|
|
379
|
+
}
|
|
380
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: DeviceService, decorators: [{
|
|
381
|
+
type: Injectable
|
|
382
|
+
}] });
|
|
383
|
+
|
|
384
|
+
class DeviceServiceBase {
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
class IntersectionComponent {
|
|
388
|
+
constructor(_hostRef, _u, cd) {
|
|
389
|
+
this._hostRef = _hostRef;
|
|
390
|
+
this._u = _u;
|
|
391
|
+
this.intersected = new EventEmitter();
|
|
392
|
+
this._intersectSubject = new BehaviorSubject(false);
|
|
393
|
+
cd.detach();
|
|
394
|
+
// no template with variables, so we don't need to call changeDetection
|
|
395
|
+
if (typeof window === 'undefined' || typeof IntersectionObserver === 'undefined') {
|
|
396
|
+
// call intersection without any
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
this.intersectionObserver = new IntersectionObserver(this.onIntersection.bind(this));
|
|
400
|
+
}
|
|
401
|
+
ngOnInit() {
|
|
402
|
+
this._intersectSubject
|
|
403
|
+
.pipe(this._u.takeUntilDestroy, filter(x => x === true))
|
|
404
|
+
.subscribe(x => this.intersected.next());
|
|
405
|
+
}
|
|
406
|
+
set session(newSession) {
|
|
407
|
+
if (this._session === newSession)
|
|
408
|
+
return;
|
|
409
|
+
console.log('reset intersection Observer');
|
|
410
|
+
this._session = newSession;
|
|
411
|
+
this.reset();
|
|
412
|
+
}
|
|
413
|
+
get intersectedOnce() {
|
|
414
|
+
return this._intersectSubject.value;
|
|
415
|
+
}
|
|
416
|
+
reset() {
|
|
417
|
+
if (this.intersectionObserver === undefined || this.intersectionObserver === null)
|
|
418
|
+
return;
|
|
419
|
+
this.intersectionObserver.unobserve(this._hostRef.nativeElement);
|
|
420
|
+
this._intersectSubject.next(false);
|
|
421
|
+
this.intersectionObserver.observe(this._hostRef.nativeElement);
|
|
422
|
+
}
|
|
423
|
+
onIntersection(entries, observer) {
|
|
424
|
+
if (entries.length > 1) {
|
|
425
|
+
console.warn('multi entries!');
|
|
426
|
+
}
|
|
427
|
+
const isIntersecting = entries[0].isIntersecting;
|
|
428
|
+
this._intersectSubject.next(isIntersecting);
|
|
429
|
+
console.log(`intersected ${isIntersecting}`, this._hostRef.nativeElement);
|
|
430
|
+
// only once will recieve intersection
|
|
431
|
+
if (isIntersecting) {
|
|
432
|
+
observer.unobserve(this._hostRef.nativeElement);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
ngOnDestroy() {
|
|
436
|
+
this._intersectSubject.complete();
|
|
437
|
+
this.intersectionObserver?.disconnect();
|
|
438
|
+
}
|
|
439
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: IntersectionComponent, deps: [{ token: i0.ElementRef }, { token: UnsubscriberService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
440
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.0.8", type: IntersectionComponent, selector: "bon-intersection", inputs: { session: "session" }, outputs: { intersected: "intersected" }, providers: [UnsubscriberService], ngImport: i0, template: '<ng-content></ng-content>', isInline: true, styles: [":host{display:block}\n"] }); }
|
|
441
|
+
}
|
|
442
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: IntersectionComponent, decorators: [{
|
|
443
|
+
type: Component,
|
|
444
|
+
args: [{ selector: 'bon-intersection', template: '<ng-content></ng-content>', providers: [UnsubscriberService], styles: [":host{display:block}\n"] }]
|
|
445
|
+
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: UnsubscriberService }, { type: i0.ChangeDetectorRef }], propDecorators: { intersected: [{
|
|
446
|
+
type: Output
|
|
447
|
+
}], session: [{
|
|
448
|
+
type: Input
|
|
449
|
+
}] } });
|
|
450
|
+
|
|
451
|
+
class LocalizeServiceBase {
|
|
452
|
+
getLocalized(value, defaultValue, locale) {
|
|
453
|
+
if (value === undefined)
|
|
454
|
+
return defaultValue;
|
|
455
|
+
locale = locale ?? this.locale;
|
|
456
|
+
const obj = value[locale] ?? defaultValue;
|
|
457
|
+
return obj;
|
|
458
|
+
}
|
|
459
|
+
getLocalizedText(value, locale) {
|
|
460
|
+
return this.getLocalized(value, '', locale);
|
|
461
|
+
}
|
|
462
|
+
;
|
|
463
|
+
isLocalUrl(value, locale) {
|
|
464
|
+
const url = this.getLocalizedText(value, locale);
|
|
465
|
+
return isLocalUrlString(url);
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
class LocalizePipe {
|
|
470
|
+
constructor(localizeService) {
|
|
471
|
+
this.localizeService = localizeService;
|
|
472
|
+
}
|
|
473
|
+
transform(value, locale) {
|
|
474
|
+
if (value === undefined || value === null)
|
|
475
|
+
return '';
|
|
476
|
+
return this.localizeService.getLocalizedText(value, locale);
|
|
477
|
+
}
|
|
478
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: LocalizePipe, deps: [{ token: LocalizeServiceBase }], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
479
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.0.8", ngImport: i0, type: LocalizePipe, name: "localize", pure: false }); }
|
|
480
|
+
}
|
|
481
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: LocalizePipe, decorators: [{
|
|
482
|
+
type: Pipe,
|
|
483
|
+
args: [{ name: 'localize', pure: false }]
|
|
484
|
+
}], ctorParameters: () => [{ type: LocalizeServiceBase }] });
|
|
485
|
+
class LocalizeObjectPipe {
|
|
486
|
+
constructor(localizeService) {
|
|
487
|
+
this.localizeService = localizeService;
|
|
488
|
+
}
|
|
489
|
+
transform(object, locale) {
|
|
490
|
+
if (object === undefined || object === null)
|
|
491
|
+
return undefined;
|
|
492
|
+
return this.localizeService.getLocalized(object, undefined, locale);
|
|
493
|
+
}
|
|
494
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: LocalizeObjectPipe, deps: [{ token: LocalizeServiceBase }], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
495
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.0.8", ngImport: i0, type: LocalizeObjectPipe, name: "localizeObject", pure: false }); }
|
|
496
|
+
}
|
|
497
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: LocalizeObjectPipe, decorators: [{
|
|
498
|
+
type: Pipe,
|
|
499
|
+
args: [{ name: 'localizeObject', pure: false }]
|
|
500
|
+
}], ctorParameters: () => [{ type: LocalizeServiceBase }] });
|
|
501
|
+
class LocalizationIsNotEmptyPipe {
|
|
502
|
+
constructor(localizeService) {
|
|
503
|
+
this.localizeService = localizeService;
|
|
504
|
+
}
|
|
505
|
+
transform(value, locale) {
|
|
506
|
+
if (value === undefined || value === null)
|
|
507
|
+
return false;
|
|
508
|
+
const text = this.localizeService.getLocalizedText(value, locale);
|
|
509
|
+
const isNotEmpty = text.trim().length > 0;
|
|
510
|
+
return isNotEmpty;
|
|
511
|
+
}
|
|
512
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: LocalizationIsNotEmptyPipe, deps: [{ token: LocalizeServiceBase }], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
513
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.0.8", ngImport: i0, type: LocalizationIsNotEmptyPipe, name: "localizationIsNotEmpty", pure: false }); }
|
|
514
|
+
}
|
|
515
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: LocalizationIsNotEmptyPipe, decorators: [{
|
|
516
|
+
type: Pipe,
|
|
517
|
+
args: [{ name: 'localizationIsNotEmpty', pure: false }]
|
|
518
|
+
}], ctorParameters: () => [{ type: LocalizeServiceBase }] });
|
|
519
|
+
class LocalizationIsEmptyPipe {
|
|
520
|
+
constructor(localizeService) {
|
|
521
|
+
this.localizeService = localizeService;
|
|
522
|
+
}
|
|
523
|
+
transform(value, locale) {
|
|
524
|
+
if (value === undefined || value === null)
|
|
525
|
+
return true;
|
|
526
|
+
const text = this.localizeService.getLocalizedText(value, locale);
|
|
527
|
+
const isEmpty = text.trim().length === 0;
|
|
528
|
+
return isEmpty;
|
|
529
|
+
}
|
|
530
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: LocalizationIsEmptyPipe, deps: [{ token: LocalizeServiceBase }], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
531
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.0.8", ngImport: i0, type: LocalizationIsEmptyPipe, name: "localizationIsEmpty", pure: false }); }
|
|
532
|
+
}
|
|
533
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: LocalizationIsEmptyPipe, decorators: [{
|
|
534
|
+
type: Pipe,
|
|
535
|
+
args: [{ name: 'localizationIsEmpty', pure: false }]
|
|
536
|
+
}], ctorParameters: () => [{ type: LocalizeServiceBase }] });
|
|
537
|
+
class LocalizeUrlPipe {
|
|
538
|
+
constructor(localizeService, domSanitizer) {
|
|
539
|
+
this.localizeService = localizeService;
|
|
540
|
+
this.domSanitizer = domSanitizer;
|
|
541
|
+
}
|
|
542
|
+
transform(value, locale) {
|
|
543
|
+
if (value === undefined || value === null)
|
|
544
|
+
return '';
|
|
545
|
+
const urlString = this.localizeService.getLocalizedText(value, locale);
|
|
546
|
+
const safeUrl = this.domSanitizer.bypassSecurityTrustResourceUrl(urlString);
|
|
547
|
+
return safeUrl;
|
|
548
|
+
}
|
|
549
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: LocalizeUrlPipe, deps: [{ token: LocalizeServiceBase }, { token: i2.DomSanitizer }], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
550
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.0.8", ngImport: i0, type: LocalizeUrlPipe, name: "localizeUrl", pure: false }); }
|
|
551
|
+
}
|
|
552
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: LocalizeUrlPipe, decorators: [{
|
|
553
|
+
type: Pipe,
|
|
554
|
+
args: [{ name: 'localizeUrl', pure: false }]
|
|
555
|
+
}], ctorParameters: () => [{ type: LocalizeServiceBase }, { type: i2.DomSanitizer }] });
|
|
556
|
+
class IsLocalUrlPipe {
|
|
557
|
+
constructor(localizeService) {
|
|
558
|
+
this.localizeService = localizeService;
|
|
559
|
+
}
|
|
560
|
+
transform(value, locale) {
|
|
561
|
+
if (value === undefined || value === null)
|
|
562
|
+
return false;
|
|
563
|
+
const isLocal = this.localizeService.isLocalUrl(value, locale);
|
|
564
|
+
return isLocal;
|
|
565
|
+
}
|
|
566
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: IsLocalUrlPipe, deps: [{ token: LocalizeServiceBase }], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
567
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.0.8", ngImport: i0, type: IsLocalUrlPipe, name: "isLocalUrl", pure: false }); }
|
|
568
|
+
}
|
|
569
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: IsLocalUrlPipe, decorators: [{
|
|
570
|
+
type: Pipe,
|
|
571
|
+
args: [{ name: 'isLocalUrl', pure: false }]
|
|
572
|
+
}], ctorParameters: () => [{ type: LocalizeServiceBase }] });
|
|
573
|
+
class IsNotLocalUrlPipe {
|
|
574
|
+
constructor(localizeService) {
|
|
575
|
+
this.localizeService = localizeService;
|
|
576
|
+
}
|
|
577
|
+
transform(value, locale) {
|
|
578
|
+
if (value === undefined || value === null)
|
|
579
|
+
return false;
|
|
580
|
+
const isLocal = this.localizeService.isLocalUrl(value, locale);
|
|
581
|
+
return !isLocal;
|
|
582
|
+
}
|
|
583
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: IsNotLocalUrlPipe, deps: [{ token: LocalizeServiceBase }], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
584
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.0.8", ngImport: i0, type: IsNotLocalUrlPipe, name: "isNotLocalUrl", pure: false }); }
|
|
585
|
+
}
|
|
586
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: IsNotLocalUrlPipe, decorators: [{
|
|
587
|
+
type: Pipe,
|
|
588
|
+
args: [{ name: 'isNotLocalUrl', pure: false }]
|
|
589
|
+
}], ctorParameters: () => [{ type: LocalizeServiceBase }] });
|
|
590
|
+
|
|
591
|
+
class ImageSrcDirective extends SrcBaseDirective {
|
|
592
|
+
set imgsrc(value) {
|
|
593
|
+
console.log('set imgsrc', value);
|
|
594
|
+
this.data = value;
|
|
595
|
+
}
|
|
596
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: ImageSrcDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive }); }
|
|
597
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.0.8", type: ImageSrcDirective, selector: "[imgsrc]", inputs: { imgsrc: "imgsrc" }, usesInheritance: true, ngImport: i0 }); }
|
|
598
|
+
}
|
|
599
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: ImageSrcDirective, decorators: [{
|
|
600
|
+
type: Directive,
|
|
601
|
+
args: [{
|
|
602
|
+
selector: '[imgsrc]'
|
|
603
|
+
}]
|
|
604
|
+
}], propDecorators: { imgsrc: [{
|
|
605
|
+
type: Input
|
|
606
|
+
}] } });
|
|
607
|
+
|
|
608
|
+
function toHtmlPictureSources(imageSource) {
|
|
609
|
+
const sizes = generateSizesString(imageSource.sizes);
|
|
610
|
+
const groupedByMime = groupBy(imageSource.srcSet, x => x.mimeType);
|
|
611
|
+
const simpleSources = [];
|
|
612
|
+
for (const mime in groupedByMime) {
|
|
613
|
+
const fileSrcs = groupedByMime[mime].sort(ascendingT(x => x.meta.width));
|
|
614
|
+
const srcSet = fileSrcs
|
|
615
|
+
.map(x => `${x.url} ${x.meta.width}w`)
|
|
616
|
+
.join(',');
|
|
617
|
+
const source = { mime, sizes, srcSet, media: imageSource.mediaQuery };
|
|
618
|
+
simpleSources.push(source);
|
|
619
|
+
}
|
|
620
|
+
return simpleSources;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
function getDefaultSrc(image) {
|
|
624
|
+
if (image === undefined || image === null)
|
|
625
|
+
return undefined;
|
|
626
|
+
const files = image.sources
|
|
627
|
+
.flatMap(x => x.srcSet)
|
|
628
|
+
.sort(descendingT(x => x.meta.width));
|
|
629
|
+
const prefferedFiles = files.filter(x => x.mimeType === 'image/jpeg'
|
|
630
|
+
|| x.mimeType === 'image/png'
|
|
631
|
+
|| x.mimeType === 'image/gif');
|
|
632
|
+
if (prefferedFiles.length > 0)
|
|
633
|
+
return prefferedFiles[0];
|
|
634
|
+
if (files.length > 0)
|
|
635
|
+
return files[0];
|
|
636
|
+
return undefined;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
class MarcyImageComponent {
|
|
640
|
+
constructor(device, cd, _u, srcDir) {
|
|
641
|
+
this.device = device;
|
|
642
|
+
this.cd = cd;
|
|
643
|
+
this._u = _u;
|
|
644
|
+
this.MediaStatus = MediaStatus;
|
|
645
|
+
this.MarcyObjectFit = MediaObjectFit;
|
|
646
|
+
this.isLoaded = new EventEmitter();
|
|
647
|
+
this.sources = [];
|
|
648
|
+
this.$status = new BehaviorSubject(MediaStatus.NotSet);
|
|
649
|
+
this.defaultSrc = '';
|
|
650
|
+
this._objectFit = MediaObjectFit.Original;
|
|
651
|
+
console.log('MarcyImageComponent ctor');
|
|
652
|
+
if (srcDir === undefined || srcDir === null)
|
|
653
|
+
throw new Error(`${MarcyImageComponent.name} should have [imgsrc] directive as source object`);
|
|
654
|
+
this.src = srcDir;
|
|
655
|
+
// bind src changes
|
|
656
|
+
this.src.srcChange
|
|
657
|
+
.pipe(this._u.takeUntilDestroy)
|
|
658
|
+
.subscribe(this.onSrcChange.bind(this));
|
|
659
|
+
cd.detach();
|
|
660
|
+
}
|
|
661
|
+
ngOnInit() {
|
|
662
|
+
// bind loaded event
|
|
663
|
+
this.$status
|
|
664
|
+
.pipe(this._u.takeUntilDestroy, filter(status => status === MediaStatus.Loaded))
|
|
665
|
+
.subscribe(x => this.isLoaded.next());
|
|
666
|
+
this.cd.detectChanges();
|
|
667
|
+
}
|
|
668
|
+
onSrcChange(val) {
|
|
669
|
+
console.log('MarcyImageComponent onSrcChange', val);
|
|
670
|
+
this.defaultSrc = getDefaultSrc(val)?.url ?? '';
|
|
671
|
+
this.sources.splice(0, this.sources.length);
|
|
672
|
+
if (val === undefined || val === null || val.sources.length === 0) {
|
|
673
|
+
this.$status.next(MediaStatus.NotSet);
|
|
674
|
+
this.cd.detectChanges();
|
|
675
|
+
return;
|
|
676
|
+
}
|
|
677
|
+
const newSources = val.sources.flatMap(toHtmlPictureSources);
|
|
678
|
+
console.log('MarcyImageComponent newSources', newSources);
|
|
679
|
+
this.sources.push(...newSources);
|
|
680
|
+
this.$status.next(MediaStatus.NotLoaded);
|
|
681
|
+
this.cd.detectChanges();
|
|
682
|
+
}
|
|
683
|
+
set objectFit(val) {
|
|
684
|
+
this._objectFit = val ?? MediaObjectFit.Original;
|
|
685
|
+
this.cd.detectChanges();
|
|
686
|
+
}
|
|
687
|
+
get objectFit() {
|
|
688
|
+
return this._objectFit;
|
|
689
|
+
}
|
|
690
|
+
onLoad() {
|
|
691
|
+
this.$status.next(MediaStatus.Loaded);
|
|
692
|
+
}
|
|
693
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: MarcyImageComponent, deps: [{ token: DeviceServiceBase }, { token: i0.ChangeDetectorRef }, { token: UnsubscriberService }, { token: ImageSrcDirective, optional: true }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
694
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.0.8", type: MarcyImageComponent, selector: "bon-image", inputs: { objectFit: "objectFit" }, outputs: { isLoaded: "isLoaded" }, providers: [UnsubscriberService], ngImport: i0, template: "<div *ngIf=\"sources.length > 0\"\n [class.knownRatio]=\"src.ratio > 0 && objectFit === MarcyObjectFit.Original\"\n [class.cover]=\"objectFit === MarcyObjectFit.Cover\"\n [class.contain]=\"objectFit === MarcyObjectFit.Contain\"\n [class.loaded]=\"($status | async) === MediaStatus.Loaded\"\n class=\"picture-container\">\n\n <ng-template #pictureTemplate>\n <picture>\n <source *ngFor=\"let source of sources\"\n [srcset]=\"source.srcSet\"\n [attr.media]=\"source.media.length > 0 ? source.media : undefined\"\n [attr.type]=\"source.mime.length > 0 ? source.mime : undefined\"\n [attr.sizes]=\"source.sizes.length > 0 ? source.sizes : undefined\" />\n\n <img [src]=\"defaultSrc\" (load)=\"onLoad()\" />\n </picture>\n </ng-template>\n\n <noscript *ngIf=\"device.isSSR\">\n <ng-container *ngTemplateOutlet=\"pictureTemplate\"></ng-container>\n </noscript>\n\n <bon-intersection #intersectionZone *ngIf=\"!device.isSSR\" [session]=\"src\" (intersected)=\"cd.detectChanges()\">\n\n <ng-container *ngIf=\"intersectionZone.intersectedOnce\">\n <ng-container *ngTemplateOutlet=\"pictureTemplate\"></ng-container>\n </ng-container>\n\n </bon-intersection>\n\n <div *ngIf=\"src.ratio > 0 && objectFit === MarcyObjectFit.Original\" [style.padding-top]=\"100 / src.ratio +'%'\"></div>\n</div>\n", styles: [":host{display:block}.picture-container{overflow:hidden}.picture-container.cover picture,.picture-container.cover bon-intersection,.picture-container.contain picture,.picture-container.contain bon-intersection,.picture-container.knownRatio picture,.picture-container.knownRatio bon-intersection{width:100%;height:100%}.picture-container.cover picture>img,.picture-container.cover bon-intersection>img,.picture-container.contain picture>img,.picture-container.contain bon-intersection>img,.picture-container.knownRatio picture>img,.picture-container.knownRatio bon-intersection>img{height:100%}.picture-container.cover{height:100%}.picture-container.cover picture>img{object-fit:cover}.picture-container.contain{height:100%}.picture-container.contain picture>img{object-fit:contain}.picture-container.knownRatio{position:relative}.picture-container.knownRatio picture{position:absolute}.picture-container.knownRatio picture>img{object-fit:fill}picture{display:block;backface-visibility:hidden}picture>img{display:block;width:100%}\n"], dependencies: [{ kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i4.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: IntersectionComponent, selector: "bon-intersection", inputs: ["session"], outputs: ["intersected"] }, { kind: "pipe", type: i4.AsyncPipe, name: "async" }] }); }
|
|
695
|
+
}
|
|
696
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: MarcyImageComponent, decorators: [{
|
|
697
|
+
type: Component,
|
|
698
|
+
args: [{ selector: 'bon-image', providers: [UnsubscriberService], template: "<div *ngIf=\"sources.length > 0\"\n [class.knownRatio]=\"src.ratio > 0 && objectFit === MarcyObjectFit.Original\"\n [class.cover]=\"objectFit === MarcyObjectFit.Cover\"\n [class.contain]=\"objectFit === MarcyObjectFit.Contain\"\n [class.loaded]=\"($status | async) === MediaStatus.Loaded\"\n class=\"picture-container\">\n\n <ng-template #pictureTemplate>\n <picture>\n <source *ngFor=\"let source of sources\"\n [srcset]=\"source.srcSet\"\n [attr.media]=\"source.media.length > 0 ? source.media : undefined\"\n [attr.type]=\"source.mime.length > 0 ? source.mime : undefined\"\n [attr.sizes]=\"source.sizes.length > 0 ? source.sizes : undefined\" />\n\n <img [src]=\"defaultSrc\" (load)=\"onLoad()\" />\n </picture>\n </ng-template>\n\n <noscript *ngIf=\"device.isSSR\">\n <ng-container *ngTemplateOutlet=\"pictureTemplate\"></ng-container>\n </noscript>\n\n <bon-intersection #intersectionZone *ngIf=\"!device.isSSR\" [session]=\"src\" (intersected)=\"cd.detectChanges()\">\n\n <ng-container *ngIf=\"intersectionZone.intersectedOnce\">\n <ng-container *ngTemplateOutlet=\"pictureTemplate\"></ng-container>\n </ng-container>\n\n </bon-intersection>\n\n <div *ngIf=\"src.ratio > 0 && objectFit === MarcyObjectFit.Original\" [style.padding-top]=\"100 / src.ratio +'%'\"></div>\n</div>\n", styles: [":host{display:block}.picture-container{overflow:hidden}.picture-container.cover picture,.picture-container.cover bon-intersection,.picture-container.contain picture,.picture-container.contain bon-intersection,.picture-container.knownRatio picture,.picture-container.knownRatio bon-intersection{width:100%;height:100%}.picture-container.cover picture>img,.picture-container.cover bon-intersection>img,.picture-container.contain picture>img,.picture-container.contain bon-intersection>img,.picture-container.knownRatio picture>img,.picture-container.knownRatio bon-intersection>img{height:100%}.picture-container.cover{height:100%}.picture-container.cover picture>img{object-fit:cover}.picture-container.contain{height:100%}.picture-container.contain picture>img{object-fit:contain}.picture-container.knownRatio{position:relative}.picture-container.knownRatio picture{position:absolute}.picture-container.knownRatio picture>img{object-fit:fill}picture{display:block;backface-visibility:hidden}picture>img{display:block;width:100%}\n"] }]
|
|
699
|
+
}], ctorParameters: () => [{ type: DeviceServiceBase }, { type: i0.ChangeDetectorRef }, { type: UnsubscriberService }, { type: ImageSrcDirective, decorators: [{
|
|
700
|
+
type: Optional
|
|
701
|
+
}] }], propDecorators: { isLoaded: [{
|
|
702
|
+
type: Output
|
|
703
|
+
}], objectFit: [{
|
|
704
|
+
type: Input
|
|
705
|
+
}] } });
|
|
706
|
+
|
|
707
|
+
class VideoSrcDirective extends SrcBaseDirective {
|
|
708
|
+
set vidsrc(value) {
|
|
709
|
+
this.data = value;
|
|
710
|
+
console.log('set vidsrc', value);
|
|
711
|
+
}
|
|
712
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: VideoSrcDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive }); }
|
|
713
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.0.8", type: VideoSrcDirective, selector: "[vidsrc]", inputs: { vidsrc: "vidsrc" }, usesInheritance: true, ngImport: i0 }); }
|
|
714
|
+
}
|
|
715
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: VideoSrcDirective, decorators: [{
|
|
716
|
+
type: Directive,
|
|
717
|
+
args: [{
|
|
718
|
+
selector: '[vidsrc]'
|
|
719
|
+
}]
|
|
720
|
+
}], propDecorators: { vidsrc: [{
|
|
721
|
+
type: Input
|
|
722
|
+
}] } });
|
|
723
|
+
|
|
724
|
+
class MarcyVideoComponent {
|
|
725
|
+
constructor(device, cd, _u, srcDir) {
|
|
726
|
+
this.device = device;
|
|
727
|
+
this.cd = cd;
|
|
728
|
+
this._u = _u;
|
|
729
|
+
this.MediaStatus = MediaStatus;
|
|
730
|
+
this.MarcyObjectFit = MediaObjectFit;
|
|
731
|
+
this.isLoaded = new EventEmitter();
|
|
732
|
+
this.$status = new BehaviorSubject(MediaStatus.NotSet);
|
|
733
|
+
this._objectFit = MediaObjectFit.Original;
|
|
734
|
+
console.log('MarcyVideoComponent ctor');
|
|
735
|
+
if (srcDir === undefined || srcDir === null)
|
|
736
|
+
throw new Error(`${MarcyVideoComponent.name} should have [vidsrc] directive as source object`);
|
|
737
|
+
this.src = srcDir;
|
|
738
|
+
cd.detach();
|
|
739
|
+
}
|
|
740
|
+
ngOnInit() {
|
|
741
|
+
console.log('MarcyVideoComponent ngOnInit');
|
|
742
|
+
// bind loaded event
|
|
743
|
+
this.$status
|
|
744
|
+
.pipe(this._u.takeUntilDestroy, filter(status => status === MediaStatus.Loaded))
|
|
745
|
+
.subscribe(() => this.isLoaded.next());
|
|
746
|
+
this.cd.detectChanges();
|
|
747
|
+
}
|
|
748
|
+
ngAfterViewInit() {
|
|
749
|
+
console.log('MarcyVideoComponent ngAfterViewInit');
|
|
750
|
+
// bind src changes
|
|
751
|
+
this.src.srcChange
|
|
752
|
+
.pipe(this._u.takeUntilDestroy)
|
|
753
|
+
.subscribe((val) => {
|
|
754
|
+
console.log('MarcyVideoComponent onSrcChange', val);
|
|
755
|
+
this.updateSources();
|
|
756
|
+
// resubscribe because its updated with src
|
|
757
|
+
this.subscribeToMediaQueryChange();
|
|
758
|
+
});
|
|
759
|
+
this.updateSources();
|
|
760
|
+
// initial, for src added before init
|
|
761
|
+
this.subscribeToMediaQueryChange();
|
|
762
|
+
}
|
|
763
|
+
subscribeToMediaQueryChange() {
|
|
764
|
+
this.src
|
|
765
|
+
.watchMediaQueries()
|
|
766
|
+
.subscribe(() => {
|
|
767
|
+
console.log('MarcyVideoComponent watchMediaQueries');
|
|
768
|
+
this.updateSources();
|
|
769
|
+
});
|
|
770
|
+
}
|
|
771
|
+
updateSources() {
|
|
772
|
+
console.log('MarcyVideoComponent updateSources');
|
|
773
|
+
this.source = this.findMoreSuitableSource();
|
|
774
|
+
console.log('MarcyVideoComponent new source', this.source);
|
|
775
|
+
if (this.$status.value === MediaStatus.NotSet && this.source === undefined) {
|
|
776
|
+
return;
|
|
777
|
+
}
|
|
778
|
+
if (this.source === undefined) {
|
|
779
|
+
this.$status.next(MediaStatus.NotSet);
|
|
780
|
+
this.cd.detectChanges();
|
|
781
|
+
return;
|
|
782
|
+
}
|
|
783
|
+
this.$status.next(MediaStatus.NotLoaded);
|
|
784
|
+
this.cd.detectChanges();
|
|
785
|
+
}
|
|
786
|
+
set objectFit(val) {
|
|
787
|
+
this._objectFit = val ?? MediaObjectFit.Original;
|
|
788
|
+
this.cd.detectChanges();
|
|
789
|
+
}
|
|
790
|
+
get objectFit() {
|
|
791
|
+
return this._objectFit;
|
|
792
|
+
}
|
|
793
|
+
onLoad() {
|
|
794
|
+
this.$status.next(MediaStatus.Loaded);
|
|
795
|
+
}
|
|
796
|
+
findMoreSuitableSource() {
|
|
797
|
+
if (this.videoRef === undefined) {
|
|
798
|
+
console.log('skipping findMoreSuitableSource. videoRef is empty still');
|
|
799
|
+
return;
|
|
800
|
+
}
|
|
801
|
+
const videoSources = this.src.data?.sources ?? [];
|
|
802
|
+
const currentVideoWidth = this.videoRef.nativeElement.clientWidth;
|
|
803
|
+
const realPixelsVideoWidth = this.device.devicePixelRatio * currentVideoWidth;
|
|
804
|
+
console.log(`MarcyVideoComponent currentVideoWidth ${currentVideoWidth}`);
|
|
805
|
+
console.log(`MarcyVideoComponent realPixelsVideoWidth ${realPixelsVideoWidth}`);
|
|
806
|
+
for (let i = 0; i < videoSources.length; i++) {
|
|
807
|
+
const videoSource = videoSources[i];
|
|
808
|
+
if (!matchesMediaQuery(videoSource.mediaQuery))
|
|
809
|
+
continue;
|
|
810
|
+
// SSR
|
|
811
|
+
if (typeof this.videoRef.nativeElement.canPlayType !== 'function') {
|
|
812
|
+
// return first mp4, because all players can play them
|
|
813
|
+
const mp4Srcs = videoSource
|
|
814
|
+
.srcSet
|
|
815
|
+
.filter(x => x.mimeType === 'video/mp4')
|
|
816
|
+
.sort(descendingT(x => x.meta.width)); // bigest video
|
|
817
|
+
// element or undefined
|
|
818
|
+
return mp4Srcs[0];
|
|
819
|
+
}
|
|
820
|
+
const fileSrcs = videoSource
|
|
821
|
+
.srcSet
|
|
822
|
+
.filter(x => this.videoRef.nativeElement.canPlayType(x.mimeType))
|
|
823
|
+
.sort(ascendingT(x => x.meta.width)) // smallest video
|
|
824
|
+
.sort(x => x.mimeType.includes('webm') ? 1 : -1); // webm first
|
|
825
|
+
if (fileSrcs.length === 0)
|
|
826
|
+
continue;
|
|
827
|
+
let bestSrc = fileSrcs[0];
|
|
828
|
+
for (let i = 1; i < fileSrcs.length; i++) {
|
|
829
|
+
const fileSrc = fileSrcs[i];
|
|
830
|
+
const currentDiff = fileSrc.meta.width - realPixelsVideoWidth;
|
|
831
|
+
// too big video source width
|
|
832
|
+
if (currentDiff > 0)
|
|
833
|
+
break;
|
|
834
|
+
bestSrc = fileSrc;
|
|
835
|
+
}
|
|
836
|
+
return bestSrc;
|
|
837
|
+
}
|
|
838
|
+
return undefined;
|
|
839
|
+
}
|
|
840
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: MarcyVideoComponent, deps: [{ token: DeviceServiceBase }, { token: i0.ChangeDetectorRef }, { token: UnsubscriberService }, { token: VideoSrcDirective, optional: true }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
841
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.0.8", type: MarcyVideoComponent, selector: "bon-video", inputs: { objectFit: "objectFit" }, outputs: { isLoaded: "isLoaded" }, providers: [UnsubscriberService], viewQueries: [{ propertyName: "videoRef", first: true, predicate: ["video"], descendants: true }], ngImport: i0, template: "<div [class.knownRatio]=\"src.ratio > 0 && objectFit === MarcyObjectFit.Original\"\n [class.cover]=\"objectFit === MarcyObjectFit.Cover\"\n [class.contain]=\"objectFit === MarcyObjectFit.Contain\"\n [class.loaded]=\"($status | async) === MediaStatus.Loaded\"\n class=\"video-container\">\n\n <ng-container *ngIf=\"device.isSSR ; then ssrTemplate else browserTemplate\"></ng-container>\n\n <ng-template #videoTemplate>\n <video #video\n [src]=\"source !== undefined ? source.url :'' \"\n (load)=\"onLoad()\"\n (canplay)=\"video.muted=true;video.play();\"\n autoplay\n loop\n muted> </video>\n </ng-template>\n\n <ng-template #ssrTemplate>\n <noscript *ngIf=\"device.isSSR\">\n <ng-container *ngTemplateOutlet=\"videoTemplate\"></ng-container>\n </noscript>\n </ng-template>\n\n <ng-template #browserTemplate>\n <bon-intersection #intersectionZone [session]=\"src\" (intersected)=\"cd.detectChanges()\">\n <ng-container *ngTemplateOutlet=\"videoTemplate\"></ng-container>\n </bon-intersection>\n </ng-template>\n\n <div *ngIf=\"src.ratio > 0 && objectFit === MarcyObjectFit.Original\" [style.padding-top]=\"100 / src.ratio +'%'\"></div>\n</div>\n", styles: [":host{display:block}.video-container{background-color:#000;overflow:hidden}.video-container.cover video,.video-container.cover bon-intersection,.video-container.contain video,.video-container.contain bon-intersection,.video-container.knownRatio video,.video-container.knownRatio bon-intersection{width:100%;height:100%}.video-container.cover{height:100%}.video-container.cover video{object-fit:cover}.video-container.contain{height:100%}.video-container.contain video{object-fit:contain}.video-container.knownRatio{position:relative}.video-container.knownRatio video{position:absolute;object-fit:fill}video{display:block;width:100%}\n"], dependencies: [{ kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i4.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: IntersectionComponent, selector: "bon-intersection", inputs: ["session"], outputs: ["intersected"] }, { kind: "pipe", type: i4.AsyncPipe, name: "async" }] }); }
|
|
842
|
+
}
|
|
843
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: MarcyVideoComponent, decorators: [{
|
|
844
|
+
type: Component,
|
|
845
|
+
args: [{ selector: 'bon-video', providers: [UnsubscriberService], template: "<div [class.knownRatio]=\"src.ratio > 0 && objectFit === MarcyObjectFit.Original\"\n [class.cover]=\"objectFit === MarcyObjectFit.Cover\"\n [class.contain]=\"objectFit === MarcyObjectFit.Contain\"\n [class.loaded]=\"($status | async) === MediaStatus.Loaded\"\n class=\"video-container\">\n\n <ng-container *ngIf=\"device.isSSR ; then ssrTemplate else browserTemplate\"></ng-container>\n\n <ng-template #videoTemplate>\n <video #video\n [src]=\"source !== undefined ? source.url :'' \"\n (load)=\"onLoad()\"\n (canplay)=\"video.muted=true;video.play();\"\n autoplay\n loop\n muted> </video>\n </ng-template>\n\n <ng-template #ssrTemplate>\n <noscript *ngIf=\"device.isSSR\">\n <ng-container *ngTemplateOutlet=\"videoTemplate\"></ng-container>\n </noscript>\n </ng-template>\n\n <ng-template #browserTemplate>\n <bon-intersection #intersectionZone [session]=\"src\" (intersected)=\"cd.detectChanges()\">\n <ng-container *ngTemplateOutlet=\"videoTemplate\"></ng-container>\n </bon-intersection>\n </ng-template>\n\n <div *ngIf=\"src.ratio > 0 && objectFit === MarcyObjectFit.Original\" [style.padding-top]=\"100 / src.ratio +'%'\"></div>\n</div>\n", styles: [":host{display:block}.video-container{background-color:#000;overflow:hidden}.video-container.cover video,.video-container.cover bon-intersection,.video-container.contain video,.video-container.contain bon-intersection,.video-container.knownRatio video,.video-container.knownRatio bon-intersection{width:100%;height:100%}.video-container.cover{height:100%}.video-container.cover video{object-fit:cover}.video-container.contain{height:100%}.video-container.contain video{object-fit:contain}.video-container.knownRatio{position:relative}.video-container.knownRatio video{position:absolute;object-fit:fill}video{display:block;width:100%}\n"] }]
|
|
846
|
+
}], ctorParameters: () => [{ type: DeviceServiceBase }, { type: i0.ChangeDetectorRef }, { type: UnsubscriberService }, { type: VideoSrcDirective, decorators: [{
|
|
847
|
+
type: Optional
|
|
848
|
+
}] }], propDecorators: { videoRef: [{
|
|
849
|
+
type: ViewChild,
|
|
850
|
+
args: ['video']
|
|
851
|
+
}], isLoaded: [{
|
|
852
|
+
type: Output
|
|
853
|
+
}], objectFit: [{
|
|
854
|
+
type: Input
|
|
855
|
+
}] } });
|
|
856
|
+
|
|
857
|
+
class MarcyMediaComponent {
|
|
858
|
+
constructor(device, cd, _u) {
|
|
859
|
+
this.device = device;
|
|
860
|
+
this.cd = cd;
|
|
861
|
+
this._u = _u;
|
|
862
|
+
this.MarcyObjectFit = MediaObjectFit;
|
|
863
|
+
this.isLoaded = new EventEmitter();
|
|
864
|
+
this._objectFit = MediaObjectFit.Original;
|
|
865
|
+
console.log('MarcyMediaComponent ctor');
|
|
866
|
+
cd.detach();
|
|
867
|
+
}
|
|
868
|
+
ngOnInit() {
|
|
869
|
+
console.log('MarcyMediaComponent ngOnInit');
|
|
870
|
+
this.cd.detectChanges();
|
|
871
|
+
}
|
|
872
|
+
get src() {
|
|
873
|
+
return this._src;
|
|
874
|
+
}
|
|
875
|
+
set src(val) {
|
|
876
|
+
console.log('set data', val);
|
|
877
|
+
this._src = val;
|
|
878
|
+
this.cd.detectChanges();
|
|
879
|
+
}
|
|
880
|
+
set objectFit(val) {
|
|
881
|
+
this._objectFit = val ?? MediaObjectFit.Original;
|
|
882
|
+
this.cd.detectChanges();
|
|
883
|
+
}
|
|
884
|
+
get objectFit() {
|
|
885
|
+
return this._objectFit;
|
|
886
|
+
}
|
|
887
|
+
onLoad() {
|
|
888
|
+
this.isLoaded.next();
|
|
889
|
+
}
|
|
890
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: MarcyMediaComponent, deps: [{ token: DeviceServiceBase }, { token: i0.ChangeDetectorRef }, { token: UnsubscriberService }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
891
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.0.8", type: MarcyMediaComponent, selector: "bon-media", inputs: { src: "src", objectFit: "objectFit" }, outputs: { isLoaded: "isLoaded" }, providers: [UnsubscriberService], ngImport: i0, template: "<bon-image *ngIf=\"src && src.type==='image'\"\n [imgsrc]=\"src\"\n [objectFit]=\"objectFit\"\n (isLoaded)=\"onLoad()\"></bon-image>\n\n<bon-video *ngIf=\"src && src.type==='video'\"\n [vidsrc]=\"src\"\n [objectFit]=\"objectFit\"\n (isLoaded)=\"onLoad()\"></bon-video>\n", styles: [":host{display:block}\n"], dependencies: [{ kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: MarcyImageComponent, selector: "bon-image", inputs: ["objectFit"], outputs: ["isLoaded"] }, { kind: "component", type: MarcyVideoComponent, selector: "bon-video", inputs: ["objectFit"], outputs: ["isLoaded"] }, { kind: "directive", type: ImageSrcDirective, selector: "[imgsrc]", inputs: ["imgsrc"] }, { kind: "directive", type: VideoSrcDirective, selector: "[vidsrc]", inputs: ["vidsrc"] }] }); }
|
|
892
|
+
}
|
|
893
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: MarcyMediaComponent, decorators: [{
|
|
894
|
+
type: Component,
|
|
895
|
+
args: [{ selector: 'bon-media', providers: [UnsubscriberService], template: "<bon-image *ngIf=\"src && src.type==='image'\"\n [imgsrc]=\"src\"\n [objectFit]=\"objectFit\"\n (isLoaded)=\"onLoad()\"></bon-image>\n\n<bon-video *ngIf=\"src && src.type==='video'\"\n [vidsrc]=\"src\"\n [objectFit]=\"objectFit\"\n (isLoaded)=\"onLoad()\"></bon-video>\n", styles: [":host{display:block}\n"] }]
|
|
896
|
+
}], ctorParameters: () => [{ type: DeviceServiceBase }, { type: i0.ChangeDetectorRef }, { type: UnsubscriberService }], propDecorators: { isLoaded: [{
|
|
897
|
+
type: Output
|
|
898
|
+
}], src: [{
|
|
899
|
+
type: Input
|
|
900
|
+
}], objectFit: [{
|
|
901
|
+
type: Input
|
|
902
|
+
}] } });
|
|
903
|
+
|
|
904
|
+
class BoneDirective {
|
|
905
|
+
constructor(cd, _u, localizationService) {
|
|
906
|
+
this.cd = cd;
|
|
907
|
+
this._u = _u;
|
|
908
|
+
this.localizationService = localizationService;
|
|
909
|
+
this.cd.detach();
|
|
910
|
+
}
|
|
911
|
+
ngOnInit() {
|
|
912
|
+
this.localizationService.locale$
|
|
913
|
+
.pipe(this._u.takeUntilDestroy)
|
|
914
|
+
.subscribe(() => {
|
|
915
|
+
// need to detect changes in our detached components
|
|
916
|
+
this.cd.detectChanges();
|
|
917
|
+
});
|
|
918
|
+
}
|
|
919
|
+
set bone(value) {
|
|
920
|
+
this._bone = value;
|
|
921
|
+
this.cd.detectChanges();
|
|
922
|
+
}
|
|
923
|
+
get bone() {
|
|
924
|
+
if (this._bone === undefined || this._bone === null)
|
|
925
|
+
throw new Error('The property "bone" should be set at least once. For example in skeleton');
|
|
926
|
+
return this._bone;
|
|
927
|
+
}
|
|
928
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: BoneDirective, deps: [{ token: i0.ChangeDetectorRef }, { token: UnsubscriberService }, { token: LocalizeServiceBase }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
929
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.0.8", type: BoneDirective, isStandalone: true, selector: "[bonBoneDir]", ngImport: i0 }); }
|
|
930
|
+
}
|
|
931
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: BoneDirective, decorators: [{
|
|
932
|
+
type: Directive,
|
|
933
|
+
args: [{
|
|
934
|
+
selector: '[bonBoneDir]',
|
|
935
|
+
standalone: true
|
|
936
|
+
}]
|
|
937
|
+
}], ctorParameters: () => [{ type: i0.ChangeDetectorRef }, { type: UnsubscriberService }, { type: LocalizeServiceBase }] });
|
|
938
|
+
|
|
939
|
+
class SkeletonAnchorDirective {
|
|
940
|
+
constructor(viewContainerRef) {
|
|
941
|
+
this.viewContainerRef = viewContainerRef;
|
|
942
|
+
}
|
|
943
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: SkeletonAnchorDirective, deps: [{ token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
944
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.0.8", type: SkeletonAnchorDirective, isStandalone: true, selector: "[bonSkeletonAnchor]", ngImport: i0 }); }
|
|
945
|
+
}
|
|
946
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: SkeletonAnchorDirective, decorators: [{
|
|
947
|
+
type: Directive,
|
|
948
|
+
args: [{
|
|
949
|
+
selector: '[bonSkeletonAnchor]',
|
|
950
|
+
standalone: true
|
|
951
|
+
}]
|
|
952
|
+
}], ctorParameters: () => [{ type: i0.ViewContainerRef }] });
|
|
953
|
+
|
|
954
|
+
class UnknownBoneComponent {
|
|
955
|
+
constructor(cd, bd) {
|
|
956
|
+
this.cd = cd;
|
|
957
|
+
this.bd = bd;
|
|
958
|
+
console.log('BoneDirective', bd);
|
|
959
|
+
cd.detach();
|
|
960
|
+
}
|
|
961
|
+
ngOnInit() {
|
|
962
|
+
this.cd.detectChanges();
|
|
963
|
+
}
|
|
964
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: UnknownBoneComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: BoneDirective }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
965
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.0.8", type: UnknownBoneComponent, selector: "bon-unknown-bone", hostDirectives: [{ directive: BoneDirective }], ngImport: i0, template: `<h2>unknown bone {{bd.bone.type}}</h2>
|
|
966
|
+
<div>{{bd.bone | json}}</div>`, isInline: true, styles: [":host{display:block;border:2px solid red;box-sizing:border-box}\n"], dependencies: [{ kind: "pipe", type: i4.JsonPipe, name: "json" }] }); }
|
|
967
|
+
}
|
|
968
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: UnknownBoneComponent, decorators: [{
|
|
969
|
+
type: Component,
|
|
970
|
+
args: [{ selector: 'bon-unknown-bone', hostDirectives: [BoneDirective], template: `<h2>unknown bone {{bd.bone.type}}</h2>
|
|
971
|
+
<div>{{bd.bone | json}}</div>`, styles: [":host{display:block;border:2px solid red;box-sizing:border-box}\n"] }]
|
|
972
|
+
}], ctorParameters: () => [{ type: i0.ChangeDetectorRef }, { type: BoneDirective }] });
|
|
973
|
+
|
|
974
|
+
class SkeletonComponent {
|
|
975
|
+
constructor(cd) {
|
|
976
|
+
this.cd = cd;
|
|
977
|
+
this._bones = [];
|
|
978
|
+
this.iniailized = false;
|
|
979
|
+
}
|
|
980
|
+
ngOnInit() {
|
|
981
|
+
this.iniailized = true;
|
|
982
|
+
this.fillComponentFromBones();
|
|
983
|
+
}
|
|
984
|
+
set bones(newValue) {
|
|
985
|
+
this._bones.splice(0, this._bones.length);
|
|
986
|
+
this._bones.push(...newValue ?? []);
|
|
987
|
+
this.fillComponentFromBones();
|
|
988
|
+
}
|
|
989
|
+
fillComponentFromBones() {
|
|
990
|
+
if (this.iniailized === false)
|
|
991
|
+
return;
|
|
992
|
+
const viewContainerRef = this.skeletonAnchor.viewContainerRef;
|
|
993
|
+
viewContainerRef.clear();
|
|
994
|
+
if (this.map === undefined || this.map === null)
|
|
995
|
+
throw new Error('add type map with input: [map]="..."');
|
|
996
|
+
for (const bone of this._bones) {
|
|
997
|
+
let componentType = this.map.get(bone.type);
|
|
998
|
+
if (componentType === undefined || componentType === null) {
|
|
999
|
+
console.warn(`Mapping type for ${bone.type} not found`);
|
|
1000
|
+
componentType = UnknownBoneComponent;
|
|
1001
|
+
}
|
|
1002
|
+
const boneComponentRef = viewContainerRef.createComponent(componentType);
|
|
1003
|
+
boneComponentRef.instance.bd.bone = bone;
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: SkeletonComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1007
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.0.8", type: SkeletonComponent, selector: "bon-skeleton", inputs: { map: "map", bones: "bones" }, viewQueries: [{ propertyName: "skeletonAnchor", first: true, predicate: SkeletonAnchorDirective, descendants: true, static: true }], ngImport: i0, template: "<ng-template bonSkeletonAnchor></ng-template>\n", styles: [":host{display:block}\n"], dependencies: [{ kind: "directive", type: SkeletonAnchorDirective, selector: "[bonSkeletonAnchor]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
1008
|
+
}
|
|
1009
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: SkeletonComponent, decorators: [{
|
|
1010
|
+
type: Component,
|
|
1011
|
+
args: [{ selector: 'bon-skeleton', changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-template bonSkeletonAnchor></ng-template>\n", styles: [":host{display:block}\n"] }]
|
|
1012
|
+
}], ctorParameters: () => [{ type: i0.ChangeDetectorRef }], propDecorators: { skeletonAnchor: [{
|
|
1013
|
+
type: ViewChild,
|
|
1014
|
+
args: [SkeletonAnchorDirective, { static: true }]
|
|
1015
|
+
}], map: [{
|
|
1016
|
+
type: Input,
|
|
1017
|
+
args: [{ required: true }]
|
|
1018
|
+
}], bones: [{
|
|
1019
|
+
type: Input
|
|
1020
|
+
}] } });
|
|
1021
|
+
|
|
1022
|
+
const components = [
|
|
1023
|
+
MarcyImageComponent,
|
|
1024
|
+
MarcyVideoComponent,
|
|
1025
|
+
MarcyMediaComponent,
|
|
1026
|
+
IntersectionComponent,
|
|
1027
|
+
//
|
|
1028
|
+
SkeletonComponent,
|
|
1029
|
+
UnknownBoneComponent
|
|
1030
|
+
];
|
|
1031
|
+
const directives = [
|
|
1032
|
+
SrcBaseDirective,
|
|
1033
|
+
ImageSrcDirective,
|
|
1034
|
+
VideoSrcDirective,
|
|
1035
|
+
];
|
|
1036
|
+
const standAloneDirectives = [
|
|
1037
|
+
SkeletonAnchorDirective,
|
|
1038
|
+
BoneDirective
|
|
1039
|
+
];
|
|
1040
|
+
const pipes = [
|
|
1041
|
+
LocalizePipe,
|
|
1042
|
+
LocalizationIsNotEmptyPipe
|
|
1043
|
+
];
|
|
1044
|
+
class MarcyElementsModule {
|
|
1045
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: MarcyElementsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
1046
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.8", ngImport: i0, type: MarcyElementsModule, declarations: [MarcyImageComponent,
|
|
1047
|
+
MarcyVideoComponent,
|
|
1048
|
+
MarcyMediaComponent,
|
|
1049
|
+
IntersectionComponent,
|
|
1050
|
+
//
|
|
1051
|
+
SkeletonComponent,
|
|
1052
|
+
UnknownBoneComponent, SrcBaseDirective,
|
|
1053
|
+
ImageSrcDirective,
|
|
1054
|
+
VideoSrcDirective, LocalizePipe,
|
|
1055
|
+
LocalizationIsNotEmptyPipe], imports: [CommonModule, SkeletonAnchorDirective,
|
|
1056
|
+
BoneDirective], exports: [CommonModule, LocalizePipe,
|
|
1057
|
+
LocalizationIsNotEmptyPipe, MarcyImageComponent,
|
|
1058
|
+
MarcyVideoComponent,
|
|
1059
|
+
MarcyMediaComponent,
|
|
1060
|
+
IntersectionComponent,
|
|
1061
|
+
//
|
|
1062
|
+
SkeletonComponent,
|
|
1063
|
+
UnknownBoneComponent, SrcBaseDirective,
|
|
1064
|
+
ImageSrcDirective,
|
|
1065
|
+
VideoSrcDirective, SkeletonAnchorDirective,
|
|
1066
|
+
BoneDirective] }); }
|
|
1067
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: MarcyElementsModule, providers: [
|
|
1068
|
+
...pipes,
|
|
1069
|
+
UnsubscriberService,
|
|
1070
|
+
DeviceService,
|
|
1071
|
+
{ provide: DeviceServiceBase, useExisting: DeviceService },
|
|
1072
|
+
], imports: [CommonModule, CommonModule] }); }
|
|
1073
|
+
}
|
|
1074
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: MarcyElementsModule, decorators: [{
|
|
1075
|
+
type: NgModule,
|
|
1076
|
+
args: [{
|
|
1077
|
+
declarations: [
|
|
1078
|
+
...components,
|
|
1079
|
+
...directives,
|
|
1080
|
+
...pipes,
|
|
1081
|
+
],
|
|
1082
|
+
providers: [
|
|
1083
|
+
...pipes,
|
|
1084
|
+
UnsubscriberService,
|
|
1085
|
+
DeviceService,
|
|
1086
|
+
{ provide: DeviceServiceBase, useExisting: DeviceService },
|
|
1087
|
+
],
|
|
1088
|
+
imports: [
|
|
1089
|
+
CommonModule,
|
|
1090
|
+
...standAloneDirectives
|
|
1091
|
+
],
|
|
1092
|
+
exports: [
|
|
1093
|
+
CommonModule,
|
|
1094
|
+
...pipes,
|
|
1095
|
+
...components,
|
|
1096
|
+
...directives,
|
|
1097
|
+
...standAloneDirectives
|
|
1098
|
+
]
|
|
1099
|
+
}]
|
|
1100
|
+
}] });
|
|
1101
|
+
|
|
1102
|
+
/**
|
|
1103
|
+
* Generated bundle index. Do not edit.
|
|
1104
|
+
*/
|
|
1105
|
+
|
|
1106
|
+
export { BoneDirective, DeviceService, DeviceServiceBase, ImageSrcDirective, IntersectionComponent, IsLocalUrlPipe, IsNotLocalUrlPipe, LocalizationIsEmptyPipe, LocalizationIsNotEmptyPipe, LocalizeObjectPipe, LocalizePipe, LocalizeServiceBase, LocalizeUrlPipe, MarcyElementsModule, MarcyImageComponent, MarcyMediaComponent, MarcyVideoComponent, MediaObjectFit, MediaStatus, PublishStatus, SizesWidthUnit, SkeletonAnchorDirective, SkeletonComponent, SrcBaseDirective, UnknownBoneComponent, UnsubscriberService, VideoSrcDirective, getDefaultSrc, toHtmlPictureSources };
|
|
1107
|
+
//# sourceMappingURL=candy-kingdom-bonnie.mjs.map
|