@anaralabs/lector 3.10.3 → 3.10.4
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/_tsup-dts-rollup.d.ts +9 -0
- package/dist/index.js +34 -4
- package/package.json +1 -1
|
@@ -186,6 +186,8 @@ export declare const ensureAnnotationLayerStyles: () => void;
|
|
|
186
186
|
|
|
187
187
|
export declare const firstMemo: <T>(first: boolean, memo: unknown, initializer: () => T) => T;
|
|
188
188
|
|
|
189
|
+
export declare const getDefaultPdfJsAssetUrls: (version: string) => PdfJsAssetUrls;
|
|
190
|
+
|
|
189
191
|
export declare const getEndOfHighlight: (selection: ColoredHighlight) => number;
|
|
190
192
|
|
|
191
193
|
export declare const getFitWidthZoom: (containerWidth: number, viewports: PageViewport[], zoomOptions: {
|
|
@@ -299,6 +301,13 @@ export declare const Pages: ({ children, gap, virtualizerOptions, initialOffset,
|
|
|
299
301
|
onOffsetChange?: (offset: number) => void;
|
|
300
302
|
}) => JSX.Element;
|
|
301
303
|
|
|
304
|
+
export declare interface PdfJsAssetUrls {
|
|
305
|
+
wasmUrl: string;
|
|
306
|
+
cMapUrl: string;
|
|
307
|
+
standardFontDataUrl: string;
|
|
308
|
+
iccUrl: string;
|
|
309
|
+
}
|
|
310
|
+
|
|
302
311
|
export declare const PDFLinkServiceContext: Context<LinkService>;
|
|
303
312
|
|
|
304
313
|
declare interface PDFState {
|
package/dist/index.js
CHANGED
|
@@ -5246,9 +5246,19 @@ var loadPdfJs = () => {
|
|
|
5246
5246
|
}
|
|
5247
5247
|
return pdfJsPromise;
|
|
5248
5248
|
};
|
|
5249
|
+
var ASSET_CDN_BASE = "https://cdn.jsdelivr.net/npm/pdfjs-dist";
|
|
5250
|
+
var getDefaultPdfJsAssetUrls = (version) => {
|
|
5251
|
+
const base = `${ASSET_CDN_BASE}@${version}`;
|
|
5252
|
+
return {
|
|
5253
|
+
wasmUrl: `${base}/wasm/`,
|
|
5254
|
+
cMapUrl: `${base}/cmaps/`,
|
|
5255
|
+
standardFontDataUrl: `${base}/standard_fonts/`,
|
|
5256
|
+
iccUrl: `${base}/iccs/`
|
|
5257
|
+
};
|
|
5258
|
+
};
|
|
5249
5259
|
|
|
5250
5260
|
// src/hooks/document/document.ts
|
|
5251
|
-
function buildDocumentInitParams(source, overrides) {
|
|
5261
|
+
function buildDocumentInitParams(source, pdfJsVersion, overrides) {
|
|
5252
5262
|
let params;
|
|
5253
5263
|
if (typeof source === "string" || source instanceof URL) {
|
|
5254
5264
|
params = { url: source };
|
|
@@ -5257,6 +5267,7 @@ function buildDocumentInitParams(source, overrides) {
|
|
|
5257
5267
|
} else {
|
|
5258
5268
|
params = { ...source };
|
|
5259
5269
|
}
|
|
5270
|
+
const assetUrls = getDefaultPdfJsAssetUrls(pdfJsVersion);
|
|
5260
5271
|
const defaults = {
|
|
5261
5272
|
// Skip the slow _guessMax binary-search auto-detection of max canvas area.
|
|
5262
5273
|
// 1 GiB = 256 megapixels at 4 bytes/pixel. If the device can't allocate
|
|
@@ -5268,7 +5279,22 @@ function buildDocumentInitParams(source, overrides) {
|
|
|
5268
5279
|
enableHWA: true,
|
|
5269
5280
|
// Explicitly opt-in to OffscreenCanvas in the worker for image processing.
|
|
5270
5281
|
// Already the browser default, but being explicit avoids edge cases.
|
|
5271
|
-
isOffscreenCanvasSupported: true
|
|
5282
|
+
isOffscreenCanvasSupported: true,
|
|
5283
|
+
// PDF.js 5.x split out auxiliary resources that are loaded on demand.
|
|
5284
|
+
// Without these URLs, several content types render as blank pages
|
|
5285
|
+
// because pdf.js silently fails to load decoders / fonts / colour
|
|
5286
|
+
// profiles. The most visible symptom: scanned PDFs with JPEG2000 or
|
|
5287
|
+
// JBIG2 images (Internet Archive, government archives) render as
|
|
5288
|
+
// completely blank pages — every image fails with
|
|
5289
|
+
// "OpenJPEG failed to initialize". Defaulting these to a versioned
|
|
5290
|
+
// jsDelivr URL gets the viewer working out of the box; production
|
|
5291
|
+
// deployments should self-host and pass overrides via
|
|
5292
|
+
// `documentOptions`.
|
|
5293
|
+
wasmUrl: assetUrls.wasmUrl,
|
|
5294
|
+
cMapUrl: assetUrls.cMapUrl,
|
|
5295
|
+
cMapPacked: true,
|
|
5296
|
+
standardFontDataUrl: assetUrls.standardFontDataUrl,
|
|
5297
|
+
iccUrl: assetUrls.iccUrl
|
|
5272
5298
|
};
|
|
5273
5299
|
return { ...defaults, ...params, ...overrides };
|
|
5274
5300
|
}
|
|
@@ -5321,12 +5347,16 @@ var usePDFDocumentContext = ({
|
|
|
5321
5347
|
setProgress(0);
|
|
5322
5348
|
let loadingTask = null;
|
|
5323
5349
|
let isDisposed = false;
|
|
5324
|
-
void loadPdfJs().then(({ getDocument }) => {
|
|
5350
|
+
void loadPdfJs().then(({ getDocument, version }) => {
|
|
5325
5351
|
if (isDisposed) {
|
|
5326
5352
|
return;
|
|
5327
5353
|
}
|
|
5328
5354
|
loadingTask = getDocument(
|
|
5329
|
-
buildDocumentInitParams(
|
|
5355
|
+
buildDocumentInitParams(
|
|
5356
|
+
source,
|
|
5357
|
+
version,
|
|
5358
|
+
documentOptionsRef.current
|
|
5359
|
+
)
|
|
5330
5360
|
);
|
|
5331
5361
|
loadingTask.onProgress = (progressEvent) => {
|
|
5332
5362
|
if (progressEvent.loaded === progressEvent.total) {
|