@pdfme/converter 6.0.5 → 6.0.6-dev.3

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/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/index.browser.ts"],"sourcesContent":["import * as pdfjsLib from 'pdfjs-dist/legacy/build/pdf.mjs';\nimport { pdf2img as _pdf2img, Pdf2ImgOptions } from './pdf2img.js';\nimport { pdf2size as _pdf2size, Pdf2SizeOptions } from './pdf2size.js';\nimport workerSrc from './pdfjs-worker.js?worker&url';\n\nconst clonePdfData = (pdf: ArrayBuffer | Uint8Array) =>\n pdf instanceof Uint8Array ? new Uint8Array(pdf) : new Uint8Array(pdf);\n\nconst loadingTaskMap = new WeakMap<object, { destroy: () => Promise<void> }>();\n\nconst getDocument = async (pdf: ArrayBuffer | Uint8Array) => {\n if (\n typeof Worker !== 'undefined' &&\n pdfjsLib.GlobalWorkerOptions.workerSrc !== workerSrc\n ) {\n pdfjsLib.GlobalWorkerOptions.workerSrc = workerSrc;\n }\n\n const loadingTask = pdfjsLib.getDocument({\n data: clonePdfData(pdf),\n isEvalSupported: false,\n });\n const document = await loadingTask.promise;\n loadingTaskMap.set(document, { destroy: () => loadingTask.destroy() });\n return document;\n};\n\nconst destroyDocument = async (document: object) => {\n const loadingTask = loadingTaskMap.get(document);\n loadingTaskMap.delete(document);\n await loadingTask?.destroy();\n};\n\nfunction dataURLToArrayBuffer(dataURL: string): ArrayBuffer {\n // Split out the actual base64 string from the data URL scheme\n const base64String = dataURL.split(',')[1];\n\n // Decode the Base64 string to get the binary data\n const byteString = atob(base64String);\n\n // Create a typed array from the binary string\n const arrayBuffer = new ArrayBuffer(byteString.length);\n const uintArray = new Uint8Array(arrayBuffer);\n\n for (let i = 0; i < byteString.length; i++) {\n uintArray[i] = byteString.charCodeAt(i);\n }\n\n return arrayBuffer;\n}\n\nexport const pdf2img = async (\n pdf: ArrayBuffer | Uint8Array,\n options: Pdf2ImgOptions = {},\n): Promise<ArrayBuffer[]> =>\n _pdf2img(pdf, options, {\n getDocument,\n destroyDocument,\n createCanvas: (width, height) => {\n const canvas = document.createElement('canvas');\n canvas.width = width;\n canvas.height = height;\n return canvas;\n },\n canvasToArrayBuffer: (canvas, imageType) => {\n // Using type assertion to handle the canvas method\n const dataUrl = (canvas as HTMLCanvasElement).toDataURL(`image/${imageType}`);\n return dataURLToArrayBuffer(dataUrl);\n },\n });\n\nexport const pdf2size = async (pdf: ArrayBuffer | Uint8Array, options: Pdf2SizeOptions = {}) =>\n _pdf2size(pdf, options, {\n getDocument,\n destroyDocument,\n });\n\nexport { img2pdf } from './img2pdf.js';\n"],"mappings":";;;;;;AAKA,IAAM,gBAAgB,QACpB,eAAe,aAAa,IAAI,WAAW,IAAI,GAAG,IAAI,WAAW,IAAI;AAEvE,IAAM,iCAAiB,IAAI,SAAmD;AAE9E,IAAM,cAAc,OAAO,QAAkC;AAC3D,KACE,OAAO,WAAW,eAClB,SAAS,oBAAoB,cAAA,KAAA,IAAA,IAAA,mCAAA,OAAA,KAAA,IAAA,CAAA,KAE7B,UAAS,oBAAoB,YAAY;CAG3C,MAAM,cAAc,SAAS,YAAY;EACvC,MAAM,aAAa,IAAI;EACvB,iBAAiB;EAClB,CAAC;CACF,MAAM,WAAW,MAAM,YAAY;AACnC,gBAAe,IAAI,UAAU,EAAE,eAAe,YAAY,SAAS,EAAE,CAAC;AACtE,QAAO;;AAGT,IAAM,kBAAkB,OAAO,aAAqB;CAClD,MAAM,cAAc,eAAe,IAAI,SAAS;AAChD,gBAAe,OAAO,SAAS;AAC/B,OAAM,aAAa,SAAS;;AAG9B,SAAS,qBAAqB,SAA8B;CAE1D,MAAM,eAAe,QAAQ,MAAM,IAAI,CAAC;CAGxC,MAAM,aAAa,KAAK,aAAa;CAGrC,MAAM,cAAc,IAAI,YAAY,WAAW,OAAO;CACtD,MAAM,YAAY,IAAI,WAAW,YAAY;AAE7C,MAAK,IAAI,IAAI,GAAG,IAAI,WAAW,QAAQ,IACrC,WAAU,KAAK,WAAW,WAAW,EAAE;AAGzC,QAAO;;AAGT,IAAa,UAAU,OACrB,KACA,UAA0B,EAAE,KAE5B,UAAS,KAAK,SAAS;CACrB;CACA;CACA,eAAe,OAAO,WAAW;EAC/B,MAAM,SAAS,SAAS,cAAc,SAAS;AAC/C,SAAO,QAAQ;AACf,SAAO,SAAS;AAChB,SAAO;;CAET,sBAAsB,QAAQ,cAAc;AAG1C,SAAO,qBADU,OAA6B,UAAU,SAAS,YAAY,CACzC;;CAEvC,CAAC;AAEJ,IAAa,WAAW,OAAO,KAA+B,UAA2B,EAAE,KACzF,WAAU,KAAK,SAAS;CACtB;CACA;CACD,CAAC"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.browser.ts"],"sourcesContent":["import * as pdfjsLib from 'pdfjs-dist/legacy/build/pdf.mjs';\nimport { pdf2img as _pdf2img, Pdf2ImgOptions } from './pdf2img.js';\nimport { pdf2size as _pdf2size, Pdf2SizeOptions } from './pdf2size.js';\nimport workerSrc from './pdfjs-worker.js?worker&url';\n\nconst clonePdfData = (pdf: ArrayBuffer | Uint8Array) =>\n pdf instanceof Uint8Array ? new Uint8Array(pdf) : new Uint8Array(pdf);\n\nconst loadingTaskMap = new WeakMap<object, { destroy: () => Promise<void> }>();\n\nconst getDocument = async (pdf: ArrayBuffer | Uint8Array) => {\n if (typeof Worker !== 'undefined' && pdfjsLib.GlobalWorkerOptions.workerSrc !== workerSrc) {\n pdfjsLib.GlobalWorkerOptions.workerSrc = workerSrc;\n }\n\n const loadingTask = pdfjsLib.getDocument({\n data: clonePdfData(pdf),\n isEvalSupported: false,\n });\n const document = await loadingTask.promise;\n loadingTaskMap.set(document, { destroy: () => loadingTask.destroy() });\n return document;\n};\n\nconst destroyDocument = async (document: object) => {\n const loadingTask = loadingTaskMap.get(document);\n loadingTaskMap.delete(document);\n await loadingTask?.destroy();\n};\n\nfunction dataURLToArrayBuffer(dataURL: string): ArrayBuffer {\n // Split out the actual base64 string from the data URL scheme\n const base64String = dataURL.split(',')[1];\n\n // Decode the Base64 string to get the binary data\n const byteString = atob(base64String);\n\n // Create a typed array from the binary string\n const arrayBuffer = new ArrayBuffer(byteString.length);\n const uintArray = new Uint8Array(arrayBuffer);\n\n for (let i = 0; i < byteString.length; i++) {\n uintArray[i] = byteString.charCodeAt(i);\n }\n\n return arrayBuffer;\n}\n\nexport const pdf2img = async (\n pdf: ArrayBuffer | Uint8Array,\n options: Pdf2ImgOptions = {},\n): Promise<ArrayBuffer[]> =>\n _pdf2img(pdf, options, {\n getDocument,\n destroyDocument,\n createCanvas: (width, height) => {\n const canvas = document.createElement('canvas');\n canvas.width = width;\n canvas.height = height;\n return canvas;\n },\n canvasToArrayBuffer: (canvas, imageType) => {\n // Using type assertion to handle the canvas method\n const dataUrl = (canvas as HTMLCanvasElement).toDataURL(`image/${imageType}`);\n return dataURLToArrayBuffer(dataUrl);\n },\n });\n\nexport const pdf2size = async (pdf: ArrayBuffer | Uint8Array, options: Pdf2SizeOptions = {}) =>\n _pdf2size(pdf, options, {\n getDocument,\n destroyDocument,\n });\n\nexport { img2pdf } from './img2pdf.js';\n"],"mappings":";;;;;;AAKA,IAAM,gBAAgB,QACpB,eAAe,aAAa,IAAI,WAAW,IAAI,GAAG,IAAI,WAAW,IAAI;AAEvE,IAAM,iCAAiB,IAAI,SAAmD;AAE9E,IAAM,cAAc,OAAO,QAAkC;AAC3D,KAAI,OAAO,WAAW,eAAe,SAAS,oBAAoB,cAAA,KAAA,IAAA,IAAA,mCAAA,OAAA,KAAA,IAAA,CAAA,KAChE,UAAS,oBAAoB,YAAY;CAG3C,MAAM,cAAc,SAAS,YAAY;EACvC,MAAM,aAAa,IAAI;EACvB,iBAAiB;EAClB,CAAC;CACF,MAAM,WAAW,MAAM,YAAY;AACnC,gBAAe,IAAI,UAAU,EAAE,eAAe,YAAY,SAAS,EAAE,CAAC;AACtE,QAAO;;AAGT,IAAM,kBAAkB,OAAO,aAAqB;CAClD,MAAM,cAAc,eAAe,IAAI,SAAS;AAChD,gBAAe,OAAO,SAAS;AAC/B,OAAM,aAAa,SAAS;;AAG9B,SAAS,qBAAqB,SAA8B;CAE1D,MAAM,eAAe,QAAQ,MAAM,IAAI,CAAC;CAGxC,MAAM,aAAa,KAAK,aAAa;CAGrC,MAAM,cAAc,IAAI,YAAY,WAAW,OAAO;CACtD,MAAM,YAAY,IAAI,WAAW,YAAY;AAE7C,MAAK,IAAI,IAAI,GAAG,IAAI,WAAW,QAAQ,IACrC,WAAU,KAAK,WAAW,WAAW,EAAE;AAGzC,QAAO;;AAGT,IAAa,UAAU,OACrB,KACA,UAA0B,EAAE,KAE5B,UAAS,KAAK,SAAS;CACrB;CACA;CACA,eAAe,OAAO,WAAW;EAC/B,MAAM,SAAS,SAAS,cAAc,SAAS;AAC/C,SAAO,QAAQ;AACf,SAAO,SAAS;AAChB,SAAO;;CAET,sBAAsB,QAAQ,cAAc;AAG1C,SAAO,qBADU,OAA6B,UAAU,SAAS,YAAY,CACzC;;CAEvC,CAAC;AAEJ,IAAa,WAAW,OAAO,KAA+B,UAA2B,EAAE,KACzF,WAAU,KAAK,SAAS;CACtB;CACA;CACD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pdfme/converter",
3
- "version": "6.0.5",
3
+ "version": "6.0.6-dev.3",
4
4
  "description": "TypeScript base PDF generator and React base UI. Open source, developed by the community, and completely free to use under the MIT license!",
5
5
  "keywords": [
6
6
  "pdf",
@@ -20,12 +20,12 @@
20
20
  "type": "git",
21
21
  "url": "git@github.com:pdfme/pdfme.git"
22
22
  },
23
- "type": "module",
24
- "sideEffects": false,
25
23
  "files": [
26
24
  "dist",
27
25
  "README.md"
28
26
  ],
27
+ "type": "module",
28
+ "sideEffects": false,
29
29
  "main": "./dist/index.js",
30
30
  "module": "./dist/index.js",
31
31
  "types": "./dist/index.d.ts",