jsdomに戻す

This commit is contained in:
kakkokari-gtyih 2024-09-25 09:42:05 +09:00
parent c4bd6dfb6b
commit c03603611b
4 changed files with 40 additions and 65 deletions

View File

@ -119,7 +119,6 @@
"fluent-ffmpeg": "2.1.3", "fluent-ffmpeg": "2.1.3",
"form-data": "4.0.0", "form-data": "4.0.0",
"got": "14.4.2", "got": "14.4.2",
"happy-dom": "15.7.4",
"hpagent": "1.2.0", "hpagent": "1.2.0",
"htmlescape": "1.1.1", "htmlescape": "1.1.1",
"http-link-header": "1.1.3", "http-link-header": "1.1.3",
@ -132,8 +131,8 @@
"json5": "2.2.3", "json5": "2.2.3",
"jsonld": "8.3.2", "jsonld": "8.3.2",
"jsrsasign": "11.1.0", "jsrsasign": "11.1.0",
"meilisearch": "0.42.0",
"juice": "11.0.0", "juice": "11.0.0",
"meilisearch": "0.42.0",
"mfm-js": "0.24.0", "mfm-js": "0.24.0",
"microformats-parser": "2.0.2", "microformats-parser": "2.0.2",
"mime-types": "2.1.35", "mime-types": "2.1.35",

View File

@ -6,7 +6,7 @@
import { URL } from 'node:url'; import { URL } from 'node:url';
import { Inject, Injectable } from '@nestjs/common'; import { Inject, Injectable } from '@nestjs/common';
import * as parse5 from 'parse5'; import * as parse5 from 'parse5';
import { Window, XMLSerializer } from 'happy-dom'; import { JSDOM } from 'jsdom';
import { DI } from '@/di-symbols.js'; import { DI } from '@/di-symbols.js';
import type { Config } from '@/config.js'; import type { Config } from '@/config.js';
import { intersperse } from '@/misc/prelude/array.js'; import { intersperse } from '@/misc/prelude/array.js';
@ -239,7 +239,7 @@ export class MfmService {
return null; return null;
} }
const { happyDOM, window } = new Window(); const { window } = new JSDOM();
const doc = window.document; const doc = window.document;
@ -457,9 +457,9 @@ export class MfmService {
appendChildren(nodes, body); appendChildren(nodes, body);
const serialized = new XMLSerializer().serializeToString(body); const serialized = body.outerHTML;
happyDOM.close().catch(err => {}); window.close();
return serialized; return serialized;
} }

View File

@ -6,7 +6,7 @@
import * as crypto from 'node:crypto'; import * as crypto from 'node:crypto';
import { URL } from 'node:url'; import { URL } from 'node:url';
import { Inject, Injectable } from '@nestjs/common'; import { Inject, Injectable } from '@nestjs/common';
import { Window } from 'happy-dom'; import { JSDOM } from 'jsdom';
import { DI } from '@/di-symbols.js'; import { DI } from '@/di-symbols.js';
import type { Config } from '@/config.js'; import type { Config } from '@/config.js';
import type { MiUser } from '@/models/User.js'; import type { MiUser } from '@/models/User.js';
@ -211,26 +211,7 @@ export class ApRequestService {
&& _followAlternate === true && _followAlternate === true
) { ) {
const html = await res.text(); const html = await res.text();
const { window, happyDOM } = new Window({ const { window } = new JSDOM(html);
settings: {
disableJavaScriptEvaluation: true,
disableJavaScriptFileLoading: true,
disableCSSFileLoading: true,
disableComputedStyleRendering: true,
handleDisabledFileLoadingAsSuccess: true,
navigation: {
disableMainFrameNavigation: true,
disableChildFrameNavigation: true,
disableChildPageNavigation: true,
disableFallbackToSetURL: true,
},
timer: {
maxTimeout: 0,
maxIntervalTime: 0,
maxIntervalIterations: 0,
},
},
});
const document = window.document; const document = window.document;
try { try {
document.documentElement.innerHTML = html; document.documentElement.innerHTML = html;
@ -245,7 +226,7 @@ export class ApRequestService {
} catch (e) { } catch (e) {
// something went wrong parsing the HTML, ignore the whole thing // something went wrong parsing the HTML, ignore the whole thing
} finally { } finally {
happyDOM.close().catch(err => {}); window.close();
} }
} }
//#endregion //#endregion

View File

@ -245,9 +245,6 @@ importers:
got: got:
specifier: 14.4.2 specifier: 14.4.2
version: 14.4.2 version: 14.4.2
happy-dom:
specifier: 15.7.4
version: 15.7.4
hpagent: hpagent:
specifier: 1.2.0 specifier: 1.2.0
version: 1.2.0 version: 1.2.0
@ -7345,10 +7342,6 @@ packages:
happy-dom@10.0.3: happy-dom@10.0.3:
resolution: {integrity: sha512-WkCP+Z5fX6U5PY+yHP3ElV5D9PoxRAHRWPFq3pG9rg/6Hjf5ak7dozAgSCywsTRUq2qfa8vV8OQvUy5pRXy8EQ==} resolution: {integrity: sha512-WkCP+Z5fX6U5PY+yHP3ElV5D9PoxRAHRWPFq3pG9rg/6Hjf5ak7dozAgSCywsTRUq2qfa8vV8OQvUy5pRXy8EQ==}
happy-dom@15.7.4:
resolution: {integrity: sha512-r1vadDYGMtsHAAsqhDuk4IpPvr6N8MGKy5ntBo7tSdim+pWDxus2PNqOcOt8LuDZ4t3KJHE+gCuzupcx/GKnyQ==}
engines: {node: '>=18.0.0'}
har-schema@2.0.0: har-schema@2.0.0:
resolution: {integrity: sha512-Oqluz6zhGX8cyRaTQlFMPw80bSJVG2x/cFb8ZPhUILGgHka9SsokCCOQgpveePerqidZOrT14ipqfJb7ILcW5Q==} resolution: {integrity: sha512-Oqluz6zhGX8cyRaTQlFMPw80bSJVG2x/cFb8ZPhUILGgHka9SsokCCOQgpveePerqidZOrT14ipqfJb7ILcW5Q==}
engines: {node: '>=4'} engines: {node: '>=4'}
@ -12277,7 +12270,7 @@ snapshots:
'@babel/traverse': 7.23.5 '@babel/traverse': 7.23.5
'@babel/types': 7.24.7 '@babel/types': 7.24.7
convert-source-map: 2.0.0 convert-source-map: 2.0.0
debug: 4.3.5(supports-color@8.1.1) debug: 4.3.5(supports-color@5.5.0)
gensync: 1.0.0-beta.2 gensync: 1.0.0-beta.2
json5: 2.2.3 json5: 2.2.3
semver: 6.3.1 semver: 6.3.1
@ -12297,7 +12290,7 @@ snapshots:
'@babel/traverse': 7.24.7 '@babel/traverse': 7.24.7
'@babel/types': 7.24.7 '@babel/types': 7.24.7
convert-source-map: 2.0.0 convert-source-map: 2.0.0
debug: 4.3.5(supports-color@8.1.1) debug: 4.3.5(supports-color@5.5.0)
gensync: 1.0.0-beta.2 gensync: 1.0.0-beta.2
json5: 2.2.3 json5: 2.2.3
semver: 6.3.1 semver: 6.3.1
@ -12556,7 +12549,7 @@ snapshots:
'@babel/helper-split-export-declaration': 7.22.6 '@babel/helper-split-export-declaration': 7.22.6
'@babel/parser': 7.24.7 '@babel/parser': 7.24.7
'@babel/types': 7.24.7 '@babel/types': 7.24.7
debug: 4.3.5(supports-color@8.1.1) debug: 4.3.5(supports-color@5.5.0)
globals: 11.12.0 globals: 11.12.0
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
@ -12571,7 +12564,7 @@ snapshots:
'@babel/helper-split-export-declaration': 7.24.7 '@babel/helper-split-export-declaration': 7.24.7
'@babel/parser': 7.24.7 '@babel/parser': 7.24.7
'@babel/types': 7.24.7 '@babel/types': 7.24.7
debug: 4.3.5(supports-color@8.1.1) debug: 4.3.5(supports-color@5.5.0)
globals: 11.12.0 globals: 11.12.0
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
@ -15978,7 +15971,7 @@ snapshots:
'@typescript-eslint/types': 7.17.0 '@typescript-eslint/types': 7.17.0
'@typescript-eslint/typescript-estree': 7.17.0(typescript@5.6.2) '@typescript-eslint/typescript-estree': 7.17.0(typescript@5.6.2)
'@typescript-eslint/visitor-keys': 7.17.0 '@typescript-eslint/visitor-keys': 7.17.0
debug: 4.3.5(supports-color@8.1.1) debug: 4.3.5(supports-color@5.5.0)
eslint: 9.11.0 eslint: 9.11.0
optionalDependencies: optionalDependencies:
typescript: 5.6.2 typescript: 5.6.2
@ -16036,7 +16029,7 @@ snapshots:
dependencies: dependencies:
'@typescript-eslint/typescript-estree': 7.17.0(typescript@5.6.2) '@typescript-eslint/typescript-estree': 7.17.0(typescript@5.6.2)
'@typescript-eslint/utils': 7.17.0(eslint@9.11.0)(typescript@5.6.2) '@typescript-eslint/utils': 7.17.0(eslint@9.11.0)(typescript@5.6.2)
debug: 4.3.5(supports-color@8.1.1) debug: 4.3.5(supports-color@5.5.0)
eslint: 9.11.0 eslint: 9.11.0
ts-api-utils: 1.3.0(typescript@5.6.2) ts-api-utils: 1.3.0(typescript@5.6.2)
optionalDependencies: optionalDependencies:
@ -16094,7 +16087,7 @@ snapshots:
dependencies: dependencies:
'@typescript-eslint/types': 7.17.0 '@typescript-eslint/types': 7.17.0
'@typescript-eslint/visitor-keys': 7.17.0 '@typescript-eslint/visitor-keys': 7.17.0
debug: 4.3.5(supports-color@8.1.1) debug: 4.3.5(supports-color@5.5.0)
globby: 11.1.0 globby: 11.1.0
is-glob: 4.0.3 is-glob: 4.0.3
minimatch: 9.0.4 minimatch: 9.0.4
@ -16491,14 +16484,14 @@ snapshots:
agent-base@6.0.2: agent-base@6.0.2:
dependencies: dependencies:
debug: 4.3.5(supports-color@8.1.1) debug: 4.3.5(supports-color@5.5.0)
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
optional: true optional: true
agent-base@7.1.0: agent-base@7.1.0:
dependencies: dependencies:
debug: 4.3.5(supports-color@8.1.1) debug: 4.3.5(supports-color@5.5.0)
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
@ -17676,12 +17669,20 @@ snapshots:
dependencies: dependencies:
ms: 2.0.0 ms: 2.0.0
debug@3.2.7:
dependencies:
ms: 2.1.3
debug@3.2.7(supports-color@8.1.1): debug@3.2.7(supports-color@8.1.1):
dependencies: dependencies:
ms: 2.1.3 ms: 2.1.3
optionalDependencies: optionalDependencies:
supports-color: 8.1.1 supports-color: 8.1.1
debug@4.3.4:
dependencies:
ms: 2.1.2
debug@4.3.4(supports-color@5.5.0): debug@4.3.4(supports-color@5.5.0):
dependencies: dependencies:
ms: 2.1.2 ms: 2.1.2
@ -18287,7 +18288,7 @@ snapshots:
eslint-import-resolver-node@0.3.9: eslint-import-resolver-node@0.3.9:
dependencies: dependencies:
debug: 3.2.7(supports-color@8.1.1) debug: 3.2.7
is-core-module: 2.15.1 is-core-module: 2.15.1
resolve: 1.22.8 resolve: 1.22.8
transitivePeerDependencies: transitivePeerDependencies:
@ -18295,7 +18296,7 @@ snapshots:
eslint-module-utils@2.11.0(@typescript-eslint/parser@7.17.0(eslint@9.11.0)(typescript@5.6.2))(eslint-import-resolver-node@0.3.9)(eslint@9.11.0): eslint-module-utils@2.11.0(@typescript-eslint/parser@7.17.0(eslint@9.11.0)(typescript@5.6.2))(eslint-import-resolver-node@0.3.9)(eslint@9.11.0):
dependencies: dependencies:
debug: 3.2.7(supports-color@8.1.1) debug: 3.2.7
optionalDependencies: optionalDependencies:
'@typescript-eslint/parser': 7.17.0(eslint@9.11.0)(typescript@5.6.2) '@typescript-eslint/parser': 7.17.0(eslint@9.11.0)(typescript@5.6.2)
eslint: 9.11.0 eslint: 9.11.0
@ -18320,7 +18321,7 @@ snapshots:
array.prototype.findlastindex: 1.2.5 array.prototype.findlastindex: 1.2.5
array.prototype.flat: 1.3.2 array.prototype.flat: 1.3.2
array.prototype.flatmap: 1.3.2 array.prototype.flatmap: 1.3.2
debug: 3.2.7(supports-color@8.1.1) debug: 3.2.7
doctrine: 2.1.0 doctrine: 2.1.0
eslint: 9.11.0 eslint: 9.11.0
eslint-import-resolver-node: 0.3.9 eslint-import-resolver-node: 0.3.9
@ -19288,12 +19289,6 @@ snapshots:
whatwg-encoding: 2.0.0 whatwg-encoding: 2.0.0
whatwg-mimetype: 3.0.0 whatwg-mimetype: 3.0.0
happy-dom@15.7.4:
dependencies:
entities: 4.5.0
webidl-conversions: 7.0.0
whatwg-mimetype: 3.0.0
har-schema@2.0.0: {} har-schema@2.0.0: {}
har-validator@5.1.5: har-validator@5.1.5:
@ -19426,7 +19421,7 @@ snapshots:
http-proxy-agent@7.0.2: http-proxy-agent@7.0.2:
dependencies: dependencies:
agent-base: 7.1.0 agent-base: 7.1.0
debug: 4.3.5(supports-color@8.1.1) debug: 4.3.5(supports-color@5.5.0)
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
@ -19457,7 +19452,7 @@ snapshots:
https-proxy-agent@2.2.4: https-proxy-agent@2.2.4:
dependencies: dependencies:
agent-base: 4.3.0 agent-base: 4.3.0
debug: 3.2.7(supports-color@8.1.1) debug: 3.2.7
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
optional: true optional: true
@ -19465,7 +19460,7 @@ snapshots:
https-proxy-agent@5.0.1: https-proxy-agent@5.0.1:
dependencies: dependencies:
agent-base: 6.0.2 agent-base: 6.0.2
debug: 4.3.5(supports-color@8.1.1) debug: 4.3.5(supports-color@5.5.0)
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
optional: true optional: true
@ -19473,14 +19468,14 @@ snapshots:
https-proxy-agent@7.0.2: https-proxy-agent@7.0.2:
dependencies: dependencies:
agent-base: 7.1.0 agent-base: 7.1.0
debug: 4.3.5(supports-color@8.1.1) debug: 4.3.5(supports-color@5.5.0)
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
https-proxy-agent@7.0.5: https-proxy-agent@7.0.5:
dependencies: dependencies:
agent-base: 7.1.0 agent-base: 7.1.0
debug: 4.3.5(supports-color@8.1.1) debug: 4.3.5(supports-color@5.5.0)
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
@ -19584,7 +19579,7 @@ snapshots:
dependencies: dependencies:
'@ioredis/commands': 1.2.0 '@ioredis/commands': 1.2.0
cluster-key-slot: 1.1.2 cluster-key-slot: 1.1.2
debug: 4.3.4(supports-color@5.5.0) debug: 4.3.4
denque: 2.1.0 denque: 2.1.0
lodash.defaults: 4.2.0 lodash.defaults: 4.2.0
lodash.isarguments: 3.1.0 lodash.isarguments: 3.1.0
@ -19844,7 +19839,7 @@ snapshots:
istanbul-lib-source-maps@4.0.1: istanbul-lib-source-maps@4.0.1:
dependencies: dependencies:
debug: 4.3.5(supports-color@8.1.1) debug: 4.3.5(supports-color@5.5.0)
istanbul-lib-coverage: 3.2.2 istanbul-lib-coverage: 3.2.2
source-map: 0.6.1 source-map: 0.6.1
transitivePeerDependencies: transitivePeerDependencies:
@ -21259,7 +21254,7 @@ snapshots:
needle@2.9.1: needle@2.9.1:
dependencies: dependencies:
debug: 3.2.7(supports-color@8.1.1) debug: 3.2.7
iconv-lite: 0.4.24 iconv-lite: 0.4.24
sax: 1.2.4 sax: 1.2.4
transitivePeerDependencies: transitivePeerDependencies:
@ -22526,7 +22521,7 @@ snapshots:
require-in-the-middle@7.3.0: require-in-the-middle@7.3.0:
dependencies: dependencies:
debug: 4.3.5(supports-color@8.1.1) debug: 4.3.5(supports-color@5.5.0)
module-details-from-path: 1.0.3 module-details-from-path: 1.0.3
resolve: 1.22.8 resolve: 1.22.8
transitivePeerDependencies: transitivePeerDependencies:
@ -22868,7 +22863,7 @@ snapshots:
dependencies: dependencies:
'@hapi/hoek': 11.0.4 '@hapi/hoek': 11.0.4
'@hapi/wreck': 18.0.1 '@hapi/wreck': 18.0.1
debug: 4.3.5(supports-color@8.1.1) debug: 4.3.5(supports-color@5.5.0)
joi: 17.11.0 joi: 17.11.0
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
@ -22968,7 +22963,7 @@ snapshots:
socks-proxy-agent@8.0.2: socks-proxy-agent@8.0.2:
dependencies: dependencies:
agent-base: 7.1.0 agent-base: 7.1.0
debug: 4.3.5(supports-color@8.1.1) debug: 4.3.5(supports-color@5.5.0)
socks: 2.7.1 socks: 2.7.1
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
@ -23609,7 +23604,7 @@ snapshots:
chalk: 4.1.2 chalk: 4.1.2
cli-highlight: 2.1.11 cli-highlight: 2.1.11
dayjs: 1.11.10 dayjs: 1.11.10
debug: 4.3.4(supports-color@5.5.0) debug: 4.3.4
dotenv: 16.0.3 dotenv: 16.0.3
glob: 10.3.10 glob: 10.3.10
mkdirp: 2.1.6 mkdirp: 2.1.6