@servicetitan/dte-pdf-editor 1.89.0 → 1.90.0

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.
@@ -1,7 +1,6 @@
1
1
  import { DragEvent, FC, ReactNode } from 'react';
2
2
  import 'react-pdf/dist/Page/AnnotationLayer.css';
3
3
  import 'react-pdf/dist/Page/TextLayer.css';
4
- import '../../utils/pdf/pdfjs-init';
5
4
  interface PdfDocumentRendererProps {
6
5
  pdfUrl: string;
7
6
  pageWidth?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"pdf-document-renderer.d.ts","sourceRoot":"","sources":["../../../src/components/pdf-canvas/pdf-document-renderer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEjD,OAAO,yCAAyC,CAAC;AACjD,OAAO,mCAAmC,CAAC;AAE3C,OAAO,4BAA4B,CAAC;AAEpC,UAAU,wBAAwB;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,gBAAgB,CAAC,EAAE,SAAS,CAAC;IAC7B,kBAAkB,CAAC,EAAE,SAAS,CAAC;IAC/B,qBAAqB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,UAAU,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC;IAChD,MAAM,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,cAAc,CAAC,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CACnE;AAED,eAAO,MAAM,mBAAmB,EAAE,EAAE,CAAC,wBAAwB,CAkE5D,CAAC"}
1
+ {"version":3,"file":"pdf-document-renderer.d.ts","sourceRoot":"","sources":["../../../src/components/pdf-canvas/pdf-document-renderer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEjD,OAAO,yCAAyC,CAAC;AACjD,OAAO,mCAAmC,CAAC;AAW3C,UAAU,wBAAwB;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,gBAAgB,CAAC,EAAE,SAAS,CAAC;IAC7B,kBAAkB,CAAC,EAAE,SAAS,CAAC;IAC/B,qBAAqB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,UAAU,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC;IAChD,MAAM,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,cAAc,CAAC,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CACnE;AAED,eAAO,MAAM,mBAAmB,EAAE,EAAE,CAAC,wBAAwB,CAmE5D,CAAC"}
@@ -3,7 +3,13 @@ import { Document, Page } from 'react-pdf';
3
3
  import 'react-pdf/dist/Page/AnnotationLayer.css';
4
4
  import 'react-pdf/dist/Page/TextLayer.css';
5
5
  import { usePdfDocumentRenderer } from '../../hooks';
6
- import '../../utils/pdf/pdfjs-init'; // Initialize PDF.js worker at a module load
6
+ import { PDFJS_WASM_URL } from '../../utils/pdf/pdfjs-init'; // Initialize PDF.js worker at a module load
7
+ /*
8
+ * Defined outside the component (per react-pdf's own guidance for `options`) so it's referentially
9
+ * stable across renders - passing a fresh object each render would make react-pdf treat the file as
10
+ * "changed" and reload the document.
11
+ */
12
+ const documentOptions = { wasmUrl: PDFJS_WASM_URL };
7
13
  export const PdfDocumentRenderer = ({ errorPlaceholder, loading, loadingPlaceholder, onDocumentLoadSuccess, onDragOver, onDrop, pageWidth, pdfUrl, }) => {
8
14
  const { handleDocumentLoadSuccess: handleLoadSuccess, numPages, pages, } = usePdfDocumentRenderer();
9
15
  const handleDocumentLoadSuccess = ({ numPages }) => {
@@ -19,7 +25,7 @@ export const PdfDocumentRenderer = ({ errorPlaceholder, loading, loadingPlacehol
19
25
  e.stopPropagation();
20
26
  onDragOver === null || onDragOver === void 0 ? void 0 : onDragOver(e);
21
27
  };
22
- return (_jsx(Document, { file: pdfUrl, error: errorPlaceholder, loading: loadingPlaceholder, onLoadSuccess: handleDocumentLoadSuccess, noData: loading ? loadingPlaceholder : undefined, children: pages.map(pageNumber => {
28
+ return (_jsx(Document, { file: pdfUrl, options: documentOptions, error: errorPlaceholder, loading: loadingPlaceholder, onLoadSuccess: handleDocumentLoadSuccess, noData: loading ? loadingPlaceholder : undefined, children: pages.map(pageNumber => {
23
29
  return (_jsx("div", { "data-page-number": pageNumber, className: "dte-pdf-document-renderer-page", onDragOver: handlePageDragOver, onDrop: e => handlePageDrop(e, pageNumber), children: _jsx(Page, { loading: loadingPlaceholder, onLoadSuccess: e => {
24
30
  if (e._pageIndex + 1 === numPages) {
25
31
  onDocumentLoadSuccess === null || onDocumentLoadSuccess === void 0 ? void 0 : onDocumentLoadSuccess(numPages);
@@ -1 +1 @@
1
- {"version":3,"file":"pdf-document-renderer.js","sourceRoot":"","sources":["../../../src/components/pdf-canvas/pdf-document-renderer.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,yCAAyC,CAAC;AACjD,OAAO,mCAAmC,CAAC;AAC3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,4BAA4B,CAAC,CAAC,4CAA4C;AAajF,MAAM,CAAC,MAAM,mBAAmB,GAAiC,CAAC,EAC9D,gBAAgB,EAChB,OAAO,EACP,kBAAkB,EAClB,qBAAqB,EACrB,UAAU,EACV,MAAM,EACN,SAAS,EACT,MAAM,GACT,EAAE,EAAE;IACD,MAAM,EACF,yBAAyB,EAAE,iBAAiB,EAC5C,QAAQ,EACR,KAA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CAAC,CAAC;wBACtC,CAAC;oBACL,CAAC,EACD,UAAU,EAAE,UAAU,EACtB,KAAK,EAAE,SAAS,EAChB,eAAe,EAAE,KAAK,EACtB,qBAAqB,EAAE,KAAK,GAC9B,IAjBG,QAAQ,UAAU,EAAE,CAkBvB,CACT,CAAC;QACN,CAAC,CAAC,GACK,CACd,CAAC;AACN,CAAC,CAAC"}
1
+ {"version":3,"file":"pdf-document-renderer.js","sourceRoot":"","sources":["../../../src/components/pdf-canvas/pdf-document-renderer.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,yCAAyC,CAAC;AACjD,OAAO,mCAAmC,CAAC;AAC3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC,CAAC,4CAA4C;AAEzG;;;;GAIG;AACH,MAAM,eAAe,GAAG,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC;AAapD,MAAM,CAAC,MAAM,mBAAmB,GAAiC,CAAC,EAC9D,gBAAgB,EAChB,OAAO,EACP,kBAAkB,EAClB,qBAAqB,EACrB,UAAU,EACV,MAAM,EACN,SAAS,EACT,MAAM,GACT,EAAE,EAAE;IACD,MAAM,EACF,yBAAyB,EAAE,iBAAiB,EAC5C,QAAQ,EACR,KAAK,GACR,GAAG,sBAAsB,EAAE,CAAC;IAE7B,MAAM,yBAAyB,GAAG,CAAC,EAAE,QAAQ,EAAwB,EAAE,EAAE;QACrE,iBAAiB,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;IACpC,CAAC,CAAC;IAEF,MAAM,cAAc,GAAG,CAAC,CAA4B,EAAE,UAAkB,EAAE,EAAE;QACxE,CAAC,CAAC,cAAc,EAAE,CAAC;QACnB,CAAC,CAAC,eAAe,EAAE,CAAC;QACpB,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAG,CAAC,EAAE,UAAU,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1 @@
1
- {"version":3,"file":"pdfjs-init.d.ts","sourceRoot":"","sources":["../../../src/utils/pdf/pdfjs-init.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"pdfjs-init.d.ts","sourceRoot":"","sources":["../../../src/utils/pdf/pdfjs-init.ts"],"names":[],"mappings":"AAwCA,eAAO,MAAM,cAAc,QAAwD,CAAC"}
@@ -25,4 +25,14 @@ if (typeof window !== 'undefined' &&
25
25
  pdfjs.GlobalWorkerOptions.workerSrc === 'pdf.worker.mjs')) {
26
26
  pdfjs.GlobalWorkerOptions.workerSrc = `https://unpkg.com/pdfjs-dist@${pdfjs.version}/build/pdf.worker.min.mjs`;
27
27
  }
28
+ /*
29
+ * pdfjs-dist 5.x moved its wasm-backed image codecs (OpenJPEG for JPX/JPEG2000, JBIG2, qcms)
30
+ * out of build/ into a sibling wasm/ directory, gated behind the `wasmUrl` document-load option.
31
+ * That option defaults to null, and the worker builds each fetch path as `${wasmUrl}<file>` -
32
+ * so with no wasmUrl set it literally tries to import "nullopenjpeg_nowasm_fallback.js" and the
33
+ * JPX decoder throws, silently dropping any JPEG2000 image in the PDF. Point it at the same
34
+ * unpkg-hosted version's wasm/ folder (must end with a trailing slash - it's string-concatenated
35
+ * with the filename, not resolved as a URL).
36
+ */
37
+ export const PDFJS_WASM_URL = `https://unpkg.com/pdfjs-dist@${pdfjs.version}/wasm/`;
28
38
  //# sourceMappingURL=pdfjs-init.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pdfjs-init.js","sourceRoot":"","sources":["../../../src/utils/pdf/pdfjs-init.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAElC;;;;;;;;;;;;GAYG;AACH,IACI,OAAO,MAAM,KAAK,WAAW;IAC7B,CAAC,CAAC,KAAK,CAAC,mBAAmB,CAAC,SAAS;QACjC,KAAK,CAAC,mBAAmB,CAAC,SAAS,KAAK,gBAAgB,CAAC,EAC/D,CAAC;IACC,KAAK,CAAC,mBAAmB,CAAC,SAAS,GAAG,gCAAgC,KAAK,CAAC,OAAO,2BAA2B,CAAC;AACnH,CAAC"}
1
+ {"version":3,"file":"pdfjs-init.js","sourceRoot":"","sources":["../../../src/utils/pdf/pdfjs-init.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAElC;;;;;;;;;;;;GAYG;AACH,IACI,OAAO,MAAM,KAAK,WAAW;IAC7B,CAAC,CAAC,KAAK,CAAC,mBAAmB,CAAC,SAAS;QACjC,KAAK,CAAC,mBAAmB,CAAC,SAAS,KAAK,gBAAgB,CAAC,EAC/D,CAAC;IACC,KAAK,CAAC,mBAAmB,CAAC,SAAS,GAAG,gCAAgC,KAAK,CAAC,OAAO,2BAA2B,CAAC;AACnH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,gCAAgC,KAAK,CAAC,OAAO,QAAQ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@servicetitan/dte-pdf-editor",
3
- "version": "1.89.0",
3
+ "version": "1.90.0",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "typings": "./dist/index.d.ts",
@@ -3,7 +3,14 @@ import { Document, Page } from 'react-pdf';
3
3
  import 'react-pdf/dist/Page/AnnotationLayer.css';
4
4
  import 'react-pdf/dist/Page/TextLayer.css';
5
5
  import { usePdfDocumentRenderer } from '../../hooks';
6
- import '../../utils/pdf/pdfjs-init'; // Initialize PDF.js worker at a module load
6
+ import { PDFJS_WASM_URL } from '../../utils/pdf/pdfjs-init'; // Initialize PDF.js worker at a module load
7
+
8
+ /*
9
+ * Defined outside the component (per react-pdf's own guidance for `options`) so it's referentially
10
+ * stable across renders - passing a fresh object each render would make react-pdf treat the file as
11
+ * "changed" and reload the document.
12
+ */
13
+ const documentOptions = { wasmUrl: PDFJS_WASM_URL };
7
14
 
8
15
  interface PdfDocumentRendererProps {
9
16
  pdfUrl: string;
@@ -51,6 +58,7 @@ export const PdfDocumentRenderer: FC<PdfDocumentRendererProps> = ({
51
58
  return (
52
59
  <Document
53
60
  file={pdfUrl}
61
+ options={documentOptions}
54
62
  error={errorPlaceholder}
55
63
  loading={loadingPlaceholder}
56
64
  onLoadSuccess={handleDocumentLoadSuccess}
@@ -28,3 +28,14 @@ if (
28
28
  ) {
29
29
  pdfjs.GlobalWorkerOptions.workerSrc = `https://unpkg.com/pdfjs-dist@${pdfjs.version}/build/pdf.worker.min.mjs`;
30
30
  }
31
+
32
+ /*
33
+ * pdfjs-dist 5.x moved its wasm-backed image codecs (OpenJPEG for JPX/JPEG2000, JBIG2, qcms)
34
+ * out of build/ into a sibling wasm/ directory, gated behind the `wasmUrl` document-load option.
35
+ * That option defaults to null, and the worker builds each fetch path as `${wasmUrl}<file>` -
36
+ * so with no wasmUrl set it literally tries to import "nullopenjpeg_nowasm_fallback.js" and the
37
+ * JPX decoder throws, silently dropping any JPEG2000 image in the PDF. Point it at the same
38
+ * unpkg-hosted version's wasm/ folder (must end with a trailing slash - it's string-concatenated
39
+ * with the filename, not resolved as a URL).
40
+ */
41
+ export const PDFJS_WASM_URL = `https://unpkg.com/pdfjs-dist@${pdfjs.version}/wasm/`;