@plasmicapp/react-web 0.2.318 → 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.
@@ -1100,6 +1100,7 @@ function PlasmicIcon(props) {
1100
1100
  /**
1101
1101
  * Responsive `<img/>` replacement, based on `next/image`
1102
1102
  */
1103
+ var IMG_OPTIMIZER_HOST = "https://img.plasmic.app";
1103
1104
  // Default image sizes to snap to
1104
1105
  // TODO: make this configurable?
1105
1106
  var IMG_SIZES = [16, 32, 48, 64, 96, 128, 256, 384];
@@ -1112,9 +1113,11 @@ var PlasmicImg = React__default.forwardRef(function PlasmicImg(props, outerRef)
1112
1113
  // html img, which defaults to eager!)
1113
1114
  loading: loading !== null && loading !== void 0 ? loading : "lazy",
1114
1115
  });
1115
- var _a = typeof src === "string" || !src
1116
+ var _a = !src
1116
1117
  ? { fullWidth: undefined, fullHeight: undefined, aspectRatio: undefined }
1117
- : src, fullWidth = _a.fullWidth, fullHeight = _a.fullHeight, aspectRatio = _a.aspectRatio;
1118
+ : typeof src === "string"
1119
+ ? getImageSizeData(getPixelLength(props.width), getPixelLength(props.height))
1120
+ : src, fullWidth = _a.fullWidth, fullHeight = _a.fullHeight, aspectRatio = _a.aspectRatio;
1118
1121
  var srcStr = src
1119
1122
  ? typeof src === "string"
1120
1123
  ? src
@@ -1371,6 +1374,14 @@ function parseNumeric(val) {
1371
1374
  var units = res[2];
1372
1375
  return { num: +num, units: units };
1373
1376
  }
1377
+ function getImageSizeData(width, height) {
1378
+ var aspectRatio = width && height ? width / height : undefined;
1379
+ return {
1380
+ fullWidth: width,
1381
+ fullHeight: height,
1382
+ aspectRatio: aspectRatio && isFinite(aspectRatio) ? aspectRatio : undefined,
1383
+ };
1384
+ }
1374
1385
  function getImageLoader(loader) {
1375
1386
  if (loader == null) {
1376
1387
  return undefined;
@@ -1384,16 +1395,17 @@ function getImageLoader(loader) {
1384
1395
  }
1385
1396
  var PLASMIC_IMAGE_LOADER = {
1386
1397
  supportsUrl: function (src) {
1387
- return src.startsWith("https://img.plasmic.app") && !isSvg(src);
1398
+ return src.startsWith("http") && !isSvg(src);
1388
1399
  },
1389
1400
  transformUrl: function (opts) {
1390
1401
  var _a;
1391
1402
  var params = [
1403
+ "src=".concat(opts.src),
1392
1404
  opts.width ? "w=".concat(opts.width) : undefined,
1393
1405
  "q=".concat((_a = opts.quality) !== null && _a !== void 0 ? _a : 75),
1394
1406
  opts.format ? "f=".concat(opts.format) : undefined,
1395
1407
  ].filter(function (x) { return !!x; });
1396
- return "".concat(opts.src, "?").concat(params.join("&"));
1408
+ return "".concat(IMG_OPTIMIZER_HOST, "/img-optimizer/v1/img?").concat(params.join("&"));
1397
1409
  },
1398
1410
  };
1399
1411