vviinn-widgets 2.7.2 → 2.7.3
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/dist/cjs/{index-df6896e2.js → cropper-handler_30.cjs.entry.js} +2323 -165
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/vviinn-widgets.cjs.js +1 -1
- package/dist/collection/components/vviinn-product-card/vviinn-product-card.js +5 -2
- package/dist/esm/{app-globals-865bc7a7.js → app-globals-2f864b5d.js} +1 -1
- package/dist/esm/{index-2fdd499d.js → cropper-handler_30.entry.js} +2294 -119
- package/dist/esm/{index-443468c7.js → index-040cfca9.js} +2 -2
- package/dist/esm/{index-51f71d18.js → index-2d36a726.js} +1 -1
- package/dist/esm/loader.js +3 -3
- package/dist/esm/vviinn-recommendations-sidebar.entry.js +2 -2
- package/dist/esm/vviinn-vpr-button.entry.js +2 -2
- package/dist/esm/vviinn-widgets.js +3 -3
- package/dist/types/components/vviinn-product-card/vviinn-product-card.d.ts +1 -0
- package/dist/vviinn-widgets/{p-3469b71a.js → p-334db07e.js} +1 -1
- package/dist/vviinn-widgets/{p-40bea5b5.entry.js → p-a98df480.entry.js} +1 -1
- package/dist/vviinn-widgets/p-da99b592.entry.js +1 -0
- package/dist/vviinn-widgets/{p-a6e0710f.entry.js → p-dc124f62.entry.js} +1 -1
- package/dist/vviinn-widgets/{p-465d043d.js → p-e5a7f685.js} +1 -1
- package/dist/vviinn-widgets/{p-166970f3.js → p-fe8dc0b9.js} +1 -1
- package/dist/vviinn-widgets/vviinn-widgets.esm.js +1 -1
- package/package.json +1 -1
- package/www/build/{p-3469b71a.js → p-334db07e.js} +1 -1
- package/www/build/{p-40bea5b5.entry.js → p-a98df480.entry.js} +1 -1
- package/www/build/p-c5ef37e7.js +125 -0
- package/www/build/p-da99b592.entry.js +1 -0
- package/www/build/{p-a6e0710f.entry.js → p-dc124f62.entry.js} +1 -1
- package/www/build/p-e0153ae2.css +6 -0
- package/www/build/{p-465d043d.js → p-e5a7f685.js} +1 -1
- package/www/build/{p-166970f3.js → p-fe8dc0b9.js} +1 -1
- package/www/build/vviinn-widgets.esm.js +1 -1
- package/www/index.html +2495 -1
- package/dist/cjs/cropper-handler_27.cjs.entry.js +0 -1135
- package/dist/cjs/customized-slots-06ca4007.js +0 -53
- package/dist/cjs/vviinn-carousel_2.cjs.entry.js +0 -1001
- package/dist/cjs/vviinn-vps-button.cjs.entry.js +0 -43
- package/dist/esm/cropper-handler_27.entry.js +0 -1105
- package/dist/esm/customized-slots-96902edf.js +0 -50
- package/dist/esm/vviinn-carousel_2.entry.js +0 -996
- package/dist/esm/vviinn-vps-button.entry.js +0 -39
- package/dist/vviinn-widgets/p-2dd35f19.entry.js +0 -1
- package/dist/vviinn-widgets/p-59bd2a99.js +0 -1
- package/dist/vviinn-widgets/p-74ed36af.entry.js +0 -1
- package/dist/vviinn-widgets/p-9def6b8b.entry.js +0 -1
- package/dist/vviinn-widgets/p-cd995515.js +0 -1
- package/www/build/p-2dd35f19.entry.js +0 -1
- package/www/build/p-59bd2a99.js +0 -1
- package/www/build/p-61933b75.js +0 -1
- package/www/build/p-74ed36af.entry.js +0 -1
- package/www/build/p-9def6b8b.entry.js +0 -1
- package/www/build/p-a67898be.css +0 -1
- package/www/build/p-cd995515.js +0 -1
|
@@ -1,1001 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
const index = require('./index-3c3ab815.js');
|
|
6
|
-
const index$1 = require('./index-df6896e2.js');
|
|
7
|
-
const index$2 = require('./index-f66cd8d1.js');
|
|
8
|
-
|
|
9
|
-
const vviinnCarouselCss = ":host{--vviinn-progressbar-width:0;--vviinn-carousel-item-width:150px;--vviinn-carousel-columns-internal:var(--vviinn-carousel-columns, 4);--vviinn-carousel-image-width-system:140px}.body{display:flex;position:relative;width:var(--vviinn-carousel-content-width);flex-direction:column}.content-wrapper *{box-sizing:border-box}.content-wrapper{overflow-y:hidden;overflow-x:auto;flex-grow:1}.bullets{margin-top:16px;display:flex;flex-direction:row;grid-gap:24px;justify-content:center}.bullet{width:10px;height:10px;background:#E0E0E0;border-radius:50%;cursor:pointer}.bullet.active{background:#161616}.content:not(.show-scrollbar),.content.grid{scrollbar-color:#fff0 #fff0}.content:not(.show-scrollbar)::-webkit-scrollbar,.content.grid::-webkit-scrollbar{opacity:0}.content{display:flex;flex-direction:row;grid-gap:8px;-ms-scroll-snap-type:x mandatory;scroll-snap-type:x mandatory;overflow-y:hidden;overflow-x:auto;flex-grow:1;padding-bottom:16px}.content.left>*{scroll-snap-align:start}.content.right>*{scroll-snap-align:end}:host(.continuity) button{border-radius:2px}:host(.grid) button{border-radius:50%}button{align-items:center;background-color:white;border:none;box-shadow:0px 2px 6px rgba(0, 0, 0, 0.15);cursor:pointer;display:grid;height:40px;justify-items:center;position:absolute;top:calc(50% - 20px);width:40px;z-index:1;padding:0;margin:0}button{fill:#525252}button.prev svg{transform:rotate(180deg);margin-left:-5px}.prev{left:0}.next{right:0}.items-group{display:grid;grid-gap:16px;grid-template-columns:repeat(var(--vviinn-carousel-columns-internal), 1fr);min-width:100%}vviinn-product-card::part(price-container){text-align:center}:host(.classic) vviinn-product-card::part(title),:host(.classic) vviinn-product-card::part(brand),:host(.classic) vviinn-product-card::part(type){text-align:center}@media (max-width: 480px){:host(.modern) button{display:none}.items-group{grid-template-columns:repeat(2, 1fr)}}";
|
|
10
|
-
|
|
11
|
-
const COLUMNS_NUMBER_CSS_VAR = "--vviinn-carousel-columns-internal";
|
|
12
|
-
const CAROUSEL_WIDTH_CSS_VAR = "--vviinn-carousel-content-width";
|
|
13
|
-
const CAROUSEL_IMAGE_WIDTH_CSS_VAR = "--vviinn-carousel-image-width";
|
|
14
|
-
const CONTENT_GROUP_CSS_CLASS = "items-group";
|
|
15
|
-
let VviinnCarousel = class {
|
|
16
|
-
constructor(hostRef) {
|
|
17
|
-
index.registerInstance(this, hostRef);
|
|
18
|
-
this.moveDirection = "right";
|
|
19
|
-
this.contentGroups = [];
|
|
20
|
-
this.activeContentGroup = 0;
|
|
21
|
-
this.mode = "continuity";
|
|
22
|
-
this.imageWidth = 140;
|
|
23
|
-
this.showScroll = true;
|
|
24
|
-
this.recommendations = [];
|
|
25
|
-
this.columns = 0;
|
|
26
|
-
this.resizeObserver = new ResizeObserver(() => this.handleResize());
|
|
27
|
-
this.mutationObserver = new MutationObserver(() => this.cloneSlottedContent());
|
|
28
|
-
}
|
|
29
|
-
connectedCallback() {
|
|
30
|
-
this.setItemWidth();
|
|
31
|
-
}
|
|
32
|
-
disconnectedCallback() {
|
|
33
|
-
this.resizeObserver.disconnect();
|
|
34
|
-
}
|
|
35
|
-
componentDidLoad() {
|
|
36
|
-
this.setWidth();
|
|
37
|
-
this.processScrollbarWidth();
|
|
38
|
-
this.columns = this.getColumnsNumber();
|
|
39
|
-
const slot = this.el.querySelector(".content");
|
|
40
|
-
this.mutationObserver.observe(slot, { subtree: true, childList: true });
|
|
41
|
-
this.resizeObserver.observe(this.getHostParent());
|
|
42
|
-
}
|
|
43
|
-
getItemWidthFromDocument() {
|
|
44
|
-
return parseInt(getComputedStyle(document.body).getPropertyValue(CAROUSEL_IMAGE_WIDTH_CSS_VAR));
|
|
45
|
-
}
|
|
46
|
-
setItemWidth() {
|
|
47
|
-
const widthInDocument = this.getItemWidthFromDocument();
|
|
48
|
-
const itemWidth = isNaN(widthInDocument)
|
|
49
|
-
? this.imageWidth
|
|
50
|
-
: widthInDocument;
|
|
51
|
-
this.el.style.setProperty(CAROUSEL_IMAGE_WIDTH_CSS_VAR, `${itemWidth}px`);
|
|
52
|
-
}
|
|
53
|
-
getContentClassMap() {
|
|
54
|
-
return {
|
|
55
|
-
content: true,
|
|
56
|
-
[this.moveDirection]: true,
|
|
57
|
-
[this.mode]: true,
|
|
58
|
-
"show-scrollbar": this.showScroll,
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
handleResize() {
|
|
62
|
-
this.setWidth();
|
|
63
|
-
this.processScrollbarWidth();
|
|
64
|
-
this.setItemWidth();
|
|
65
|
-
const newColumns = this.getColumnsNumber();
|
|
66
|
-
if (newColumns !== this.columns) {
|
|
67
|
-
this.columns = newColumns;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
calculateMoveStep() {
|
|
71
|
-
const contentWidths = this.getContent().map((el) => el.getBoundingClientRect().width);
|
|
72
|
-
const sum = contentWidths.reduce((acc, val) => acc + val, 0);
|
|
73
|
-
return sum / contentWidths.length;
|
|
74
|
-
}
|
|
75
|
-
getHostParent() {
|
|
76
|
-
const parent = this.el.parentNode;
|
|
77
|
-
return parent.host.parentElement;
|
|
78
|
-
}
|
|
79
|
-
setWidth() {
|
|
80
|
-
const parent = this.getHostParent();
|
|
81
|
-
if (!parent)
|
|
82
|
-
return;
|
|
83
|
-
const parentStyles = getComputedStyle(parent);
|
|
84
|
-
const parentWidth = parent.getBoundingClientRect().width;
|
|
85
|
-
const width = parentWidth -
|
|
86
|
-
(parseInt(parentStyles["padding-right"]) +
|
|
87
|
-
parseInt(parentStyles["padding-left"]));
|
|
88
|
-
this.el.style.setProperty(CAROUSEL_WIDTH_CSS_VAR, `${width}px`);
|
|
89
|
-
}
|
|
90
|
-
getParent() {
|
|
91
|
-
const parentNode = this.el.parentNode;
|
|
92
|
-
const host = parentNode.host;
|
|
93
|
-
return host.parentElement;
|
|
94
|
-
}
|
|
95
|
-
cloneSlottedContent() {
|
|
96
|
-
this.setWidth();
|
|
97
|
-
}
|
|
98
|
-
getActiveGroupIndex() {
|
|
99
|
-
var _a, _b;
|
|
100
|
-
const contentNodeLeft = (_b = (_a = this.getContentNode()) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect()) === null || _b === void 0 ? void 0 : _b.left;
|
|
101
|
-
if (!contentNodeLeft)
|
|
102
|
-
return 0;
|
|
103
|
-
const groups = this.getContentGroups();
|
|
104
|
-
const groupsPositions = groups.map((g) => g.getBoundingClientRect().left);
|
|
105
|
-
const indexedPositions = groupsPositions
|
|
106
|
-
.map((value, index) => [value, index])
|
|
107
|
-
.filter((x) => x[0] >= 0);
|
|
108
|
-
return indexedPositions.length > 0 ? indexedPositions[0][1] : 0;
|
|
109
|
-
}
|
|
110
|
-
getContentNode() {
|
|
111
|
-
return this.el.querySelector(".content");
|
|
112
|
-
}
|
|
113
|
-
getContent() {
|
|
114
|
-
const children = this.getContentNode().children;
|
|
115
|
-
return Array.from(children).map((c) => c);
|
|
116
|
-
}
|
|
117
|
-
getColumnsNumber() {
|
|
118
|
-
const styleSheet = getComputedStyle(this.el);
|
|
119
|
-
const columnsInCss = styleSheet.getPropertyValue(COLUMNS_NUMBER_CSS_VAR);
|
|
120
|
-
return parseInt(columnsInCss);
|
|
121
|
-
}
|
|
122
|
-
getContentGroups() {
|
|
123
|
-
return Array.from(this.el.querySelectorAll(`.${CONTENT_GROUP_CSS_CLASS}`));
|
|
124
|
-
}
|
|
125
|
-
showNext() {
|
|
126
|
-
this.moveDirection = "right";
|
|
127
|
-
const contentContainer = this.getContentNode();
|
|
128
|
-
requestAnimationFrame(() => {
|
|
129
|
-
contentContainer.scrollTo({
|
|
130
|
-
top: 0,
|
|
131
|
-
left: contentContainer.scrollLeft + this.calculateMoveStep(),
|
|
132
|
-
behavior: "smooth",
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
showPrev() {
|
|
137
|
-
this.moveDirection = "left";
|
|
138
|
-
const contentContainer = this.getContentNode();
|
|
139
|
-
requestAnimationFrame(() => {
|
|
140
|
-
contentContainer.scrollTo({
|
|
141
|
-
top: 0,
|
|
142
|
-
left: contentContainer.scrollLeft - this.calculateMoveStep(),
|
|
143
|
-
behavior: "smooth",
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
scroll(index) {
|
|
148
|
-
const contentContainer = this.getContentNode();
|
|
149
|
-
requestAnimationFrame(() => {
|
|
150
|
-
contentContainer.scrollTo({
|
|
151
|
-
top: 0,
|
|
152
|
-
left: this.calculateMoveStep() * index,
|
|
153
|
-
behavior: "smooth",
|
|
154
|
-
});
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
processScrollbarWidth() {
|
|
158
|
-
const target = this.getContentNode();
|
|
159
|
-
const scrollRatio = (target.scrollLeft + target.clientWidth) / target.scrollWidth;
|
|
160
|
-
const scrolledWidth = target.clientWidth * scrollRatio;
|
|
161
|
-
this.el.style.setProperty("--vviinn-progressbar-width", `${scrolledWidth}px`);
|
|
162
|
-
this.activeContentGroup = this.getActiveGroupIndex();
|
|
163
|
-
}
|
|
164
|
-
showBullets() {
|
|
165
|
-
return this.mode === "grid" && this.showScroll;
|
|
166
|
-
}
|
|
167
|
-
showScrollbar() {
|
|
168
|
-
return this.mode === "continuity" && this.showScroll;
|
|
169
|
-
}
|
|
170
|
-
getClassMap() {
|
|
171
|
-
return {
|
|
172
|
-
[this.mode]: true,
|
|
173
|
-
"show-scrollbar": this.showScrollbar(),
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
renderRecommendation(recommendation, rank) {
|
|
177
|
-
return (index.h("vviinn-product-card", { part: "product-part", productId: recommendation.productId, productTitle: recommendation.title, deeplink: recommendation.deeplink, image: recommendation.image.thumbnail, brand: recommendation.brand, imageWidth: this.imageWidth, imageRatio: 1, price: recommendation.price.actual, salePrice: recommendation.price.sale, responsive: this.mode === "grid", dimmedBackground: this.mode === "continuity", index: rank }));
|
|
178
|
-
}
|
|
179
|
-
renderRecommendationGroup(elements) {
|
|
180
|
-
return index.h("div", { class: CONTENT_GROUP_CSS_CLASS }, elements);
|
|
181
|
-
}
|
|
182
|
-
renderRecommendationGroups(elements) {
|
|
183
|
-
return elements.map((el) => this.renderRecommendationGroup(el));
|
|
184
|
-
}
|
|
185
|
-
renderRecommendations() {
|
|
186
|
-
return this.mode === "grid"
|
|
187
|
-
? this.renderGrid()
|
|
188
|
-
: this.renderRecommendationsElements();
|
|
189
|
-
}
|
|
190
|
-
renderRecommendationsElements() {
|
|
191
|
-
return this.recommendations.map((r, i) => this.renderRecommendation(r, i));
|
|
192
|
-
}
|
|
193
|
-
renderGrid() {
|
|
194
|
-
const recommendations = this.renderRecommendationsElements();
|
|
195
|
-
const grouppedContent = index$1._Array.chunksOf(this.getColumnsNumber())(recommendations);
|
|
196
|
-
return this.renderRecommendationGroups(grouppedContent);
|
|
197
|
-
}
|
|
198
|
-
renderBullets() {
|
|
199
|
-
const numberOfBullets = Math.ceil(this.recommendations.length / this.getColumnsNumber());
|
|
200
|
-
const bulletsArray = Array.from(Array(numberOfBullets).keys());
|
|
201
|
-
return bulletsArray.map((index$1) => (index.h("div", { class: {
|
|
202
|
-
bullet: true,
|
|
203
|
-
active: this.activeContentGroup === index$1,
|
|
204
|
-
}, onClick: () => this.scroll(index$1) })));
|
|
205
|
-
}
|
|
206
|
-
render() {
|
|
207
|
-
return (index.h(index.Host, { class: this.getClassMap() }, index.h("div", { class: Object.assign({ body: true }, this.getClassMap()) }, index.h("button", { class: "prev", onClick: () => this.showPrev(), part: "carousel-button" }, index.h(index$2.ChevronIcon, null)), index.h("div", { class: this.getContentClassMap(), onScroll: () => this.processScrollbarWidth() }, this.renderRecommendations()), index.h("button", { class: "next", onClick: () => this.showNext(), part: "carousel-button" }, index.h(index$2.ChevronIcon, null))), this.showBullets() ? (index.h("div", { class: "bullets" }, this.renderBullets())) : ("")));
|
|
208
|
-
}
|
|
209
|
-
get el() { return index.getElement(this); }
|
|
210
|
-
};
|
|
211
|
-
VviinnCarousel.style = vviinnCarouselCss;
|
|
212
|
-
|
|
213
|
-
const createBearerString = (x) => `Bearer ${x}`;
|
|
214
|
-
const createAuthedHeader = (x) => new Headers({
|
|
215
|
-
Authorization: x,
|
|
216
|
-
});
|
|
217
|
-
const createFetchAuthOptions = (x) => {
|
|
218
|
-
return {
|
|
219
|
-
headers: x,
|
|
220
|
-
};
|
|
221
|
-
};
|
|
222
|
-
const createBearAuthedHeader = index$1._function.flow(createBearerString, createAuthedHeader, createFetchAuthOptions);
|
|
223
|
-
|
|
224
|
-
const isVPR = (c) => c._tag === "VPR";
|
|
225
|
-
function fold(onVPR, onVCS) {
|
|
226
|
-
return (c) => (isVPR(c) ? onVPR() : onVCS());
|
|
227
|
-
}
|
|
228
|
-
function fromString(s) {
|
|
229
|
-
return s === "VPR" ? { _tag: "VPR" } : { _tag: "VCS" };
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
const sequenceToEither = index$1.sequenceT(index$1.Apply);
|
|
233
|
-
const apiGet = (path, data = {}) => index$1.pipe(sequenceToEither(index$1.getApiPath(), index$1.createInitGetRequest), index$1.fromEither, index$1.chainW(index$1.makeRequest(path, data)));
|
|
234
|
-
|
|
235
|
-
const getVPRRecommendations = (productId) => (campaigns) => (options) => {
|
|
236
|
-
const url = index$1._function.pipe(campaigns, index$1.map(encodeURIComponent), index$1.match$1(() => `product/${productId}/similar-products`, (encodedCampaignsIds) => `product/${productId}/similar-products?campaigns=${encodedCampaignsIds}`));
|
|
237
|
-
return apiGet(url, options);
|
|
238
|
-
};
|
|
239
|
-
|
|
240
|
-
const getVCSRecommendations = (productId) => (campaigns) => (options) => {
|
|
241
|
-
const url = index$1._function.pipe(campaigns, index$1.map(encodeURIComponent), index$1.match$1(() => `product/${productId}/cross-selling-products`, (encodedCampaignsIds) => `product/${productId}/cross-selling-products?campaigns=${encodedCampaignsIds}`));
|
|
242
|
-
return apiGet(url, options);
|
|
243
|
-
};
|
|
244
|
-
|
|
245
|
-
const getRecommendationsService = (campaignType) => index$1._function.pipe(fromString(campaignType), fold(() => getVPRRecommendations, () => getVCSRecommendations));
|
|
246
|
-
|
|
247
|
-
function isFunction(value) {
|
|
248
|
-
return typeof value === 'function';
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
function createErrorClass(createImpl) {
|
|
252
|
-
const _super = (instance) => {
|
|
253
|
-
Error.call(instance);
|
|
254
|
-
instance.stack = new Error().stack;
|
|
255
|
-
};
|
|
256
|
-
const ctorFunc = createImpl(_super);
|
|
257
|
-
ctorFunc.prototype = Object.create(Error.prototype);
|
|
258
|
-
ctorFunc.prototype.constructor = ctorFunc;
|
|
259
|
-
return ctorFunc;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
const UnsubscriptionError = createErrorClass((_super) => function UnsubscriptionErrorImpl(errors) {
|
|
263
|
-
_super(this);
|
|
264
|
-
this.message = errors
|
|
265
|
-
? `${errors.length} errors occurred during unsubscription:
|
|
266
|
-
${errors.map((err, i) => `${i + 1}) ${err.toString()}`).join('\n ')}`
|
|
267
|
-
: '';
|
|
268
|
-
this.name = 'UnsubscriptionError';
|
|
269
|
-
this.errors = errors;
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
function arrRemove(arr, item) {
|
|
273
|
-
if (arr) {
|
|
274
|
-
const index = arr.indexOf(item);
|
|
275
|
-
0 <= index && arr.splice(index, 1);
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
class Subscription {
|
|
280
|
-
constructor(initialTeardown) {
|
|
281
|
-
this.initialTeardown = initialTeardown;
|
|
282
|
-
this.closed = false;
|
|
283
|
-
this._parentage = null;
|
|
284
|
-
this._finalizers = null;
|
|
285
|
-
}
|
|
286
|
-
unsubscribe() {
|
|
287
|
-
let errors;
|
|
288
|
-
if (!this.closed) {
|
|
289
|
-
this.closed = true;
|
|
290
|
-
const { _parentage } = this;
|
|
291
|
-
if (_parentage) {
|
|
292
|
-
this._parentage = null;
|
|
293
|
-
if (Array.isArray(_parentage)) {
|
|
294
|
-
for (const parent of _parentage) {
|
|
295
|
-
parent.remove(this);
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
else {
|
|
299
|
-
_parentage.remove(this);
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
const { initialTeardown: initialFinalizer } = this;
|
|
303
|
-
if (isFunction(initialFinalizer)) {
|
|
304
|
-
try {
|
|
305
|
-
initialFinalizer();
|
|
306
|
-
}
|
|
307
|
-
catch (e) {
|
|
308
|
-
errors = e instanceof UnsubscriptionError ? e.errors : [e];
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
const { _finalizers } = this;
|
|
312
|
-
if (_finalizers) {
|
|
313
|
-
this._finalizers = null;
|
|
314
|
-
for (const finalizer of _finalizers) {
|
|
315
|
-
try {
|
|
316
|
-
execFinalizer(finalizer);
|
|
317
|
-
}
|
|
318
|
-
catch (err) {
|
|
319
|
-
errors = errors !== null && errors !== void 0 ? errors : [];
|
|
320
|
-
if (err instanceof UnsubscriptionError) {
|
|
321
|
-
errors = [...errors, ...err.errors];
|
|
322
|
-
}
|
|
323
|
-
else {
|
|
324
|
-
errors.push(err);
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
if (errors) {
|
|
330
|
-
throw new UnsubscriptionError(errors);
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
add(teardown) {
|
|
335
|
-
var _a;
|
|
336
|
-
if (teardown && teardown !== this) {
|
|
337
|
-
if (this.closed) {
|
|
338
|
-
execFinalizer(teardown);
|
|
339
|
-
}
|
|
340
|
-
else {
|
|
341
|
-
if (teardown instanceof Subscription) {
|
|
342
|
-
if (teardown.closed || teardown._hasParent(this)) {
|
|
343
|
-
return;
|
|
344
|
-
}
|
|
345
|
-
teardown._addParent(this);
|
|
346
|
-
}
|
|
347
|
-
(this._finalizers = (_a = this._finalizers) !== null && _a !== void 0 ? _a : []).push(teardown);
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
_hasParent(parent) {
|
|
352
|
-
const { _parentage } = this;
|
|
353
|
-
return _parentage === parent || (Array.isArray(_parentage) && _parentage.includes(parent));
|
|
354
|
-
}
|
|
355
|
-
_addParent(parent) {
|
|
356
|
-
const { _parentage } = this;
|
|
357
|
-
this._parentage = Array.isArray(_parentage) ? (_parentage.push(parent), _parentage) : _parentage ? [_parentage, parent] : parent;
|
|
358
|
-
}
|
|
359
|
-
_removeParent(parent) {
|
|
360
|
-
const { _parentage } = this;
|
|
361
|
-
if (_parentage === parent) {
|
|
362
|
-
this._parentage = null;
|
|
363
|
-
}
|
|
364
|
-
else if (Array.isArray(_parentage)) {
|
|
365
|
-
arrRemove(_parentage, parent);
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
remove(teardown) {
|
|
369
|
-
const { _finalizers } = this;
|
|
370
|
-
_finalizers && arrRemove(_finalizers, teardown);
|
|
371
|
-
if (teardown instanceof Subscription) {
|
|
372
|
-
teardown._removeParent(this);
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
Subscription.EMPTY = (() => {
|
|
377
|
-
const empty = new Subscription();
|
|
378
|
-
empty.closed = true;
|
|
379
|
-
return empty;
|
|
380
|
-
})();
|
|
381
|
-
const EMPTY_SUBSCRIPTION = Subscription.EMPTY;
|
|
382
|
-
function isSubscription(value) {
|
|
383
|
-
return (value instanceof Subscription ||
|
|
384
|
-
(value && 'closed' in value && isFunction(value.remove) && isFunction(value.add) && isFunction(value.unsubscribe)));
|
|
385
|
-
}
|
|
386
|
-
function execFinalizer(finalizer) {
|
|
387
|
-
if (isFunction(finalizer)) {
|
|
388
|
-
finalizer();
|
|
389
|
-
}
|
|
390
|
-
else {
|
|
391
|
-
finalizer.unsubscribe();
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
const config = {
|
|
396
|
-
onUnhandledError: null,
|
|
397
|
-
onStoppedNotification: null,
|
|
398
|
-
Promise: undefined,
|
|
399
|
-
useDeprecatedSynchronousErrorHandling: false,
|
|
400
|
-
useDeprecatedNextContext: false,
|
|
401
|
-
};
|
|
402
|
-
|
|
403
|
-
const timeoutProvider = {
|
|
404
|
-
setTimeout(handler, timeout, ...args) {
|
|
405
|
-
const { delegate } = timeoutProvider;
|
|
406
|
-
if (delegate === null || delegate === void 0 ? void 0 : delegate.setTimeout) {
|
|
407
|
-
return delegate.setTimeout(handler, timeout, ...args);
|
|
408
|
-
}
|
|
409
|
-
return setTimeout(handler, timeout, ...args);
|
|
410
|
-
},
|
|
411
|
-
clearTimeout(handle) {
|
|
412
|
-
const { delegate } = timeoutProvider;
|
|
413
|
-
return ((delegate === null || delegate === void 0 ? void 0 : delegate.clearTimeout) || clearTimeout)(handle);
|
|
414
|
-
},
|
|
415
|
-
delegate: undefined,
|
|
416
|
-
};
|
|
417
|
-
|
|
418
|
-
function reportUnhandledError(err) {
|
|
419
|
-
timeoutProvider.setTimeout(() => {
|
|
420
|
-
const { onUnhandledError } = config;
|
|
421
|
-
if (onUnhandledError) {
|
|
422
|
-
onUnhandledError(err);
|
|
423
|
-
}
|
|
424
|
-
else {
|
|
425
|
-
throw err;
|
|
426
|
-
}
|
|
427
|
-
});
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
function noop() { }
|
|
431
|
-
|
|
432
|
-
const COMPLETE_NOTIFICATION = (() => createNotification('C', undefined, undefined))();
|
|
433
|
-
function errorNotification(error) {
|
|
434
|
-
return createNotification('E', undefined, error);
|
|
435
|
-
}
|
|
436
|
-
function nextNotification(value) {
|
|
437
|
-
return createNotification('N', value, undefined);
|
|
438
|
-
}
|
|
439
|
-
function createNotification(kind, value, error) {
|
|
440
|
-
return {
|
|
441
|
-
kind,
|
|
442
|
-
value,
|
|
443
|
-
error,
|
|
444
|
-
};
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
function errorContext(cb) {
|
|
448
|
-
{
|
|
449
|
-
cb();
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
class Subscriber extends Subscription {
|
|
454
|
-
constructor(destination) {
|
|
455
|
-
super();
|
|
456
|
-
this.isStopped = false;
|
|
457
|
-
if (destination) {
|
|
458
|
-
this.destination = destination;
|
|
459
|
-
if (isSubscription(destination)) {
|
|
460
|
-
destination.add(this);
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
else {
|
|
464
|
-
this.destination = EMPTY_OBSERVER;
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
static create(next, error, complete) {
|
|
468
|
-
return new SafeSubscriber(next, error, complete);
|
|
469
|
-
}
|
|
470
|
-
next(value) {
|
|
471
|
-
if (this.isStopped) {
|
|
472
|
-
handleStoppedNotification(nextNotification(value), this);
|
|
473
|
-
}
|
|
474
|
-
else {
|
|
475
|
-
this._next(value);
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
error(err) {
|
|
479
|
-
if (this.isStopped) {
|
|
480
|
-
handleStoppedNotification(errorNotification(err), this);
|
|
481
|
-
}
|
|
482
|
-
else {
|
|
483
|
-
this.isStopped = true;
|
|
484
|
-
this._error(err);
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
complete() {
|
|
488
|
-
if (this.isStopped) {
|
|
489
|
-
handleStoppedNotification(COMPLETE_NOTIFICATION, this);
|
|
490
|
-
}
|
|
491
|
-
else {
|
|
492
|
-
this.isStopped = true;
|
|
493
|
-
this._complete();
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
unsubscribe() {
|
|
497
|
-
if (!this.closed) {
|
|
498
|
-
this.isStopped = true;
|
|
499
|
-
super.unsubscribe();
|
|
500
|
-
this.destination = null;
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
_next(value) {
|
|
504
|
-
this.destination.next(value);
|
|
505
|
-
}
|
|
506
|
-
_error(err) {
|
|
507
|
-
try {
|
|
508
|
-
this.destination.error(err);
|
|
509
|
-
}
|
|
510
|
-
finally {
|
|
511
|
-
this.unsubscribe();
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
_complete() {
|
|
515
|
-
try {
|
|
516
|
-
this.destination.complete();
|
|
517
|
-
}
|
|
518
|
-
finally {
|
|
519
|
-
this.unsubscribe();
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
const _bind = Function.prototype.bind;
|
|
524
|
-
function bind(fn, thisArg) {
|
|
525
|
-
return _bind.call(fn, thisArg);
|
|
526
|
-
}
|
|
527
|
-
class ConsumerObserver {
|
|
528
|
-
constructor(partialObserver) {
|
|
529
|
-
this.partialObserver = partialObserver;
|
|
530
|
-
}
|
|
531
|
-
next(value) {
|
|
532
|
-
const { partialObserver } = this;
|
|
533
|
-
if (partialObserver.next) {
|
|
534
|
-
try {
|
|
535
|
-
partialObserver.next(value);
|
|
536
|
-
}
|
|
537
|
-
catch (error) {
|
|
538
|
-
handleUnhandledError(error);
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
error(err) {
|
|
543
|
-
const { partialObserver } = this;
|
|
544
|
-
if (partialObserver.error) {
|
|
545
|
-
try {
|
|
546
|
-
partialObserver.error(err);
|
|
547
|
-
}
|
|
548
|
-
catch (error) {
|
|
549
|
-
handleUnhandledError(error);
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
else {
|
|
553
|
-
handleUnhandledError(err);
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
complete() {
|
|
557
|
-
const { partialObserver } = this;
|
|
558
|
-
if (partialObserver.complete) {
|
|
559
|
-
try {
|
|
560
|
-
partialObserver.complete();
|
|
561
|
-
}
|
|
562
|
-
catch (error) {
|
|
563
|
-
handleUnhandledError(error);
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
class SafeSubscriber extends Subscriber {
|
|
569
|
-
constructor(observerOrNext, error, complete) {
|
|
570
|
-
super();
|
|
571
|
-
let partialObserver;
|
|
572
|
-
if (isFunction(observerOrNext) || !observerOrNext) {
|
|
573
|
-
partialObserver = {
|
|
574
|
-
next: observerOrNext !== null && observerOrNext !== void 0 ? observerOrNext : undefined,
|
|
575
|
-
error: error !== null && error !== void 0 ? error : undefined,
|
|
576
|
-
complete: complete !== null && complete !== void 0 ? complete : undefined,
|
|
577
|
-
};
|
|
578
|
-
}
|
|
579
|
-
else {
|
|
580
|
-
let context;
|
|
581
|
-
if (this && config.useDeprecatedNextContext) {
|
|
582
|
-
context = Object.create(observerOrNext);
|
|
583
|
-
context.unsubscribe = () => this.unsubscribe();
|
|
584
|
-
partialObserver = {
|
|
585
|
-
next: observerOrNext.next && bind(observerOrNext.next, context),
|
|
586
|
-
error: observerOrNext.error && bind(observerOrNext.error, context),
|
|
587
|
-
complete: observerOrNext.complete && bind(observerOrNext.complete, context),
|
|
588
|
-
};
|
|
589
|
-
}
|
|
590
|
-
else {
|
|
591
|
-
partialObserver = observerOrNext;
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
this.destination = new ConsumerObserver(partialObserver);
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
function handleUnhandledError(error) {
|
|
598
|
-
{
|
|
599
|
-
reportUnhandledError(error);
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
function defaultErrorHandler(err) {
|
|
603
|
-
throw err;
|
|
604
|
-
}
|
|
605
|
-
function handleStoppedNotification(notification, subscriber) {
|
|
606
|
-
const { onStoppedNotification } = config;
|
|
607
|
-
onStoppedNotification && timeoutProvider.setTimeout(() => onStoppedNotification(notification, subscriber));
|
|
608
|
-
}
|
|
609
|
-
const EMPTY_OBSERVER = {
|
|
610
|
-
closed: true,
|
|
611
|
-
next: noop,
|
|
612
|
-
error: defaultErrorHandler,
|
|
613
|
-
complete: noop,
|
|
614
|
-
};
|
|
615
|
-
|
|
616
|
-
const observable = (() => (typeof Symbol === 'function' && Symbol.observable) || '@@observable')();
|
|
617
|
-
|
|
618
|
-
function identity(x) {
|
|
619
|
-
return x;
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
function pipeFromArray(fns) {
|
|
623
|
-
if (fns.length === 0) {
|
|
624
|
-
return identity;
|
|
625
|
-
}
|
|
626
|
-
if (fns.length === 1) {
|
|
627
|
-
return fns[0];
|
|
628
|
-
}
|
|
629
|
-
return function piped(input) {
|
|
630
|
-
return fns.reduce((prev, fn) => fn(prev), input);
|
|
631
|
-
};
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
class Observable {
|
|
635
|
-
constructor(subscribe) {
|
|
636
|
-
if (subscribe) {
|
|
637
|
-
this._subscribe = subscribe;
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
|
-
lift(operator) {
|
|
641
|
-
const observable = new Observable();
|
|
642
|
-
observable.source = this;
|
|
643
|
-
observable.operator = operator;
|
|
644
|
-
return observable;
|
|
645
|
-
}
|
|
646
|
-
subscribe(observerOrNext, error, complete) {
|
|
647
|
-
const subscriber = isSubscriber(observerOrNext) ? observerOrNext : new SafeSubscriber(observerOrNext, error, complete);
|
|
648
|
-
errorContext(() => {
|
|
649
|
-
const { operator, source } = this;
|
|
650
|
-
subscriber.add(operator
|
|
651
|
-
?
|
|
652
|
-
operator.call(subscriber, source)
|
|
653
|
-
: source
|
|
654
|
-
?
|
|
655
|
-
this._subscribe(subscriber)
|
|
656
|
-
:
|
|
657
|
-
this._trySubscribe(subscriber));
|
|
658
|
-
});
|
|
659
|
-
return subscriber;
|
|
660
|
-
}
|
|
661
|
-
_trySubscribe(sink) {
|
|
662
|
-
try {
|
|
663
|
-
return this._subscribe(sink);
|
|
664
|
-
}
|
|
665
|
-
catch (err) {
|
|
666
|
-
sink.error(err);
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
forEach(next, promiseCtor) {
|
|
670
|
-
promiseCtor = getPromiseCtor(promiseCtor);
|
|
671
|
-
return new promiseCtor((resolve, reject) => {
|
|
672
|
-
const subscriber = new SafeSubscriber({
|
|
673
|
-
next: (value) => {
|
|
674
|
-
try {
|
|
675
|
-
next(value);
|
|
676
|
-
}
|
|
677
|
-
catch (err) {
|
|
678
|
-
reject(err);
|
|
679
|
-
subscriber.unsubscribe();
|
|
680
|
-
}
|
|
681
|
-
},
|
|
682
|
-
error: reject,
|
|
683
|
-
complete: resolve,
|
|
684
|
-
});
|
|
685
|
-
this.subscribe(subscriber);
|
|
686
|
-
});
|
|
687
|
-
}
|
|
688
|
-
_subscribe(subscriber) {
|
|
689
|
-
var _a;
|
|
690
|
-
return (_a = this.source) === null || _a === void 0 ? void 0 : _a.subscribe(subscriber);
|
|
691
|
-
}
|
|
692
|
-
[observable]() {
|
|
693
|
-
return this;
|
|
694
|
-
}
|
|
695
|
-
pipe(...operations) {
|
|
696
|
-
return pipeFromArray(operations)(this);
|
|
697
|
-
}
|
|
698
|
-
toPromise(promiseCtor) {
|
|
699
|
-
promiseCtor = getPromiseCtor(promiseCtor);
|
|
700
|
-
return new promiseCtor((resolve, reject) => {
|
|
701
|
-
let value;
|
|
702
|
-
this.subscribe((x) => (value = x), (err) => reject(err), () => resolve(value));
|
|
703
|
-
});
|
|
704
|
-
}
|
|
705
|
-
}
|
|
706
|
-
Observable.create = (subscribe) => {
|
|
707
|
-
return new Observable(subscribe);
|
|
708
|
-
};
|
|
709
|
-
function getPromiseCtor(promiseCtor) {
|
|
710
|
-
var _a;
|
|
711
|
-
return (_a = promiseCtor !== null && promiseCtor !== void 0 ? promiseCtor : config.Promise) !== null && _a !== void 0 ? _a : Promise;
|
|
712
|
-
}
|
|
713
|
-
function isObserver(value) {
|
|
714
|
-
return value && isFunction(value.next) && isFunction(value.error) && isFunction(value.complete);
|
|
715
|
-
}
|
|
716
|
-
function isSubscriber(value) {
|
|
717
|
-
return (value && value instanceof Subscriber) || (isObserver(value) && isSubscription(value));
|
|
718
|
-
}
|
|
719
|
-
|
|
720
|
-
const ObjectUnsubscribedError = createErrorClass((_super) => function ObjectUnsubscribedErrorImpl() {
|
|
721
|
-
_super(this);
|
|
722
|
-
this.name = 'ObjectUnsubscribedError';
|
|
723
|
-
this.message = 'object unsubscribed';
|
|
724
|
-
});
|
|
725
|
-
|
|
726
|
-
class Subject extends Observable {
|
|
727
|
-
constructor() {
|
|
728
|
-
super();
|
|
729
|
-
this.closed = false;
|
|
730
|
-
this.currentObservers = null;
|
|
731
|
-
this.observers = [];
|
|
732
|
-
this.isStopped = false;
|
|
733
|
-
this.hasError = false;
|
|
734
|
-
this.thrownError = null;
|
|
735
|
-
}
|
|
736
|
-
lift(operator) {
|
|
737
|
-
const subject = new AnonymousSubject(this, this);
|
|
738
|
-
subject.operator = operator;
|
|
739
|
-
return subject;
|
|
740
|
-
}
|
|
741
|
-
_throwIfClosed() {
|
|
742
|
-
if (this.closed) {
|
|
743
|
-
throw new ObjectUnsubscribedError();
|
|
744
|
-
}
|
|
745
|
-
}
|
|
746
|
-
next(value) {
|
|
747
|
-
errorContext(() => {
|
|
748
|
-
this._throwIfClosed();
|
|
749
|
-
if (!this.isStopped) {
|
|
750
|
-
if (!this.currentObservers) {
|
|
751
|
-
this.currentObservers = Array.from(this.observers);
|
|
752
|
-
}
|
|
753
|
-
for (const observer of this.currentObservers) {
|
|
754
|
-
observer.next(value);
|
|
755
|
-
}
|
|
756
|
-
}
|
|
757
|
-
});
|
|
758
|
-
}
|
|
759
|
-
error(err) {
|
|
760
|
-
errorContext(() => {
|
|
761
|
-
this._throwIfClosed();
|
|
762
|
-
if (!this.isStopped) {
|
|
763
|
-
this.hasError = this.isStopped = true;
|
|
764
|
-
this.thrownError = err;
|
|
765
|
-
const { observers } = this;
|
|
766
|
-
while (observers.length) {
|
|
767
|
-
observers.shift().error(err);
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
});
|
|
771
|
-
}
|
|
772
|
-
complete() {
|
|
773
|
-
errorContext(() => {
|
|
774
|
-
this._throwIfClosed();
|
|
775
|
-
if (!this.isStopped) {
|
|
776
|
-
this.isStopped = true;
|
|
777
|
-
const { observers } = this;
|
|
778
|
-
while (observers.length) {
|
|
779
|
-
observers.shift().complete();
|
|
780
|
-
}
|
|
781
|
-
}
|
|
782
|
-
});
|
|
783
|
-
}
|
|
784
|
-
unsubscribe() {
|
|
785
|
-
this.isStopped = this.closed = true;
|
|
786
|
-
this.observers = this.currentObservers = null;
|
|
787
|
-
}
|
|
788
|
-
get observed() {
|
|
789
|
-
var _a;
|
|
790
|
-
return ((_a = this.observers) === null || _a === void 0 ? void 0 : _a.length) > 0;
|
|
791
|
-
}
|
|
792
|
-
_trySubscribe(subscriber) {
|
|
793
|
-
this._throwIfClosed();
|
|
794
|
-
return super._trySubscribe(subscriber);
|
|
795
|
-
}
|
|
796
|
-
_subscribe(subscriber) {
|
|
797
|
-
this._throwIfClosed();
|
|
798
|
-
this._checkFinalizedStatuses(subscriber);
|
|
799
|
-
return this._innerSubscribe(subscriber);
|
|
800
|
-
}
|
|
801
|
-
_innerSubscribe(subscriber) {
|
|
802
|
-
const { hasError, isStopped, observers } = this;
|
|
803
|
-
if (hasError || isStopped) {
|
|
804
|
-
return EMPTY_SUBSCRIPTION;
|
|
805
|
-
}
|
|
806
|
-
this.currentObservers = null;
|
|
807
|
-
observers.push(subscriber);
|
|
808
|
-
return new Subscription(() => {
|
|
809
|
-
this.currentObservers = null;
|
|
810
|
-
arrRemove(observers, subscriber);
|
|
811
|
-
});
|
|
812
|
-
}
|
|
813
|
-
_checkFinalizedStatuses(subscriber) {
|
|
814
|
-
const { hasError, thrownError, isStopped } = this;
|
|
815
|
-
if (hasError) {
|
|
816
|
-
subscriber.error(thrownError);
|
|
817
|
-
}
|
|
818
|
-
else if (isStopped) {
|
|
819
|
-
subscriber.complete();
|
|
820
|
-
}
|
|
821
|
-
}
|
|
822
|
-
asObservable() {
|
|
823
|
-
const observable = new Observable();
|
|
824
|
-
observable.source = this;
|
|
825
|
-
return observable;
|
|
826
|
-
}
|
|
827
|
-
}
|
|
828
|
-
Subject.create = (destination, source) => {
|
|
829
|
-
return new AnonymousSubject(destination, source);
|
|
830
|
-
};
|
|
831
|
-
class AnonymousSubject extends Subject {
|
|
832
|
-
constructor(destination, source) {
|
|
833
|
-
super();
|
|
834
|
-
this.destination = destination;
|
|
835
|
-
this.source = source;
|
|
836
|
-
}
|
|
837
|
-
next(value) {
|
|
838
|
-
var _a, _b;
|
|
839
|
-
(_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.next) === null || _b === void 0 ? void 0 : _b.call(_a, value);
|
|
840
|
-
}
|
|
841
|
-
error(err) {
|
|
842
|
-
var _a, _b;
|
|
843
|
-
(_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.error) === null || _b === void 0 ? void 0 : _b.call(_a, err);
|
|
844
|
-
}
|
|
845
|
-
complete() {
|
|
846
|
-
var _a, _b;
|
|
847
|
-
(_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.complete) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
848
|
-
}
|
|
849
|
-
_subscribe(subscriber) {
|
|
850
|
-
var _a, _b;
|
|
851
|
-
return (_b = (_a = this.source) === null || _a === void 0 ? void 0 : _a.subscribe(subscriber)) !== null && _b !== void 0 ? _b : EMPTY_SUBSCRIPTION;
|
|
852
|
-
}
|
|
853
|
-
}
|
|
854
|
-
|
|
855
|
-
const vviinnVprWidgetCss = ":host{display:grid;grid-gap:1rem;width:100%}:host(:not(.loaded)){position:absolute;visibility:hidden}:host(.grid) vviinn-product-card::part(image){border:1px solid #DDDDDD;width:100%}h2{margin:0}vviinn-product-card::part(price-container){align-self:flex-start;text-align:left;display:flex}.results{display:grid;grid-gap:1rem}.visually-hidden{position:absolute;top:0;left:0;z-index:-1;height:0;width:0}h2{margin:0}:host(.grid) h2{justify-content:center}:host(.grid) vviinn-product-card::part(image){min-width:100%}:host(.grid) vviinn-product-card::part(image-link){width:100%}:host(.grid) vviinn-product-card::part(title),:host(.grid) vviinn-product-card::part(brand),:host(.grid) vviinn-product-card::part(type){text-align:center}:host(.grid) vviinn-product-card::part(price-container){align-self:center}:host(.continuity) vviinn-product-card::part(title),:host(.continuity) vviinn-product-card::part(brand),:host(.continuity) vviinn-product-card::part(type),:host(.continuity) vviinn-product-card::part(deeplink){text-align:left;max-width:unset;align-self:start}";
|
|
856
|
-
|
|
857
|
-
let VviinnVprWidget = class {
|
|
858
|
-
constructor(hostRef) {
|
|
859
|
-
index.registerInstance(this, hostRef);
|
|
860
|
-
this.recommendationsLoaded = index.createEvent(this, "recommendationsLoaded", 7);
|
|
861
|
-
/** Title for recommendations widget */
|
|
862
|
-
this.blockTitle = "Recommended products";
|
|
863
|
-
/** Ratio of each recommended product image */
|
|
864
|
-
this.imageRatio = 1;
|
|
865
|
-
/** Width of each recommended product image */
|
|
866
|
-
this.imageWidth = 300;
|
|
867
|
-
/** Currency sign will shown after price */
|
|
868
|
-
this.currencySign = "€";
|
|
869
|
-
/** Use slider or grid view */
|
|
870
|
-
this.mode = "continuity";
|
|
871
|
-
/** Campaign type */
|
|
872
|
-
this.campaignType = "VPR";
|
|
873
|
-
/** Locale for currency formatting */
|
|
874
|
-
this.locale = "de-DE";
|
|
875
|
-
/** comma-separated list of campaign-ids */
|
|
876
|
-
this.campaigns = "";
|
|
877
|
-
/** @internal */
|
|
878
|
-
this.apiPath = "https://api.vviinn.com";
|
|
879
|
-
/** @internal */
|
|
880
|
-
this.useCarousel = true;
|
|
881
|
-
this.showScroll = true;
|
|
882
|
-
this.cssUrl = null;
|
|
883
|
-
this.recommendations = [];
|
|
884
|
-
this.loaded = false;
|
|
885
|
-
this.productImageLoadedSubject = new Subject();
|
|
886
|
-
}
|
|
887
|
-
handleProductIdChange() {
|
|
888
|
-
this.getRecommendations();
|
|
889
|
-
}
|
|
890
|
-
handleCampaignTypeChange() {
|
|
891
|
-
this.getRecommendations();
|
|
892
|
-
}
|
|
893
|
-
handleCampaignsChange() {
|
|
894
|
-
this.getRecommendations();
|
|
895
|
-
}
|
|
896
|
-
handleApiPathChange(newPath) {
|
|
897
|
-
index$1.state.apiPath = newPath;
|
|
898
|
-
this.getRecommendations();
|
|
899
|
-
}
|
|
900
|
-
handleImageLoading({ detail }) {
|
|
901
|
-
this.productImageLoadedSubject.next(detail);
|
|
902
|
-
}
|
|
903
|
-
trackRecommendationView({ detail }) {
|
|
904
|
-
const recommendationViewEvent = index$1.createProductViewVprEvent(Object.assign({ session_id: this.uiSessionId }, detail));
|
|
905
|
-
this.trackingApi.trackEvent(recommendationViewEvent);
|
|
906
|
-
}
|
|
907
|
-
trackRecommendationClick({ detail }) {
|
|
908
|
-
const recommendationClickEvent = index$1.createProductClickVprEvent(Object.assign({ session_id: this.uiSessionId }, detail));
|
|
909
|
-
this.trackingApi.trackEvent(recommendationClickEvent).finally(() => {
|
|
910
|
-
const product = this.recommendations.find((r) => r.productId === detail.product);
|
|
911
|
-
if (!product || !product.deeplink)
|
|
912
|
-
return;
|
|
913
|
-
window.location.href = product.deeplink;
|
|
914
|
-
});
|
|
915
|
-
}
|
|
916
|
-
connectedCallback() {
|
|
917
|
-
index$1.state.apiPath = this.apiPath;
|
|
918
|
-
index$1.state.currencySign = this.currencySign;
|
|
919
|
-
index$1.state.locale = this.locale;
|
|
920
|
-
this.uiSessionId = index$1.v4();
|
|
921
|
-
this.trackingApi = index$1.createTrackingApi(this.apiPath, this.token);
|
|
922
|
-
const widgetOpenEvent = index$1.createWidgetVprEvent({
|
|
923
|
-
action: "open",
|
|
924
|
-
session_id: this.uiSessionId,
|
|
925
|
-
});
|
|
926
|
-
this.trackingApi.trackEvent(widgetOpenEvent);
|
|
927
|
-
}
|
|
928
|
-
disconnectedCallback() {
|
|
929
|
-
const widgetCloseEvent = index$1.createWidgetVprEvent({
|
|
930
|
-
action: "close",
|
|
931
|
-
session_id: this.uiSessionId,
|
|
932
|
-
});
|
|
933
|
-
this.trackingApi.trackEvent(widgetCloseEvent);
|
|
934
|
-
}
|
|
935
|
-
async componentWillLoad() {
|
|
936
|
-
index$1.state.pricePrefix = this.pricePrefix;
|
|
937
|
-
index$1.state.currencySign = this.currencySign;
|
|
938
|
-
this.getRecommendations();
|
|
939
|
-
}
|
|
940
|
-
async getRecommendations() {
|
|
941
|
-
if (this.productId === undefined || this.token === undefined)
|
|
942
|
-
return;
|
|
943
|
-
const campaignType = this.campaignType.length > 0 ? this.campaignType : "VPR";
|
|
944
|
-
const headers = createBearAuthedHeader(this.token);
|
|
945
|
-
const request = index$1._function.pipe(index$1.TaskEither.of(getRecommendationsService(campaignType)), index$1.TaskEither.ap(index$1.TaskEither.of(this.productId)), index$1.TaskEither.ap(index$1.TaskEither.of(index$1.checkEmpryString(this.campaigns))), index$1.TaskEither.ap(index$1.TaskEither.of(headers)), index$1.TaskEither.flatten);
|
|
946
|
-
const runRequest = await request();
|
|
947
|
-
index$1._function.pipe(runRequest, index$1.Either.fold((error) => this.handleError(error), (data) => this.handleRecommendationsSucces(data)));
|
|
948
|
-
}
|
|
949
|
-
handleError(error) {
|
|
950
|
-
console.log("ERROR:", error);
|
|
951
|
-
}
|
|
952
|
-
handleRecommendationsSucces(data) {
|
|
953
|
-
var _a;
|
|
954
|
-
this.recommendations = (_a = data === null || data === void 0 ? void 0 : data.extended) !== null && _a !== void 0 ? _a : data;
|
|
955
|
-
index$1.imageSearchState.results = this.recommendations;
|
|
956
|
-
this.loaded = true;
|
|
957
|
-
this.productIds = this.recommendations.map((r) => r.productId);
|
|
958
|
-
this.productImageLoadedSubject.subscribe((id) => {
|
|
959
|
-
this.productIds = this.productIds.filter((x) => x !== id);
|
|
960
|
-
if (this.productIds.length === 0) {
|
|
961
|
-
this.recommendationsLoaded.emit();
|
|
962
|
-
}
|
|
963
|
-
});
|
|
964
|
-
}
|
|
965
|
-
isExternalCSS() {
|
|
966
|
-
return this.cssUrl && this.cssUrl.length > 0;
|
|
967
|
-
}
|
|
968
|
-
renderExternalCSS() {
|
|
969
|
-
return this.isExternalCSS() ? (index.h("link", { href: this.cssUrl, rel: "stylesheet" })) : ("");
|
|
970
|
-
}
|
|
971
|
-
render() {
|
|
972
|
-
return (index.h(index.Host, { class: {
|
|
973
|
-
loaded: this.loaded,
|
|
974
|
-
empty: this.recommendations.length == 0,
|
|
975
|
-
[this.mode]: true,
|
|
976
|
-
}, "aria-hidden": this.loaded ? "false" : "true" }, this.renderExternalCSS(), index.h("style", null, index$1.state.fallbackStyles), index.h("h2", { part: "recommendations-title" }, this.blockTitle), this.useCarousel ? this.renderCarousel() : this.renderResults()));
|
|
977
|
-
}
|
|
978
|
-
renderRecommendation(recommendation, index$1) {
|
|
979
|
-
return (index.h("vviinn-product-card", { part: "product-part", productId: recommendation.productId, productTitle: recommendation.title, deeplink: recommendation.deeplink, image: recommendation.image.thumbnail, brand: recommendation.brand, imageWidth: this.imageWidth, imageRatio: 1, price: recommendation.price.actual, salePrice: recommendation.price.sale, responsive: this.mode === "grid", dimmedBackground: this.useDimmedBackgroundInCard(), index: index$1 }));
|
|
980
|
-
}
|
|
981
|
-
useDimmedBackgroundInCard() {
|
|
982
|
-
return this.mode === "continuity" || !this.useCarousel;
|
|
983
|
-
}
|
|
984
|
-
renderResults() {
|
|
985
|
-
return (index.h("div", { class: "recommendations-grid", part: "recommendations-grid" }, this.recommendations.map((r, i) => this.renderRecommendation(r, i))));
|
|
986
|
-
}
|
|
987
|
-
renderCarousel() {
|
|
988
|
-
return (index.h("vviinn-carousel", { mode: this.mode, imageWidth: this.imageWidth, showScroll: this.showScroll, recommendations: this.recommendations }));
|
|
989
|
-
}
|
|
990
|
-
get el() { return index.getElement(this); }
|
|
991
|
-
static get watchers() { return {
|
|
992
|
-
"productId": ["handleProductIdChange"],
|
|
993
|
-
"campaignType": ["handleCampaignTypeChange"],
|
|
994
|
-
"campaigns": ["handleCampaignsChange"],
|
|
995
|
-
"apiPath": ["handleApiPathChange"]
|
|
996
|
-
}; }
|
|
997
|
-
};
|
|
998
|
-
VviinnVprWidget.style = vviinnVprWidgetCss;
|
|
999
|
-
|
|
1000
|
-
exports.vviinn_carousel = VviinnCarousel;
|
|
1001
|
-
exports.vviinn_vpr_widget = VviinnVprWidget;
|