@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.
package/dist/all.d.ts CHANGED
@@ -11404,6 +11404,10 @@ interface JsonElement {
11404
11404
  interface DefaultComponentElement<P> {
11405
11405
  type: "default-component";
11406
11406
  kind: "button" | "text-input";
11407
+ /**
11408
+ * The name of the element in the tree
11409
+ */
11410
+ elementName?: string;
11407
11411
  props?: {
11408
11412
  [prop in keyof Partial<P>]: number | string | boolean | null | undefined | JsonElement | PlasmicElement | PlasmicElement[];
11409
11413
  } & {
@@ -11417,6 +11421,10 @@ interface CodeComponentElement<P> {
11417
11421
  * The registered component name
11418
11422
  */
11419
11423
  name: string;
11424
+ /**
11425
+ * The name of the element in the tree
11426
+ */
11427
+ elementName?: string;
11420
11428
  styles?: CSSProperties;
11421
11429
  props?: {
11422
11430
  [prop in keyof Partial<P>]: number | string | boolean | null | undefined | JsonElement | PlasmicElement | PlasmicElement[];
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 = typeof src === "string" || !src
1135
+ var _a = !src
1135
1136
  ? { fullWidth: undefined, fullHeight: undefined, aspectRatio: undefined }
1136
- : src, fullWidth = _a.fullWidth, fullHeight = _a.fullHeight, aspectRatio = _a.aspectRatio;
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;
@@ -1401,18 +1412,22 @@ function getImageLoader(loader) {
1401
1412
  return loader;
1402
1413
  }
1403
1414
  }
1415
+ function isInternalKey(src) {
1416
+ return /^([a-f0-9]{32})\..{1,16}$/i.test(src);
1417
+ }
1404
1418
  var PLASMIC_IMAGE_LOADER = {
1405
1419
  supportsUrl: function (src) {
1406
- return src.startsWith("https://img.plasmic.app") && !isSvg(src);
1420
+ return (src.startsWith("http") || isInternalKey(src)) && !isSvg(src);
1407
1421
  },
1408
1422
  transformUrl: function (opts) {
1409
1423
  var _a;
1410
1424
  var params = [
1425
+ "src=".concat(encodeURIComponent(opts.src)),
1411
1426
  opts.width ? "w=".concat(opts.width) : undefined,
1412
1427
  "q=".concat((_a = opts.quality) !== null && _a !== void 0 ? _a : 75),
1413
1428
  opts.format ? "f=".concat(opts.format) : undefined,
1414
1429
  ].filter(function (x) { return !!x; });
1415
- return "".concat(opts.src, "?").concat(params.join("&"));
1430
+ return "".concat(IMG_OPTIMIZER_HOST, "/img-optimizer/v1/img?").concat(params.join("&"));
1416
1431
  },
1417
1432
  };
1418
1433