Skip to content

Commit

Permalink
jsdomに戻す
Browse files Browse the repository at this point in the history
  • Loading branch information
kakkokari-gtyih committed Sep 25, 2024
1 parent c4bd6df commit c036036
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 65 deletions.
3 changes: 1 addition & 2 deletions packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@
"fluent-ffmpeg": "2.1.3",
"form-data": "4.0.0",
"got": "14.4.2",
"happy-dom": "15.7.4",
"hpagent": "1.2.0",
"htmlescape": "1.1.1",
"http-link-header": "1.1.3",
Expand All @@ -132,8 +131,8 @@
"json5": "2.2.3",
"jsonld": "8.3.2",
"jsrsasign": "11.1.0",
"meilisearch": "0.42.0",
"juice": "11.0.0",
"meilisearch": "0.42.0",
"mfm-js": "0.24.0",
"microformats-parser": "2.0.2",
"mime-types": "2.1.35",
Expand Down
8 changes: 4 additions & 4 deletions packages/backend/src/core/MfmService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { URL } from 'node:url';
import { Inject, Injectable } from '@nestjs/common';
import * as parse5 from 'parse5';
import { Window, XMLSerializer } from 'happy-dom';
import { JSDOM } from 'jsdom';
import { DI } from '@/di-symbols.js';
import type { Config } from '@/config.js';
import { intersperse } from '@/misc/prelude/array.js';
Expand Down Expand Up @@ -239,7 +239,7 @@ export class MfmService {
return null;
}

const { happyDOM, window } = new Window();
const { window } = new JSDOM();

const doc = window.document;

Expand Down Expand Up @@ -457,9 +457,9 @@ export class MfmService {

appendChildren(nodes, body);

const serialized = new XMLSerializer().serializeToString(body);
const serialized = body.outerHTML;

happyDOM.close().catch(err => {});
window.close();

return serialized;
}
Expand Down
25 changes: 3 additions & 22 deletions packages/backend/src/core/activitypub/ApRequestService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import * as crypto from 'node:crypto';
import { URL } from 'node:url';
import { Inject, Injectable } from '@nestjs/common';
import { Window } from 'happy-dom';
import { JSDOM } from 'jsdom';
import { DI } from '@/di-symbols.js';
import type { Config } from '@/config.js';
import type { MiUser } from '@/models/User.js';
Expand Down Expand Up @@ -211,26 +211,7 @@ export class ApRequestService {
&& _followAlternate === true
) {
const html = await res.text();
const { window, happyDOM } = new Window({
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 { window } = new JSDOM(html);
const document = window.document;
try {
document.documentElement.innerHTML = html;
Expand All @@ -245,7 +226,7 @@ export class ApRequestService {
} catch (e) {
// something went wrong parsing the HTML, ignore the whole thing
} finally {
happyDOM.close().catch(err => {});
window.close();
}
}
//#endregion
Expand Down
69 changes: 32 additions & 37 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c036036

Please sign in to comment.