From 5229064a22d0429fbb49bae41fa6d7552d639fc7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 14 Oct 2026 21:28:58 -0400 Subject: [PATCH] deps: update hotkeys-js to 4.0.8 with compatible browser assets (#8343) * deps(deps): bump hotkeys-js from 3.10.1 to 4.0.8 Bumps [hotkeys-js](https://github.com/jaywcjlove/hotkeys-js) from 3.10.1 to 4.0.8. - [Release notes](https://github.com/jaywcjlove/hotkeys-js/releases) - [Commits](https://github.com/jaywcjlove/hotkeys-js/compare/v3.10.1...v4.0.8) --- updated-dependencies: - dependency-name: hotkeys-js dependency-version: 4.0.8 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] * fix(build): use hotkeys v4 browser artifact paths Signed-off-by: Thomas Vincent --------- Signed-off-by: dependabot[bot] Signed-off-by: Thomas Vincent Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Thomas Vincent --- build/sync-js.mjs | 4 +-- package-lock.json | 13 ++++---- package.json | 2 +- tests/js/dependency_browser_assets.test.mjs | 33 +++++++++++++++++++++ 4 files changed, 44 insertions(+), 8 deletions(-) create mode 100644 tests/js/dependency_browser_assets.test.mjs diff --git a/build/sync-js.mjs b/build/sync-js.mjs index 4c47c970a..6133b7978 100644 --- a/build/sync-js.mjs +++ b/build/sync-js.mjs @@ -24,8 +24,8 @@ export const assetMap = Object.freeze({ 'node_modules/moment/min/moment.min.js': 'include/js/vendor/moment/moment.min.js', 'node_modules/moment/LICENSE': 'include/js/vendor/moment/LICENSE', 'node_modules/daterangepicker/daterangepicker.js': 'include/js/vendor/daterangepicker/daterangepicker.js', - 'node_modules/hotkeys-js/dist/hotkeys.js': 'include/js/vendor/hotkeys/hotkeys.js', - 'node_modules/hotkeys-js/dist/hotkeys.min.js': 'include/js/vendor/hotkeys/hotkeys.min.js', + 'node_modules/hotkeys-js/dist/hotkeys-js.umd.cjs': 'include/js/vendor/hotkeys/hotkeys.js', + 'node_modules/hotkeys-js/dist/hotkeys-js.min.js': 'include/js/vendor/hotkeys/hotkeys.min.js', 'node_modules/hotkeys-js/LICENSE': 'include/js/vendor/hotkeys/LICENSE', 'node_modules/mark.js/dist/jquery.mark.js': 'include/js/vendor/mark/jquery.mark.js', 'node_modules/jstree/dist/jstree.js': 'include/js/jstree.js', diff --git a/package-lock.json b/package-lock.json index 611710f7e..9ca50971a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,7 @@ "d3": "7.9.0", "daterangepicker": "3.1.0", "dompurify": "3.4.16", - "hotkeys-js": "3.10.1", + "hotkeys-js": "4.0.8", "htmx.org": "2.0.11", "jquery": "4.0.0", "jquery-ui": "1.14.2", @@ -585,10 +585,13 @@ } }, "node_modules/hotkeys-js": { - "version": "3.10.1", - "resolved": "https://registry.npmjs.org/hotkeys-js/-/hotkeys-js-3.10.1.tgz", - "integrity": "sha512-mshqjgTqx8ee0qryHvRgZaZDxTwxam/2yTQmQlqAWS3+twnq1jsY9Yng9zB7lWq6WRrjTbTOc7knNwccXQiAjQ==", - "license": "MIT" + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/hotkeys-js/-/hotkeys-js-4.0.8.tgz", + "integrity": "sha512-A0nu5ZU7cN8nEx3uGUHrv1WnJvjPFUw4Cfxj8pLyR5AIg14ACP4D0YZ+5JHAPjlvUbPbgok56+XTZWjscYCV4A==", + "license": "MIT", + "funding": { + "url": "https://jaywcjlove.github.io/#/sponsor" + } }, "node_modules/htmx.org": { "version": "2.0.11", diff --git a/package.json b/package.json index 7f7ce0191..f8dc1d797 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "daterangepicker": "3.1.0", "dompurify": "3.4.16", "htmx.org": "2.0.11", - "hotkeys-js": "3.10.1", + "hotkeys-js": "4.0.8", "jquery": "4.0.0", "jquery-ui": "1.14.2", "jquery-ui-touch-punch": "0.2.3", diff --git a/tests/js/dependency_browser_assets.test.mjs b/tests/js/dependency_browser_assets.test.mjs new file mode 100644 index 000000000..59a8f350d --- /dev/null +++ b/tests/js/dependency_browser_assets.test.mjs @@ -0,0 +1,33 @@ +import assert from 'node:assert/strict'; +import { readFileSync } from 'node:fs'; +import { resolve } from 'node:path'; +import { test } from 'node:test'; +import vm from 'node:vm'; + +const root = resolve(import.meta.dirname, '../..'); +const dependencies = JSON.parse(readFileSync(resolve(root, 'package.json'), 'utf8')).dependencies; + +test('the pinned Chart build loads through Cacti\'s classic script tag', () => { + const context = { window: {}, self: {} }; + const source = readFileSync(resolve(root, 'include/js/Chart.js'), 'utf8'); + vm.runInNewContext(source, context); + assert.equal(typeof context.Chart, 'function'); + assert.ok(source.includes('Chart.js v' + dependencies['chart.js'])); + if (context.Chart.version !== undefined) assert.equal(context.Chart.version, dependencies['chart.js']); +}); + +for (const name of ['hotkeys.js', 'hotkeys.min.js']) { + test(`${name} preserves shortcut registration, triggering, and removal`, () => { + const target = { addEventListener() {}, removeEventListener() {} }; + const context = { window: { ...target }, document: { ...target } }; + vm.runInNewContext(readFileSync(resolve(root, 'include/js/vendor/hotkeys', name), 'utf8'), context); + const hotkeys = context.window.hotkeys; + assert.equal(typeof hotkeys, 'function'); + let calls = 0; + hotkeys('ctrl+g', () => { calls++; }); + hotkeys.trigger('ctrl+g'); + hotkeys.unbind('ctrl+g'); + hotkeys.trigger('ctrl+g'); + assert.equal(calls, 1); + }); +}