canvu-react 0.4.68 → 0.4.69

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.
@@ -1,5 +1,5 @@
1
1
  import { V as VectorSceneItem } from './types-fJNwEnHf.cjs';
2
- import { a as VectorViewportAssetStore } from './raster-image-canvas-zerVYllB.cjs';
2
+ import { a as VectorViewportAssetStore } from './raster-image-canvas-nK9kM9UJ.cjs';
3
3
 
4
4
  declare class IndexedDbImageStore {
5
5
  private dbPromise;
@@ -1,5 +1,5 @@
1
1
  import { V as VectorSceneItem } from './types-fJNwEnHf.js';
2
- import { a as VectorViewportAssetStore } from './raster-image-canvas-BZh73aoc.js';
2
+ import { a as VectorViewportAssetStore } from './raster-image-canvas-CCOmB4NY.js';
3
3
 
4
4
  declare class IndexedDbImageStore {
5
5
  private dbPromise;
@@ -1,9 +1,9 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { c as CanvasPlugin } from './types-BZ9wK9Y3.cjs';
2
+ import { c as CanvasPlugin } from './types-D402X18k.cjs';
3
3
  import 'react';
4
4
  import './types-fJNwEnHf.cjs';
5
5
  import './shape-builders-DzhCOuzo.cjs';
6
- import './raster-image-canvas-zerVYllB.cjs';
6
+ import './raster-image-canvas-nK9kM9UJ.cjs';
7
7
  import './link-item-BMV3VUCr.cjs';
8
8
  import './types-DqsqQQVf.cjs';
9
9
 
package/dist/chatbot.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { c as CanvasPlugin } from './types-94XpQMy7.js';
2
+ import { c as CanvasPlugin } from './types-CMuEaiM7.js';
3
3
  import 'react';
4
4
  import './types-fJNwEnHf.js';
5
5
  import './shape-builders-xG3A66sv.js';
6
- import './raster-image-canvas-BZh73aoc.js';
6
+ import './raster-image-canvas-CCOmB4NY.js';
7
7
  import './link-item-COoNNvCu.js';
8
8
  import './types-BXa2CIrc.js';
9
9
 
package/dist/index.cjs CHANGED
@@ -2586,6 +2586,7 @@ function resolveRasterImageCanvasRenderingOptions(options) {
2586
2586
  if (!options) return null;
2587
2587
  const fallbackDevicePixelRatio = typeof window === "undefined" ? 1 : window.devicePixelRatio;
2588
2588
  return {
2589
+ resolveSourceSize: options.resolveSourceSize,
2589
2590
  resolveRenderTarget: options.resolveRenderTarget,
2590
2591
  devicePixelRatio: toPositiveFiniteNumber(
2591
2592
  options.devicePixelRatio,
@@ -2628,6 +2629,28 @@ function getRasterImageContentRect(item) {
2628
2629
  const height = width / imageAspectRatio;
2629
2630
  return { x: 0, y: (bounds.height - height) / 2, width, height };
2630
2631
  }
2632
+ function resolveRasterImageCanvasSourceSize({
2633
+ item,
2634
+ href,
2635
+ intrinsicSize,
2636
+ contentRect,
2637
+ viewportSize,
2638
+ cameraZoom,
2639
+ options
2640
+ }) {
2641
+ const resolved = options.resolveSourceSize?.({
2642
+ item,
2643
+ href,
2644
+ intrinsicSize,
2645
+ contentRect,
2646
+ viewportSize,
2647
+ cameraZoom,
2648
+ devicePixelRatio: options.devicePixelRatio
2649
+ });
2650
+ const width = toPositiveFiniteNumber(resolved?.width, intrinsicSize.width);
2651
+ const height = toPositiveFiniteNumber(resolved?.height, intrinsicSize.height);
2652
+ return { width, height };
2653
+ }
2631
2654
  function getRasterImageCanvasTargetSize({
2632
2655
  intrinsicSize,
2633
2656
  contentRect,
@@ -2667,6 +2690,7 @@ function resolveRasterImageCanvasRenderTarget({
2667
2690
  item,
2668
2691
  href,
2669
2692
  intrinsicSize,
2693
+ sourceSize,
2670
2694
  contentRect,
2671
2695
  targetSize,
2672
2696
  viewportSize,
@@ -2677,6 +2701,7 @@ function resolveRasterImageCanvasRenderTarget({
2677
2701
  item,
2678
2702
  href,
2679
2703
  intrinsicSize,
2704
+ sourceSize,
2680
2705
  contentRect,
2681
2706
  targetSize,
2682
2707
  viewportSize,
@@ -3012,9 +3037,18 @@ var SvgVectorRenderer = class {
3012
3037
  this.releaseRasterImageCanvas(cached);
3013
3038
  return;
3014
3039
  }
3015
- const targetSize = getRasterImageCanvasTargetSize({
3040
+ const sourceSize = resolveRasterImageCanvasSourceSize({
3041
+ item,
3042
+ href: item.imageRasterHref,
3016
3043
  intrinsicSize: item.imageIntrinsicSize,
3017
3044
  contentRect,
3045
+ viewportSize,
3046
+ cameraZoom: this.camera.zoom,
3047
+ options
3048
+ });
3049
+ const targetSize = getRasterImageCanvasTargetSize({
3050
+ intrinsicSize: sourceSize,
3051
+ contentRect,
3018
3052
  cameraZoom: this.camera.zoom,
3019
3053
  devicePixelRatio: options.devicePixelRatio,
3020
3054
  pixelHeadroom: options.pixelHeadroom,
@@ -3025,6 +3059,7 @@ var SvgVectorRenderer = class {
3025
3059
  item,
3026
3060
  href: item.imageRasterHref,
3027
3061
  intrinsicSize: item.imageIntrinsicSize,
3062
+ sourceSize,
3028
3063
  contentRect,
3029
3064
  targetSize,
3030
3065
  viewportSize,