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/{asset-hydration-D2xaUoAT.d.cts → asset-hydration-BeWWxiBq.d.cts} +1 -1
- package/dist/{asset-hydration-D9eThWse.d.ts → asset-hydration-CLoDkZDh.d.ts} +1 -1
- package/dist/chatbot.d.cts +2 -2
- package/dist/chatbot.d.ts +2 -2
- package/dist/index.cjs +52 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +52 -2
- package/dist/index.js.map +1 -1
- package/dist/{raster-image-canvas-CCOmB4NY.d.ts → raster-image-canvas-BqBgE8C-.d.ts} +33 -1
- package/dist/{raster-image-canvas-nK9kM9UJ.d.cts → raster-image-canvas-Byq087t9.d.cts} +33 -1
- package/dist/react.cjs +52 -2
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +6 -6
- package/dist/react.d.ts +6 -6
- package/dist/react.js +52 -2
- package/dist/react.js.map +1 -1
- package/dist/realtime.cjs.map +1 -1
- package/dist/realtime.d.cts +2 -2
- package/dist/realtime.d.ts +2 -2
- package/dist/realtime.js.map +1 -1
- package/dist/{types-CMuEaiM7.d.ts → types-D_cQxUug.d.ts} +1 -1
- package/dist/{types-D402X18k.d.cts → types-f8d-2-6N.d.cts} +1 -1
- package/package.json +1 -1
|
@@ -179,6 +179,37 @@ type RasterImageCanvasRenderRequest = {
|
|
|
179
179
|
cameraZoom: number;
|
|
180
180
|
devicePixelRatio: number;
|
|
181
181
|
};
|
|
182
|
+
/**
|
|
183
|
+
* Bitmap-like source returned by `imageCanvasRendering.resolveCanvasSource`.
|
|
184
|
+
*
|
|
185
|
+
* Apps can render into an offscreen canvas, create an `ImageBitmap`, or wrap any
|
|
186
|
+
* other canvas-compatible source and let Canvu copy it into the visible canvas
|
|
187
|
+
* without changing the underlying SVG image URL.
|
|
188
|
+
*/
|
|
189
|
+
type RasterImageCanvasSource = {
|
|
190
|
+
width: number;
|
|
191
|
+
height: number;
|
|
192
|
+
draw: (context: CanvasRenderingContext2D) => void;
|
|
193
|
+
close?: () => void;
|
|
194
|
+
};
|
|
195
|
+
/**
|
|
196
|
+
* Input passed to `imageCanvasRendering.resolveCanvasSource`.
|
|
197
|
+
*
|
|
198
|
+
* Use this for custom async rendering pipelines such as PDF page rasterization.
|
|
199
|
+
* Canvu keeps the previous canvas visible while this request resolves and aborts
|
|
200
|
+
* stale requests when the item leaves the viewport or a sharper target is queued.
|
|
201
|
+
*/
|
|
202
|
+
type RasterImageCanvasSourceRequest = RasterImageCanvasRenderRequest & {
|
|
203
|
+
targetHref: string;
|
|
204
|
+
sourceKey: string;
|
|
205
|
+
signal: AbortSignal;
|
|
206
|
+
};
|
|
207
|
+
/**
|
|
208
|
+
* Maps an image item plus requested bitmap size to a custom canvas source.
|
|
209
|
+
*
|
|
210
|
+
* Return `null`/`undefined` to let Canvu fetch and decode the resolved URL.
|
|
211
|
+
*/
|
|
212
|
+
type RasterImageCanvasSourceResolver = (request: RasterImageCanvasSourceRequest) => RasterImageCanvasSource | null | undefined | Promise<RasterImageCanvasSource | null | undefined>;
|
|
182
213
|
/**
|
|
183
214
|
* Resolved raster source for a zoom-aware canvas redraw.
|
|
184
215
|
*
|
|
@@ -209,6 +240,7 @@ type RasterImageCanvasRenderTargetResolver = (request: RasterImageCanvasRenderRe
|
|
|
209
240
|
type RasterImageCanvasRenderingOptions = {
|
|
210
241
|
resolveSourceSize?: RasterImageCanvasSourceSizeResolver;
|
|
211
242
|
resolveRenderTarget?: RasterImageCanvasRenderTargetResolver;
|
|
243
|
+
resolveCanvasSource?: RasterImageCanvasSourceResolver;
|
|
212
244
|
devicePixelRatio?: number;
|
|
213
245
|
pixelHeadroom?: number;
|
|
214
246
|
maxPixelCount?: number;
|
|
@@ -216,4 +248,4 @@ type RasterImageCanvasRenderingOptions = {
|
|
|
216
248
|
upscaleRedrawRatio?: number;
|
|
217
249
|
};
|
|
218
250
|
|
|
219
|
-
export type { RasterImageCanvasRenderingOptions as R, VectorViewportAssetKind as V, VectorViewportAssetStore as a, RasterImageCanvasRenderRequest as b, RasterImageCanvasRenderTarget as c, RasterImageCanvasRenderTargetResolver as d,
|
|
251
|
+
export type { RasterImageCanvasRenderingOptions as R, VectorViewportAssetKind as V, VectorViewportAssetStore as a, RasterImageCanvasRenderRequest as b, RasterImageCanvasRenderTarget as c, RasterImageCanvasRenderTargetResolver as d, RasterImageCanvasSource as e, RasterImageCanvasSourceRequest as f, RasterImageCanvasSourceResolver as g, RasterImageCanvasSourceSizeRequest as h, RasterImageCanvasSourceSizeResolver as i, VectorViewportAssetHydrationRequest as j, VectorViewportAssetResolveRequest as k, VectorViewportAssetResolveResult as l, VectorViewportAssetUploadRequest as m, VectorViewportAssetUploadResult as n };
|
|
@@ -179,6 +179,37 @@ type RasterImageCanvasRenderRequest = {
|
|
|
179
179
|
cameraZoom: number;
|
|
180
180
|
devicePixelRatio: number;
|
|
181
181
|
};
|
|
182
|
+
/**
|
|
183
|
+
* Bitmap-like source returned by `imageCanvasRendering.resolveCanvasSource`.
|
|
184
|
+
*
|
|
185
|
+
* Apps can render into an offscreen canvas, create an `ImageBitmap`, or wrap any
|
|
186
|
+
* other canvas-compatible source and let Canvu copy it into the visible canvas
|
|
187
|
+
* without changing the underlying SVG image URL.
|
|
188
|
+
*/
|
|
189
|
+
type RasterImageCanvasSource = {
|
|
190
|
+
width: number;
|
|
191
|
+
height: number;
|
|
192
|
+
draw: (context: CanvasRenderingContext2D) => void;
|
|
193
|
+
close?: () => void;
|
|
194
|
+
};
|
|
195
|
+
/**
|
|
196
|
+
* Input passed to `imageCanvasRendering.resolveCanvasSource`.
|
|
197
|
+
*
|
|
198
|
+
* Use this for custom async rendering pipelines such as PDF page rasterization.
|
|
199
|
+
* Canvu keeps the previous canvas visible while this request resolves and aborts
|
|
200
|
+
* stale requests when the item leaves the viewport or a sharper target is queued.
|
|
201
|
+
*/
|
|
202
|
+
type RasterImageCanvasSourceRequest = RasterImageCanvasRenderRequest & {
|
|
203
|
+
targetHref: string;
|
|
204
|
+
sourceKey: string;
|
|
205
|
+
signal: AbortSignal;
|
|
206
|
+
};
|
|
207
|
+
/**
|
|
208
|
+
* Maps an image item plus requested bitmap size to a custom canvas source.
|
|
209
|
+
*
|
|
210
|
+
* Return `null`/`undefined` to let Canvu fetch and decode the resolved URL.
|
|
211
|
+
*/
|
|
212
|
+
type RasterImageCanvasSourceResolver = (request: RasterImageCanvasSourceRequest) => RasterImageCanvasSource | null | undefined | Promise<RasterImageCanvasSource | null | undefined>;
|
|
182
213
|
/**
|
|
183
214
|
* Resolved raster source for a zoom-aware canvas redraw.
|
|
184
215
|
*
|
|
@@ -209,6 +240,7 @@ type RasterImageCanvasRenderTargetResolver = (request: RasterImageCanvasRenderRe
|
|
|
209
240
|
type RasterImageCanvasRenderingOptions = {
|
|
210
241
|
resolveSourceSize?: RasterImageCanvasSourceSizeResolver;
|
|
211
242
|
resolveRenderTarget?: RasterImageCanvasRenderTargetResolver;
|
|
243
|
+
resolveCanvasSource?: RasterImageCanvasSourceResolver;
|
|
212
244
|
devicePixelRatio?: number;
|
|
213
245
|
pixelHeadroom?: number;
|
|
214
246
|
maxPixelCount?: number;
|
|
@@ -216,4 +248,4 @@ type RasterImageCanvasRenderingOptions = {
|
|
|
216
248
|
upscaleRedrawRatio?: number;
|
|
217
249
|
};
|
|
218
250
|
|
|
219
|
-
export type { RasterImageCanvasRenderingOptions as R, VectorViewportAssetKind as V, VectorViewportAssetStore as a, RasterImageCanvasRenderRequest as b, RasterImageCanvasRenderTarget as c, RasterImageCanvasRenderTargetResolver as d,
|
|
251
|
+
export type { RasterImageCanvasRenderingOptions as R, VectorViewportAssetKind as V, VectorViewportAssetStore as a, RasterImageCanvasRenderRequest as b, RasterImageCanvasRenderTarget as c, RasterImageCanvasRenderTargetResolver as d, RasterImageCanvasSource as e, RasterImageCanvasSourceRequest as f, RasterImageCanvasSourceResolver as g, RasterImageCanvasSourceSizeRequest as h, RasterImageCanvasSourceSizeResolver as i, VectorViewportAssetHydrationRequest as j, VectorViewportAssetResolveRequest as k, VectorViewportAssetResolveResult as l, VectorViewportAssetUploadRequest as m, VectorViewportAssetUploadResult as n };
|
package/dist/react.cjs
CHANGED
|
@@ -6896,6 +6896,7 @@ function resolveRasterImageCanvasRenderingOptions(options) {
|
|
|
6896
6896
|
return {
|
|
6897
6897
|
resolveSourceSize: options.resolveSourceSize,
|
|
6898
6898
|
resolveRenderTarget: options.resolveRenderTarget,
|
|
6899
|
+
resolveCanvasSource: options.resolveCanvasSource,
|
|
6899
6900
|
devicePixelRatio: toPositiveFiniteNumber(
|
|
6900
6901
|
options.devicePixelRatio,
|
|
6901
6902
|
fallbackDevicePixelRatio
|
|
@@ -7160,6 +7161,36 @@ function loadImageElement(href, signal) {
|
|
|
7160
7161
|
image.src = href;
|
|
7161
7162
|
});
|
|
7162
7163
|
}
|
|
7164
|
+
function normalizeDecodedRasterImageSource(source) {
|
|
7165
|
+
if (!source) return null;
|
|
7166
|
+
const width = Math.max(1, Math.round(source.width));
|
|
7167
|
+
const height = Math.max(1, Math.round(source.height));
|
|
7168
|
+
if (!Number.isFinite(width) || !Number.isFinite(height)) return null;
|
|
7169
|
+
return {
|
|
7170
|
+
width,
|
|
7171
|
+
height,
|
|
7172
|
+
draw: source.draw,
|
|
7173
|
+
close: source.close ?? (() => {
|
|
7174
|
+
})
|
|
7175
|
+
};
|
|
7176
|
+
}
|
|
7177
|
+
async function resolveDecodedRasterImageSource({
|
|
7178
|
+
options,
|
|
7179
|
+
request,
|
|
7180
|
+
width,
|
|
7181
|
+
height,
|
|
7182
|
+
signal
|
|
7183
|
+
}) {
|
|
7184
|
+
if (options?.resolveCanvasSource) {
|
|
7185
|
+
const source = await options.resolveCanvasSource({
|
|
7186
|
+
...request,
|
|
7187
|
+
signal
|
|
7188
|
+
});
|
|
7189
|
+
const decoded = normalizeDecodedRasterImageSource(source);
|
|
7190
|
+
if (decoded) return decoded;
|
|
7191
|
+
}
|
|
7192
|
+
return decodeRasterImage(request.targetHref, width, height, signal);
|
|
7193
|
+
}
|
|
7163
7194
|
var SvgVectorRenderer = class {
|
|
7164
7195
|
container;
|
|
7165
7196
|
scene;
|
|
@@ -7392,7 +7423,20 @@ var SvgVectorRenderer = class {
|
|
|
7392
7423
|
}
|
|
7393
7424
|
const request = {
|
|
7394
7425
|
itemHref: item.imageRasterHref,
|
|
7395
|
-
target
|
|
7426
|
+
target,
|
|
7427
|
+
sourceRequest: {
|
|
7428
|
+
item,
|
|
7429
|
+
href: item.imageRasterHref,
|
|
7430
|
+
intrinsicSize: item.imageIntrinsicSize,
|
|
7431
|
+
sourceSize,
|
|
7432
|
+
contentRect: target.contentRect,
|
|
7433
|
+
targetSize: target.targetSize,
|
|
7434
|
+
viewportSize,
|
|
7435
|
+
cameraZoom: this.camera.zoom,
|
|
7436
|
+
devicePixelRatio: options.devicePixelRatio,
|
|
7437
|
+
targetHref: target.href,
|
|
7438
|
+
sourceKey: target.sourceKey
|
|
7439
|
+
}
|
|
7396
7440
|
};
|
|
7397
7441
|
if (rasterCanvas.abortController) {
|
|
7398
7442
|
if (rasterCanvas.loadingItemHref !== item.imageRasterHref) {
|
|
@@ -7482,7 +7526,13 @@ var SvgVectorRenderer = class {
|
|
|
7482
7526
|
rasterCanvas.loadingWidth = width;
|
|
7483
7527
|
rasterCanvas.loadingHeight = height;
|
|
7484
7528
|
rasterCanvas.queuedTarget = null;
|
|
7485
|
-
|
|
7529
|
+
resolveDecodedRasterImageSource({
|
|
7530
|
+
options: this.rasterImageCanvasRendering,
|
|
7531
|
+
request: request.sourceRequest,
|
|
7532
|
+
width,
|
|
7533
|
+
height,
|
|
7534
|
+
signal: abortController.signal
|
|
7535
|
+
}).then((decoded) => {
|
|
7486
7536
|
if (abortController.signal.aborted || rasterCanvas.loadSequence !== sequence) {
|
|
7487
7537
|
decoded.close();
|
|
7488
7538
|
return;
|