From 9f6c7c792d70dbfa24e97acf364c0688a0156dd8 Mon Sep 17 00:00:00 2001 From: Yuki Hattori Date: Tue, 21 Jan 2025 22:18:06 +0900 Subject: [PATCH] Debug JPEG conversion --- .circleci/config.yml | 1 + .github/workflows/test-win.yml | 1 + src/utils/jpeg.ts | 8 +++++++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ab352ea4..26d03ba9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -99,6 +99,7 @@ commands: name: Jest command: npm run test:coverage -- --ci --reporters=default --reporters=jest-junit <<#parameters.runInBand>>-i<><<^parameters.runInBand>>--maxWorkers=2<> environment: + DEBUG: marp-cli:jpeg JEST_JUNIT_CLASSNAME: '{filepath}' JEST_JUNIT_OUTPUT_DIR: tmp/test-results MARP_TEST_CI: 1 diff --git a/.github/workflows/test-win.yml b/.github/workflows/test-win.yml index 02ad3a06..658b3f03 100644 --- a/.github/workflows/test-win.yml +++ b/.github/workflows/test-win.yml @@ -48,6 +48,7 @@ jobs: # https://stackoverflow.com/a/59365905 - name: Jest env: + DEBUG: marp-cli:jpeg JEST_JUNIT_CLASSNAME: '{filepath}' JEST_JUNIT_OUTPUT_DIR: tmp/test-results MARP_TEST_CI: 1 diff --git a/src/utils/jpeg.ts b/src/utils/jpeg.ts index e1ead540..a982c998 100644 --- a/src/utils/jpeg.ts +++ b/src/utils/jpeg.ts @@ -1,5 +1,7 @@ +import dbg from 'debug' import { Browser } from '../browser/browser' -import { debug } from './debug' + +const debug = dbg('marp-cli:jpeg') export const png2jpegViaPuppeteer = async ( browser: Browser, @@ -13,6 +15,8 @@ export const png2jpegViaPuppeteer = async ( waitUntil: ['domcontentloaded', 'networkidle0'], }) + debug('Evaluating JavaScript to convert PNG to JPEG') + const jpegDataURL = await page.evaluate( async (pngUri, q, timeout) => { /* c8 ignore start */ @@ -52,6 +56,8 @@ export const png2jpegViaPuppeteer = async ( browser.timeout ) + debug('Evaluated JavaScript to convert PNG to JPEG') + if (!jpegDataURL.startsWith('data:image/jpeg;base64,')) throw new Error('Failed to convert PNG to JPEG')