@shopgate/webpack 7.23.5-beta.5 → 7.23.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopgate/webpack",
3
- "version": "7.23.5-beta.5",
3
+ "version": "7.23.5",
4
4
  "description": "The webpack configuration for Shopgate's Engage.",
5
5
  "main": "webpack.config.js",
6
6
  "license": "Apache-2.0",
@@ -0,0 +1,347 @@
1
+ /* eslint-disable import/extensions, require-jsdoc, no-void, no-param-reassign,
2
+ prefer-destructuring, no-underscore-dangle, consistent-return, no-mixed-operators,
3
+ eslint-comments/no-unlimited-disable, prefer-rest-params, max-len */
4
+ /**
5
+ * Replacement of a sub-module of the Swiper library.
6
+ * Contains some refactored code inside the elementIsChildOfSlot function to remove optional
7
+ * chaining which causes issues with webpack.
8
+ */
9
+ import { a as getWindow, g as getDocument } from 'swiper/shared/ssr-window.esm.mjs';
10
+
11
+ function classesToTokens(classes) {
12
+ if (classes === void 0) {
13
+ classes = '';
14
+ }
15
+ return classes.trim().split(' ').filter(c => !!c.trim());
16
+ }
17
+
18
+ function deleteProps(obj) {
19
+ const object = obj;
20
+ Object.keys(object).forEach((key) => {
21
+ try {
22
+ object[key] = null;
23
+ } catch (e) {
24
+ // no getter for object
25
+ }
26
+ try {
27
+ delete object[key];
28
+ } catch (e) {
29
+ // something got wrong
30
+ }
31
+ });
32
+ }
33
+ function nextTick(callback, delay) {
34
+ if (delay === void 0) {
35
+ delay = 0;
36
+ }
37
+ return setTimeout(callback, delay);
38
+ }
39
+ function now() {
40
+ return Date.now();
41
+ }
42
+ function getComputedStyle(el) {
43
+ const window = getWindow();
44
+ let style;
45
+ if (window.getComputedStyle) {
46
+ style = window.getComputedStyle(el, null);
47
+ }
48
+ if (!style && el.currentStyle) {
49
+ style = el.currentStyle;
50
+ }
51
+ if (!style) {
52
+ style = el.style;
53
+ }
54
+ return style;
55
+ }
56
+ function getTranslate(el, axis) {
57
+ if (axis === void 0) {
58
+ axis = 'x';
59
+ }
60
+ const window = getWindow();
61
+ let matrix;
62
+ let curTransform;
63
+ let transformMatrix;
64
+ const curStyle = getComputedStyle(el);
65
+ if (window.WebKitCSSMatrix) {
66
+ curTransform = curStyle.transform || curStyle.webkitTransform;
67
+ if (curTransform.split(',').length > 6) {
68
+ curTransform = curTransform.split(', ').map(a => a.replace(',', '.')).join(', ');
69
+ }
70
+ // Some old versions of Webkit choke when 'none' is passed; pass
71
+ // empty string instead in this case
72
+ transformMatrix = new window.WebKitCSSMatrix(curTransform === 'none' ? '' : curTransform);
73
+ } else {
74
+ transformMatrix = curStyle.MozTransform || curStyle.OTransform || curStyle.MsTransform || curStyle.msTransform || curStyle.transform || curStyle.getPropertyValue('transform').replace('translate(', 'matrix(1, 0, 0, 1,');
75
+ matrix = transformMatrix.toString().split(',');
76
+ }
77
+ if (axis === 'x') {
78
+ // Latest Chrome and webkits Fix
79
+ if (window.WebKitCSSMatrix) curTransform = transformMatrix.m41;
80
+ // Crazy IE10 Matrix
81
+ else if (matrix.length === 16) curTransform = parseFloat(matrix[12]);
82
+ // Normal Browsers
83
+ else curTransform = parseFloat(matrix[4]);
84
+ }
85
+ if (axis === 'y') {
86
+ // Latest Chrome and webkits Fix
87
+ if (window.WebKitCSSMatrix) curTransform = transformMatrix.m42;
88
+ // Crazy IE10 Matrix
89
+ else if (matrix.length === 16) curTransform = parseFloat(matrix[13]);
90
+ // Normal Browsers
91
+ else curTransform = parseFloat(matrix[5]);
92
+ }
93
+ return curTransform || 0;
94
+ }
95
+ function isObject(o) {
96
+ return typeof o === 'object' && o !== null && o.constructor && Object.prototype.toString.call(o).slice(8, -1) === 'Object';
97
+ }
98
+ function isNode(node) {
99
+ if (typeof window !== 'undefined' && typeof window.HTMLElement !== 'undefined') {
100
+ return node instanceof HTMLElement;
101
+ }
102
+ return node && (node.nodeType === 1 || node.nodeType === 11);
103
+ }
104
+ function extend() {
105
+ const to = Object(arguments.length <= 0 ? undefined : arguments[0]);
106
+ const noExtend = ['__proto__', 'constructor', 'prototype'];
107
+ for (let i = 1; i < arguments.length; i += 1) {
108
+ const nextSource = i < 0 || arguments.length <= i ? undefined : arguments[i];
109
+ if (nextSource !== undefined && nextSource !== null && !isNode(nextSource)) {
110
+ const keysArray = Object.keys(Object(nextSource)).filter(key => noExtend.indexOf(key) < 0);
111
+ for (let nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex += 1) {
112
+ const nextKey = keysArray[nextIndex];
113
+ const desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);
114
+ if (desc !== undefined && desc.enumerable) {
115
+ if (isObject(to[nextKey]) && isObject(nextSource[nextKey])) {
116
+ if (nextSource[nextKey].__swiper__) {
117
+ to[nextKey] = nextSource[nextKey];
118
+ } else {
119
+ extend(to[nextKey], nextSource[nextKey]);
120
+ }
121
+ } else if (!isObject(to[nextKey]) && isObject(nextSource[nextKey])) {
122
+ to[nextKey] = {};
123
+ if (nextSource[nextKey].__swiper__) {
124
+ to[nextKey] = nextSource[nextKey];
125
+ } else {
126
+ extend(to[nextKey], nextSource[nextKey]);
127
+ }
128
+ } else {
129
+ to[nextKey] = nextSource[nextKey];
130
+ }
131
+ }
132
+ }
133
+ }
134
+ }
135
+ return to;
136
+ }
137
+ function setCSSProperty(el, varName, varValue) {
138
+ el.style.setProperty(varName, varValue);
139
+ }
140
+ function animateCSSModeScroll(_ref) {
141
+ const {
142
+ swiper,
143
+ targetPosition,
144
+ side,
145
+ } = _ref;
146
+ const window = getWindow();
147
+ const startPosition = -swiper.translate;
148
+ let startTime = null;
149
+ let time;
150
+ const duration = swiper.params.speed;
151
+ swiper.wrapperEl.style.scrollSnapType = 'none';
152
+ window.cancelAnimationFrame(swiper.cssModeFrameID);
153
+ const dir = targetPosition > startPosition ? 'next' : 'prev';
154
+ const isOutOfBound = (current, target) => dir === 'next' && current >= target || dir === 'prev' && current <= target;
155
+ const animate = () => {
156
+ time = new Date().getTime();
157
+ if (startTime === null) {
158
+ startTime = time;
159
+ }
160
+ const progress = Math.max(Math.min((time - startTime) / duration, 1), 0);
161
+ const easeProgress = 0.5 - Math.cos(progress * Math.PI) / 2;
162
+ let currentPosition = startPosition + easeProgress * (targetPosition - startPosition);
163
+ if (isOutOfBound(currentPosition, targetPosition)) {
164
+ currentPosition = targetPosition;
165
+ }
166
+ swiper.wrapperEl.scrollTo({
167
+ [side]: currentPosition,
168
+ });
169
+ if (isOutOfBound(currentPosition, targetPosition)) {
170
+ swiper.wrapperEl.style.overflow = 'hidden';
171
+ swiper.wrapperEl.style.scrollSnapType = '';
172
+ setTimeout(() => {
173
+ swiper.wrapperEl.style.overflow = '';
174
+ swiper.wrapperEl.scrollTo({
175
+ [side]: currentPosition,
176
+ });
177
+ });
178
+ window.cancelAnimationFrame(swiper.cssModeFrameID);
179
+ return;
180
+ }
181
+ swiper.cssModeFrameID = window.requestAnimationFrame(animate);
182
+ };
183
+ animate();
184
+ }
185
+ function getSlideTransformEl(slideEl) {
186
+ return slideEl.querySelector('.swiper-slide-transform') || slideEl.shadowRoot && slideEl.shadowRoot.querySelector('.swiper-slide-transform') || slideEl;
187
+ }
188
+ function elementChildren(element, selector) {
189
+ if (selector === void 0) {
190
+ selector = '';
191
+ }
192
+ const window = getWindow();
193
+ const children = [...element.children];
194
+ if (window.HTMLSlotElement && element instanceof HTMLSlotElement) {
195
+ children.push(...element.assignedElements());
196
+ }
197
+ if (!selector) {
198
+ return children;
199
+ }
200
+ return children.filter(el => el.matches(selector));
201
+ }
202
+ function elementIsChildOfSlot(el, slot) {
203
+ // Breadth-first search through all parent's children and assigned elements
204
+ const elementsQueue = [slot];
205
+ while (elementsQueue.length > 0) {
206
+ const elementToCheck = elementsQueue.shift();
207
+ if (el === elementToCheck) {
208
+ return true;
209
+ }
210
+
211
+ // !!!! Rewrote this code to remove optional chaining syntax
212
+ elementsQueue.push(
213
+ ...elementToCheck.children,
214
+ ...(elementToCheck.shadowRoot && elementToCheck.shadowRoot.children ? elementToCheck.shadowRoot.children : []),
215
+ ...(elementToCheck.assignedElements ? elementToCheck.assignedElements() : [])
216
+ );
217
+ }
218
+ }
219
+ function elementIsChildOf(el, parent) {
220
+ const window = getWindow();
221
+ let isChild = parent.contains(el);
222
+ if (!isChild && window.HTMLSlotElement && parent instanceof HTMLSlotElement) {
223
+ const children = [...parent.assignedElements()];
224
+ isChild = children.includes(el);
225
+ if (!isChild) {
226
+ isChild = elementIsChildOfSlot(el, parent);
227
+ }
228
+ }
229
+ return isChild;
230
+ }
231
+ function showWarning(text) {
232
+ try {
233
+ console.warn(text);
234
+ } catch (err) {
235
+ // err
236
+ }
237
+ }
238
+ function createElement(tag, classes) {
239
+ if (classes === void 0) {
240
+ classes = [];
241
+ }
242
+ const el = document.createElement(tag);
243
+ el.classList.add(...(Array.isArray(classes) ? classes : classesToTokens(classes)));
244
+ return el;
245
+ }
246
+ function elementOffset(el) {
247
+ const window = getWindow();
248
+ const document = getDocument();
249
+ const box = el.getBoundingClientRect();
250
+ const body = document.body;
251
+ const clientTop = el.clientTop || body.clientTop || 0;
252
+ const clientLeft = el.clientLeft || body.clientLeft || 0;
253
+ const scrollTop = el === window ? window.scrollY : el.scrollTop;
254
+ const scrollLeft = el === window ? window.scrollX : el.scrollLeft;
255
+ return {
256
+ top: box.top + scrollTop - clientTop,
257
+ left: box.left + scrollLeft - clientLeft,
258
+ };
259
+ }
260
+ function elementPrevAll(el, selector) {
261
+ const prevEls = [];
262
+ while (el.previousElementSibling) {
263
+ const prev = el.previousElementSibling; // eslint-disable-line
264
+ if (selector) {
265
+ if (prev.matches(selector)) prevEls.push(prev);
266
+ } else prevEls.push(prev);
267
+ el = prev;
268
+ }
269
+ return prevEls;
270
+ }
271
+ function elementNextAll(el, selector) {
272
+ const nextEls = [];
273
+ while (el.nextElementSibling) {
274
+ const next = el.nextElementSibling; // eslint-disable-line
275
+ if (selector) {
276
+ if (next.matches(selector)) nextEls.push(next);
277
+ } else nextEls.push(next);
278
+ el = next;
279
+ }
280
+ return nextEls;
281
+ }
282
+ function elementStyle(el, prop) {
283
+ const window = getWindow();
284
+ return window.getComputedStyle(el, null).getPropertyValue(prop);
285
+ }
286
+ function elementIndex(el) {
287
+ let child = el;
288
+ let i;
289
+ if (child) {
290
+ i = 0;
291
+ // eslint-disable-next-line
292
+ while ((child = child.previousSibling) !== null) {
293
+ if (child.nodeType === 1) i += 1;
294
+ }
295
+ return i;
296
+ }
297
+ return undefined;
298
+ }
299
+ function elementParents(el, selector) {
300
+ const parents = []; // eslint-disable-line
301
+ let parent = el.parentElement; // eslint-disable-line
302
+ while (parent) {
303
+ if (selector) {
304
+ if (parent.matches(selector)) parents.push(parent);
305
+ } else {
306
+ parents.push(parent);
307
+ }
308
+ parent = parent.parentElement;
309
+ }
310
+ return parents;
311
+ }
312
+ function elementTransitionEnd(el, callback) {
313
+ function fireCallBack(e) {
314
+ if (e.target !== el) return;
315
+ callback.call(el, e);
316
+ el.removeEventListener('transitionend', fireCallBack);
317
+ }
318
+ if (callback) {
319
+ el.addEventListener('transitionend', fireCallBack);
320
+ }
321
+ }
322
+ function elementOuterSize(el, size, includeMargins) {
323
+ const window = getWindow();
324
+ if (includeMargins) {
325
+ return el[size === 'width' ? 'offsetWidth' : 'offsetHeight'] + parseFloat(window.getComputedStyle(el, null).getPropertyValue(size === 'width' ? 'margin-right' : 'margin-top')) + parseFloat(window.getComputedStyle(el, null).getPropertyValue(size === 'width' ? 'margin-left' : 'margin-bottom'));
326
+ }
327
+ return el.offsetWidth;
328
+ }
329
+ function makeElementsArray(el) {
330
+ return (Array.isArray(el) ? el : [el]).filter(e => !!e);
331
+ }
332
+ function getRotateFix(swiper) {
333
+ return (v) => {
334
+ if (Math.abs(v) > 0 && swiper.browser && swiper.browser.need3dFix && Math.abs(v) % 90 === 0) {
335
+ return v + 0.001;
336
+ }
337
+ return v;
338
+ };
339
+ }
340
+
341
+ export {
342
+ elementParents as a, elementOffset as b, createElement as c, now as d, elementChildren as e, elementOuterSize as f, getSlideTransformEl as g, elementIndex as h, classesToTokens as i, getTranslate as j, elementTransitionEnd as k, isObject as l, makeElementsArray as m, nextTick as n, getRotateFix as o, elementStyle as p, elementNextAll as q, elementPrevAll as r, setCSSProperty as s, animateCSSModeScroll as t, showWarning as u, elementIsChildOf as v, extend as w, deleteProps as x,
343
+ };
344
+
345
+ /* eslint-enable import/extensions, require-jsdoc, no-void, no-param-reassign,
346
+ prefer-destructuring, no-underscore-dangle, consistent-return, no-mixed-operators,
347
+ eslint-comments/no-unlimited-disable, prefer-rest-params, max-len */
package/webpack.config.js CHANGED
@@ -74,6 +74,22 @@ const config = {
74
74
  plugins: [
75
75
  new ShopgateThemeConfigValidatorPlugin(),
76
76
  new ShopgateIndexerPlugin(),
77
+ /**
78
+ * Workaround to enable latest swiper version (11.2.1) with webpack.
79
+ * The utils.mjs file in swiper/shared/utils.mjs is not compatible with webpack due to use of
80
+ * optional chaining.
81
+ *
82
+ * Processing the module with babel-loader doesn't work, since transpilation of some array
83
+ * operations break the module logic inside the browser.
84
+ *
85
+ * As a workaround we replace the file with a local patched version.
86
+ * Alternative approaches e.g. via patch-package didn't work as expected due to issues in
87
+ * release process.
88
+ */
89
+ new webpack.NormalModuleReplacementPlugin(
90
+ /swiper\/shared\/utils\.mjs$/,
91
+ path.resolve(__dirname, 'patches', 'swiper', 'shared', 'utils.mjs')
92
+ ),
77
93
  new webpack.DefinePlugin({
78
94
  'process.env': {
79
95
  NODE_ENV: JSON.stringify(ENV),