canvu-react 0.4.69 → 0.4.71

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-nK9kM9UJ.cjs';
2
+ import { a as VectorViewportAssetStore } from './raster-image-canvas-Byq087t9.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-CCOmB4NY.js';
2
+ import { a as VectorViewportAssetStore } from './raster-image-canvas-BqBgE8C-.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-D402X18k.cjs';
2
+ import { c as CanvasPlugin } from './types-f8d-2-6N.cjs';
3
3
  import 'react';
4
4
  import './types-fJNwEnHf.cjs';
5
5
  import './shape-builders-DzhCOuzo.cjs';
6
- import './raster-image-canvas-nK9kM9UJ.cjs';
6
+ import './raster-image-canvas-Byq087t9.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-CMuEaiM7.js';
2
+ import { c as CanvasPlugin } from './types-D_cQxUug.js';
3
3
  import 'react';
4
4
  import './types-fJNwEnHf.js';
5
5
  import './shape-builders-xG3A66sv.js';
6
- import './raster-image-canvas-CCOmB4NY.js';
6
+ import './raster-image-canvas-BqBgE8C-.js';
7
7
  import './link-item-COoNNvCu.js';
8
8
  import './types-BXa2CIrc.js';
9
9
 
package/dist/index.cjs CHANGED
@@ -2588,6 +2588,7 @@ function resolveRasterImageCanvasRenderingOptions(options) {
2588
2588
  return {
2589
2589
  resolveSourceSize: options.resolveSourceSize,
2590
2590
  resolveRenderTarget: options.resolveRenderTarget,
2591
+ resolveCanvasSource: options.resolveCanvasSource,
2591
2592
  devicePixelRatio: toPositiveFiniteNumber(
2592
2593
  options.devicePixelRatio,
2593
2594
  fallbackDevicePixelRatio
@@ -2852,6 +2853,36 @@ function loadImageElement(href, signal) {
2852
2853
  image.src = href;
2853
2854
  });
2854
2855
  }
2856
+ function normalizeDecodedRasterImageSource(source) {
2857
+ if (!source) return null;
2858
+ const width = Math.max(1, Math.round(source.width));
2859
+ const height = Math.max(1, Math.round(source.height));
2860
+ if (!Number.isFinite(width) || !Number.isFinite(height)) return null;
2861
+ return {
2862
+ width,
2863
+ height,
2864
+ draw: source.draw,
2865
+ close: source.close ?? (() => {
2866
+ })
2867
+ };
2868
+ }
2869
+ async function resolveDecodedRasterImageSource({
2870
+ options,
2871
+ request,
2872
+ width,
2873
+ height,
2874
+ signal
2875
+ }) {
2876
+ if (options?.resolveCanvasSource) {
2877
+ const source = await options.resolveCanvasSource({
2878
+ ...request,
2879
+ signal
2880
+ });
2881
+ const decoded = normalizeDecodedRasterImageSource(source);
2882
+ if (decoded) return decoded;
2883
+ }
2884
+ return decodeRasterImage(request.targetHref, width, height, signal);
2885
+ }
2855
2886
  var SvgVectorRenderer = class {
2856
2887
  container;
2857
2888
  scene;
@@ -3084,7 +3115,20 @@ var SvgVectorRenderer = class {
3084
3115
  }
3085
3116
  const request = {
3086
3117
  itemHref: item.imageRasterHref,
3087
- target
3118
+ target,
3119
+ sourceRequest: {
3120
+ item,
3121
+ href: item.imageRasterHref,
3122
+ intrinsicSize: item.imageIntrinsicSize,
3123
+ sourceSize,
3124
+ contentRect: target.contentRect,
3125
+ targetSize: target.targetSize,
3126
+ viewportSize,
3127
+ cameraZoom: this.camera.zoom,
3128
+ devicePixelRatio: options.devicePixelRatio,
3129
+ targetHref: target.href,
3130
+ sourceKey: target.sourceKey
3131
+ }
3088
3132
  };
3089
3133
  if (rasterCanvas.abortController) {
3090
3134
  if (rasterCanvas.loadingItemHref !== item.imageRasterHref) {
@@ -3174,7 +3218,13 @@ var SvgVectorRenderer = class {
3174
3218
  rasterCanvas.loadingWidth = width;
3175
3219
  rasterCanvas.loadingHeight = height;
3176
3220
  rasterCanvas.queuedTarget = null;
3177
- decodeRasterImage(target.href, width, height, abortController.signal).then((decoded) => {
3221
+ resolveDecodedRasterImageSource({
3222
+ options: this.rasterImageCanvasRendering,
3223
+ request: request.sourceRequest,
3224
+ width,
3225
+ height,
3226
+ signal: abortController.signal
3227
+ }).then((decoded) => {
3178
3228
  if (abortController.signal.aborted || rasterCanvas.loadSequence !== sequence) {
3179
3229
  decoded.close();
3180
3230
  return;