@things-factory/ai-assistant 10.1.263 → 10.1.265
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/client/components/assistant-chat.ts +3 -3
- package/client/index.ts +1 -1
- package/client/utils/pdf-pages.ts +2 -15
- package/dist-client/components/assistant-chat.js +3 -3
- package/dist-client/components/assistant-chat.js.map +1 -1
- package/dist-client/index.d.ts +1 -1
- package/dist-client/index.js +1 -1
- package/dist-client/index.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-client/utils/pdf-pages.d.ts +0 -2
- package/dist-client/utils/pdf-pages.js +2 -14
- package/dist-client/utils/pdf-pages.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -10
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/** pdf.js with its worker - the worker parses the file off the page's thread. */
|
|
2
|
-
export declare function loadPdfjs(): Promise<any>;
|
|
3
1
|
/** The longest side of a drawn page, in pixels - enough for a model to read print, small enough to send. */
|
|
4
2
|
export declare const PAGE_IMAGE_SIDE = 1600;
|
|
5
3
|
/** One page drawn into a JPEG. */
|
|
@@ -1,19 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* A PDF page drawn into an image - for a scanned page, whose text has to be read from its picture. The PDF is opened
|
|
3
|
+
* through @operato/utils pdf-loader (document-text.ts reads the pages' text).
|
|
4
4
|
*/
|
|
5
|
-
let loading;
|
|
6
|
-
/** pdf.js with its worker - the worker parses the file off the page's thread. */
|
|
7
|
-
export function loadPdfjs() {
|
|
8
|
-
loading ??= (async () => {
|
|
9
|
-
const pdfjs = await import('pdfjs-dist');
|
|
10
|
-
if (!pdfjs.GlobalWorkerOptions.workerPort) {
|
|
11
|
-
pdfjs.GlobalWorkerOptions.workerPort = new Worker(new URL('pdfjs-dist/build/pdf.worker.min.mjs', import.meta.url), { type: 'module' });
|
|
12
|
-
}
|
|
13
|
-
return pdfjs;
|
|
14
|
-
})();
|
|
15
|
-
return loading;
|
|
16
|
-
}
|
|
17
5
|
/** The longest side of a drawn page, in pixels - enough for a model to read print, small enough to send. */
|
|
18
6
|
export const PAGE_IMAGE_SIDE = 1600;
|
|
19
7
|
/** One page drawn into a JPEG. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pdf-pages.js","sourceRoot":"","sources":["../../client/utils/pdf-pages.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"pdf-pages.js","sourceRoot":"","sources":["../../client/utils/pdf-pages.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,4GAA4G;AAC5G,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,CAAA;AAEnC,kCAAkC;AAClC,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,GAAQ,EAAE,MAAc;IACxD,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IACtC,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAA;IAC3C,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAA;IAC9G,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;IAC/C,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;IACxC,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;IAC1C,MAAM,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAE,CAAA;IACxC,uEAAuE;IACvE,OAAO,CAAC,SAAS,GAAG,SAAS,CAAA;IAC7B,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;IACnD,MAAM,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAA;IACvE,OAAO,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,CACjD,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,IAAI,CAAC,CACrH,CAAA;AACH,CAAC","sourcesContent":["/*\n * A PDF page drawn into an image - for a scanned page, whose text has to be read from its picture. The PDF is opened\n * through @operato/utils pdf-loader (document-text.ts reads the pages' text).\n */\n\n/** The longest side of a drawn page, in pixels - enough for a model to read print, small enough to send. */\nexport const PAGE_IMAGE_SIDE = 1600\n\n/** One page drawn into a JPEG. */\nexport async function drawPdfPage(pdf: any, number: number): Promise<Blob> {\n const page = await pdf.getPage(number)\n const base = page.getViewport({ scale: 1 })\n const viewport = page.getViewport({ scale: Math.min(2, PAGE_IMAGE_SIDE / Math.max(base.width, base.height)) })\n const canvas = document.createElement('canvas')\n canvas.width = Math.ceil(viewport.width)\n canvas.height = Math.ceil(viewport.height)\n const context = canvas.getContext('2d')!\n /* A page draws on transparent pixels; a JPEG would turn them black. */\n context.fillStyle = '#ffffff'\n context.fillRect(0, 0, canvas.width, canvas.height)\n await page.render({ canvas, canvasContext: context, viewport }).promise\n return await new Promise<Blob>((resolve, reject) =>\n canvas.toBlob(blob => (blob ? resolve(blob) : reject(new Error('the page could not be drawn'))), 'image/jpeg', 0.85)\n )\n}\n"]}
|