@websolutespa/bom-mixer-ui 1.8.2 → 1.8.4

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/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @websolutespa/bom-mixer-ui
2
2
 
3
+ ## 1.8.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Added: ImageStrategy.Token
8
+ - Updated dependencies
9
+ - @websolutespa/bom-core@1.8.4
10
+
11
+ ## 1.8.3
12
+
13
+ ### Patch Changes
14
+
15
+ - Modified: IAnchor
16
+ - Updated dependencies
17
+ - @websolutespa/bom-core@1.8.3
18
+
3
19
  ## 1.8.2
4
20
 
5
21
  ### Patch Changes
package/dist/cjs/index.js CHANGED
@@ -4402,21 +4402,13 @@ function useMediaGalleryContext() {
4402
4402
  return React.useContext(MediaGalleryContext);
4403
4403
  }
4404
4404
 
4405
- exports.ImageStrategy = void 0;
4406
- (function (ImageStrategy) {
4407
- ImageStrategy["None"] = "none";
4408
- ImageStrategy["Next"] = "next";
4409
- ImageStrategy["Mixer"] = "mixer";
4410
- ImageStrategy["Oven"] = "oven";
4411
- ImageStrategy["Custom"] = "custom";
4412
- })(exports.ImageStrategy || (exports.ImageStrategy = {}));
4413
4405
  const IMAGE_SIZE_VARIANTS = ['xs', 'sm', 'md', 'lg', 'xl'];
4414
4406
  const IMAGE_SIZES = process.env.IMAGE_SIZES ? process.env.IMAGE_SIZES.split(',').map(x => parseInt(x)) : [750, 960, 1440, 1600, 1920];
4415
4407
  const IMAGE_SIZEMAP = Object.fromEntries(IMAGE_SIZES.map((x, i) => [IMAGE_SIZE_VARIANTS[i], x]));
4416
4408
  const IMAGE_FOCAL_X = 50;
4417
4409
  const IMAGE_FOCAL_Y = 50;
4418
4410
  const IMAGE_QUALITY = process.env.IMAGE_QUALITY ? parseInt(process.env.IMAGE_QUALITY) : 90;
4419
- const IMAGE_STRATEGY = process.env.IMAGE_STRATEGY ? process.env.IMAGE_STRATEGY : exports.ImageStrategy.Mixer;
4411
+ const IMAGE_STRATEGY = process.env.IMAGE_STRATEGY ? process.env.IMAGE_STRATEGY : bomCore.ImageStrategy.Mixer;
4420
4412
  function isMediaSizeVariant(item) {
4421
4413
  return typeof item === 'string';
4422
4414
  // return typeof item === 'string' && IMAGE_SIZE_VARIANTS.includes(item);
@@ -4531,7 +4523,7 @@ function getImageProps(_a, mediaQuery) {
4531
4523
  src
4532
4524
  } = _a,
4533
4525
  props = __rest(_a, ["src"]);
4534
- if (IMAGE_STRATEGY === exports.ImageStrategy.None || !src || isSVG(src)) {
4526
+ if (IMAGE_STRATEGY === bomCore.ImageStrategy.None || !src || isSVG(src)) {
4535
4527
  return Object.assign({
4536
4528
  src
4537
4529
  }, props);
@@ -4594,9 +4586,10 @@ function getRatio(aspectRatio, defaultRatio) {
4594
4586
  return typeof aspectRatio === 'string' ? parseFloat(aspectRatio) : aspectRatio || defaultRatio;
4595
4587
  }
4596
4588
  const BASE_URLS = {
4597
- [exports.ImageStrategy.Mixer]: '/api/_image',
4598
- [exports.ImageStrategy.Next]: '/_next/image',
4599
- [exports.ImageStrategy.Oven]: bomMixerStore.getRemoteApiUrl('/_image')
4589
+ [bomCore.ImageStrategy.Mixer]: '/api/_image',
4590
+ [bomCore.ImageStrategy.Token]: '/api/_image',
4591
+ [bomCore.ImageStrategy.Next]: '/_next/image',
4592
+ [bomCore.ImageStrategy.Oven]: bomMixerStore.getRemoteApiUrl('/_image')
4600
4593
  };
4601
4594
  const BASE_URL = BASE_URLS[IMAGE_STRATEGY];
4602
4595
  function getImageSrc(src, width, ratio, focalX, focalY, quality) {
@@ -4613,8 +4606,34 @@ function getImageSrc(src, width, ratio, focalX, focalY, quality) {
4613
4606
  return src;
4614
4607
  }
4615
4608
  switch (IMAGE_STRATEGY) {
4616
- case exports.ImageStrategy.Mixer:
4617
- case exports.ImageStrategy.Oven:
4609
+ case bomCore.ImageStrategy.Token:
4610
+ {
4611
+ const {
4612
+ origin,
4613
+ pathname,
4614
+ search
4615
+ } = src.indexOf('http') === 0 ? new URL(src) : {
4616
+ origin: '',
4617
+ pathname: src,
4618
+ search: ''
4619
+ };
4620
+ const imageResize = ratio !== 0 ? {
4621
+ w: width,
4622
+ h: Math.round(width / ratio),
4623
+ x: focalX,
4624
+ y: focalY,
4625
+ q: quality,
4626
+ src
4627
+ } : {
4628
+ w: width,
4629
+ q: quality,
4630
+ src
4631
+ };
4632
+ const token = bomCore.encryptImageToken(imageResize);
4633
+ return `${BASE_URL}${pathname}?origin=${encodeURIComponent(origin)}&search=${encodeURIComponent(search)}&t=${encodeURIComponent(token)}`;
4634
+ }
4635
+ case bomCore.ImageStrategy.Mixer:
4636
+ case bomCore.ImageStrategy.Oven:
4618
4637
  {
4619
4638
  const {
4620
4639
  origin,
@@ -11394,7 +11413,7 @@ const TextDescription = _ref => {
11394
11413
  const classNames = bomCore.getClassNames('text-description');
11395
11414
  return jsxRuntime.jsx(Section, {
11396
11415
  className: classNames,
11397
- id: (_a = item.anchor) === null || _a === void 0 ? void 0 : _a.id,
11416
+ id: (_a = item.anchor) === null || _a === void 0 ? void 0 : _a.hash,
11398
11417
  padding: "0 0 2rem 0",
11399
11418
  children: jsxRuntime.jsx(Container, {
11400
11419
  maxWidthMd: "80ch",