Repository navigation
Conversation
…rt x.pdf` on Windows)
pdf.js runs its fake worker on Node by import()ing GlobalWorkerOptions.workerSrc.
We set it to the resolved absolute path, which Node's ESM loader rejects on
Windows ("Only URLs with a scheme in: file, data, and node are supported by
the default ESM loader. Received protocol 'd:'"), so every PDF conversion in
the CLI fails there, including the published @uurtech/jdf-cli bundle.
pathToFileURL() gives a file:// URL on every platform. On macOS the output of
spec/examples/sample.pdf is byte-identical before and after (same sha256),
and verify:regress (25 checked, 0 changed), verify:tables (120/120) and
verify:order (100%) stay green.
The same fix was part of the win branch (ed4622f) and was reverted in
2572af0 only to keep that PR scoped to the desktop app.
Co-authored-by: rcpzen <recepzen@hotmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Windows every PDF conversion in the CLI fails before the first page:
pdf.js runs its fake worker on Node by
import()ingGlobalWorkerOptions.workerSrc, andpackages/jdf-pdf-import/src/node.tssets it to the resolved absolute path. The published@uurtech/jdf-cli@0.2.9bundles this package, sonpx @uurtech/jdf-cli convert x.pdffails the same way on Windows.Fix
Pass
pathToFileURL(workerPath).hrefinstead of the bare path. Same code on every platform.Verification
Windows (windows-latest, Node 22): https://github.com/EienMosu/jdf/actions/runs/37241435201
npx @uurtech/jdf-cli@0.2.9 convert spec/examples/sample.pdfReceived protocol 'c:'masterfrom sourceReceived protocol 'd:'jdf validatepassesThe
.jdfproduced on Windows is byte-identical to the macOS one (sha256a431d18f…aaa7b707).macOS, before and after the change:
spec/examples/sample.pdfoutput unchanged (same sha256),verify:regress25 checked / 0 changed,verify:tables120/120,verify:order100%,pnpm typecheckgreen.The same change was in the win branch (ed4622f) and was reverted in 2572af0 only to keep #5 scoped to the desktop app, so @rcpzen is co-author.
Side note, not part of this PR: on Node 18 and 20,
jdf convert x.pdffails earlier on every OS withPromise.withResolvers is not a function(pdfjs-dist 4.10 modern build), whiletools/jdf-clideclaresengines.node >= 18and the README says Node 20+. Happy to send a separate PR (bump engines to >= 22, or a small polyfill), whichever you prefer.