@plasmicapp/react-web 0.2.319 → 0.2.320
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/index.cjs.js
CHANGED
|
@@ -1119,6 +1119,7 @@ function PlasmicIcon(props) {
|
|
|
1119
1119
|
/**
|
|
1120
1120
|
* Responsive `<img/>` replacement, based on `next/image`
|
|
1121
1121
|
*/
|
|
1122
|
+
var IMG_OPTIMIZER_HOST = "https://img.plasmic.app";
|
|
1122
1123
|
// Default image sizes to snap to
|
|
1123
1124
|
// TODO: make this configurable?
|
|
1124
1125
|
var IMG_SIZES = [16, 32, 48, 64, 96, 128, 256, 384];
|
|
@@ -1131,9 +1132,11 @@ var PlasmicImg = React.forwardRef(function PlasmicImg(props, outerRef) {
|
|
|
1131
1132
|
// html img, which defaults to eager!)
|
|
1132
1133
|
loading: loading !== null && loading !== void 0 ? loading : "lazy",
|
|
1133
1134
|
});
|
|
1134
|
-
var _a =
|
|
1135
|
+
var _a = !src
|
|
1135
1136
|
? { fullWidth: undefined, fullHeight: undefined, aspectRatio: undefined }
|
|
1136
|
-
: src
|
|
1137
|
+
: typeof src === "string"
|
|
1138
|
+
? getImageSizeData(getPixelLength(props.width), getPixelLength(props.height))
|
|
1139
|
+
: src, fullWidth = _a.fullWidth, fullHeight = _a.fullHeight, aspectRatio = _a.aspectRatio;
|
|
1137
1140
|
var srcStr = src
|
|
1138
1141
|
? typeof src === "string"
|
|
1139
1142
|
? src
|
|
@@ -1390,6 +1393,14 @@ function parseNumeric(val) {
|
|
|
1390
1393
|
var units = res[2];
|
|
1391
1394
|
return { num: +num, units: units };
|
|
1392
1395
|
}
|
|
1396
|
+
function getImageSizeData(width, height) {
|
|
1397
|
+
var aspectRatio = width && height ? width / height : undefined;
|
|
1398
|
+
return {
|
|
1399
|
+
fullWidth: width,
|
|
1400
|
+
fullHeight: height,
|
|
1401
|
+
aspectRatio: aspectRatio && isFinite(aspectRatio) ? aspectRatio : undefined,
|
|
1402
|
+
};
|
|
1403
|
+
}
|
|
1393
1404
|
function getImageLoader(loader) {
|
|
1394
1405
|
if (loader == null) {
|
|
1395
1406
|
return undefined;
|
|
@@ -1403,16 +1414,17 @@ function getImageLoader(loader) {
|
|
|
1403
1414
|
}
|
|
1404
1415
|
var PLASMIC_IMAGE_LOADER = {
|
|
1405
1416
|
supportsUrl: function (src) {
|
|
1406
|
-
return src.startsWith("
|
|
1417
|
+
return src.startsWith("http") && !isSvg(src);
|
|
1407
1418
|
},
|
|
1408
1419
|
transformUrl: function (opts) {
|
|
1409
1420
|
var _a;
|
|
1410
1421
|
var params = [
|
|
1422
|
+
"src=".concat(opts.src),
|
|
1411
1423
|
opts.width ? "w=".concat(opts.width) : undefined,
|
|
1412
1424
|
"q=".concat((_a = opts.quality) !== null && _a !== void 0 ? _a : 75),
|
|
1413
1425
|
opts.format ? "f=".concat(opts.format) : undefined,
|
|
1414
1426
|
].filter(function (x) { return !!x; });
|
|
1415
|
-
return "".concat(
|
|
1427
|
+
return "".concat(IMG_OPTIMIZER_HOST, "/img-optimizer/v1/img?").concat(params.join("&"));
|
|
1416
1428
|
},
|
|
1417
1429
|
};
|
|
1418
1430
|
|