Skip to content

Create JS Context for PDF worker#1224

Merged
mvasilak merged 9 commits intozotero:masterfrom
mvasilak:create-js-context-for-pdf-worker
Mar 6, 2026
Merged

Create JS Context for PDF worker#1224
mvasilak merged 9 commits intozotero:masterfrom
mvasilak:create-js-context-for-pdf-worker

Conversation

@mvasilak
Copy link
Contributor

Creates a JS Context to load the PDF worker in, that will run solely in a background queue.

@mvasilak mvasilak force-pushed the create-js-context-for-pdf-worker branch from 67f8733 to c63ba05 Compare December 31, 2025 11:27
@mvasilak mvasilak force-pushed the create-js-context-for-pdf-worker branch from 73ac616 to 0dcc951 Compare January 9, 2026 13:35
@mvasilak
Copy link
Contributor Author

mvasilak commented Jan 9, 2026

@mrtcode you can check in this PR how the PDF worker is used in a JSContext, via this js shim. Previously we used this html shim which we loaded in the web view. Any feedback is welcome.

@mvasilak mvasilak force-pushed the create-js-context-for-pdf-worker branch from 0dcc951 to fe041f8 Compare January 9, 2026 14:25
@mrtcode
Copy link
Member

mrtcode commented Jan 12, 2026

@mvasilak great, thanks! I'll try it soon. I'll need to setup Xcode…

@mvasilak mvasilak force-pushed the create-js-context-for-pdf-worker branch from fe041f8 to 47f29ee Compare January 13, 2026 15:18
@mrtcode
Copy link
Member

mrtcode commented Jan 15, 2026

I now have an Xcode environment set up and can build the app, but I’m not sure what exactly I should be testing. Is this already expected to work, or does it currently just load the worker.js code via the shim?

What I really need is a test in the pdf-worker repo that runs the worker in a JSContext environment. I briefly tried to vibe code some Swift code that loads the shim and executes worker.js. At first glance, it evaluates without errors, although I haven’t yet tried loading an actual PDF file.

@mvasilak
Copy link
Contributor Author

@mrtcode it is expected to work. In app you can test it with retrieve metadata, or if you enable the speech feature, which (for the time being) uses the PDF worker to extract text to read. Furthermore, there are tests that do test PDF worker metadata and text extraction. If you have more tests of your own, you could vibe convert them to the iOS test harness.

All in all, just taking a look at the JS shim file and commenting on that if needed, should suffice, as this is the vibe coded layer that glues the PDF worker to the JSContext environment.

@mrtcode
Copy link
Member

mrtcode commented Jan 16, 2026

it is expected to work

Great job then!

So there are many changes coming to pdf-worker (document-worker), such as model inference, and I’ll set up JSContext tests in its repo to make sure everything continues to work.

@mvasilak mvasilak marked this pull request as ready for review January 29, 2026 08:22
@mvasilak mvasilak force-pushed the create-js-context-for-pdf-worker branch from 47f29ee to c873471 Compare February 18, 2026 12:36
@mvasilak
Copy link
Contributor Author

@michalrentka ready for another quick look, updated to properly use the latest pdf-worker, with some extra tests.

@mvasilak mvasilak force-pushed the create-js-context-for-pdf-worker branch from fdc5d80 to abcc9b2 Compare February 20, 2026 19:13
@mrtcode
Copy link
Member

mrtcode commented Mar 5, 2026

Note that I also added JSContext tests to the new pdf-worker (which will be renamed to document-worker) https://github.com/zotero/pdf-worker/tree/document-worker/test/jscontext

@mvasilak mvasilak merged commit 8ad7d43 into zotero:master Mar 6, 2026
1 check passed
@mvasilak mvasilak deleted the create-js-context-for-pdf-worker branch March 6, 2026 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants