Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feat/vite-plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
spring-raining committed Dec 31, 2024
2 parents 881473a + bc5a65f commit 0825946
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
with:
node-version: ${{ matrix.node }}
- run: yarn install
- run: yarn playwright-core install chromium
- run: yarn playwright-core install chromium --no-shell
- run: yarn build
- run: yarn test
build-and-push-image:
Expand Down
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
## [8.17.1](https://github.com/vivliostyle/vivliostyle-cli/compare/v8.17.0...v8.17.1) (2024-11-27)

### Bug Fixes

- Fix accidental release ([ddd92b3](https://github.com/vivliostyle/vivliostyle-cli/commit/ddd92b31f169fc87d8ab8a6b61cb1e84a4f5eb61))

# [8.17.0](https://github.com/vivliostyle/vivliostyle-cli/compare/v8.16.2...v8.17.0) (2024-11-27)

### Bug Fixes

- Fix to work `--browser` option ([da522f7](https://github.com/vivliostyle/vivliostyle-cli/commit/da522f7aad8d45e5ea1e77c7778ad450b6a6034e)), closes [#546](https://github.com/vivliostyle/vivliostyle-cli/issues/546)
- Update Vivliostyle.js to 2.30.7: Layout bug fixes ([3e3310c](https://github.com/vivliostyle/vivliostyle-cli/commit/3e3310c6d246002cd3dc261aaf3e7bf9edf26b7e))

### Features

- Update Playwright to 1.49.0 (Chromium 131.0.6778.33) ([eadf6da](https://github.com/vivliostyle/vivliostyle-cli/commit/eadf6da7c6507ff16576b4dbf088c4eec7578e1d))

## [8.16.2](https://github.com/vivliostyle/vivliostyle-cli/compare/v8.16.1...v8.16.2) (2024-11-18)

### Bug Fixes

- Update Vivliostyle.js to 2.30.6: Bug Fixes ([52e4839](https://github.com/vivliostyle/vivliostyle-cli/commit/52e48399a0060dcdc1d5b52939f7b27088241a86))

## [8.16.1](https://github.com/vivliostyle/vivliostyle-cli/compare/v8.16.0...v8.16.1) (2024-11-06)

### Bug Fixes
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@vivliostyle/cli",
"description": "Save the pdf file via headless browser and Vivliostyle.",
"version": "8.16.1",
"version": "8.17.1",
"author": "spring_raining <[email protected]>",
"type": "module",
"scripts": {
Expand All @@ -12,7 +12,7 @@
"clean": "shx rm -rf dist tmp",
"dev": "tsc -w --preserveWatchOutput",
"example": "yarn --cwd example build",
"pretest": "playwright-core install chromium",
"pretest": "playwright-core install chromium --no-shell",
"release": "release-it",
"release:pre": "release-it --preRelease --npm.tag=next",
"test": "vitest run --coverage",
Expand All @@ -25,7 +25,7 @@
"@npmcli/arborist": "^6.1.3",
"@vivliostyle/jsdom": "22.1.0-vivliostyle-cli.1",
"@vivliostyle/vfm": "2.2.1",
"@vivliostyle/viewer": "2.30.5",
"@vivliostyle/viewer": "2.30.7",
"ajv": "^8.11.2",
"ajv-formats": "^2.1.1",
"archiver": "^5.3.1",
Expand All @@ -49,7 +49,7 @@
"node-stream-zip": "^1.14.0",
"ora": "^5.4.1",
"pdf-lib": "^1.16.0",
"playwright-core": "1.48.1",
"playwright-core": "1.49.0",
"press-ready": "^4.0.3",
"prettier": "^3.3.3",
"resolve-pkg": "^2.0.0",
Expand Down
8 changes: 5 additions & 3 deletions src/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ export async function launchBrowser({
'--allow-file-access-from-files',
disableWebSecurity ? '--disable-web-security' : '',
disableDevShmUsage ? '--disable-dev-shm-usage' : '',
// #357: Set devicePixelRatio=1 otherwise it causes layout issues in HiDPI displays
headless ? '--force-device-scale-factor=1' : '',
// set Chromium language to English to avoid locale-dependent issues (e.g. minimum font size)
'--lang=en',
...(!headless && process.platform === 'darwin'
Expand Down Expand Up @@ -82,9 +84,9 @@ export function checkBrowserAvailability(path: string): boolean {
}

export function isPlaywrightExecutable(path: string): boolean {
return registry
.executables()
.some((exe) => pathEquals(exe.executablePath() ?? '', path));
return [playwright.chromium, playwright.firefox, playwright.webkit].some(
(exe) => pathEquals(exe.executablePath() ?? '', path),
);
}

export async function downloadBrowser(
Expand Down
14 changes: 12 additions & 2 deletions src/processor/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ export interface VSFile extends VFile {
};
}

function safeReadMetadata(content: string): Metadata {
// The input assumes VFM format, but errors during metadata extraction
// should be suppressed to allow processing of non-VFM files as well.
try {
return readMetadata(content);
} catch {
return {};
}
}

export async function processMarkdown(
documentProcessorFactory: DocumentProcessorFactory,
filepath: string,
Expand All @@ -22,7 +32,7 @@ export async function processMarkdown(
const markdownString = fs.readFileSync(filepath, 'utf8');
const processor = documentProcessorFactory(
options,
readMetadata(markdownString),
safeReadMetadata(markdownString),
);
const processed = (await processor.process(
vfile({ path: filepath, contents: markdownString }),
Expand All @@ -31,5 +41,5 @@ export async function processMarkdown(
}

export function readMarkdownMetadata(filepath: string): Metadata {
return readMetadata(fs.readFileSync(filepath, 'utf8'));
return safeReadMetadata(fs.readFileSync(filepath, 'utf8'));
}
26 changes: 13 additions & 13 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1506,10 +1506,10 @@
loupe "^3.1.1"
tinyrainbow "^1.2.0"

"@vivliostyle/core@^2.30.5":
version "2.30.5"
resolved "https://registry.yarnpkg.com/@vivliostyle/core/-/core-2.30.5.tgz#fc9412aa81b07bcb79932f46f82a044bb5c0c212"
integrity sha512-54/ZAxP5PK0lqkmUrOY7d9vL9rwvDSOiq8rbEA9YDQxiZJniLuQifqZt2Dtm1885e69yGXlfmztsZ3PWS8I4iw==
"@vivliostyle/core@^2.30.7":
version "2.30.7"
resolved "https://registry.yarnpkg.com/@vivliostyle/core/-/core-2.30.7.tgz#7ea8e45067b20031748d69d2591f649ac9023082"
integrity sha512-4BOtX4olH48NhljInvtDmwj5QSwcU6zjfH5ZsYSncXByljsBYQXVKrmjPMZrmHpjXNYXvk0+JQzd6qp65VVVTQ==
dependencies:
fast-diff "^1.2.0"

Expand Down Expand Up @@ -1581,12 +1581,12 @@
unist-util-visit "^2.0.3"
unist-util-visit-parents "^3.1.1"

"@vivliostyle/[email protected].5":
version "2.30.5"
resolved "https://registry.yarnpkg.com/@vivliostyle/viewer/-/viewer-2.30.5.tgz#d708212b7ac7852c7f5a4d7fbcd030c16ed15c1a"
integrity sha512-vffbyd3K1kQsBhOwqdBd9f5MMLvyIOqhUnFixLYriB1C6edjykEVfQTmd2iN+TSVOcPYpE4mJuc0kUL6Ffb57g==
"@vivliostyle/[email protected].7":
version "2.30.7"
resolved "https://registry.yarnpkg.com/@vivliostyle/viewer/-/viewer-2.30.7.tgz#76095131403be0dc89a050a3e07cdec64288fd9d"
integrity sha512-RwER9A2qzDP27CRHfYm3tLE1ySRYkQDBMk8zSMoe2srPoxwSqaGSk+Zk9NOEskb+AZPuccaAWAuZ2Hp90+0nEg==
dependencies:
"@vivliostyle/core" "^2.30.5"
"@vivliostyle/core" "^2.30.7"
i18next-ko "^3.0.1"
knockout "^3.5.0"

Expand Down Expand Up @@ -6636,10 +6636,10 @@ pify@^3.0.0:
resolved "https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176"
integrity sha512-C3FsVNH1udSEX48gGX1xfvwTWfsYWj5U+8/uK15BGzIGrKoUpghX8hWZwa/OFnakBiiVNmBvemTJR5mcy7iPcg==

playwright-core@1.48.1:
version "1.48.1"
resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.48.1.tgz#5fe28fb9a9326dae88d4608c35e819163cceeb23"
integrity sha512-Yw/t4VAFX/bBr1OzwCuOMZkY1Cnb4z/doAFSwf4huqAGWmf9eMNjmK7NiOljCdLmxeRYcGPPmcDgU0zOlzP0YA==
playwright-core@1.49.0:
version "1.49.0"
resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.49.0.tgz#8e69ffed3f41855b854982f3632f2922c890afcb"
integrity sha512-R+3KKTQF3npy5GTiKH/T+kdhoJfJojjHESR1YEWhYuEKRVfVaxH3+4+GvXE5xyCngCxhxnykk0Vlah9v8fs3jA==

possible-typed-array-names@^1.0.0:
version "1.0.0"
Expand Down

0 comments on commit 0825946

Please sign in to comment.