@plasmicapp/react-web 0.2.319 → 0.2.321

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;
@@ -1382,18 +1393,22 @@ function getImageLoader(loader) {
1382
1393
  return loader;
1383
1394
  }
1384
1395
  }
1396
+ function isInternalKey(src) {
1397
+ return /^([a-f0-9]{32})\..{1,16}$/i.test(src);
1398
+ }
1385
1399
  var PLASMIC_IMAGE_LOADER = {
1386
1400
  supportsUrl: function (src) {
1387
- return src.startsWith("https://img.plasmic.app") && !isSvg(src);
1401
+ return (src.startsWith("http") || isInternalKey(src)) && !isSvg(src);
1388
1402
  },
1389
1403
  transformUrl: function (opts) {
1390
1404
  var _a;
1391
1405
  var params = [
1406
+ "src=".concat(encodeURIComponent(opts.src)),
1392
1407
  opts.width ? "w=".concat(opts.width) : undefined,
1393
1408
  "q=".concat((_a = opts.quality) !== null && _a !== void 0 ? _a : 75),
1394
1409
  opts.format ? "f=".concat(opts.format) : undefined,
1395
1410
  ].filter(function (x) { return !!x; });
1396
- return "".concat(opts.src, "?").concat(params.join("&"));
1411
+ return "".concat(IMG_OPTIMIZER_HOST, "/img-optimizer/v1/img?").concat(params.join("&"));
1397
1412
  },
1398
1413
  };
1399
1414