From af50d2463ca165a13bbffb444f5d3018b706a6d2 Mon Sep 17 00:00:00 2001 From: cvasseng Date: Thu, 18 Jan 2024 14:12:23 +0100 Subject: [PATCH 01/11] Update build-and-push.yml --- .github/workflows/build-and-push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml index 3466112e..8589d437 100644 --- a/.github/workflows/build-and-push.yml +++ b/.github/workflows/build-and-push.yml @@ -30,4 +30,4 @@ jobs: git config --local user.name "GitHub Action" git add dist/ git commit -m "Build the dist files after merge." - git push \ No newline at end of file + git push -f From 67afcecc56470121f7134a56441ca0d85af74e45 Mon Sep 17 00:00:00 2001 From: cvasseng Date: Thu, 18 Jan 2024 14:13:47 +0100 Subject: [PATCH 02/11] Update build-and-push.yml --- .github/workflows/build-and-push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml index 8589d437..436b781e 100644 --- a/.github/workflows/build-and-push.yml +++ b/.github/workflows/build-and-push.yml @@ -28,6 +28,6 @@ jobs: run: | git config --local user.email "action@github.com" git config --local user.name "GitHub Action" - git add dist/ + git add dist/ -f git commit -m "Build the dist files after merge." git push -f From 75b16a94ec48af1fbf709c3ec13cae4766e1d4c7 Mon Sep 17 00:00:00 2001 From: cvasseng Date: Thu, 18 Jan 2024 14:15:43 +0100 Subject: [PATCH 03/11] Update build-and-push.yml --- .github/workflows/build-and-push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml index 436b781e..334d06d6 100644 --- a/.github/workflows/build-and-push.yml +++ b/.github/workflows/build-and-push.yml @@ -28,6 +28,6 @@ jobs: run: | git config --local user.email "action@github.com" git config --local user.name "GitHub Action" - git add dist/ -f + git add -f dist/ git commit -m "Build the dist files after merge." git push -f From a45006566c6d65e71fd3497a7e00d42632377df5 Mon Sep 17 00:00:00 2001 From: "Chris M. Vasseng" Date: Mon, 22 Jan 2024 11:22:16 +0100 Subject: [PATCH 04/11] Check if HC exists before trying to access its namespace in cleanup --- lib/export.js | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/lib/export.js b/lib/export.js index c9d02198..45ad250c 100644 --- a/lib/export.js +++ b/lib/export.js @@ -57,7 +57,7 @@ const getClipRegion = (page) => * @returns {string} - A string representation of a screenshot. */ const createImage = async (page, type, encoding, clip, rasterizationTimeout) => - await Promise.race([ + Promise.race([ page.screenshot({ type, encoding, @@ -67,7 +67,7 @@ const createImage = async (page, type, encoding, clip, rasterizationTimeout) => // the expected type format is PNG omitBackground: type == 'png' }), - new Promise((resolve, reject) => + new Promise((_resolve, reject) => setTimeout( () => reject(new Error('Rasterization timeout')), rasterizationTimeout || 1500 @@ -425,16 +425,20 @@ export default async (page, chart, options) => { // Destroy old charts after the export is done await page.evaluate(() => { - // eslint-disable-next-line no-undef - const oldCharts = Highcharts.charts; - - // Check in any already existing charts - if (oldCharts.length) { - // Destroy old charts - for (const oldChart of oldCharts) { - oldChart && oldChart.destroy(); - // eslint-disable-next-line no-undef - Highcharts.charts.shift(); + // We are not guaranteed that Highcharts is loaded, e,g, when doing SVG + // exports + if (typeof Highcharts !== 'undefined') { + // eslint-disable-next-line no-undef + const oldCharts = Highcharts.charts; + + // Check in any already existing charts + if (Array.isArray(oldCharts) && oldCharts.length) { + // Destroy old charts + for (const oldChart of oldCharts) { + oldChart && oldChart.destroy(); + // eslint-disable-next-line no-undef + Highcharts.charts.shift(); + } } } }); From ca255e8e416a6d93144c9a3b4c6a0ce520c90c15 Mon Sep 17 00:00:00 2001 From: jakubSzuminski Date: Mon, 22 Jan 2024 12:02:04 +0100 Subject: [PATCH 05/11] Fixed SVG export from the public ES website. --- public/js/main.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/js/main.js b/public/js/main.js index f29cdedc..374b9875 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -68,7 +68,8 @@ const highexp = {}; preview.innerHTML = ''; } else if (format.value === 'image/svg+xml') { - preview.innerHTML = data; + preview.innerHTML = + ''; } else if (format.value === 'application/pdf') { preview.innerHTML = ''; try { From 976c5714102d315cf559c0ad230746878a0a0ffa Mon Sep 17 00:00:00 2001 From: "Chris M. Vasseng" Date: Mon, 22 Jan 2024 12:09:25 +0100 Subject: [PATCH 06/11] Force page reset when aquiring new resource from the pool --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 9c970a2e..5cffadac 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -101,7 +101,7 @@ const factory = { } // Clear page - await clearPage(workerHandle.page, false); + await clearPage(workerHandle.page, true); return true; }, From 3296e6053643066d54c0d1f14ca31fe0f72591fc Mon Sep 17 00:00:00 2001 From: "Chris M. Vasseng" Date: Mon, 22 Jan 2024 12:20:50 +0100 Subject: [PATCH 07/11] Fixed min/max workers type exception when setting through CLI --- lib/pool.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 5cffadac..f8cbd307 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -161,13 +161,17 @@ export const init = async (config) => { attachProcessExitListeners(); } + if (parseInt(poolConfig.minWorkers) > parseInt(poolConfig.maxWorkers)) { + poolConfig.minWorkers = poolConfig.maxWorkers; + } + try { // Create a pool along with a minimal number of resources pool = new Pool({ // Get the create/validate/destroy/log functions ...factory, - min: poolConfig.minWorkers, - max: poolConfig.maxWorkers, + min: parseInt(poolConfig.minWorkers), + max: parseInt(poolConfig.maxWorkers), acquireTimeoutMillis: poolConfig.acquireTimeout, createTimeoutMillis: poolConfig.createTimeout, destroyTimeoutMillis: poolConfig.destroyTimeout, From a8ea1912ec51c65cfe97dc50fdd04c8d5d7e97a2 Mon Sep 17 00:00:00 2001 From: "Chris M. Vasseng" Date: Mon, 22 Jan 2024 12:39:09 +0100 Subject: [PATCH 08/11] Fixed version output for /health and splash when running as a module --- lib/server/routes/health.js | 11 +++++++++-- lib/utils.js | 8 ++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/server/routes/health.js b/lib/server/routes/health.js index 52ff3e24..2c8e61bb 100644 --- a/lib/server/routes/health.js +++ b/lib/server/routes/health.js @@ -15,7 +15,14 @@ See LICENSE file in root for details. import cache from '../../cache.js'; import pool from '../../pool.js'; -const packageVersion = process.env.npm_package_version; +import { readFileSync } from 'fs'; +import { __dirname } from './../../utils.js'; +import { join as pather } from 'path'; + +const pkgFile = JSON.parse( + readFileSync(pather(__dirname, 'package.json')) + ); + const serverStartTime = new Date(); /** @@ -32,7 +39,7 @@ export default (app) => Math.floor( (new Date().getTime() - serverStartTime.getTime()) / 1000 / 60 ) + ' minutes', - version: packageVersion, + version: pkgFile.version, highchartsVersion: cache.version(), averageProcessingTime: pool.averageTime(), performedExports: pool.processedWorkCount(), diff --git a/lib/utils.js b/lib/utils.js index 7a5922de..d391ddd2 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -14,6 +14,7 @@ See LICENSE file in root for details. import { readFileSync } from 'fs'; import { fileURLToPath } from 'url'; +import { join as pather } from 'path'; import { defaultConfig } from '../lib/schemas/config.js'; import { log } from './logger.js'; @@ -280,10 +281,9 @@ export const optionsStringify = (options, allowFunctions) => { */ export const printLogo = (noLogo) => { // Get package version either from env or from package.json - const packageVersion = - process.env.npm_package_version || - JSON.parse(readFileSync(new URL('../package.json', import.meta.url))) - .version; + const packageVersion = JSON.parse( + readFileSync(pather(__dirname, 'package.json')) + ).version; // Print text only if (noLogo) { From 0ab56a79c6cac7c8a6b548cc7df3b726fd39781d Mon Sep 17 00:00:00 2001 From: PaulDalek Date: Mon, 22 Jan 2024 12:42:35 +0100 Subject: [PATCH 09/11] Corrected problem with string size. --- lib/chart.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/chart.js b/lib/chart.js index a8e5e645..d2724731 100644 --- a/lib/chart.js +++ b/lib/chart.js @@ -203,7 +203,7 @@ export const findChartSize = (options) => { scale = roundNumber(scale, 2); // Find chart size and scale - return { + const size = { height: options.export?.height || exporting?.sourceHeight || @@ -222,6 +222,13 @@ export const findChartSize = (options) => { 600, scale }; + + // Get rid of potential px and % + for (var [param, value] of Object.entries(size)) { + size[param] = + typeof value === 'string' ? +value.replace(/px|%/gi, '') : value; + } + return size; }; /** From ae97fe2e178c45975e8470bc98dd0e464e36c3f0 Mon Sep 17 00:00:00 2001 From: "Chris M. Vasseng" Date: Mon, 22 Jan 2024 12:57:28 +0100 Subject: [PATCH 10/11] Bump version --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 16e96f3e..61b69b26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# 3.1.1 + +- Version number is now correct in splash and `/health` when running as a node module +- Fixed an issue with setting `minWorkers` and `maxWorkers` as CLI arguments +- Fixed issues with page resets between exports causing exceptions +- Fixed an issue with width settings causing bad exports if set to a percentage or a `px` suffixed width + # 3.1.0 - Fixed an issue with SVG base 64 exports diff --git a/package.json b/package.json index e05009c3..c6e5b674 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "author": "Highsoft AS (http://www.highcharts.com/about)", "license": "MIT", "type": "module", - "version": "3.1.0", + "version": "3.1.1", "main": "dist/index.esm.js", "exports": { ".": { From 809d9729f885e22729b2cd3d7b0daa76452b0302 Mon Sep 17 00:00:00 2001 From: "Chris M. Vasseng" Date: Mon, 22 Jan 2024 13:02:12 +0100 Subject: [PATCH 11/11] Updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 61b69b26..7ab0b505 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Fixed an issue with setting `minWorkers` and `maxWorkers` as CLI arguments - Fixed issues with page resets between exports causing exceptions - Fixed an issue with width settings causing bad exports if set to a percentage or a `px` suffixed width +- Fixed an issue with SVG exports in the UI # 3.1.0