Skip to content

Commit

Permalink
fix: pdfjs imports
Browse files Browse the repository at this point in the history
  • Loading branch information
jhpedemonte committed May 29, 2024
1 parent e5a7dc3 commit 411194c
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 66 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import DiscoveryV2, { JsonObject, QueryResult } from 'ibm-watson/discovery/v2';
import { DocumentInitParameters } from 'pdfjs-dist/types/display/api';
import { DocumentInitParameters } from 'pdfjs-dist/types/src/display/api';

export type SearchClient = Pick<
DiscoveryV2,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Debug from 'debug';
import flatMap from 'lodash/flatMap';
import { TextContent } from 'pdfjs-dist/types/display/api';
import { PageViewport } from 'pdfjs-dist/types/display/display_utils';
import { TextContent } from 'pdfjs-dist/types/src/display/api';
import { PageViewport } from 'pdfjs-dist/types/src/display/display_utils';
import { nonEmpty } from 'utils/nonEmpty';
import { DocumentFields, HighlightShape, HighlightShapeBox } from '../types';
import { DocumentFieldHighlight, TextMappings } from 'components/DocumentPreview/types';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { bboxesIntersect } from 'components/DocumentPreview/utils/box';
import { TextItem } from 'pdfjs-dist/types/display/api';
import { PageViewport, PageViewportParameters } from 'pdfjs-dist/types/display/display_utils';
import { TextItem } from 'pdfjs-dist/types/src/display/api';
import { PageViewport, PageViewportParameters } from 'pdfjs-dist/types/src/display/display_utils';
import { Bbox, TextSpan } from '../../types';
import { BaseTextLayoutCell } from './BaseTextLayout';
import { getAdjustedCellByOffsetByDom } from './dom';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TextMappings } from 'components/DocumentPreview/types';
import { TextContent } from 'pdfjs-dist/types/display/api';
import { PageViewport } from 'pdfjs-dist/types/display/display_utils';
import { TextContent } from 'pdfjs-dist/types/src/display/api';
import { PageViewport } from 'pdfjs-dist/types/src/display/display_utils';
import { ProcessedDoc } from 'utils/document';
import { Bbox, DocumentFields, TextSpan } from '../../types';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import {
} from 'react';
import cx from 'classnames';
import * as PdfjsLib from 'pdfjs-dist';
import { PDFDocumentProxy, PDFPageProxy } from 'pdfjs-dist/types/display/api';
import { PageViewport } from 'pdfjs-dist/types/display/display_utils';
import { PDFDocumentProxy, PDFPageProxy } from 'pdfjs-dist/types/src/display/api';
import { PageViewport } from 'pdfjs-dist/types/src/display/display_utils';
import { settings } from 'carbon-components';
import useSafeRef from 'utils/useSafeRef';
import useSize from 'utils/useSize';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { FC, useEffect, useRef, useCallback } from 'react';
import cx from 'classnames';
import { TextContent, TextItem, PDFPageProxy } from 'pdfjs-dist/types/display/api';
import { PageViewport } from 'pdfjs-dist/types/display/display_utils';
import { EventBus } from 'pdfjs-dist/lib/web/ui_utils';
import { TextLayerBuilder } from 'pdfjs-dist/lib/web/text_layer_builder';
import { TextContent, TextItem, PDFPageProxy } from 'pdfjs-dist/types/src/display/api';
import { PageViewport } from 'pdfjs-dist/types/src/display/display_utils';
import { EventBus, TextLayerBuilder } from 'pdfjs-dist/web/pdf_viewer.mjs';
import useAsyncFunctionCall from 'utils/useAsyncFunctionCall';
import { PdfDisplayProps } from './types';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DocumentInitParameters, TypedArray } from 'pdfjs-dist/types/display/api';
import { DocumentInitParameters, TypedArray } from 'pdfjs-dist/types/src/display/api';
import { toPDFSource } from '../utils';

describe('utils', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
declare module 'pdfjs-dist/build/pdf.worker.min.js';
// declare module 'pdfjs-dist/build/pdf.worker.min.js';

//
// Declare modules and their types that is referred from PDF text layer rendering.
// Unused properties are commented out
//
declare module 'pdfjs-dist/lib/web/ui_utils' {
export class EventBus {
on(eventName: string, listener: any): void;
off(eventName: string, listener: any): void;
dispatch(eventName: string, args?: any): void;
}
// export function getGlobalEventBus(): EventBus;
}
// //
// // Declare modules and their types that is referred from PDF text layer rendering.
// // Unused properties are commented out
// //
// declare module 'pdfjs-dist/lib/web/ui_utils' {
// export class EventBus {
// on(eventName: string, listener: any): void;
// off(eventName: string, listener: any): void;
// dispatch(eventName: string, args?: any): void;
// }
// // export function getGlobalEventBus(): EventBus;
// }

declare module 'pdfjs-dist/lib/web/text_layer_builder' {
import { EventBus } from 'pdfjs-dist/lib/web/ui_utils';
import { PageViewport } from 'pdfjs-dist/types/display/display_utils';
import { TextContent } from 'pdfjs-dist/types/display/api';
// declare module 'pdfjs-dist/lib/web/text_layer_builder' {
// import { EventBus } from 'pdfjs-dist/lib/web/ui_utils';
// import { PageViewport } from 'pdfjs-dist/types/src/display/display_utils';
// import { TextContent } from 'pdfjs-dist/types/src/display/api';

export class TextLayerBuilder {
constructor(options: TextLayerBuilder.Options);
// export class TextLayerBuilder {
// constructor(options: TextLayerBuilder.Options);

textLayerDiv: HTMLElement;
eventBus: EventBus;
textContent: TextContent | null;
// textContentItemsStr: any[];
renderingDone: boolean;
// pageIdx: number;
pageNumber: number;
// matches: any[];
// viewport: PageViewport;
textDivs: HTMLElement[];
// findController: any;
textLayerRenderTask: TextLayerRenderTask;
// enhanceTextSelection: any;
// textLayerDiv: HTMLElement;
// eventBus: EventBus;
// textContent: TextContent | null;
// // textContentItemsStr: any[];
// renderingDone: boolean;
// // pageIdx: number;
// pageNumber: number;
// // matches: any[];
// // viewport: PageViewport;
// textDivs: HTMLElement[];
// // findController: any;
// textLayerRenderTask: TextLayerRenderTask;
// // enhanceTextSelection: any;

render(timeout?: number): void;
cancel(): void;
// setTextContentStream(readableStream: any): void;
setTextContent(textContent: TextContent): void;
}
export const DefaultTextLayerFactory;
// render(timeout?: number): void;
// cancel(): void;
// // setTextContentStream(readableStream: any): void;
// setTextContent(textContent: TextContent): void;
// }
// export const DefaultTextLayerFactory;

declare namespace TextLayerBuilder {
export interface Options {
textLayerDiv: HTMLElement;
eventBus: EventBus;
pageIndex: number;
viewport: PageViewport;
// findController?: any;
// enhanceTextSelection?: any;
}
}
}
// declare namespace TextLayerBuilder {
// export interface Options {
// textLayerDiv: HTMLElement;
// eventBus: EventBus;
// pageIndex: number;
// viewport: PageViewport;
// // findController?: any;
// // enhanceTextSelection?: any;
// }
// }
// }
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DocumentInitParameters, TypedArray } from 'pdfjs-dist/types/display/api';
import { DocumentInitParameters, TypedArray } from 'pdfjs-dist/types/src/display/api';

export function toPDFSource(
data: NonNullable<DocumentInitParameters['data']> | DocumentInitParameters
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { QueryResult, QueryResultMetadata } from 'ibm-watson/discovery/v2';
import { DocumentInitParameters, TypedArray } from 'pdfjs-dist/types/display/api';
import { DocumentInitParameters, TypedArray } from 'pdfjs-dist/types/src/display/api';

export interface TextMappings {
pages: Page[];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as PdfjsLib from 'pdfjs-dist';
import { GlobalWorkerOptionsType } from 'pdfjs-dist/types/display/worker_options';
import { GlobalWorkerOptionsType } from 'pdfjs-dist/types/src/display/worker_options';

// Make fields from GlobalWorkerOptionsType optional
type GlobalWorkerOptionsDelta = {
Expand Down

0 comments on commit 411194c

Please sign in to comment.