canvu-react 0.4.70 → 0.4.72
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-6swZ6ciN.d.cts} +1 -1
- package/dist/{asset-hydration-D9eThWse.d.ts → asset-hydration-P0M5hn-p.d.ts} +1 -1
- package/dist/chatbot.d.cts +2 -2
- package/dist/chatbot.d.ts +2 -2
- package/dist/index.cjs +139 -8
- 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 +139 -8
- package/dist/index.js.map +1 -1
- package/dist/{raster-image-canvas-nK9kM9UJ.d.cts → raster-image-canvas-ByaCKEVw.d.cts} +35 -1
- package/dist/{raster-image-canvas-CCOmB4NY.d.ts → raster-image-canvas-D3ZrySjr.d.ts} +35 -1
- package/dist/react.cjs +178 -15
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +13 -6
- package/dist/react.d.ts +13 -6
- package/dist/react.js +178 -15
- 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-C5wxwquF.d.ts} +1 -1
- package/dist/{types-D402X18k.d.cts → types-DOUBapS4.d.cts} +1 -1
- package/package.json +1 -1
package/dist/react.d.cts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { V as VectorSceneItem } from './types-fJNwEnHf.cjs';
|
|
2
2
|
export { C as CustomShapeResizeHandles, b as ResizeHandleId } from './types-fJNwEnHf.cjs';
|
|
3
|
-
import { V as VectorViewportAssetKind, a as VectorViewportAssetStore } from './raster-image-canvas-
|
|
4
|
-
export { b as RasterImageCanvasRenderRequest, c as RasterImageCanvasRenderTarget, d as RasterImageCanvasRenderTargetResolver, R as RasterImageCanvasRenderingOptions, e as
|
|
5
|
-
import { I as IndexedDbImageStore } from './asset-hydration-
|
|
6
|
-
export { H as HydratedSceneItemsWithAssetsResult, h as hydrateSceneItemsWithAssets } from './asset-hydration-
|
|
7
|
-
import { B as BoardComponentPosition, V as VectorToolDefinition, C as CustomShapePlacementOptions, a as CanvuBeforeInteractionHook, b as CanvuAfterInteractionHook, c as CanvasPlugin, d as VectorSelectionInspector } from './types-
|
|
8
|
-
export { e as CanvasPluginComponentProps, f as CanvasPluginContribution, g as CanvasPluginItemsChangeMiddlewareContext, h as CanvasPluginRenderContext, i as CanvuAfterInteractionDetail, j as CanvuBeforeInteractionResult, k as CanvuChromeActiveToolStyle, l as CanvuChromeContext, m as CanvuChromeContextValue, n as CanvuChromeSelectionStyleChange, o as CanvuInteractionDetail, p as CanvuInteractionKind, q as CanvuInteractionOutcome, r as CanvuInteractionPoint, s as CanvuPluginContext, t as CanvuPluginContextValue, u as CanvuPluginViewportSnapshot, P as PlacementPreview, R as ReadOnlyInteractionOptions, v as ReadOnlyItemClickCandidateDetail, w as ReadOnlyItemClickScope, S as SHAPE_CONTEXT_MENU_ITEM_IDS, x as SelectModeItemClickDetail, y as SelectModeItemClickResult, z as ShapeContextMenu, A as ShapeContextMenuItem, D as ShapeContextMenuProps, E as ShapeContextMenuRenderContext, F as VectorCanvasSpacePosition, G as VectorItemsChangeInfo, H as VectorItemsChangeMotive, I as VectorSelectionInspectorProps, J as VectorViewport, K as VectorViewportHandle, L as VectorViewportProps, W as WorldPointerDownDetail, M as createCanvuPlugin, N as getBoardPositionStyle, O as useCanvuChromeContext, Q as useCanvuDocumentContext, T as useCanvuPluginContext, U as useCanvuPluginContribution, X as useCanvuResolvedTools, Y as useCanvuViewportContext } from './types-
|
|
3
|
+
import { V as VectorViewportAssetKind, a as VectorViewportAssetStore } from './raster-image-canvas-ByaCKEVw.cjs';
|
|
4
|
+
export { b as RasterImageCanvasRenderRequest, c as RasterImageCanvasRenderTarget, d as RasterImageCanvasRenderTargetResolver, R as RasterImageCanvasRenderingOptions, e as RasterImageCanvasSource, f as RasterImageCanvasSourceRequest, g as RasterImageCanvasSourceResolver, h as RasterImageCanvasSourceSizeRequest, i as RasterImageCanvasSourceSizeResolver, j as VectorViewportAssetHydrationRequest, k as VectorViewportAssetResolveRequest, l as VectorViewportAssetResolveResult, m as VectorViewportAssetUploadRequest, n as VectorViewportAssetUploadResult } from './raster-image-canvas-ByaCKEVw.cjs';
|
|
5
|
+
import { I as IndexedDbImageStore } from './asset-hydration-6swZ6ciN.cjs';
|
|
6
|
+
export { H as HydratedSceneItemsWithAssetsResult, h as hydrateSceneItemsWithAssets } from './asset-hydration-6swZ6ciN.cjs';
|
|
7
|
+
import { B as BoardComponentPosition, V as VectorToolDefinition, C as CustomShapePlacementOptions, a as CanvuBeforeInteractionHook, b as CanvuAfterInteractionHook, c as CanvasPlugin, d as VectorSelectionInspector } from './types-DOUBapS4.cjs';
|
|
8
|
+
export { e as CanvasPluginComponentProps, f as CanvasPluginContribution, g as CanvasPluginItemsChangeMiddlewareContext, h as CanvasPluginRenderContext, i as CanvuAfterInteractionDetail, j as CanvuBeforeInteractionResult, k as CanvuChromeActiveToolStyle, l as CanvuChromeContext, m as CanvuChromeContextValue, n as CanvuChromeSelectionStyleChange, o as CanvuInteractionDetail, p as CanvuInteractionKind, q as CanvuInteractionOutcome, r as CanvuInteractionPoint, s as CanvuPluginContext, t as CanvuPluginContextValue, u as CanvuPluginViewportSnapshot, P as PlacementPreview, R as ReadOnlyInteractionOptions, v as ReadOnlyItemClickCandidateDetail, w as ReadOnlyItemClickScope, S as SHAPE_CONTEXT_MENU_ITEM_IDS, x as SelectModeItemClickDetail, y as SelectModeItemClickResult, z as ShapeContextMenu, A as ShapeContextMenuItem, D as ShapeContextMenuProps, E as ShapeContextMenuRenderContext, F as VectorCanvasSpacePosition, G as VectorItemsChangeInfo, H as VectorItemsChangeMotive, I as VectorSelectionInspectorProps, J as VectorViewport, K as VectorViewportHandle, L as VectorViewportProps, W as WorldPointerDownDetail, M as createCanvuPlugin, N as getBoardPositionStyle, O as useCanvuChromeContext, Q as useCanvuDocumentContext, T as useCanvuPluginContext, U as useCanvuPluginContribution, X as useCanvuResolvedTools, Y as useCanvuViewportContext } from './types-DOUBapS4.cjs';
|
|
9
9
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
10
10
|
import * as react from 'react';
|
|
11
11
|
import { CSSProperties, ReactNode, ReactElement, SVGProps } from 'react';
|
|
@@ -115,6 +115,13 @@ type IngestAssetFilesToSceneItemsOptions = {
|
|
|
115
115
|
*/
|
|
116
116
|
pdfScale?: number;
|
|
117
117
|
pdfPageConcurrency?: number;
|
|
118
|
+
/**
|
|
119
|
+
* Cancels in-flight PDF rendering, asset uploads, and item emission.
|
|
120
|
+
*
|
|
121
|
+
* Pass this when ingestion is tied to a component lifecycle or route so stale
|
|
122
|
+
* imports stop work instead of continuing in the background.
|
|
123
|
+
*/
|
|
124
|
+
signal?: AbortSignal;
|
|
118
125
|
/**
|
|
119
126
|
* Called as soon as canvu finishes converting one or more items from the
|
|
120
127
|
* source files.
|
package/dist/react.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { V as VectorSceneItem } from './types-fJNwEnHf.js';
|
|
2
2
|
export { C as CustomShapeResizeHandles, b as ResizeHandleId } from './types-fJNwEnHf.js';
|
|
3
|
-
import { V as VectorViewportAssetKind, a as VectorViewportAssetStore } from './raster-image-canvas-
|
|
4
|
-
export { b as RasterImageCanvasRenderRequest, c as RasterImageCanvasRenderTarget, d as RasterImageCanvasRenderTargetResolver, R as RasterImageCanvasRenderingOptions, e as
|
|
5
|
-
import { I as IndexedDbImageStore } from './asset-hydration-
|
|
6
|
-
export { H as HydratedSceneItemsWithAssetsResult, h as hydrateSceneItemsWithAssets } from './asset-hydration-
|
|
7
|
-
import { B as BoardComponentPosition, V as VectorToolDefinition, C as CustomShapePlacementOptions, a as CanvuBeforeInteractionHook, b as CanvuAfterInteractionHook, c as CanvasPlugin, d as VectorSelectionInspector } from './types-
|
|
8
|
-
export { e as CanvasPluginComponentProps, f as CanvasPluginContribution, g as CanvasPluginItemsChangeMiddlewareContext, h as CanvasPluginRenderContext, i as CanvuAfterInteractionDetail, j as CanvuBeforeInteractionResult, k as CanvuChromeActiveToolStyle, l as CanvuChromeContext, m as CanvuChromeContextValue, n as CanvuChromeSelectionStyleChange, o as CanvuInteractionDetail, p as CanvuInteractionKind, q as CanvuInteractionOutcome, r as CanvuInteractionPoint, s as CanvuPluginContext, t as CanvuPluginContextValue, u as CanvuPluginViewportSnapshot, P as PlacementPreview, R as ReadOnlyInteractionOptions, v as ReadOnlyItemClickCandidateDetail, w as ReadOnlyItemClickScope, S as SHAPE_CONTEXT_MENU_ITEM_IDS, x as SelectModeItemClickDetail, y as SelectModeItemClickResult, z as ShapeContextMenu, A as ShapeContextMenuItem, D as ShapeContextMenuProps, E as ShapeContextMenuRenderContext, F as VectorCanvasSpacePosition, G as VectorItemsChangeInfo, H as VectorItemsChangeMotive, I as VectorSelectionInspectorProps, J as VectorViewport, K as VectorViewportHandle, L as VectorViewportProps, W as WorldPointerDownDetail, M as createCanvuPlugin, N as getBoardPositionStyle, O as useCanvuChromeContext, Q as useCanvuDocumentContext, T as useCanvuPluginContext, U as useCanvuPluginContribution, X as useCanvuResolvedTools, Y as useCanvuViewportContext } from './types-
|
|
3
|
+
import { V as VectorViewportAssetKind, a as VectorViewportAssetStore } from './raster-image-canvas-D3ZrySjr.js';
|
|
4
|
+
export { b as RasterImageCanvasRenderRequest, c as RasterImageCanvasRenderTarget, d as RasterImageCanvasRenderTargetResolver, R as RasterImageCanvasRenderingOptions, e as RasterImageCanvasSource, f as RasterImageCanvasSourceRequest, g as RasterImageCanvasSourceResolver, h as RasterImageCanvasSourceSizeRequest, i as RasterImageCanvasSourceSizeResolver, j as VectorViewportAssetHydrationRequest, k as VectorViewportAssetResolveRequest, l as VectorViewportAssetResolveResult, m as VectorViewportAssetUploadRequest, n as VectorViewportAssetUploadResult } from './raster-image-canvas-D3ZrySjr.js';
|
|
5
|
+
import { I as IndexedDbImageStore } from './asset-hydration-P0M5hn-p.js';
|
|
6
|
+
export { H as HydratedSceneItemsWithAssetsResult, h as hydrateSceneItemsWithAssets } from './asset-hydration-P0M5hn-p.js';
|
|
7
|
+
import { B as BoardComponentPosition, V as VectorToolDefinition, C as CustomShapePlacementOptions, a as CanvuBeforeInteractionHook, b as CanvuAfterInteractionHook, c as CanvasPlugin, d as VectorSelectionInspector } from './types-C5wxwquF.js';
|
|
8
|
+
export { e as CanvasPluginComponentProps, f as CanvasPluginContribution, g as CanvasPluginItemsChangeMiddlewareContext, h as CanvasPluginRenderContext, i as CanvuAfterInteractionDetail, j as CanvuBeforeInteractionResult, k as CanvuChromeActiveToolStyle, l as CanvuChromeContext, m as CanvuChromeContextValue, n as CanvuChromeSelectionStyleChange, o as CanvuInteractionDetail, p as CanvuInteractionKind, q as CanvuInteractionOutcome, r as CanvuInteractionPoint, s as CanvuPluginContext, t as CanvuPluginContextValue, u as CanvuPluginViewportSnapshot, P as PlacementPreview, R as ReadOnlyInteractionOptions, v as ReadOnlyItemClickCandidateDetail, w as ReadOnlyItemClickScope, S as SHAPE_CONTEXT_MENU_ITEM_IDS, x as SelectModeItemClickDetail, y as SelectModeItemClickResult, z as ShapeContextMenu, A as ShapeContextMenuItem, D as ShapeContextMenuProps, E as ShapeContextMenuRenderContext, F as VectorCanvasSpacePosition, G as VectorItemsChangeInfo, H as VectorItemsChangeMotive, I as VectorSelectionInspectorProps, J as VectorViewport, K as VectorViewportHandle, L as VectorViewportProps, W as WorldPointerDownDetail, M as createCanvuPlugin, N as getBoardPositionStyle, O as useCanvuChromeContext, Q as useCanvuDocumentContext, T as useCanvuPluginContext, U as useCanvuPluginContribution, X as useCanvuResolvedTools, Y as useCanvuViewportContext } from './types-C5wxwquF.js';
|
|
9
9
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
10
10
|
import * as react from 'react';
|
|
11
11
|
import { CSSProperties, ReactNode, ReactElement, SVGProps } from 'react';
|
|
@@ -115,6 +115,13 @@ type IngestAssetFilesToSceneItemsOptions = {
|
|
|
115
115
|
*/
|
|
116
116
|
pdfScale?: number;
|
|
117
117
|
pdfPageConcurrency?: number;
|
|
118
|
+
/**
|
|
119
|
+
* Cancels in-flight PDF rendering, asset uploads, and item emission.
|
|
120
|
+
*
|
|
121
|
+
* Pass this when ingestion is tied to a component lifecycle or route so stale
|
|
122
|
+
* imports stop work instead of continuing in the background.
|
|
123
|
+
*/
|
|
124
|
+
signal?: AbortSignal;
|
|
118
125
|
/**
|
|
119
126
|
* Called as soon as canvu finishes converting one or more items from the
|
|
120
127
|
* source files.
|
package/dist/react.js
CHANGED
|
@@ -1201,7 +1201,8 @@ function getPdfJs() {
|
|
|
1201
1201
|
}
|
|
1202
1202
|
return pdfjsPromise;
|
|
1203
1203
|
}
|
|
1204
|
-
async function renderPageToCanvas(page, scale) {
|
|
1204
|
+
async function renderPageToCanvas(page, scale, signal) {
|
|
1205
|
+
throwIfAborted(signal);
|
|
1205
1206
|
const raw = page.getViewport({ scale: 1 });
|
|
1206
1207
|
const adjustedScale = Math.round(raw.width * scale) / raw.width;
|
|
1207
1208
|
const viewport = page.getViewport({ scale: adjustedScale });
|
|
@@ -1214,22 +1215,48 @@ async function renderPageToCanvas(page, scale) {
|
|
|
1214
1215
|
if (!ctx) throw new Error("Canvas 2D context unavailable");
|
|
1215
1216
|
ctx.imageSmoothingEnabled = true;
|
|
1216
1217
|
ctx.imageSmoothingQuality = "high";
|
|
1217
|
-
|
|
1218
|
+
const renderTask = page.render({ canvas, viewport });
|
|
1219
|
+
if (signal) {
|
|
1220
|
+
const abortRender = () => {
|
|
1221
|
+
renderTask.cancel();
|
|
1222
|
+
};
|
|
1223
|
+
signal.addEventListener("abort", abortRender, { once: true });
|
|
1224
|
+
try {
|
|
1225
|
+
await renderTask.promise;
|
|
1226
|
+
} catch (error) {
|
|
1227
|
+
if (signal.aborted) throw createAbortError();
|
|
1228
|
+
throw error;
|
|
1229
|
+
} finally {
|
|
1230
|
+
signal.removeEventListener("abort", abortRender);
|
|
1231
|
+
}
|
|
1232
|
+
} else {
|
|
1233
|
+
await renderTask.promise;
|
|
1234
|
+
}
|
|
1235
|
+
throwIfAborted(signal);
|
|
1218
1236
|
return { canvas, width: w, height: h };
|
|
1219
1237
|
}
|
|
1238
|
+
function createAbortError() {
|
|
1239
|
+
return new DOMException("Aborted", "AbortError");
|
|
1240
|
+
}
|
|
1241
|
+
function throwIfAborted(signal) {
|
|
1242
|
+
if (signal?.aborted) {
|
|
1243
|
+
throw createAbortError();
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1220
1246
|
function normalizePdfPageNumbers(pageNumbers, pageCount) {
|
|
1221
1247
|
if (!pageNumbers || pageNumbers.length === 0) {
|
|
1222
1248
|
return Array.from({ length: pageCount }, (_, index) => index + 1);
|
|
1223
1249
|
}
|
|
1224
1250
|
return [...new Set(pageNumbers)].filter((pageNumber) => pageNumber >= 1 && pageNumber <= pageCount).sort((left, right) => left - right);
|
|
1225
1251
|
}
|
|
1226
|
-
async function runWithConcurrency(items, concurrency, execute) {
|
|
1252
|
+
async function runWithConcurrency(items, concurrency, execute, signal) {
|
|
1227
1253
|
const results = new Array(items.length);
|
|
1228
1254
|
let nextIndex = 0;
|
|
1229
1255
|
const workerCount = Math.max(1, Math.min(concurrency, items.length));
|
|
1230
1256
|
await Promise.all(
|
|
1231
1257
|
Array.from({ length: workerCount }, async () => {
|
|
1232
1258
|
while (nextIndex < items.length) {
|
|
1259
|
+
throwIfAborted(signal);
|
|
1233
1260
|
const currentIndex = nextIndex;
|
|
1234
1261
|
nextIndex += 1;
|
|
1235
1262
|
const item = items[currentIndex];
|
|
@@ -1237,6 +1264,7 @@ async function runWithConcurrency(items, concurrency, execute) {
|
|
|
1237
1264
|
continue;
|
|
1238
1265
|
}
|
|
1239
1266
|
results[currentIndex] = await execute(item);
|
|
1267
|
+
throwIfAborted(signal);
|
|
1240
1268
|
}
|
|
1241
1269
|
})
|
|
1242
1270
|
);
|
|
@@ -1246,9 +1274,49 @@ async function loadPdfToStore(file, store, options) {
|
|
|
1246
1274
|
const scale = options?.scale ?? 1.5;
|
|
1247
1275
|
const pageConcurrency = options?.pageConcurrency ?? 2;
|
|
1248
1276
|
const storeThumbnails = options?.storeThumbnails ?? false;
|
|
1277
|
+
const signal = options?.signal;
|
|
1278
|
+
throwIfAborted(signal);
|
|
1249
1279
|
const pdfjs = await getPdfJs();
|
|
1280
|
+
throwIfAborted(signal);
|
|
1250
1281
|
const arrayBuffer = await file.arrayBuffer();
|
|
1251
|
-
|
|
1282
|
+
throwIfAborted(signal);
|
|
1283
|
+
const loadingTask = pdfjs.getDocument({ data: arrayBuffer });
|
|
1284
|
+
if (signal) {
|
|
1285
|
+
const abortLoading = () => {
|
|
1286
|
+
void loadingTask.destroy();
|
|
1287
|
+
};
|
|
1288
|
+
signal.addEventListener("abort", abortLoading, { once: true });
|
|
1289
|
+
try {
|
|
1290
|
+
const pdf2 = await loadingTask.promise;
|
|
1291
|
+
signal.removeEventListener("abort", abortLoading);
|
|
1292
|
+
return await loadPdfDocumentToStore(pdf2, store, {
|
|
1293
|
+
scale,
|
|
1294
|
+
pageNumbers: options?.pageNumbers,
|
|
1295
|
+
pageConcurrency,
|
|
1296
|
+
storeThumbnails,
|
|
1297
|
+
signal,
|
|
1298
|
+
onPageStored: options?.onPageStored
|
|
1299
|
+
});
|
|
1300
|
+
} catch (error) {
|
|
1301
|
+
if (signal.aborted) throw createAbortError();
|
|
1302
|
+
throw error;
|
|
1303
|
+
} finally {
|
|
1304
|
+
signal.removeEventListener("abort", abortLoading);
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
const pdf = await loadingTask.promise;
|
|
1308
|
+
return await loadPdfDocumentToStore(pdf, store, {
|
|
1309
|
+
scale,
|
|
1310
|
+
pageNumbers: options?.pageNumbers,
|
|
1311
|
+
pageConcurrency,
|
|
1312
|
+
storeThumbnails,
|
|
1313
|
+
onPageStored: options?.onPageStored
|
|
1314
|
+
});
|
|
1315
|
+
}
|
|
1316
|
+
async function loadPdfDocumentToStore(pdf, store, options) {
|
|
1317
|
+
const { pageConcurrency, scale, signal } = options;
|
|
1318
|
+
const storeThumbnails = options.storeThumbnails ?? false;
|
|
1319
|
+
throwIfAborted(signal);
|
|
1252
1320
|
const pageNumbers = normalizePdfPageNumbers(options?.pageNumbers, pdf.numPages);
|
|
1253
1321
|
const bufferedResults = /* @__PURE__ */ new Map();
|
|
1254
1322
|
let nextEmitIndex = 0;
|
|
@@ -1263,7 +1331,9 @@ async function loadPdfToStore(file, store, options) {
|
|
|
1263
1331
|
if (!bufferedResult) break;
|
|
1264
1332
|
bufferedResults.delete(nextPageNumber);
|
|
1265
1333
|
nextEmitIndex += 1;
|
|
1334
|
+
throwIfAborted(signal);
|
|
1266
1335
|
await options?.onPageStored?.(bufferedResult);
|
|
1336
|
+
throwIfAborted(signal);
|
|
1267
1337
|
}
|
|
1268
1338
|
};
|
|
1269
1339
|
const nextChain = emitChain.then(run, run);
|
|
@@ -1275,11 +1345,20 @@ async function loadPdfToStore(file, store, options) {
|
|
|
1275
1345
|
pageNumbers,
|
|
1276
1346
|
pageConcurrency,
|
|
1277
1347
|
async (pageNumber) => {
|
|
1348
|
+
throwIfAborted(signal);
|
|
1278
1349
|
const page = await pdf.getPage(pageNumber);
|
|
1279
|
-
|
|
1350
|
+
throwIfAborted(signal);
|
|
1351
|
+
const { canvas, width, height } = await renderPageToCanvas(
|
|
1352
|
+
page,
|
|
1353
|
+
scale,
|
|
1354
|
+
signal
|
|
1355
|
+
);
|
|
1356
|
+
throwIfAborted(signal);
|
|
1280
1357
|
const mime = "image/png";
|
|
1281
1358
|
const pageBlob = await encodeCanvasToBlob(canvas, { mimeType: mime });
|
|
1359
|
+
throwIfAborted(signal);
|
|
1282
1360
|
const blobId = await store.storeOriginal(pageBlob);
|
|
1361
|
+
throwIfAborted(signal);
|
|
1283
1362
|
const thumbnailBlobId = storeThumbnails ? await (async () => {
|
|
1284
1363
|
const thumbScale = Math.min(1, 256 / Math.max(width, height));
|
|
1285
1364
|
const tw = Math.max(1, Math.round(width * thumbScale));
|
|
@@ -1296,6 +1375,7 @@ async function loadPdfToStore(file, store, options) {
|
|
|
1296
1375
|
const thumbBlob = await encodeCanvasToBlob(thumbCanvas, {
|
|
1297
1376
|
mimeType: mime
|
|
1298
1377
|
});
|
|
1378
|
+
throwIfAborted(signal);
|
|
1299
1379
|
return await store.storeThumbnail(thumbBlob);
|
|
1300
1380
|
})() : "";
|
|
1301
1381
|
const pageResult = {
|
|
@@ -1307,7 +1387,8 @@ async function loadPdfToStore(file, store, options) {
|
|
|
1307
1387
|
};
|
|
1308
1388
|
await queuePageEmission(pageResult);
|
|
1309
1389
|
return pageResult;
|
|
1310
|
-
}
|
|
1390
|
+
},
|
|
1391
|
+
signal
|
|
1311
1392
|
);
|
|
1312
1393
|
}
|
|
1313
1394
|
|
|
@@ -1648,9 +1729,22 @@ function finalizeIngestedItem(item, context, uploadResult, decorateItem) {
|
|
|
1648
1729
|
const itemWithAssetData = applyAssetUploadResultToItem(item, uploadResult);
|
|
1649
1730
|
return decorateItem ? decorateItem(itemWithAssetData, context) : itemWithAssetData;
|
|
1650
1731
|
}
|
|
1651
|
-
|
|
1732
|
+
function createAbortError2() {
|
|
1733
|
+
return new DOMException("Aborted", "AbortError");
|
|
1734
|
+
}
|
|
1735
|
+
function throwIfAborted2(signal) {
|
|
1736
|
+
if (signal?.aborted) {
|
|
1737
|
+
throw createAbortError2();
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1740
|
+
function isAbortError(error) {
|
|
1741
|
+
return (error instanceof DOMException || error instanceof Error) && error.name === "AbortError";
|
|
1742
|
+
}
|
|
1743
|
+
async function uploadAssetIfNeeded(assetStore, file, kind, signal) {
|
|
1744
|
+
throwIfAborted2(signal);
|
|
1652
1745
|
if (!assetStore) return null;
|
|
1653
|
-
const result = await assetStore.upload({ file, kind });
|
|
1746
|
+
const result = await assetStore.upload({ file, kind, signal });
|
|
1747
|
+
throwIfAborted2(signal);
|
|
1654
1748
|
return result ?? null;
|
|
1655
1749
|
}
|
|
1656
1750
|
async function ingestAssetFilesToSceneItems(options) {
|
|
@@ -1664,6 +1758,7 @@ async function ingestAssetFilesToSceneItems(options) {
|
|
|
1664
1758
|
gapWorld = 16,
|
|
1665
1759
|
pdfScale = 1.15,
|
|
1666
1760
|
pdfPageConcurrency = 2,
|
|
1761
|
+
signal,
|
|
1667
1762
|
decorateItem,
|
|
1668
1763
|
onItemsReady,
|
|
1669
1764
|
onError
|
|
@@ -1672,6 +1767,7 @@ async function ingestAssetFilesToSceneItems(options) {
|
|
|
1672
1767
|
const errors = [];
|
|
1673
1768
|
let occupiedBottomY = existingItems.length > 0 ? Math.max(...existingItems.map((item) => item.bounds.y + item.bounds.height)) : null;
|
|
1674
1769
|
for (const file of files) {
|
|
1770
|
+
throwIfAborted2(signal);
|
|
1675
1771
|
const kind = getAssetKindForFile(file);
|
|
1676
1772
|
if (!kind) {
|
|
1677
1773
|
const error = {
|
|
@@ -1684,14 +1780,23 @@ async function ingestAssetFilesToSceneItems(options) {
|
|
|
1684
1780
|
}
|
|
1685
1781
|
try {
|
|
1686
1782
|
if (kind === "pdf") {
|
|
1687
|
-
const uploadResultPromise = uploadAssetIfNeeded(
|
|
1783
|
+
const uploadResultPromise = uploadAssetIfNeeded(
|
|
1784
|
+
assetStore,
|
|
1785
|
+
file,
|
|
1786
|
+
kind,
|
|
1787
|
+
signal
|
|
1788
|
+
);
|
|
1789
|
+
void uploadResultPromise.catch(() => void 0);
|
|
1688
1790
|
await loadPdfToStore(file, imageStore, {
|
|
1689
1791
|
scale: pdfScale,
|
|
1690
1792
|
pageConcurrency: pdfPageConcurrency,
|
|
1691
1793
|
storeThumbnails: false,
|
|
1794
|
+
signal,
|
|
1692
1795
|
onPageStored: async (page) => {
|
|
1796
|
+
throwIfAborted2(signal);
|
|
1693
1797
|
const uploadResult2 = await uploadResultPromise;
|
|
1694
1798
|
const fullUrl2 = await createBlobUrlFromStore(imageStore, page.blobId);
|
|
1799
|
+
throwIfAborted2(signal);
|
|
1695
1800
|
const naturalTopY2 = worldCenter.y - page.height / 2;
|
|
1696
1801
|
const stackedTopY2 = occupiedBottomY == null ? naturalTopY2 : occupiedBottomY + gapWorld;
|
|
1697
1802
|
const bounds2 = {
|
|
@@ -1731,15 +1836,18 @@ async function ingestAssetFilesToSceneItems(options) {
|
|
|
1731
1836
|
);
|
|
1732
1837
|
items.push(item2);
|
|
1733
1838
|
occupiedBottomY = bounds2.y + page.height;
|
|
1839
|
+
throwIfAborted2(signal);
|
|
1734
1840
|
onItemsReady?.([item2], { file, kind });
|
|
1735
1841
|
}
|
|
1736
1842
|
});
|
|
1737
1843
|
continue;
|
|
1738
1844
|
}
|
|
1845
|
+
throwIfAborted2(signal);
|
|
1739
1846
|
const [uploadResult, storedImage] = await Promise.all([
|
|
1740
|
-
uploadAssetIfNeeded(assetStore, file, kind),
|
|
1847
|
+
uploadAssetIfNeeded(assetStore, file, kind, signal),
|
|
1741
1848
|
loadImageToStore(file, imageStore)
|
|
1742
1849
|
]);
|
|
1850
|
+
throwIfAborted2(signal);
|
|
1743
1851
|
const { blobId, thumbnailBlobId, width, height } = storedImage;
|
|
1744
1852
|
const fullUrl = await createBlobUrlFromStore(imageStore, blobId);
|
|
1745
1853
|
const thumbBlob = await imageStore.getThumbnail(thumbnailBlobId);
|
|
@@ -1777,9 +1885,13 @@ async function ingestAssetFilesToSceneItems(options) {
|
|
|
1777
1885
|
decorateItem
|
|
1778
1886
|
);
|
|
1779
1887
|
items.push(item);
|
|
1888
|
+
throwIfAborted2(signal);
|
|
1780
1889
|
onItemsReady?.([item], { file, kind });
|
|
1781
1890
|
occupiedBottomY = occupiedBottomY == null ? bounds.y + height : Math.max(occupiedBottomY, bounds.y + height);
|
|
1782
1891
|
} catch (error) {
|
|
1892
|
+
if (isAbortError(error)) {
|
|
1893
|
+
throw error;
|
|
1894
|
+
}
|
|
1783
1895
|
const fileError = {
|
|
1784
1896
|
file,
|
|
1785
1897
|
kind,
|
|
@@ -6889,6 +7001,7 @@ function resolveRasterImageCanvasRenderingOptions(options) {
|
|
|
6889
7001
|
return {
|
|
6890
7002
|
resolveSourceSize: options.resolveSourceSize,
|
|
6891
7003
|
resolveRenderTarget: options.resolveRenderTarget,
|
|
7004
|
+
resolveCanvasSource: options.resolveCanvasSource,
|
|
6892
7005
|
devicePixelRatio: toPositiveFiniteNumber(
|
|
6893
7006
|
options.devicePixelRatio,
|
|
6894
7007
|
fallbackDevicePixelRatio
|
|
@@ -7153,6 +7266,36 @@ function loadImageElement(href, signal) {
|
|
|
7153
7266
|
image.src = href;
|
|
7154
7267
|
});
|
|
7155
7268
|
}
|
|
7269
|
+
function normalizeDecodedRasterImageSource(source) {
|
|
7270
|
+
if (!source) return null;
|
|
7271
|
+
const width = Math.max(1, Math.round(source.width));
|
|
7272
|
+
const height = Math.max(1, Math.round(source.height));
|
|
7273
|
+
if (!Number.isFinite(width) || !Number.isFinite(height)) return null;
|
|
7274
|
+
return {
|
|
7275
|
+
width,
|
|
7276
|
+
height,
|
|
7277
|
+
draw: source.draw,
|
|
7278
|
+
close: source.close ?? (() => {
|
|
7279
|
+
})
|
|
7280
|
+
};
|
|
7281
|
+
}
|
|
7282
|
+
async function resolveDecodedRasterImageSource({
|
|
7283
|
+
options,
|
|
7284
|
+
request,
|
|
7285
|
+
width,
|
|
7286
|
+
height,
|
|
7287
|
+
signal
|
|
7288
|
+
}) {
|
|
7289
|
+
if (options?.resolveCanvasSource) {
|
|
7290
|
+
const source = await options.resolveCanvasSource({
|
|
7291
|
+
...request,
|
|
7292
|
+
signal
|
|
7293
|
+
});
|
|
7294
|
+
const decoded = normalizeDecodedRasterImageSource(source);
|
|
7295
|
+
if (decoded) return decoded;
|
|
7296
|
+
}
|
|
7297
|
+
return decodeRasterImage(request.targetHref, width, height, signal);
|
|
7298
|
+
}
|
|
7156
7299
|
var SvgVectorRenderer = class {
|
|
7157
7300
|
container;
|
|
7158
7301
|
scene;
|
|
@@ -7385,7 +7528,20 @@ var SvgVectorRenderer = class {
|
|
|
7385
7528
|
}
|
|
7386
7529
|
const request = {
|
|
7387
7530
|
itemHref: item.imageRasterHref,
|
|
7388
|
-
target
|
|
7531
|
+
target,
|
|
7532
|
+
sourceRequest: {
|
|
7533
|
+
item,
|
|
7534
|
+
href: item.imageRasterHref,
|
|
7535
|
+
intrinsicSize: item.imageIntrinsicSize,
|
|
7536
|
+
sourceSize,
|
|
7537
|
+
contentRect: target.contentRect,
|
|
7538
|
+
targetSize: target.targetSize,
|
|
7539
|
+
viewportSize,
|
|
7540
|
+
cameraZoom: this.camera.zoom,
|
|
7541
|
+
devicePixelRatio: options.devicePixelRatio,
|
|
7542
|
+
targetHref: target.href,
|
|
7543
|
+
sourceKey: target.sourceKey
|
|
7544
|
+
}
|
|
7389
7545
|
};
|
|
7390
7546
|
if (rasterCanvas.abortController) {
|
|
7391
7547
|
if (rasterCanvas.loadingItemHref !== item.imageRasterHref) {
|
|
@@ -7475,7 +7631,13 @@ var SvgVectorRenderer = class {
|
|
|
7475
7631
|
rasterCanvas.loadingWidth = width;
|
|
7476
7632
|
rasterCanvas.loadingHeight = height;
|
|
7477
7633
|
rasterCanvas.queuedTarget = null;
|
|
7478
|
-
|
|
7634
|
+
resolveDecodedRasterImageSource({
|
|
7635
|
+
options: this.rasterImageCanvasRendering,
|
|
7636
|
+
request: request.sourceRequest,
|
|
7637
|
+
width,
|
|
7638
|
+
height,
|
|
7639
|
+
signal: abortController.signal
|
|
7640
|
+
}).then((decoded) => {
|
|
7479
7641
|
if (abortController.signal.aborted || rasterCanvas.loadSequence !== sequence) {
|
|
7480
7642
|
decoded.close();
|
|
7481
7643
|
return;
|
|
@@ -8384,6 +8546,7 @@ function shallowEqualStringArray(a, b) {
|
|
|
8384
8546
|
}
|
|
8385
8547
|
|
|
8386
8548
|
// src/react/stroke-input.ts
|
|
8549
|
+
var MAX_INTERPOLATED_POINTS_PER_SAMPLE = 192;
|
|
8387
8550
|
function getPointerEventSamples(event) {
|
|
8388
8551
|
if (typeof event.getCoalescedEvents !== "function") {
|
|
8389
8552
|
return [event];
|
|
@@ -8407,9 +8570,9 @@ function appendInterpolatedStrokePoint(points, nextPoint, maxStepWorld) {
|
|
|
8407
8570
|
const distanceSquared = deltaX * deltaX + deltaY * deltaY;
|
|
8408
8571
|
if (distanceSquared < 1e-12) return points;
|
|
8409
8572
|
const distance = Math.sqrt(distanceSquared);
|
|
8410
|
-
const stepCount = Math.
|
|
8411
|
-
|
|
8412
|
-
Math.ceil(distance / resolveMaxStepWorld(maxStepWorld))
|
|
8573
|
+
const stepCount = Math.min(
|
|
8574
|
+
MAX_INTERPOLATED_POINTS_PER_SAMPLE,
|
|
8575
|
+
Math.max(1, Math.ceil(distance / resolveMaxStepWorld(maxStepWorld)))
|
|
8413
8576
|
);
|
|
8414
8577
|
if (stepCount === 1) return [...points, nextPoint];
|
|
8415
8578
|
const interpolatedPoints = Array.from({ length: stepCount }, (_, index) => {
|