Merge pull request #916 from TriliumNext/renovate/jsdom-26.x

fix(deps): update dependency jsdom to v26
This commit is contained in:
Elian Doran 2025-01-10 21:51:51 +02:00 committed by GitHub
commit 69fd215471
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 201 additions and 25 deletions

171
package-lock.json generated
View File

@ -63,7 +63,7 @@
"jquery": "3.7.1", "jquery": "3.7.1",
"jquery-hotkeys": "0.2.2", "jquery-hotkeys": "0.2.2",
"jquery.fancytree": "2.38.4", "jquery.fancytree": "2.38.4",
"jsdom": "25.0.1", "jsdom": "26.0.0",
"jsplumb": "2.15.6", "jsplumb": "2.15.6",
"katex": "0.16.19", "katex": "0.16.19",
"knockout": "3.5.1", "knockout": "3.5.1",
@ -192,6 +192,28 @@
"url": "https://github.com/sponsors/antfu" "url": "https://github.com/sponsors/antfu"
} }
}, },
"node_modules/@asamuzakjp/css-color": {
"version": "2.8.2",
"resolved": "https://registry.npmjs.org/@asamuzakjp/css-color/-/css-color-2.8.2.tgz",
"integrity": "sha512-RtWv9jFN2/bLExuZgFFZ0I3pWWeezAHGgrmjqGGWclATl1aDe3yhCUaI0Ilkp6OCk9zX7+FjvDasEX8Q9Rxc5w==",
"license": "MIT",
"dependencies": {
"@csstools/css-calc": "^2.1.1",
"@csstools/css-color-parser": "^3.0.7",
"@csstools/css-parser-algorithms": "^3.0.4",
"@csstools/css-tokenizer": "^3.0.3",
"lru-cache": "^11.0.2"
}
},
"node_modules/@asamuzakjp/css-color/node_modules/lru-cache": {
"version": "11.0.2",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.0.2.tgz",
"integrity": "sha512-123qHRfJBmo2jXDbo/a5YOQrJoHF/GNQTLzQ5+IdK5pWpceK17yRc6ozlWd25FxvGKQbIUs91fDFkXmDHTKcyA==",
"license": "ISC",
"engines": {
"node": "20 || >=22"
}
},
"node_modules/@babel/helper-string-parser": { "node_modules/@babel/helper-string-parser": {
"version": "7.25.9", "version": "7.25.9",
"resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.25.9.tgz", "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.25.9.tgz",
@ -312,6 +334,116 @@
"node": ">=12" "node": ">=12"
} }
}, },
"node_modules/@csstools/color-helpers": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/@csstools/color-helpers/-/color-helpers-5.0.1.tgz",
"integrity": "sha512-MKtmkA0BX87PKaO1NFRTFH+UnkgnmySQOvNxJubsadusqPEC2aJ9MOQiMceZJJ6oitUl/i0L6u0M1IrmAOmgBA==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/csstools"
},
{
"type": "opencollective",
"url": "https://opencollective.com/csstools"
}
],
"license": "MIT-0",
"engines": {
"node": ">=18"
}
},
"node_modules/@csstools/css-calc": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/@csstools/css-calc/-/css-calc-2.1.1.tgz",
"integrity": "sha512-rL7kaUnTkL9K+Cvo2pnCieqNpTKgQzy5f+N+5Iuko9HAoasP+xgprVh7KN/MaJVvVL1l0EzQq2MoqBHKSrDrag==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/csstools"
},
{
"type": "opencollective",
"url": "https://opencollective.com/csstools"
}
],
"license": "MIT",
"engines": {
"node": ">=18"
},
"peerDependencies": {
"@csstools/css-parser-algorithms": "^3.0.4",
"@csstools/css-tokenizer": "^3.0.3"
}
},
"node_modules/@csstools/css-color-parser": {
"version": "3.0.7",
"resolved": "https://registry.npmjs.org/@csstools/css-color-parser/-/css-color-parser-3.0.7.tgz",
"integrity": "sha512-nkMp2mTICw32uE5NN+EsJ4f5N+IGFeCFu4bGpiKgb2Pq/7J/MpyLBeQ5ry4KKtRFZaYs6sTmcMYrSRIyj5DFKA==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/csstools"
},
{
"type": "opencollective",
"url": "https://opencollective.com/csstools"
}
],
"license": "MIT",
"dependencies": {
"@csstools/color-helpers": "^5.0.1",
"@csstools/css-calc": "^2.1.1"
},
"engines": {
"node": ">=18"
},
"peerDependencies": {
"@csstools/css-parser-algorithms": "^3.0.4",
"@csstools/css-tokenizer": "^3.0.3"
}
},
"node_modules/@csstools/css-parser-algorithms": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/@csstools/css-parser-algorithms/-/css-parser-algorithms-3.0.4.tgz",
"integrity": "sha512-Up7rBoV77rv29d3uKHUIVubz1BTcgyUK72IvCQAbfbMv584xHcGKCKbWh7i8hPrRJ7qU4Y8IO3IY9m+iTB7P3A==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/csstools"
},
{
"type": "opencollective",
"url": "https://opencollective.com/csstools"
}
],
"license": "MIT",
"engines": {
"node": ">=18"
},
"peerDependencies": {
"@csstools/css-tokenizer": "^3.0.3"
}
},
"node_modules/@csstools/css-tokenizer": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/@csstools/css-tokenizer/-/css-tokenizer-3.0.3.tgz",
"integrity": "sha512-UJnjoFsmxfKUdNYdWgOB0mWUypuLvAfQPH1+pyvRJs6euowbFkFC6P13w1l8mJyi3vxYMxc9kld5jZEGRQs6bw==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/csstools"
},
{
"type": "opencollective",
"url": "https://opencollective.com/csstools"
}
],
"license": "MIT",
"engines": {
"node": ">=18"
}
},
"node_modules/@discoveryjs/json-ext": { "node_modules/@discoveryjs/json-ext": {
"version": "0.6.3", "version": "0.6.3",
"resolved": "https://registry.npmjs.org/@discoveryjs/json-ext/-/json-ext-0.6.3.tgz", "resolved": "https://registry.npmjs.org/@discoveryjs/json-ext/-/json-ext-0.6.3.tgz",
@ -7026,12 +7158,13 @@
} }
}, },
"node_modules/cssstyle": { "node_modules/cssstyle": {
"version": "4.1.0", "version": "4.2.1",
"resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-4.1.0.tgz", "resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-4.2.1.tgz",
"integrity": "sha512-h66W1URKpBS5YMI/V8PyXvTMFT8SupJ1IzoIV8IeBC/ji8WVmrO8dGlTi+2dh6whmdk6BiKJLD/ZBkhWbcg6nA==", "integrity": "sha512-9+vem03dMXG7gDmZ62uqmRiMRNtinIZ9ZyuF6BdxzfOD+FdN5hretzynkn0ReS2DO2GSw76RWHs0UmJPI2zUjw==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"rrweb-cssom": "^0.7.1" "@asamuzakjp/css-color": "^2.8.2",
"rrweb-cssom": "^0.8.0"
}, },
"engines": { "engines": {
"node": ">=18" "node": ">=18"
@ -12187,22 +12320,22 @@
} }
}, },
"node_modules/jsdom": { "node_modules/jsdom": {
"version": "25.0.1", "version": "26.0.0",
"resolved": "https://registry.npmjs.org/jsdom/-/jsdom-25.0.1.tgz", "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-26.0.0.tgz",
"integrity": "sha512-8i7LzZj7BF8uplX+ZyOlIz86V6TAsSs+np6m1kpW9u0JWi4z/1t+FzcK1aek+ybTnAC4KhBL4uXCNT0wcUIeCw==", "integrity": "sha512-BZYDGVAIriBWTpIxYzrXjv3E/4u8+/pSG5bQdIYCbNCGOvsPkDQfTVLAIXAf9ETdCpduCVTkDe2NNZ8NIwUVzw==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"cssstyle": "^4.1.0", "cssstyle": "^4.2.1",
"data-urls": "^5.0.0", "data-urls": "^5.0.0",
"decimal.js": "^10.4.3", "decimal.js": "^10.4.3",
"form-data": "^4.0.0", "form-data": "^4.0.1",
"html-encoding-sniffer": "^4.0.0", "html-encoding-sniffer": "^4.0.0",
"http-proxy-agent": "^7.0.2", "http-proxy-agent": "^7.0.2",
"https-proxy-agent": "^7.0.5", "https-proxy-agent": "^7.0.6",
"is-potential-custom-element-name": "^1.0.1", "is-potential-custom-element-name": "^1.0.1",
"nwsapi": "^2.2.12", "nwsapi": "^2.2.16",
"parse5": "^7.1.2", "parse5": "^7.2.1",
"rrweb-cssom": "^0.7.1", "rrweb-cssom": "^0.8.0",
"saxes": "^6.0.0", "saxes": "^6.0.0",
"symbol-tree": "^3.2.4", "symbol-tree": "^3.2.4",
"tough-cookie": "^5.0.0", "tough-cookie": "^5.0.0",
@ -12210,7 +12343,7 @@
"webidl-conversions": "^7.0.0", "webidl-conversions": "^7.0.0",
"whatwg-encoding": "^3.1.1", "whatwg-encoding": "^3.1.1",
"whatwg-mimetype": "^4.0.0", "whatwg-mimetype": "^4.0.0",
"whatwg-url": "^14.0.0", "whatwg-url": "^14.1.0",
"ws": "^8.18.0", "ws": "^8.18.0",
"xml-name-validator": "^5.0.0" "xml-name-validator": "^5.0.0"
}, },
@ -12218,7 +12351,7 @@
"node": ">=18" "node": ">=18"
}, },
"peerDependencies": { "peerDependencies": {
"canvas": "^2.11.2" "canvas": "^3.0.0"
}, },
"peerDependenciesMeta": { "peerDependenciesMeta": {
"canvas": { "canvas": {
@ -15801,9 +15934,9 @@
} }
}, },
"node_modules/rrweb-cssom": { "node_modules/rrweb-cssom": {
"version": "0.7.1", "version": "0.8.0",
"resolved": "https://registry.npmjs.org/rrweb-cssom/-/rrweb-cssom-0.7.1.tgz", "resolved": "https://registry.npmjs.org/rrweb-cssom/-/rrweb-cssom-0.8.0.tgz",
"integrity": "sha512-TrEMa7JGdVm0UThDJSx7ddw5nVm3UJS9o9CCIZ72B1vSyEZoziDqBYP3XIoi/12lKrJR8rE3jeFHMok2F/Mnsg==", "integrity": "sha512-guoltQEx+9aMf2gDZ0s62EcV8lsXR+0w8915TC3ITdn2YueuNjdAYh/levpU9nFaoChh9RUS5ZdQMrKfVEN9tw==",
"license": "MIT" "license": "MIT"
}, },
"node_modules/run-parallel": { "node_modules/run-parallel": {

View File

@ -108,7 +108,7 @@
"jquery": "3.7.1", "jquery": "3.7.1",
"jquery-hotkeys": "0.2.2", "jquery-hotkeys": "0.2.2",
"jquery.fancytree": "2.38.4", "jquery.fancytree": "2.38.4",
"jsdom": "25.0.1", "jsdom": "26.0.0",
"jsplumb": "2.15.6", "jsplumb": "2.15.6",
"katex": "0.16.19", "katex": "0.16.19",
"knockout": "3.5.1", "knockout": "3.5.1",

View File

@ -1,6 +1,9 @@
{ {
"spec_dir": "spec", "spec_dir": "",
"spec_files": ["./**/*.spec.ts"], "spec_files": [
"spec/**/*.spec.ts",
"src/**/*.spec.ts"
],
"helpers": ["helpers/**/*.js"], "helpers": ["helpers/**/*.js"],
"stopSpecOnExpectationFailure": false, "stopSpecOnExpectationFailure": false,
"random": true "random": true

View File

@ -0,0 +1,33 @@
import { renderCode, type Result } from "./content_renderer.js";
describe("content_renderer", () => {
describe("renderCode", () => {
it("identifies empty content", () => {
const emptyResult: Result = {
header: "",
content: " "
};
renderCode(emptyResult);
expect(emptyResult.isEmpty).toBeTrue();
});
it("identifies unsupported content type", () => {
const emptyResult: Result = {
header: "",
content: Buffer.from("Hello world")
};
renderCode(emptyResult);
expect(emptyResult.isEmpty).toBeTrue();
});
it("wraps code in <pre>", () => {
const result: Result = {
header: "",
content: "\tHello\nworld"
};
renderCode(result);
expect(result.isEmpty).toBeFalsy();
expect(result.content).toBe("<pre>\tHello\nworld</pre>");
});
});
});

View File

@ -5,10 +5,14 @@ import shareRoot from "./share_root.js";
import escapeHtml from "escape-html"; import escapeHtml from "escape-html";
import SNote from "./shaca/entities/snote.js"; import SNote from "./shaca/entities/snote.js";
interface Result { /**
* Represents the output of the content renderer.
*/
export interface Result {
header: string; header: string;
content: string | Buffer | undefined; content: string | Buffer | undefined;
isEmpty: boolean; /** Set to `true` if the provided content should be rendered as empty. */
isEmpty?: boolean;
} }
function getContent(note: SNote) { function getContent(note: SNote) {
@ -137,7 +141,10 @@ function handleAttachmentLink(linkEl: HTMLAnchorElement, href: string) {
} }
} }
function renderCode(result: Result) { /**
* Renders a code note.
*/
export function renderCode(result: Result) {
if (typeof result.content !== "string" || !result.content?.trim()) { if (typeof result.content !== "string" || !result.content?.trim()) {
result.isEmpty = true; result.isEmpty = true;
} else { } else {