@wix/editor-react-components 1.2787.0 → 1.2789.0

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.
@@ -0,0 +1,166 @@
1
+ import { g as getDefaultExportFromCjs } from "./_commonjsHelpers.js";
2
+ var fastdom$2 = { exports: {} };
3
+ var fastdom$1 = fastdom$2.exports;
4
+ var hasRequiredFastdom;
5
+ function requireFastdom() {
6
+ if (hasRequiredFastdom) return fastdom$2.exports;
7
+ hasRequiredFastdom = 1;
8
+ (function(module) {
9
+ !(function(win) {
10
+ var debug = function() {
11
+ };
12
+ var raf = win.requestAnimationFrame || win.webkitRequestAnimationFrame || win.mozRequestAnimationFrame || win.msRequestAnimationFrame || function(cb) {
13
+ return setTimeout(cb, 16);
14
+ };
15
+ function FastDom() {
16
+ var self = this;
17
+ self.reads = [];
18
+ self.writes = [];
19
+ self.raf = raf.bind(win);
20
+ }
21
+ FastDom.prototype = {
22
+ constructor: FastDom,
23
+ /**
24
+ * We run this inside a try catch
25
+ * so that if any jobs error, we
26
+ * are able to recover and continue
27
+ * to flush the batch until it's empty.
28
+ *
29
+ * @param {Array} tasks
30
+ */
31
+ runTasks: function(tasks) {
32
+ var task;
33
+ while (task = tasks.shift()) task();
34
+ },
35
+ /**
36
+ * Adds a job to the read batch and
37
+ * schedules a new frame if need be.
38
+ *
39
+ * @param {Function} fn
40
+ * @param {Object} ctx the context to be bound to `fn` (optional).
41
+ * @public
42
+ */
43
+ measure: function(fn, ctx) {
44
+ var task = !ctx ? fn : fn.bind(ctx);
45
+ this.reads.push(task);
46
+ scheduleFlush(this);
47
+ return task;
48
+ },
49
+ /**
50
+ * Adds a job to the
51
+ * write batch and schedules
52
+ * a new frame if need be.
53
+ *
54
+ * @param {Function} fn
55
+ * @param {Object} ctx the context to be bound to `fn` (optional).
56
+ * @public
57
+ */
58
+ mutate: function(fn, ctx) {
59
+ var task = !ctx ? fn : fn.bind(ctx);
60
+ this.writes.push(task);
61
+ scheduleFlush(this);
62
+ return task;
63
+ },
64
+ /**
65
+ * Clears a scheduled 'read' or 'write' task.
66
+ *
67
+ * @param {Object} task
68
+ * @return {Boolean} success
69
+ * @public
70
+ */
71
+ clear: function(task) {
72
+ return remove(this.reads, task) || remove(this.writes, task);
73
+ },
74
+ /**
75
+ * Extend this FastDom with some
76
+ * custom functionality.
77
+ *
78
+ * Because fastdom must *always* be a
79
+ * singleton, we're actually extending
80
+ * the fastdom instance. This means tasks
81
+ * scheduled by an extension still enter
82
+ * fastdom's global task queue.
83
+ *
84
+ * The 'super' instance can be accessed
85
+ * from `this.fastdom`.
86
+ *
87
+ * @example
88
+ *
89
+ * var myFastdom = fastdom.extend({
90
+ * initialize: function() {
91
+ * // runs on creation
92
+ * },
93
+ *
94
+ * // override a method
95
+ * measure: function(fn) {
96
+ * // do extra stuff ...
97
+ *
98
+ * // then call the original
99
+ * return this.fastdom.measure(fn);
100
+ * },
101
+ *
102
+ * ...
103
+ * });
104
+ *
105
+ * @param {Object} props properties to mixin
106
+ * @return {FastDom}
107
+ */
108
+ extend: function(props) {
109
+ if (typeof props != "object") throw new Error("expected object");
110
+ var child = Object.create(this);
111
+ mixin(child, props);
112
+ child.fastdom = this;
113
+ if (child.initialize) child.initialize();
114
+ return child;
115
+ },
116
+ // override this with a function
117
+ // to prevent Errors in console
118
+ // when tasks throw
119
+ catch: null
120
+ };
121
+ function scheduleFlush(fastdom2) {
122
+ if (!fastdom2.scheduled) {
123
+ fastdom2.scheduled = true;
124
+ fastdom2.raf(flush.bind(null, fastdom2));
125
+ }
126
+ }
127
+ function flush(fastdom2) {
128
+ var writes = fastdom2.writes;
129
+ var reads = fastdom2.reads;
130
+ var error;
131
+ try {
132
+ debug("flushing reads", reads.length);
133
+ fastdom2.runTasks(reads);
134
+ debug("flushing writes", writes.length);
135
+ fastdom2.runTasks(writes);
136
+ } catch (e) {
137
+ error = e;
138
+ }
139
+ fastdom2.scheduled = false;
140
+ if (reads.length || writes.length) scheduleFlush(fastdom2);
141
+ if (error) {
142
+ debug("task errored", error.message);
143
+ if (fastdom2.catch) fastdom2.catch(error);
144
+ else throw error;
145
+ }
146
+ }
147
+ function remove(array, item) {
148
+ var index = array.indexOf(item);
149
+ return !!~index && !!array.splice(index, 1);
150
+ }
151
+ function mixin(target, source) {
152
+ for (var key in source) {
153
+ if (source.hasOwnProperty(key)) target[key] = source[key];
154
+ }
155
+ }
156
+ var exports$1 = win.fastdom = win.fastdom || new FastDom();
157
+ module.exports = exports$1;
158
+ })(typeof window !== "undefined" ? window : typeof fastdom$1 != "undefined" ? fastdom$1 : globalThis);
159
+ })(fastdom$2);
160
+ return fastdom$2.exports;
161
+ }
162
+ var fastdomExports = requireFastdom();
163
+ const fastdom = /* @__PURE__ */ getDefaultExportFromCjs(fastdomExports);
164
+ export {
165
+ fastdom as f
166
+ };
@@ -190,28 +190,18 @@ function isImageTypeSupported(uri) {
190
190
  function isValidRequest(fittingType, src, target) {
191
191
  return target && src && !isUrlEmptyOrNone(src.id) && Object.values(fittingTypes).includes(fittingType);
192
192
  }
193
- function canTransformAnimatedWebpOrAvif(uri, hasAnimation, allowAnimatedTransform) {
194
- const isAvifWebpFormat = isWEBP(uri) || isAVIF(uri);
195
- if (!isAvifWebpFormat || !hasAnimation) {
196
- return true;
197
- }
198
- return allowAnimatedTransform;
199
- }
200
- function canTransformGIF(uri, allowAnimatedTransform, allowFullGIFTransformation) {
193
+ function canTransformGIF(uri, allowFullGIFTransformation, isPlaceholderFlow) {
201
194
  if (!isGIF(uri)) {
202
195
  return false;
203
196
  }
204
- return !!(allowAnimatedTransform || allowFullGIFTransformation);
197
+ return !!(allowFullGIFTransformation || isPlaceholderFlow);
205
198
  }
206
- function isImageTransformApplicable(uri, hasAnimation, allowAnimatedTransform, allowFullGIFTransformation) {
199
+ function isImageTransformApplicable(uri, allowFullGIFTransformation, isPlaceholderFlow) {
207
200
  if (isExternalUrl(uri)) {
208
201
  return false;
209
202
  }
210
- if (!canTransformAnimatedWebpOrAvif(uri, hasAnimation, allowAnimatedTransform)) {
211
- return false;
212
- }
213
203
  const isSupportedImageType = isImageTypeSupported(uri);
214
- const isTransformableGif = canTransformGIF(uri, allowAnimatedTransform, allowFullGIFTransformation);
204
+ const isTransformableGif = canTransformGIF(uri, allowFullGIFTransformation, isPlaceholderFlow);
215
205
  return isSupportedImageType || isTransformableGif;
216
206
  }
217
207
  function isJPG(uri) {
@@ -1047,7 +1037,7 @@ function getTransform(fittingType, src, target, options) {
1047
1037
  const devicePixelRatio = _isSEOBot ? 1 : getDevicePixelRatio(target);
1048
1038
  const fileExtension = getFileExtension(src.id);
1049
1039
  const preferredExtension = fileExtension;
1050
- const canTransformImage = isImageTransformApplicable(src.id, options == null ? void 0 : options.hasAnimation, options == null ? void 0 : options.allowAnimatedTransform, options == null ? void 0 : options.allowFullGIFTransformation);
1040
+ const canTransformImage = isImageTransformApplicable(src.id, options == null ? void 0 : options.allowFullGIFTransformation, options == null ? void 0 : options.isPlaceholderFlow);
1051
1041
  const transformsObj = {
1052
1042
  fileName,
1053
1043
  fileExtension,
@@ -1126,6 +1116,9 @@ const animatedTransformTemplate = template`,pstr`;
1126
1116
  const animatedGIFTransformTemplate = template`,anm_all`;
1127
1117
  function getImageURI(transformsObj) {
1128
1118
  var _a;
1119
+ if (transformsObj.parts.some(({ width, height }) => !Number.isFinite(width) || width <= 0 || !Number.isFinite(height) || height <= 0)) {
1120
+ return transformsObj.src.id;
1121
+ }
1129
1122
  const transformsObjStrArr = [];
1130
1123
  transformsObj.parts.forEach((transformPart) => {
1131
1124
  switch (transformPart.transformType) {
@@ -1205,15 +1198,8 @@ function getImageURI(transformsObj) {
1205
1198
  return `${transformsObj.src.id}/${API_VERSION}/${transformsStr}/${transformsObj.fileName}.${transformsObj.preferredExtension}`;
1206
1199
  }
1207
1200
  function getURI(fittingType, src, target, options = {}, transformObj) {
1208
- if (isImageTransformApplicable(src.id, options == null ? void 0 : options.hasAnimation, options == null ? void 0 : options.allowAnimatedTransform, options == null ? void 0 : options.allowFullGIFTransformation)) {
1209
- if ((isWEBP(src.id) || isAVIF(src.id)) && !options.allowWebpAvifTransforms) {
1210
- const { alignment, ...transformTarget } = target;
1211
- src.focalPoint = { x: void 0, y: void 0 };
1212
- src == null ? true : delete src.crop;
1213
- transformObj = getTransform(fittingType, src, transformTarget, options);
1214
- } else {
1215
- transformObj = transformObj || getTransform(fittingType, src, target, options);
1216
- }
1201
+ if (isImageTransformApplicable(src.id, options == null ? void 0 : options.allowFullGIFTransformation, options == null ? void 0 : options.isPlaceholderFlow)) {
1202
+ transformObj = transformObj || getTransform(fittingType, src, target, options);
1217
1203
  return getImageURI(transformObj);
1218
1204
  }
1219
1205
  return src.id;
@@ -1371,13 +1357,12 @@ function convertFillFocalToPosition(src, target, focalPoint) {
1371
1357
  }
1372
1358
  const PLACEHOLDER_IMG_CSS_OVERRIDES = { width: "100%", height: "100%" };
1373
1359
  function getPlaceholder(fittingType, src, target, options = {}) {
1374
- const { autoEncode = true, isSEOBot: isSEOBot2, shouldLoadHQImage, hasAnimation, allowAnimatedTransform, encoding } = options;
1360
+ const { autoEncode = true, isSEOBot: isSEOBot2, shouldLoadHQImage, hasAnimation, allowFullGIFTransformation, encoding } = options;
1375
1361
  if (!isValidRequest(fittingType, src, target)) {
1376
1362
  return emptyData;
1377
1363
  }
1378
1364
  const IS_IN_PLACEHOLDER_FLOW = true;
1379
- const shouldAllowAnimatedTransformInPlaceholder = allowAnimatedTransform ?? IS_IN_PLACEHOLDER_FLOW;
1380
- const canTransformImage = isImageTransformApplicable(src.id, hasAnimation, shouldAllowAnimatedTransformInPlaceholder);
1365
+ const canTransformImage = isImageTransformApplicable(src.id, allowFullGIFTransformation, IS_IN_PLACEHOLDER_FLOW);
1381
1366
  if (!canTransformImage || shouldLoadHQImage) {
1382
1367
  return getData(fittingType, src, target, {
1383
1368
  ...options,
@@ -1403,7 +1388,6 @@ function getPlaceholder(fittingType, src, target, options = {}) {
1403
1388
  autoEncode,
1404
1389
  filters: blur ? { blur } : {},
1405
1390
  hasAnimation,
1406
- allowAnimatedTransform: shouldAllowAnimatedTransformInPlaceholder,
1407
1391
  encoding,
1408
1392
  isPlaceholderFlow: IS_IN_PLACEHOLDER_FLOW
1409
1393
  });
@@ -1460,10 +1444,10 @@ export {
1460
1444
  MEDIA_ROOT_URL as M,
1461
1445
  STATIC_MEDIA_URL as S,
1462
1446
  getData as a,
1463
- getFileExtension as b,
1464
- alignTypes as c,
1465
- fittingTypes as d,
1466
- fileType as f,
1447
+ alignTypes as b,
1448
+ getFileExtension as c,
1449
+ fileType as d,
1450
+ fittingTypes as f,
1467
1451
  getPlaceholder as g,
1468
1452
  imageKit as i
1469
1453
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/editor-react-components",
3
- "version": "1.2787.0",
3
+ "version": "1.2789.0",
4
4
  "description": "React components for the Wix Editor",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -80,7 +80,7 @@
80
80
  "test:a11y": "a11y-audit-tool-plugin audit"
81
81
  },
82
82
  "peerDependencies": {
83
- "@wix/astro": "^2.75.3",
83
+ "@wix/astro": "^2.75.4",
84
84
  "@wix/editor-react-types": "^1.0.107",
85
85
  "react": "^18.2.0",
86
86
  "react-dom": "^18.2.0"
@@ -114,7 +114,7 @@
114
114
  "@vitejs/plugin-react": "^4.3.4",
115
115
  "@wix/a11y-audit-tool-plugin": "^0.397.0",
116
116
  "@wix/ambassador-devcenter-v1-component-type-data": "^1.0.592",
117
- "@wix/astro": "^2.75.3",
117
+ "@wix/astro": "^2.75.4",
118
118
  "@wix/business-tools": "^1.0.233",
119
119
  "@wix/cli": "^1.1.264",
120
120
  "@wix/cli-app": "^1.1.263",
@@ -127,8 +127,8 @@
127
127
  "@wix/editor-elements-test-utils": "^1.0.0",
128
128
  "@wix/essentials": "^0.1.28",
129
129
  "@wix/fed-cli-sled": "^1.0.39",
130
- "@wix/image": "^1.452.0",
131
- "@wix/image-kit": "^1.118.0",
130
+ "@wix/image": "^1.456.0",
131
+ "@wix/image-kit": "^1.127.0",
132
132
  "@wix/janet-build": "^1.0.10",
133
133
  "@wix/mappers-legacy-service": "^1.0.85",
134
134
  "@wix/media": "^1.0.278",
@@ -222,5 +222,5 @@
222
222
  "registry": "https://registry.npmjs.org/",
223
223
  "access": "public"
224
224
  },
225
- "falconPackageHash": "18da64a9f7c486f7ea47ba859ed9e665c07aef0f34e40bc4f266e8d7"
225
+ "falconPackageHash": "3c9322a0775e296eb0a5409dcf55b782f474434ad18f614a1308ec9d"
226
226
  }
@@ -1,160 +0,0 @@
1
- import * as React from "react";
2
- import { i as imageKit, g as getPlaceholder } from "./index6.js";
3
- const image = "image__WopE9";
4
- const styles = {
5
- image
6
- };
7
- const { STATIC_MEDIA_URL } = imageKit;
8
- const fetchLQIP = ({ fittingType, src, target, options }) => {
9
- const placeholder = getPlaceholder(fittingType, src, target, {
10
- ...options,
11
- autoEncode: true
12
- });
13
- if ((placeholder == null ? void 0 : placeholder.uri) && !/^[a-z]+:/.test(placeholder.uri)) {
14
- placeholder.uri = `${STATIC_MEDIA_URL}${placeholder.uri}`;
15
- }
16
- return placeholder;
17
- };
18
- const SCHEME_RE = /^[a-z]+:/;
19
- const Image = (props) => {
20
- var _a, _b;
21
- const { id, containerId, uri, alt, name = "", role, width, height, displayMode, devicePixelRatio, quality, alignType, bgEffectName = "", focalPoint, upscaleMethod, className = "", crop, imageStyles = {}, targetWidth, targetHeight, targetScale, onLoad = () => {
22
- }, onError = () => {
23
- }, shouldUseLQIP, containerWidth, containerHeight, getPlaceholder: getPlaceholder2, isInFirstFold, placeholderTransition, socialAttrs, isSEOBot, skipMeasure, hasAnimation, encoding, isFluidLayout, baseHostURL } = props;
24
- const imageRef = React.useRef(null);
25
- let hasSsrSrc = "";
26
- const hasBlurTransition = placeholderTransition === "blur";
27
- const ssrImageData = React.useRef(null);
28
- if (!ssrImageData.current) {
29
- if (getPlaceholder2 || shouldUseLQIP || isInFirstFold || isSEOBot) {
30
- const options = {
31
- upscaleMethod,
32
- ...quality ? quality : {},
33
- shouldLoadHQImage: isInFirstFold,
34
- isSEOBot,
35
- hasAnimation,
36
- encoding,
37
- baseHostURL
38
- };
39
- ssrImageData.current = (getPlaceholder2 || fetchLQIP)({
40
- fittingType: displayMode,
41
- src: {
42
- id: uri,
43
- width,
44
- height,
45
- crop,
46
- name,
47
- focalPoint
48
- },
49
- target: {
50
- width: containerWidth,
51
- height: containerHeight,
52
- alignment: alignType,
53
- htmlTag: "img"
54
- },
55
- options
56
- });
57
- hasSsrSrc = !ssrImageData.current.transformed || isInFirstFold || isSEOBot ? "" : "true";
58
- } else {
59
- ssrImageData.current = {
60
- uri: void 0,
61
- css: { img: {} },
62
- attr: { img: {}, container: {} },
63
- transformed: false
64
- };
65
- }
66
- }
67
- const isLQIP = !isSEOBot && (getPlaceholder2 || shouldUseLQIP) && !isInFirstFold && ssrImageData.current.transformed;
68
- const imageInfo = React.useMemo(() => JSON.stringify({
69
- containerId,
70
- ...containerId && { containerId },
71
- ...alignType && { alignType },
72
- ...skipMeasure && { skipMeasure: true },
73
- displayMode,
74
- ...containerWidth && { targetWidth: containerWidth },
75
- ...containerHeight && { targetHeight: containerHeight },
76
- ...targetWidth && { targetWidth },
77
- ...targetHeight && { targetHeight },
78
- ...targetScale && { targetScale },
79
- isLQIP,
80
- isSEOBot,
81
- lqipTransition: placeholderTransition,
82
- encoding,
83
- imageData: {
84
- width,
85
- height,
86
- uri,
87
- name,
88
- displayMode,
89
- hasAnimation,
90
- ...quality && { quality },
91
- ...devicePixelRatio && { devicePixelRatio },
92
- ...focalPoint && { focalPoint },
93
- ...crop && { crop },
94
- ...upscaleMethod && { upscaleMethod }
95
- }
96
- }), [
97
- containerId,
98
- alignType,
99
- skipMeasure,
100
- displayMode,
101
- containerWidth,
102
- containerHeight,
103
- targetWidth,
104
- targetHeight,
105
- targetScale,
106
- isLQIP,
107
- isSEOBot,
108
- placeholderTransition,
109
- encoding,
110
- width,
111
- height,
112
- uri,
113
- name,
114
- hasAnimation,
115
- quality,
116
- devicePixelRatio,
117
- focalPoint,
118
- crop,
119
- upscaleMethod
120
- ]);
121
- const ssrResult = ssrImageData.current;
122
- const src = ssrResult == null ? void 0 : ssrResult.uri;
123
- const srcset = ssrResult == null ? void 0 : ssrResult.srcset;
124
- const placeholderStyle = (_a = ssrResult.css) == null ? void 0 : _a.img;
125
- const classNames = `${styles.image} ${className}`;
126
- React.useEffect(() => {
127
- const imgElement = imageRef.current;
128
- if (onLoad && (imgElement == null ? void 0 : imgElement.currentSrc) && (imgElement == null ? void 0 : imgElement.complete)) {
129
- onLoad({
130
- target: imgElement
131
- });
132
- }
133
- }, []);
134
- const maxWidth = ssrResult && !(ssrResult == null ? void 0 : ssrResult.transformed) ? `max(${width}px, 100%)` : targetWidth ? `${targetWidth}px` : null;
135
- return React.createElement(
136
- "wow-image",
137
- { id, class: classNames, "data-image-info": imageInfo, "data-motion-part": `BG_IMG ${containerId}`, "data-bg-effect-name": bgEffectName, "data-has-ssr-src": hasSsrSrc, "data-animate-blur": !isSEOBot && isLQIP && hasBlurTransition ? "" : void 0, "data-is-responsive": isFluidLayout ? "true" : void 0, style: maxWidth ? { "--wix-img-max-width": maxWidth } : {} },
138
- React.createElement("img", {
139
- src,
140
- ref: imageRef,
141
- alt: alt || "",
142
- role,
143
- style: { ...placeholderStyle, ...imageStyles },
144
- onLoad,
145
- onError,
146
- width: containerWidth ? containerWidth : void 0,
147
- height: containerHeight ? containerHeight : void 0,
148
- ...socialAttrs,
149
- srcSet: isInFirstFold ? (_b = srcset == null ? void 0 : srcset.dpr) == null ? void 0 : _b.map((s) => SCHEME_RE.test(s) ? s : `${STATIC_MEDIA_URL}${s}`).join(", ") : void 0,
150
- // @ts-expect-error fetchpriority type should work in react > 18.3 https://github.com/facebook/react/pull/25927
151
- fetchpriority: isInFirstFold ? "high" : void 0,
152
- loading: isInFirstFold === false ? "lazy" : void 0,
153
- // The src attribute triggers a mismatch warning because wow-image updates its src outside of the React lifecycle. This causes React to retain the old value in the virtual DOM, which could potentially lead to a bug where the old value is re-rendered during updates. However, we’re confident that this issue is not reproducing in current (16-18) React versions
154
- suppressHydrationWarning: true
155
- })
156
- );
157
- };
158
- export {
159
- Image as I
160
- };