typescript fixin
Some checks failed
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Failing after 13s
Some checks failed
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Failing after 13s
This commit is contained in:
@@ -1,3 +1,13 @@
|
||||
/**
|
||||
* This interface defines the shape of the pdf.js page object that we use.
|
||||
* Since pdf.js is loaded from a CDN, we don't have its types available
|
||||
* at build time, so we define the parts we need here for type safety.
|
||||
*/
|
||||
interface PDFPageProxy {
|
||||
getViewport: (options: { scale: number }) => { width: number; height: number };
|
||||
render: (options: { canvasContext: CanvasRenderingContext2D; viewport: { width: number; height: number } }) => { promise: Promise<void> };
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders a single PDF page to a canvas and returns it as a JPEG File object.
|
||||
* @param pdfPage The PDF page object from pdf.js.
|
||||
@@ -7,7 +17,7 @@
|
||||
* @returns A promise that resolves to an image File object.
|
||||
*/
|
||||
const renderPageToImageFile = async (
|
||||
pdfPage: any, // pdf.js page object
|
||||
pdfPage: PDFPageProxy,
|
||||
pageNumber: number,
|
||||
originalFileName: string,
|
||||
scale: number
|
||||
@@ -44,12 +54,12 @@ const renderPageToImageFile = async (
|
||||
* @returns A promise that resolves to the pdf.js document object.
|
||||
*/
|
||||
const getPdfDocument = async (pdfFile: File) => {
|
||||
// @ts-ignore - pdfjsLib is globally available from the script tag in index.html
|
||||
// @ts-expect-error - pdfjsLib is globally available from the script tag in index.html
|
||||
if (typeof pdfjsLib === 'undefined') {
|
||||
throw new Error('pdf.js library is not loaded. Please check the script tag in index.html.');
|
||||
}
|
||||
const arrayBuffer = await pdfFile.arrayBuffer();
|
||||
// @ts-ignore - pdfjsLib is globally available
|
||||
// @ts-expect-error - pdfjsLib is globally available
|
||||
const pdf = await pdfjsLib.getDocument(arrayBuffer).promise;
|
||||
return pdf;
|
||||
};
|
||||
|
||||
@@ -3,7 +3,7 @@ export const parsePrice = (price: string): number => {
|
||||
const match = price.match(/\$?(\d+\.?\d*)/);
|
||||
if (!match) return 0;
|
||||
|
||||
let numericPrice = parseFloat(match[1]);
|
||||
const numericPrice = parseFloat(match[1]);
|
||||
|
||||
const forMatch = price.match(/(\d+)\s+for/i);
|
||||
if(forMatch){
|
||||
|
||||
Reference in New Issue
Block a user