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.
package/dist/index.d.cts CHANGED
@@ -2,8 +2,8 @@ import { C as Camera2D } from './shape-builders-DzhCOuzo.cjs';
2
2
  export { a as Camera2DOptions, D as DEFAULT_STROKE_STYLE, F as FreehandSvgPayload, S as StrokeStyle, b as applyStrokeToItem, c as buildArchitecturalCloudPathD, d as buildArchitecturalCloudSvg, e as buildArrowSvg, f as buildDrawDotSvg, g as buildEllipseSvg, h as buildFreehandPathSvg, i as buildLineSvg, j as buildRectSvg, k as computeFreehandSvgPayload, l as createArchitecturalCloudItem, m as createDrawDotItem, n as createEllipseItem, o as createFreehandStrokeItem, p as createImageFromVectorTrace, q as createImageItem, r as createLineItem, s as createRectangleItem, t as createShapeId, u as createTextItem, v as lineEndpointsToLocal, w as rebuildItemSvg, x as resolveStrokeStyle } from './shape-builders-DzhCOuzo.cjs';
3
3
  import { V as VectorSceneItem, A as ArrowEndpointBinding, C as CustomShapeResizeHandles, R as Rect } from './types-fJNwEnHf.cjs';
4
4
  export { a as ArrowBindings, b as ResizeHandleId, c as VectorPathPoint, n as normalizeRect, r as rectsIntersect } from './types-fJNwEnHf.cjs';
5
- export { H as HydratedSceneItemsWithAssetsResult, h as hydrateSceneItemsWithAssets } from './asset-hydration-D2xaUoAT.cjs';
6
- import { R as RasterImageCanvasRenderingOptions } from './raster-image-canvas-nK9kM9UJ.cjs';
5
+ export { H as HydratedSceneItemsWithAssetsResult, h as hydrateSceneItemsWithAssets } from './asset-hydration-BeWWxiBq.cjs';
6
+ import { R as RasterImageCanvasRenderingOptions } from './raster-image-canvas-Byq087t9.cjs';
7
7
  export { C as CanvuLinkData, D as DEFAULT_LINK_CARD_SIZE, L as LINK_PLUGIN_KEY, b as buildLinkCardSvg, c as createLinkItem, g as getLinkData, i as isLinkItem } from './link-item-BMV3VUCr.cjs';
8
8
 
9
9
  type EncodeCanvasToBlobOptions = {
package/dist/index.d.ts CHANGED
@@ -2,8 +2,8 @@ import { C as Camera2D } from './shape-builders-xG3A66sv.js';
2
2
  export { a as Camera2DOptions, D as DEFAULT_STROKE_STYLE, F as FreehandSvgPayload, S as StrokeStyle, b as applyStrokeToItem, c as buildArchitecturalCloudPathD, d as buildArchitecturalCloudSvg, e as buildArrowSvg, f as buildDrawDotSvg, g as buildEllipseSvg, h as buildFreehandPathSvg, i as buildLineSvg, j as buildRectSvg, k as computeFreehandSvgPayload, l as createArchitecturalCloudItem, m as createDrawDotItem, n as createEllipseItem, o as createFreehandStrokeItem, p as createImageFromVectorTrace, q as createImageItem, r as createLineItem, s as createRectangleItem, t as createShapeId, u as createTextItem, v as lineEndpointsToLocal, w as rebuildItemSvg, x as resolveStrokeStyle } from './shape-builders-xG3A66sv.js';
3
3
  import { V as VectorSceneItem, A as ArrowEndpointBinding, C as CustomShapeResizeHandles, R as Rect } from './types-fJNwEnHf.js';
4
4
  export { a as ArrowBindings, b as ResizeHandleId, c as VectorPathPoint, n as normalizeRect, r as rectsIntersect } from './types-fJNwEnHf.js';
5
- export { H as HydratedSceneItemsWithAssetsResult, h as hydrateSceneItemsWithAssets } from './asset-hydration-D9eThWse.js';
6
- import { R as RasterImageCanvasRenderingOptions } from './raster-image-canvas-CCOmB4NY.js';
5
+ export { H as HydratedSceneItemsWithAssetsResult, h as hydrateSceneItemsWithAssets } from './asset-hydration-CLoDkZDh.js';
6
+ import { R as RasterImageCanvasRenderingOptions } from './raster-image-canvas-BqBgE8C-.js';
7
7
  export { C as CanvuLinkData, D as DEFAULT_LINK_CARD_SIZE, L as LINK_PLUGIN_KEY, b as buildLinkCardSvg, c as createLinkItem, g as getLinkData, i as isLinkItem } from './link-item-COoNNvCu.js';
8
8
 
9
9
  type EncodeCanvasToBlobOptions = {
package/dist/index.js CHANGED
@@ -2581,6 +2581,7 @@ function resolveRasterImageCanvasRenderingOptions(options) {
2581
2581
  return {
2582
2582
  resolveSourceSize: options.resolveSourceSize,
2583
2583
  resolveRenderTarget: options.resolveRenderTarget,
2584
+ resolveCanvasSource: options.resolveCanvasSource,
2584
2585
  devicePixelRatio: toPositiveFiniteNumber(
2585
2586
  options.devicePixelRatio,
2586
2587
  fallbackDevicePixelRatio
@@ -2845,6 +2846,36 @@ function loadImageElement(href, signal) {
2845
2846
  image.src = href;
2846
2847
  });
2847
2848
  }
2849
+ function normalizeDecodedRasterImageSource(source) {
2850
+ if (!source) return null;
2851
+ const width = Math.max(1, Math.round(source.width));
2852
+ const height = Math.max(1, Math.round(source.height));
2853
+ if (!Number.isFinite(width) || !Number.isFinite(height)) return null;
2854
+ return {
2855
+ width,
2856
+ height,
2857
+ draw: source.draw,
2858
+ close: source.close ?? (() => {
2859
+ })
2860
+ };
2861
+ }
2862
+ async function resolveDecodedRasterImageSource({
2863
+ options,
2864
+ request,
2865
+ width,
2866
+ height,
2867
+ signal
2868
+ }) {
2869
+ if (options?.resolveCanvasSource) {
2870
+ const source = await options.resolveCanvasSource({
2871
+ ...request,
2872
+ signal
2873
+ });
2874
+ const decoded = normalizeDecodedRasterImageSource(source);
2875
+ if (decoded) return decoded;
2876
+ }
2877
+ return decodeRasterImage(request.targetHref, width, height, signal);
2878
+ }
2848
2879
  var SvgVectorRenderer = class {
2849
2880
  container;
2850
2881
  scene;
@@ -3077,7 +3108,20 @@ var SvgVectorRenderer = class {
3077
3108
  }
3078
3109
  const request = {
3079
3110
  itemHref: item.imageRasterHref,
3080
- target
3111
+ target,
3112
+ sourceRequest: {
3113
+ item,
3114
+ href: item.imageRasterHref,
3115
+ intrinsicSize: item.imageIntrinsicSize,
3116
+ sourceSize,
3117
+ contentRect: target.contentRect,
3118
+ targetSize: target.targetSize,
3119
+ viewportSize,
3120
+ cameraZoom: this.camera.zoom,
3121
+ devicePixelRatio: options.devicePixelRatio,
3122
+ targetHref: target.href,
3123
+ sourceKey: target.sourceKey
3124
+ }
3081
3125
  };
3082
3126
  if (rasterCanvas.abortController) {
3083
3127
  if (rasterCanvas.loadingItemHref !== item.imageRasterHref) {
@@ -3167,7 +3211,13 @@ var SvgVectorRenderer = class {
3167
3211
  rasterCanvas.loadingWidth = width;
3168
3212
  rasterCanvas.loadingHeight = height;
3169
3213
  rasterCanvas.queuedTarget = null;
3170
- decodeRasterImage(target.href, width, height, abortController.signal).then((decoded) => {
3214
+ resolveDecodedRasterImageSource({
3215
+ options: this.rasterImageCanvasRendering,
3216
+ request: request.sourceRequest,
3217
+ width,
3218
+ height,
3219
+ signal: abortController.signal
3220
+ }).then((decoded) => {
3171
3221
  if (abortController.signal.aborted || rasterCanvas.loadSequence !== sequence) {
3172
3222
  decoded.close();
3173
3223
  return;