@swisper.ai/web-file-preview 0.0.8 → 0.0.9
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.css +1 -1
- package/dist/index.es.js +2 -2
- package/dist/{pdf-engine-BtVPDh84.js → pdf-engine-DWOclI_R.js} +2 -2
- package/dist/{pdf-engine-BtVPDh84.js.map → pdf-engine-DWOclI_R.js.map} +1 -1
- package/dist/{pdf-renderer-DzQMsDqU.js → pdf-renderer-BbQMj8uz.js} +10 -10
- package/dist/{pdf-renderer-DzQMsDqU.js.map → pdf-renderer-BbQMj8uz.js.map} +1 -1
- package/dist/{pdf-thumbnail-BYW10Fds.js → pdf-thumbnail-DuanRuLw.js} +2 -2
- package/dist/{pdf-thumbnail-BYW10Fds.js.map → pdf-thumbnail-DuanRuLw.js.map} +1 -1
- package/dist/{worker-engine-Xfe-G3n0.js → worker-engine-DBU5WIrV.js} +4 -4
- package/dist/{worker-engine-Xfe-G3n0.js.map → worker-engine-DBU5WIrV.js.map} +1 -1
- package/package.json +5 -5
- package/src/components/file-thumbnail/__tests__/file-thumbnail.spec.tsx +3 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as e, t } from "./pdf-engine-
|
|
1
|
+
import { n as e, t } from "./pdf-engine-DWOclI_R.js";
|
|
2
2
|
import { t as n } from "./use-thumbnail-task-DDEyifIR.js";
|
|
3
3
|
import { t as r } from "./blob-to-data-url-JUcsCM_8.js";
|
|
4
4
|
//#region src/components/file-thumbnail/components/pdf/pdf-thumbnail.tsx
|
|
@@ -37,4 +37,4 @@ function a({ loadBlob: t, fileName: a, width: o, pixelRatio: s, onSource: c, onE
|
|
|
37
37
|
//#endregion
|
|
38
38
|
export { a as PdfThumbnail, t as applyPdfiumWasmUrl };
|
|
39
39
|
|
|
40
|
-
//# sourceMappingURL=pdf-thumbnail-
|
|
40
|
+
//# sourceMappingURL=pdf-thumbnail-DuanRuLw.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pdf-thumbnail-
|
|
1
|
+
{"version":3,"file":"pdf-thumbnail-DuanRuLw.js","names":["loadSharedPdfEngine","useThumbnailTask","blobToDataUrl","documentCounter","PdfThumbnail","blob","loadBlob","signal","engine","file","document","page","fileName","pageWidth","image","width","pixelRatio","applyPdfiumWasmUrl"],"sources":["../src/components/file-thumbnail/components/pdf/pdf-thumbnail.tsx"],"sourcesContent":["import { loadSharedPdfEngine } from '../../../file-preview/components/pdf/pdf-engine';\nimport { blobToDataUrl } from '../shared/blob-to-data-url';\nimport { useThumbnailTask } from '../shared/use-thumbnail-task';\nimport type { FileThumbnailProducerProps } from '../thumbnail-types';\n\n// Re-exported for the lazy loader, which may not import the engine module itself (see\n// `applyPdfiumWasmUrl`).\nexport { applyPdfiumWasmUrl } from '../../../file-preview/components/pdf/pdf-engine';\n\nlet documentCounter = 0;\n\n/**\n * A PDF's first page, rasterised by the PDFium engine `FilePreview` already shares: no second\n * WASM download once either has run.\n *\n * `renderPage` rather than `renderThumbnail`: the latter clamps its scale to at least 0.5,\n * so a Letter page would come out 306px wide whatever the tile asks for.\n */\nexport function PdfThumbnail({\n loadBlob,\n fileName,\n width,\n pixelRatio,\n onSource,\n onError,\n}: FileThumbnailProducerProps) {\n useThumbnailTask(\n async (signal) => {\n const blob = await loadBlob(signal);\n const engine = await loadSharedPdfEngine();\n documentCounter += 1;\n // Unique, so it can never collide with a document the viewer has open.\n const file = { id: `file-thumbnail-${documentCounter}`, content: await blob.arrayBuffer() };\n const document = await engine.openDocumentBuffer(file).toPromise();\n\n try {\n const page = document.pages[0];\n\n if (!page) {\n throw new Error(`[web-file-preview] \"${fileName}\" has no pages.`);\n }\n\n // Quarter turns swap the page's sides; `size` is unrotated.\n const pageWidth = page.rotation % 2 === 1 ? page.size.height : page.size.width;\n const image = await engine\n .renderPage(document, page, {\n scaleFactor: width / pageWidth,\n dpr: pixelRatio,\n rotation: page.rotation,\n imageType: 'image/webp',\n })\n .toPromise();\n\n return { type: 'image', fit: 'page', url: await blobToDataUrl(image) };\n } finally {\n engine\n .closeDocument(document)\n .toPromise()\n .catch(() => {});\n }\n },\n { fileName, onSource, onError },\n );\n\n return null;\n}\n"],"mappings":";;;;AASA,IAAIG,IAAkB;AAStB,SAAgBC,EAAa,EAC3B,aACA,aACA,UACA,eACA,aACA,cAC6B;CAuC7B,OAtCAH,EACE,OAAO,MAAW;EAChB,IAAMI,IAAO,MAAMC,EAASC,CAAM,GAC5BC,IAAS,MAAMR,EAAoB;EACzC,KAAmB;EAEnB,IAAMS,IAAO;GAAE,IAAI,kBAAkBN;GAAmB,SAAS,MAAME,EAAK,YAAY;EAAE,GACpFK,IAAW,MAAMF,EAAO,mBAAmBC,CAAI,CAAC,CAAC,UAAU;EAEjE,IAAI;GACF,IAAME,IAAOD,EAAS,MAAM;GAE5B,IAAI,CAACC,GACH,MAAU,MAAM,uBAAuBC,EAAS,gBAAgB;GAIlE,IAAMC,IAAYF,EAAK,WAAW,KAAM,IAAIA,EAAK,KAAK,SAASA,EAAK,KAAK,OACnEG,IAAQ,MAAMN,EACjB,WAAWE,GAAUC,GAAM;IAC1B,aAAaI,IAAQF;IACrB,KAAKG;IACL,UAAUL,EAAK;IACf,WAAW;GACb,CAAC,CAAC,CACD,UAAU;GAEb,OAAO;IAAE,MAAM;IAAS,KAAK;IAAQ,KAAK,MAAMT,EAAcY,CAAK;GAAE;EACvE,UAAU;GACR,EACG,cAAcJ,CAAQ,CAAC,CACvB,UAAU,CAAC,CACX,YAAY,CAAC,CAAC;EACnB;CACF,GACA;EAAE;EAAU;EAAU;CAAQ,CAChC,GAEO;AACT"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { g as e, i as t, l as n, n as r, r as i, t as a } from "./dist-CZsb0xlY.js";
|
|
2
|
-
//#region ../../node_modules/.pnpm/@embedpdf+engines@2.15.1_preact@10.29.8_react-dom@18.3.1_react@18.3.1__react@18.3.
|
|
2
|
+
//#region ../../node_modules/.pnpm/@embedpdf+engines@2.15.1_preact@10.29.8_react-dom@18.3.1_react@18.3.1__react@18.3.1_sve_152fbd3c02df5497dc9c1975c191f1b7/node_modules/@embedpdf/engines/dist/pdf-engine-D9v0RfKe.js
|
|
3
3
|
var o = "TaskQueue", s = "Queue", c = /* @__PURE__ */ ((e) => (e[e.CRITICAL = 3] = "CRITICAL", e[e.HIGH = 2] = "HIGH", e[e.MEDIUM = 1] = "MEDIUM", e[e.LOW = 0] = "LOW", e))(c || {}), l = class {
|
|
4
4
|
constructor(e = {}) {
|
|
5
5
|
this.queue = [], this.running = 0, this.resultTasks = /* @__PURE__ */ new Map(), this.idleListeners = /* @__PURE__ */ new Set();
|
|
@@ -855,7 +855,7 @@ var o = "TaskQueue", s = "Queue", c = /* @__PURE__ */ ((e) => (e[e.CRITICAL = 3]
|
|
|
855
855
|
}
|
|
856
856
|
};
|
|
857
857
|
//#endregion
|
|
858
|
-
//#region ../../node_modules/.pnpm/@embedpdf+engines@2.15.1_preact@10.29.8_react-dom@18.3.1_react@18.3.1__react@18.3.
|
|
858
|
+
//#region ../../node_modules/.pnpm/@embedpdf+engines@2.15.1_preact@10.29.8_react-dom@18.3.1_react@18.3.1__react@18.3.1_sve_152fbd3c02df5497dc9c1975c191f1b7/node_modules/@embedpdf/engines/dist/browser-BKLM0ThC.js
|
|
859
859
|
function p(e, t, n) {
|
|
860
860
|
let r = t * n * 4, i = (e) => [
|
|
861
861
|
e & 255,
|
|
@@ -954,7 +954,7 @@ function g(e) {
|
|
|
954
954
|
return t.destroy = () => e.destroy(), t;
|
|
955
955
|
}
|
|
956
956
|
//#endregion
|
|
957
|
-
//#region ../../node_modules/.pnpm/@embedpdf+engines@2.15.1_preact@10.29.8_react-dom@18.3.1_react@18.3.1__react@18.3.
|
|
957
|
+
//#region ../../node_modules/.pnpm/@embedpdf+engines@2.15.1_preact@10.29.8_react-dom@18.3.1_react@18.3.1__react@18.3.1_sve_152fbd3c02df5497dc9c1975c191f1b7/node_modules/@embedpdf/engines/dist/lib/pdfium/web/worker-engine.js
|
|
958
958
|
var _ = "RemoteExecutor", v = "Worker", y = class i {
|
|
959
959
|
constructor(a, o) {
|
|
960
960
|
this.worker = a, this.pendingRequests = /* @__PURE__ */ new Map(), this.requestCounter = 0, this.handleMessage = (e) => {
|
|
@@ -1395,4 +1395,4 @@ function w(e, t) {
|
|
|
1395
1395
|
//#endregion
|
|
1396
1396
|
export { w as createPdfiumEngine };
|
|
1397
1397
|
|
|
1398
|
-
//# sourceMappingURL=worker-engine-
|
|
1398
|
+
//# sourceMappingURL=worker-engine-DBU5WIrV.js.map
|