vomebook commited on
Commit
8d64eb8
·
1 Parent(s): 8b42141

Provide extracted URL boundary to OCR Worker fixture

Browse files
tests/reader/pdf-search/test_reader_ocr_transport.mjs CHANGED
@@ -5,6 +5,7 @@ import { webcrypto } from 'node:crypto';
5
  import { gzipSync } from 'node:zlib';
6
  import { createPdfBookSearch } from '../../../static/reader/search/reader-pdf-book-search.mjs';
7
  import { validateBookText, searchBookText } from '../../../static/reader/search/reader-book-text.js';
 
8
 
9
  const source=fs.readFileSync(new URL('../../../static/reader/search/workers/reader-pdf-book-search-worker.mjs',import.meta.url),'utf8');
10
  const start=source.indexOf('async function readBounded('), end=source.indexOf('\nasync function loadBook()',start);
@@ -59,7 +60,7 @@ const configuration={url,bytes:packed.length,sha256:Buffer.from(await webcrypto.
59
  const scope={self:{location:{href:'https://voiceofml-search.hf.space/static/worker.mjs',origin:'https://voiceofml-search.hf.space'},
60
  VoiceOfMLReaderSecurity:{LIMITS:{chapterTotalBytes:1024*1024}},postMessage:data=>posted.push(data)},
61
  URL,DOMException,AbortController,TextDecoder,Uint8Array,ReadableStream,DecompressionStream,
62
- crypto:webcrypto,performance,setTimeout,clearTimeout,fetch:async()=>new Response(packed),validateBookText,searchBookText};
63
  const context=vm.createContext(scope);
64
  vm.runInContext(source.replace(/^import .*;\n/gm,''),context);
65
  await scope.self.onmessage({data:{type:'init',configuration}});
 
5
  import { gzipSync } from 'node:zlib';
6
  import { createPdfBookSearch } from '../../../static/reader/search/reader-pdf-book-search.mjs';
7
  import { validateBookText, searchBookText } from '../../../static/reader/search/reader-book-text.js';
8
+ import { validPdfBookUrl, searchPath } from '../../../static/reader/search/reader-pdf-book-url.mjs';
9
 
10
  const source=fs.readFileSync(new URL('../../../static/reader/search/workers/reader-pdf-book-search-worker.mjs',import.meta.url),'utf8');
11
  const start=source.indexOf('async function readBounded('), end=source.indexOf('\nasync function loadBook()',start);
 
60
  const scope={self:{location:{href:'https://voiceofml-search.hf.space/static/worker.mjs',origin:'https://voiceofml-search.hf.space'},
61
  VoiceOfMLReaderSecurity:{LIMITS:{chapterTotalBytes:1024*1024}},postMessage:data=>posted.push(data)},
62
  URL,DOMException,AbortController,TextDecoder,Uint8Array,ReadableStream,DecompressionStream,
63
+ crypto:webcrypto,performance,setTimeout,clearTimeout,fetch:async()=>new Response(packed),validateBookText,searchBookText,validPdfBookUrl,searchPath};
64
  const context=vm.createContext(scope);
65
  vm.runInContext(source.replace(/^import .*;\n/gm,''),context);
66
  await scope.self.onmessage({data:{type:'init',configuration}});