mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-07-08 13:04:34 +00:00
merge: Consolidate duplicate HTML/XML parser libraries (!1083)
View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/1083 Approved-by: Marie <github@yuugi.dev> Approved-by: dakkar <dakkar@thenautilus.net>
This commit is contained in:
commit
4b11fd2523
50 changed files with 1051 additions and 1357 deletions
28
package.json
28
package.json
|
@ -54,17 +54,7 @@
|
||||||
"lodash": "4.17.21"
|
"lodash": "4.17.21"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cssnano": "7.0.6",
|
"js-yaml": "4.1.0"
|
||||||
"esbuild": "0.25.3",
|
|
||||||
"execa": "9.5.2",
|
|
||||||
"fast-glob": "3.3.3",
|
|
||||||
"glob": "11.0.2",
|
|
||||||
"ignore-walk": "7.0.0",
|
|
||||||
"js-yaml": "4.1.0",
|
|
||||||
"postcss": "8.5.3",
|
|
||||||
"tar": "7.4.3",
|
|
||||||
"terser": "5.39.0",
|
|
||||||
"typescript": "5.8.3"
|
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"cypress": "14.3.2"
|
"cypress": "14.3.2"
|
||||||
|
@ -75,10 +65,20 @@
|
||||||
"@typescript-eslint/eslint-plugin": "8.31.0",
|
"@typescript-eslint/eslint-plugin": "8.31.0",
|
||||||
"@typescript-eslint/parser": "8.31.0",
|
"@typescript-eslint/parser": "8.31.0",
|
||||||
"cross-env": "7.0.3",
|
"cross-env": "7.0.3",
|
||||||
|
"cssnano": "7.0.6",
|
||||||
|
"esbuild": "0.25.3",
|
||||||
"eslint": "9.25.1",
|
"eslint": "9.25.1",
|
||||||
"globals": "16.0.0",
|
"execa": "9.5.2",
|
||||||
|
"fast-glob": "3.3.3",
|
||||||
|
"glob": "11.0.2",
|
||||||
|
"globals": "16.1.0",
|
||||||
"ncp": "2.0.0",
|
"ncp": "2.0.0",
|
||||||
"pnpm": "10.10.0",
|
"pnpm": "9.6.0",
|
||||||
"start-server-and-test": "2.0.11"
|
"ignore-walk": "7.0.0",
|
||||||
|
"postcss": "8.5.3",
|
||||||
|
"start-server-and-test": "2.0.11",
|
||||||
|
"tar": "7.4.3",
|
||||||
|
"terser": "5.39.0",
|
||||||
|
"typescript": "5.8.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@
|
||||||
"@fastify/static": "8.1.1",
|
"@fastify/static": "8.1.1",
|
||||||
"@fastify/view": "10.0.2",
|
"@fastify/view": "10.0.2",
|
||||||
"@misskey-dev/sharp-read-bmp": "1.3.0",
|
"@misskey-dev/sharp-read-bmp": "1.3.0",
|
||||||
"@misskey-dev/summaly": "5.2.1",
|
"@misskey-dev/summaly": "npm:@transfem-org/summaly@5.2.2",
|
||||||
"@nestjs/common": "11.1.0",
|
"@nestjs/common": "11.1.0",
|
||||||
"@nestjs/core": "11.1.0",
|
"@nestjs/core": "11.1.0",
|
||||||
"@nestjs/testing": "11.1.0",
|
"@nestjs/testing": "11.1.0",
|
||||||
|
@ -90,33 +90,30 @@
|
||||||
"@simplewebauthn/server": "12.0.0",
|
"@simplewebauthn/server": "12.0.0",
|
||||||
"@sinonjs/fake-timers": "11.3.1",
|
"@sinonjs/fake-timers": "11.3.1",
|
||||||
"@smithy/node-http-handler": "2.5.0",
|
"@smithy/node-http-handler": "2.5.0",
|
||||||
"@swc/cli": "0.7.3",
|
"mfm-js": "npm:@transfem-org/sfm-js@0.24.6",
|
||||||
"@swc/core": "1.11.24",
|
|
||||||
"@transfem-org/sfm-js": "0.24.6",
|
|
||||||
"@twemoji/parser": "15.1.1",
|
"@twemoji/parser": "15.1.1",
|
||||||
"accepts": "1.3.8",
|
"accepts": "1.3.8",
|
||||||
"ajv": "8.17.1",
|
"ajv": "8.17.1",
|
||||||
"archiver": "7.0.1",
|
"archiver": "7.0.1",
|
||||||
"argon2": "^0.40.1",
|
"argon2": "0.43.0",
|
||||||
"axios": "1.7.4",
|
"axios": "1.7.4",
|
||||||
"async-mutex": "0.5.0",
|
|
||||||
"bcryptjs": "2.4.3",
|
"bcryptjs": "2.4.3",
|
||||||
"blurhash": "2.0.5",
|
"blurhash": "2.0.5",
|
||||||
"body-parser": "1.20.3",
|
|
||||||
"bullmq": "5.51.1",
|
"bullmq": "5.51.1",
|
||||||
"cacheable-lookup": "7.0.0",
|
"cacheable-lookup": "7.0.0",
|
||||||
"canvas": "^3.1.0",
|
"canvas": "3.1.0",
|
||||||
"cbor": "9.0.2",
|
"cbor": "9.0.2",
|
||||||
"chalk": "5.4.1",
|
"chalk": "5.4.1",
|
||||||
"chalk-template": "1.1.0",
|
"chalk-template": "1.1.0",
|
||||||
"cheerio": "1.0.0",
|
"cheerio": "1.0.0",
|
||||||
"chokidar": "3.6.0",
|
"cli-highlight": "npm:@transfem-org/cli-highlight@2.1.12",
|
||||||
"cli-highlight": "2.1.11",
|
|
||||||
"color-convert": "2.0.1",
|
"color-convert": "2.0.1",
|
||||||
"content-disposition": "0.5.4",
|
"content-disposition": "0.5.4",
|
||||||
"date-fns": "2.30.0",
|
"date-fns": "2.30.0",
|
||||||
"deep-email-validator": "0.1.21",
|
"deep-email-validator": "0.1.21",
|
||||||
"fast-xml-parser": "4.4.1",
|
"dom-serializer": "2.0.0",
|
||||||
|
"domhandler": "5.0.3",
|
||||||
|
"domutils": "3.2.2",
|
||||||
"fastify": "5.3.2",
|
"fastify": "5.3.2",
|
||||||
"fastify-raw-body": "5.0.0",
|
"fastify-raw-body": "5.0.0",
|
||||||
"feed": "4.2.2",
|
"feed": "4.2.2",
|
||||||
|
@ -125,10 +122,9 @@
|
||||||
"form-data": "4.0.2",
|
"form-data": "4.0.2",
|
||||||
"glob": "11.0.0",
|
"glob": "11.0.0",
|
||||||
"got": "14.4.7",
|
"got": "14.4.7",
|
||||||
"happy-dom": "16.8.1",
|
|
||||||
"hpagent": "1.2.0",
|
"hpagent": "1.2.0",
|
||||||
"htmlescape": "1.1.1",
|
"htmlescape": "1.1.1",
|
||||||
"http-link-header": "1.1.3",
|
"htmlparser2": "9.1.0",
|
||||||
"ioredis": "5.6.1",
|
"ioredis": "5.6.1",
|
||||||
"ip-cidr": "4.0.2",
|
"ip-cidr": "4.0.2",
|
||||||
"ipaddr.js": "2.2.0",
|
"ipaddr.js": "2.2.0",
|
||||||
|
@ -136,49 +132,39 @@
|
||||||
"js-yaml": "4.1.0",
|
"js-yaml": "4.1.0",
|
||||||
"json5": "2.2.3",
|
"json5": "2.2.3",
|
||||||
"jsonld": "8.3.3",
|
"jsonld": "8.3.3",
|
||||||
"jsrsasign": "11.1.0",
|
|
||||||
"juice": "11.0.1",
|
"juice": "11.0.1",
|
||||||
"megalodon": "workspace:*",
|
"megalodon": "workspace:*",
|
||||||
"meilisearch": "0.50.0",
|
"meilisearch": "0.50.0",
|
||||||
"microformats-parser": "2.0.2",
|
|
||||||
"mime-types": "2.1.35",
|
"mime-types": "2.1.35",
|
||||||
"misskey-js": "workspace:*",
|
"misskey-js": "workspace:*",
|
||||||
"misskey-reversi": "workspace:*",
|
"misskey-reversi": "workspace:*",
|
||||||
"moment": "^2.30.1",
|
"moment": "2.30.1",
|
||||||
"ms": "3.0.0-canary.1",
|
"ms": "3.0.0-canary.1",
|
||||||
"nanoid": "5.1.5",
|
"nanoid": "5.1.5",
|
||||||
"nested-property": "4.0.0",
|
"nested-property": "4.0.0",
|
||||||
"node-fetch": "3.3.2",
|
"node-fetch": "3.3.2",
|
||||||
"nodemailer": "6.10.1",
|
"nodemailer": "6.10.1",
|
||||||
"oauth": "0.10.2",
|
|
||||||
"oauth2orize": "1.12.0",
|
|
||||||
"oauth2orize-pkce": "0.1.2",
|
|
||||||
"os-utils": "0.0.14",
|
"os-utils": "0.0.14",
|
||||||
"otpauth": "9.4.0",
|
"otpauth": "9.4.0",
|
||||||
"parse5": "7.3.0",
|
|
||||||
"pg": "8.15.6",
|
"pg": "8.15.6",
|
||||||
"pkce-challenge": "4.1.0",
|
"pkce-challenge": "4.1.0",
|
||||||
"probe-image-size": "7.2.3",
|
"probe-image-size": "7.2.3",
|
||||||
"promise-limit": "2.7.0",
|
"promise-limit": "2.7.0",
|
||||||
"proxy-addr": "^2.0.7",
|
"proxy-addr": "2.0.7",
|
||||||
"psl": "^1.13.0",
|
"psl": "1.15.0",
|
||||||
"pug": "3.0.3",
|
"pug": "3.0.3",
|
||||||
"qrcode": "1.5.4",
|
"qrcode": "1.5.4",
|
||||||
"random-seed": "0.3.0",
|
"random-seed": "0.3.0",
|
||||||
"ratelimiter": "3.4.1",
|
|
||||||
"re2": "1.21.4",
|
"re2": "1.21.4",
|
||||||
"redis-info": "3.1.0",
|
"redis-info": "3.1.0",
|
||||||
"redis-lock": "0.1.4",
|
"redis-lock": "0.1.4",
|
||||||
"reflect-metadata": "0.2.2",
|
"reflect-metadata": "0.2.2",
|
||||||
"rename": "1.0.4",
|
"rename": "1.0.4",
|
||||||
"rss-parser": "3.13.0",
|
|
||||||
"rxjs": "7.8.2",
|
|
||||||
"sanitize-html": "2.16.0",
|
"sanitize-html": "2.16.0",
|
||||||
"secure-json-parse": "3.0.2",
|
"secure-json-parse": "3.0.2",
|
||||||
"sharp": "0.34.1",
|
"sharp": "0.34.1",
|
||||||
"slacc": "0.0.10",
|
"slacc": "0.0.10",
|
||||||
"strict-event-emitter-types": "2.0.0",
|
"strict-event-emitter-types": "2.0.0",
|
||||||
"stringz": "2.1.0",
|
|
||||||
"systeminformation": "5.25.11",
|
"systeminformation": "5.25.11",
|
||||||
"tinycolor2": "1.6.0",
|
"tinycolor2": "1.6.0",
|
||||||
"tmp": "0.2.3",
|
"tmp": "0.2.3",
|
||||||
|
@ -187,7 +173,7 @@
|
||||||
"typeorm": "0.3.22",
|
"typeorm": "0.3.22",
|
||||||
"typescript": "5.8.3",
|
"typescript": "5.8.3",
|
||||||
"ulid": "2.4.0",
|
"ulid": "2.4.0",
|
||||||
"uuid": "^9.0.1",
|
"uuid": "11.1.0",
|
||||||
"vary": "1.1.2",
|
"vary": "1.1.2",
|
||||||
"web-push": "3.6.7",
|
"web-push": "3.6.7",
|
||||||
"ws": "8.18.1",
|
"ws": "8.18.1",
|
||||||
|
@ -198,16 +184,16 @@
|
||||||
"@nestjs/platform-express": "11.1.0",
|
"@nestjs/platform-express": "11.1.0",
|
||||||
"@sentry/vue": "9.14.0",
|
"@sentry/vue": "9.14.0",
|
||||||
"@simplewebauthn/types": "12.0.0",
|
"@simplewebauthn/types": "12.0.0",
|
||||||
|
"@swc/cli": "0.7.3",
|
||||||
|
"@swc/core": "1.11.24",
|
||||||
"@swc/jest": "0.2.38",
|
"@swc/jest": "0.2.38",
|
||||||
"@types/accepts": "1.3.7",
|
"@types/accepts": "1.3.7",
|
||||||
"@types/archiver": "6.0.3",
|
"@types/archiver": "6.0.3",
|
||||||
"@types/bcryptjs": "2.4.6",
|
"@types/bcryptjs": "2.4.6",
|
||||||
"@types/body-parser": "1.19.5",
|
|
||||||
"@types/color-convert": "2.0.4",
|
"@types/color-convert": "2.0.4",
|
||||||
"@types/content-disposition": "0.5.8",
|
"@types/content-disposition": "0.5.8",
|
||||||
"@types/fluent-ffmpeg": "2.1.27",
|
"@types/fluent-ffmpeg": "2.1.27",
|
||||||
"@types/htmlescape": "1.1.3",
|
"@types/htmlescape": "1.1.3",
|
||||||
"@types/http-link-header": "1.0.7",
|
|
||||||
"@types/jest": "29.5.14",
|
"@types/jest": "29.5.14",
|
||||||
"@types/js-yaml": "4.0.9",
|
"@types/js-yaml": "4.0.9",
|
||||||
"@types/jsonld": "1.5.15",
|
"@types/jsonld": "1.5.15",
|
||||||
|
@ -220,12 +206,11 @@
|
||||||
"@types/oauth2orize": "1.11.5",
|
"@types/oauth2orize": "1.11.5",
|
||||||
"@types/oauth2orize-pkce": "0.1.2",
|
"@types/oauth2orize-pkce": "0.1.2",
|
||||||
"@types/pg": "8.11.14",
|
"@types/pg": "8.11.14",
|
||||||
"@types/proxy-addr": "^2.0.3",
|
"@types/proxy-addr": "2.0.3",
|
||||||
"@types/psl": "^1.1.3",
|
"@types/psl": "1.1.3",
|
||||||
"@types/pug": "2.0.10",
|
"@types/pug": "2.0.10",
|
||||||
"@types/qrcode": "1.5.5",
|
"@types/qrcode": "1.5.5",
|
||||||
"@types/random-seed": "0.3.5",
|
"@types/random-seed": "0.3.5",
|
||||||
"@types/ratelimiter": "3.4.6",
|
|
||||||
"@types/redis-info": "3.0.3",
|
"@types/redis-info": "3.0.3",
|
||||||
"@types/rename": "1.0.7",
|
"@types/rename": "1.0.7",
|
||||||
"@types/sanitize-html": "2.15.0",
|
"@types/sanitize-html": "2.15.0",
|
||||||
|
@ -235,7 +220,6 @@
|
||||||
"@types/supertest": "6.0.3",
|
"@types/supertest": "6.0.3",
|
||||||
"@types/tinycolor2": "1.4.6",
|
"@types/tinycolor2": "1.4.6",
|
||||||
"@types/tmp": "0.2.6",
|
"@types/tmp": "0.2.6",
|
||||||
"@types/uuid": "^9.0.4",
|
|
||||||
"@types/vary": "1.1.3",
|
"@types/vary": "1.1.3",
|
||||||
"@types/web-push": "3.6.4",
|
"@types/web-push": "3.6.4",
|
||||||
"@types/ws": "8.18.1",
|
"@types/ws": "8.18.1",
|
||||||
|
@ -244,7 +228,7 @@
|
||||||
"aws-sdk-client-mock": "4.1.0",
|
"aws-sdk-client-mock": "4.1.0",
|
||||||
"cross-env": "7.0.3",
|
"cross-env": "7.0.3",
|
||||||
"eslint-plugin-import": "2.31.0",
|
"eslint-plugin-import": "2.31.0",
|
||||||
"execa": "8.0.1",
|
"execa": "9.5.2",
|
||||||
"fkill": "9.0.0",
|
"fkill": "9.0.0",
|
||||||
"jest": "29.7.0",
|
"jest": "29.7.0",
|
||||||
"jest-mock": "29.7.0",
|
"jest-mock": "29.7.0",
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { URL } from 'node:url';
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
import tinycolor from 'tinycolor2';
|
import tinycolor from 'tinycolor2';
|
||||||
import * as Redis from 'ioredis';
|
import * as Redis from 'ioredis';
|
||||||
import { load as cheerio } from 'cheerio';
|
import { load as cheerio } from 'cheerio/slim';
|
||||||
import type { MiInstance } from '@/models/Instance.js';
|
import type { MiInstance } from '@/models/Instance.js';
|
||||||
import type Logger from '@/logger.js';
|
import type Logger from '@/logger.js';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
|
@ -16,7 +16,7 @@ import { HttpRequestService } from '@/core/HttpRequestService.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import { FederatedInstanceService } from '@/core/FederatedInstanceService.js';
|
import { FederatedInstanceService } from '@/core/FederatedInstanceService.js';
|
||||||
import { renderInlineError } from '@/misc/render-inline-error.js';
|
import { renderInlineError } from '@/misc/render-inline-error.js';
|
||||||
import type { CheerioAPI } from 'cheerio';
|
import type { CheerioAPI } from 'cheerio/slim';
|
||||||
|
|
||||||
type NodeInfo = {
|
type NodeInfo = {
|
||||||
openRegistrations?: unknown;
|
openRegistrations?: unknown;
|
||||||
|
|
|
@ -5,25 +5,22 @@
|
||||||
|
|
||||||
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 { isText, isTag, Text } from 'domhandler';
|
||||||
import { type Document, type HTMLParagraphElement, Window } from 'happy-dom';
|
import * as htmlparser2 from 'htmlparser2';
|
||||||
|
import { Node, Document, ChildNode, Element, ParentNode } from 'domhandler';
|
||||||
|
import * as domserializer from 'dom-serializer';
|
||||||
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';
|
||||||
import { normalizeForSearch } from '@/misc/normalize-for-search.js';
|
import { normalizeForSearch } from '@/misc/normalize-for-search.js';
|
||||||
import type { IMentionedRemoteUsers } from '@/models/Note.js';
|
import type { IMentionedRemoteUsers } from '@/models/Note.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import type { DefaultTreeAdapterMap } from 'parse5';
|
import type * as mfm from 'mfm-js';
|
||||||
import type * as mfm from '@transfem-org/sfm-js';
|
|
||||||
|
|
||||||
const treeAdapter = parse5.defaultTreeAdapter;
|
|
||||||
type Node = DefaultTreeAdapterMap['node'];
|
|
||||||
type ChildNode = DefaultTreeAdapterMap['childNode'];
|
|
||||||
|
|
||||||
const urlRegex = /^https?:\/\/[\w\/:%#@$&?!()\[\]~.,=+\-]+/;
|
const urlRegex = /^https?:\/\/[\w\/:%#@$&?!()\[\]~.,=+\-]+/;
|
||||||
const urlRegexFull = /^https?:\/\/[\w\/:%#@$&?!()\[\]~.,=+\-]+$/;
|
const urlRegexFull = /^https?:\/\/[\w\/:%#@$&?!()\[\]~.,=+\-]+$/;
|
||||||
|
|
||||||
export type Appender = (document: Document, body: HTMLParagraphElement) => void;
|
export type Appender = (document: Document, body: Element) => void;
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class MfmService {
|
export class MfmService {
|
||||||
|
@ -40,7 +37,7 @@ export class MfmService {
|
||||||
|
|
||||||
const normalizedHashtagNames = hashtagNames == null ? undefined : new Set<string>(hashtagNames.map(x => normalizeForSearch(x)));
|
const normalizedHashtagNames = hashtagNames == null ? undefined : new Set<string>(hashtagNames.map(x => normalizeForSearch(x)));
|
||||||
|
|
||||||
const dom = parse5.parseFragment(html);
|
const dom = htmlparser2.parseDocument(html);
|
||||||
|
|
||||||
let text = '';
|
let text = '';
|
||||||
|
|
||||||
|
@ -51,37 +48,31 @@ export class MfmService {
|
||||||
return text.trim();
|
return text.trim();
|
||||||
|
|
||||||
function getText(node: Node): string {
|
function getText(node: Node): string {
|
||||||
if (treeAdapter.isTextNode(node)) return node.value;
|
if (isText(node)) return node.data;
|
||||||
if (!treeAdapter.isElementNode(node)) return '';
|
if (!isTag(node)) return '';
|
||||||
if (node.nodeName === 'br') return '\n';
|
if (node.tagName === 'br') return '\n';
|
||||||
|
|
||||||
if (node.childNodes) {
|
return node.childNodes.map(n => getText(n)).join('');
|
||||||
return node.childNodes.map(n => getText(n)).join('');
|
|
||||||
}
|
|
||||||
|
|
||||||
return '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function appendChildren(childNodes: ChildNode[]): void {
|
function appendChildren(childNodes: ChildNode[]): void {
|
||||||
if (childNodes) {
|
for (const n of childNodes) {
|
||||||
for (const n of childNodes) {
|
analyze(n);
|
||||||
analyze(n);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function analyze(node: Node) {
|
function analyze(node: Node) {
|
||||||
if (treeAdapter.isTextNode(node)) {
|
if (isText(node)) {
|
||||||
text += node.value;
|
text += node.data;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip comment or document type node
|
// Skip comment or document type node
|
||||||
if (!treeAdapter.isElementNode(node)) {
|
if (!isTag(node)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (node.nodeName) {
|
switch (node.tagName) {
|
||||||
case 'br': {
|
case 'br': {
|
||||||
text += '\n';
|
text += '\n';
|
||||||
break;
|
break;
|
||||||
|
@ -89,19 +80,19 @@ export class MfmService {
|
||||||
|
|
||||||
case 'a': {
|
case 'a': {
|
||||||
const txt = getText(node);
|
const txt = getText(node);
|
||||||
const rel = node.attrs.find(x => x.name === 'rel');
|
const rel = node.attribs.rel;
|
||||||
const href = node.attrs.find(x => x.name === 'href');
|
const href = node.attribs.href;
|
||||||
|
|
||||||
// ハッシュタグ
|
// ハッシュタグ
|
||||||
if (normalizedHashtagNames && href && normalizedHashtagNames.has(normalizeForSearch(txt))) {
|
if (normalizedHashtagNames && href && normalizedHashtagNames.has(normalizeForSearch(txt))) {
|
||||||
text += txt;
|
text += txt;
|
||||||
// メンション
|
// メンション
|
||||||
} else if (txt.startsWith('@') && !(rel && rel.value.startsWith('me '))) {
|
} else if (txt.startsWith('@') && !(rel && rel.startsWith('me '))) {
|
||||||
const part = txt.split('@');
|
const part = txt.split('@');
|
||||||
|
|
||||||
if (part.length === 2 && href) {
|
if (part.length === 2 && href) {
|
||||||
//#region ホスト名部分が省略されているので復元する
|
//#region ホスト名部分が省略されているので復元する
|
||||||
const acct = `${txt}@${(new URL(href.value)).hostname}`;
|
const acct = `${txt}@${(new URL(href)).hostname}`;
|
||||||
text += acct;
|
text += acct;
|
||||||
//#endregion
|
//#endregion
|
||||||
} else if (part.length === 3) {
|
} else if (part.length === 3) {
|
||||||
|
@ -116,17 +107,17 @@ export class MfmService {
|
||||||
if (!href) {
|
if (!href) {
|
||||||
return txt;
|
return txt;
|
||||||
}
|
}
|
||||||
if (!txt || txt === href.value) { // #6383: Missing text node
|
if (!txt || txt === href) { // #6383: Missing text node
|
||||||
if (href.value.match(urlRegexFull)) {
|
if (href.match(urlRegexFull)) {
|
||||||
return href.value;
|
return href;
|
||||||
} else {
|
} else {
|
||||||
return `<${href.value}>`;
|
return `<${href}>`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (href.value.match(urlRegex) && !href.value.match(urlRegexFull)) {
|
if (href.match(urlRegex) && !href.match(urlRegexFull)) {
|
||||||
return `[${txt}](<${href.value}>)`; // #6846
|
return `[${txt}](<${href}>)`; // #6846
|
||||||
} else {
|
} else {
|
||||||
return `[${txt}](${href.value})`;
|
return `[${txt}](${href})`;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -185,14 +176,17 @@ export class MfmService {
|
||||||
case 'ruby--': {
|
case 'ruby--': {
|
||||||
let ruby: [string, string][] = [];
|
let ruby: [string, string][] = [];
|
||||||
for (const child of node.childNodes) {
|
for (const child of node.childNodes) {
|
||||||
if (child.nodeName === 'rp') {
|
if (isText(child) && !/\s|\[|\]/.test(child.data)) {
|
||||||
|
ruby.push([child.data, '']);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (treeAdapter.isTextNode(child) && !/\s|\[|\]/.test(child.value)) {
|
if (!isTag(child)) {
|
||||||
ruby.push([child.value, '']);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (child.nodeName === 'rt' && ruby.length > 0) {
|
if (child.tagName === 'rp') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (child.tagName === 'rt' && ruby.length > 0) {
|
||||||
const rt = getText(child);
|
const rt = getText(child);
|
||||||
if (/\s|\[|\]/.test(rt)) {
|
if (/\s|\[|\]/.test(rt)) {
|
||||||
// If any space is included in rt, it is treated as a normal text
|
// If any space is included in rt, it is treated as a normal text
|
||||||
|
@ -217,7 +211,7 @@ export class MfmService {
|
||||||
|
|
||||||
// block code (<pre><code>)
|
// block code (<pre><code>)
|
||||||
case 'pre': {
|
case 'pre': {
|
||||||
if (node.childNodes.length === 1 && node.childNodes[0].nodeName === 'code') {
|
if (node.childNodes.length === 1 && isTag(node.childNodes[0]) && node.childNodes[0].tagName === 'code') {
|
||||||
text += '\n```\n';
|
text += '\n```\n';
|
||||||
text += getText(node.childNodes[0]);
|
text += getText(node.childNodes[0]);
|
||||||
text += '\n```\n';
|
text += '\n```\n';
|
||||||
|
@ -302,17 +296,17 @@ export class MfmService {
|
||||||
let nonRtNodes = [];
|
let nonRtNodes = [];
|
||||||
// scan children, ignore `rp`, split on `rt`
|
// scan children, ignore `rp`, split on `rt`
|
||||||
for (const child of node.childNodes) {
|
for (const child of node.childNodes) {
|
||||||
if (treeAdapter.isTextNode(child)) {
|
if (isText(child)) {
|
||||||
nonRtNodes.push(child);
|
nonRtNodes.push(child);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!treeAdapter.isElementNode(child)) {
|
if (!isTag(child)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (child.nodeName === 'rp') {
|
if (child.tagName === 'rp') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (child.nodeName === 'rt') {
|
if (child.tagName === 'rt') {
|
||||||
// the only case in which we don't need a `$[group ]`
|
// the only case in which we don't need a `$[group ]`
|
||||||
// is when both sides of the ruby are simple words
|
// is when both sides of the ruby are simple words
|
||||||
const needsGroup = nonRtNodes.length > 1 ||
|
const needsGroup = nonRtNodes.length > 1 ||
|
||||||
|
@ -350,45 +344,44 @@ export class MfmService {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { happyDOM, window } = new Window();
|
const doc = new Document([]);
|
||||||
|
|
||||||
const doc = window.document;
|
const body = new Element('p', {});
|
||||||
|
doc.childNodes.push(body);
|
||||||
|
|
||||||
const body = doc.createElement('p');
|
function appendChildren(children: mfm.MfmNode[], targetElement: ParentNode): void {
|
||||||
|
for (const child of children.map(x => handle(x))) {
|
||||||
function appendChildren(children: mfm.MfmNode[], targetElement: any): void {
|
targetElement.childNodes.push(child);
|
||||||
if (children) {
|
|
||||||
for (const child of children.map(x => (handlers as any)[x.type](x))) targetElement.appendChild(child);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function fnDefault(node: mfm.MfmFn) {
|
function fnDefault(node: mfm.MfmFn) {
|
||||||
const el = doc.createElement('i');
|
const el = new Element('i', {});
|
||||||
appendChildren(node.children, el);
|
appendChildren(node.children, el);
|
||||||
return el;
|
return el;
|
||||||
}
|
}
|
||||||
|
|
||||||
const handlers: { [K in mfm.MfmNode['type']]: (node: mfm.NodeType<K>) => any } = {
|
const handlers: { [K in mfm.MfmNode['type']]: (node: mfm.NodeType<K>) => ChildNode } = {
|
||||||
bold: (node) => {
|
bold: (node) => {
|
||||||
const el = doc.createElement('b');
|
const el = new Element('b', {});
|
||||||
appendChildren(node.children, el);
|
appendChildren(node.children, el);
|
||||||
return el;
|
return el;
|
||||||
},
|
},
|
||||||
|
|
||||||
small: (node) => {
|
small: (node) => {
|
||||||
const el = doc.createElement('small');
|
const el = new Element('small', {});
|
||||||
appendChildren(node.children, el);
|
appendChildren(node.children, el);
|
||||||
return el;
|
return el;
|
||||||
},
|
},
|
||||||
|
|
||||||
strike: (node) => {
|
strike: (node) => {
|
||||||
const el = doc.createElement('del');
|
const el = new Element('del', {});
|
||||||
appendChildren(node.children, el);
|
appendChildren(node.children, el);
|
||||||
return el;
|
return el;
|
||||||
},
|
},
|
||||||
|
|
||||||
italic: (node) => {
|
italic: (node) => {
|
||||||
const el = doc.createElement('i');
|
const el = new Element('i', {});
|
||||||
appendChildren(node.children, el);
|
appendChildren(node.children, el);
|
||||||
return el;
|
return el;
|
||||||
},
|
},
|
||||||
|
@ -399,11 +392,12 @@ export class MfmService {
|
||||||
const text = node.children[0].type === 'text' ? node.children[0].props.text : '';
|
const text = node.children[0].type === 'text' ? node.children[0].props.text : '';
|
||||||
try {
|
try {
|
||||||
const date = new Date(parseInt(text, 10) * 1000);
|
const date = new Date(parseInt(text, 10) * 1000);
|
||||||
const el = doc.createElement('time');
|
const el = new Element('time', {
|
||||||
el.setAttribute('datetime', date.toISOString());
|
datetime: date.toISOString(),
|
||||||
el.textContent = date.toISOString();
|
});
|
||||||
|
el.childNodes.push(new Text(date.toISOString()));
|
||||||
return el;
|
return el;
|
||||||
} catch (err) {
|
} catch {
|
||||||
return fnDefault(node);
|
return fnDefault(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -412,20 +406,20 @@ export class MfmService {
|
||||||
if (node.children.length === 1) {
|
if (node.children.length === 1) {
|
||||||
const child = node.children[0];
|
const child = node.children[0];
|
||||||
const text = child.type === 'text' ? child.props.text : '';
|
const text = child.type === 'text' ? child.props.text : '';
|
||||||
const rubyEl = doc.createElement('ruby');
|
const rubyEl = new Element('ruby', {});
|
||||||
const rtEl = doc.createElement('rt');
|
const rtEl = new Element('rt', {});
|
||||||
|
|
||||||
// ruby未対応のHTMLサニタイザーを通したときにルビが「劉備(りゅうび)」となるようにする
|
// ruby未対応のHTMLサニタイザーを通したときにルビが「劉備(りゅうび)」となるようにする
|
||||||
const rpStartEl = doc.createElement('rp');
|
const rpStartEl = new Element('rp', {});
|
||||||
rpStartEl.appendChild(doc.createTextNode('('));
|
rpStartEl.childNodes.push(new Text('('));
|
||||||
const rpEndEl = doc.createElement('rp');
|
const rpEndEl = new Element('rp', {});
|
||||||
rpEndEl.appendChild(doc.createTextNode(')'));
|
rpEndEl.childNodes.push(new Text(')'));
|
||||||
|
|
||||||
rubyEl.appendChild(doc.createTextNode(text.split(' ')[0]));
|
rubyEl.childNodes.push(new Text(text.split(' ')[0]));
|
||||||
rtEl.appendChild(doc.createTextNode(text.split(' ')[1]));
|
rtEl.childNodes.push(new Text(text.split(' ')[1]));
|
||||||
rubyEl.appendChild(rpStartEl);
|
rubyEl.childNodes.push(rpStartEl);
|
||||||
rubyEl.appendChild(rtEl);
|
rubyEl.childNodes.push(rtEl);
|
||||||
rubyEl.appendChild(rpEndEl);
|
rubyEl.childNodes.push(rpEndEl);
|
||||||
return rubyEl;
|
return rubyEl;
|
||||||
} else {
|
} else {
|
||||||
const rt = node.children.at(-1);
|
const rt = node.children.at(-1);
|
||||||
|
@ -435,20 +429,20 @@ export class MfmService {
|
||||||
}
|
}
|
||||||
|
|
||||||
const text = rt.type === 'text' ? rt.props.text : '';
|
const text = rt.type === 'text' ? rt.props.text : '';
|
||||||
const rubyEl = doc.createElement('ruby');
|
const rubyEl = new Element('ruby', {});
|
||||||
const rtEl = doc.createElement('rt');
|
const rtEl = new Element('rt', {});
|
||||||
|
|
||||||
// ruby未対応のHTMLサニタイザーを通したときにルビが「劉備(りゅうび)」となるようにする
|
// ruby未対応のHTMLサニタイザーを通したときにルビが「劉備(りゅうび)」となるようにする
|
||||||
const rpStartEl = doc.createElement('rp');
|
const rpStartEl = new Element('rp', {});
|
||||||
rpStartEl.appendChild(doc.createTextNode('('));
|
rpStartEl.childNodes.push(new Text('('));
|
||||||
const rpEndEl = doc.createElement('rp');
|
const rpEndEl = new Element('rp', {});
|
||||||
rpEndEl.appendChild(doc.createTextNode(')'));
|
rpEndEl.childNodes.push(new Text(')'));
|
||||||
|
|
||||||
appendChildren(node.children.slice(0, node.children.length - 1), rubyEl);
|
appendChildren(node.children.slice(0, node.children.length - 1), rubyEl);
|
||||||
rtEl.appendChild(doc.createTextNode(text.trim()));
|
rtEl.childNodes.push(new Text(text.trim()));
|
||||||
rubyEl.appendChild(rpStartEl);
|
rubyEl.childNodes.push(rpStartEl);
|
||||||
rubyEl.appendChild(rtEl);
|
rubyEl.childNodes.push(rtEl);
|
||||||
rubyEl.appendChild(rpEndEl);
|
rubyEl.childNodes.push(rpEndEl);
|
||||||
return rubyEl;
|
return rubyEl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -456,7 +450,7 @@ export class MfmService {
|
||||||
// hack for ruby, should never be needed because we should
|
// hack for ruby, should never be needed because we should
|
||||||
// never send this out to other instances
|
// never send this out to other instances
|
||||||
case 'group': {
|
case 'group': {
|
||||||
const el = doc.createElement('span');
|
const el = new Element('span', {});
|
||||||
appendChildren(node.children, el);
|
appendChildren(node.children, el);
|
||||||
return el;
|
return el;
|
||||||
}
|
}
|
||||||
|
@ -468,125 +462,135 @@ export class MfmService {
|
||||||
},
|
},
|
||||||
|
|
||||||
blockCode: (node) => {
|
blockCode: (node) => {
|
||||||
const pre = doc.createElement('pre');
|
const pre = new Element('pre', {});
|
||||||
const inner = doc.createElement('code');
|
const inner = new Element('code', {});
|
||||||
inner.textContent = node.props.code;
|
inner.childNodes.push(new Text(node.props.code));
|
||||||
pre.appendChild(inner);
|
pre.childNodes.push(inner);
|
||||||
return pre;
|
return pre;
|
||||||
},
|
},
|
||||||
|
|
||||||
center: (node) => {
|
center: (node) => {
|
||||||
const el = doc.createElement('div');
|
const el = new Element('div', {});
|
||||||
appendChildren(node.children, el);
|
appendChildren(node.children, el);
|
||||||
return el;
|
return el;
|
||||||
},
|
},
|
||||||
|
|
||||||
emojiCode: (node) => {
|
emojiCode: (node) => {
|
||||||
return doc.createTextNode(`\u200B:${node.props.name}:\u200B`);
|
return new Text(`\u200B:${node.props.name}:\u200B`);
|
||||||
},
|
},
|
||||||
|
|
||||||
unicodeEmoji: (node) => {
|
unicodeEmoji: (node) => {
|
||||||
return doc.createTextNode(node.props.emoji);
|
return new Text(node.props.emoji);
|
||||||
},
|
},
|
||||||
|
|
||||||
hashtag: (node) => {
|
hashtag: (node) => {
|
||||||
const a = doc.createElement('a');
|
const a = new Element('a', {
|
||||||
a.setAttribute('href', `${this.config.url}/tags/${node.props.hashtag}`);
|
href: `${this.config.url}/tags/${node.props.hashtag}`,
|
||||||
a.textContent = `#${node.props.hashtag}`;
|
rel: 'tag',
|
||||||
a.setAttribute('rel', 'tag');
|
});
|
||||||
|
a.childNodes.push(new Text(`#${node.props.hashtag}`));
|
||||||
return a;
|
return a;
|
||||||
},
|
},
|
||||||
|
|
||||||
inlineCode: (node) => {
|
inlineCode: (node) => {
|
||||||
const el = doc.createElement('code');
|
const el = new Element('code', {});
|
||||||
el.textContent = node.props.code;
|
el.childNodes.push(new Text(node.props.code));
|
||||||
return el;
|
return el;
|
||||||
},
|
},
|
||||||
|
|
||||||
mathInline: (node) => {
|
mathInline: (node) => {
|
||||||
const el = doc.createElement('code');
|
const el = new Element('code', {});
|
||||||
el.textContent = node.props.formula;
|
el.childNodes.push(new Text(node.props.formula));
|
||||||
return el;
|
return el;
|
||||||
},
|
},
|
||||||
|
|
||||||
mathBlock: (node) => {
|
mathBlock: (node) => {
|
||||||
const el = doc.createElement('code');
|
const el = new Element('code', {});
|
||||||
el.textContent = node.props.formula;
|
el.childNodes.push(new Text(node.props.formula));
|
||||||
return el;
|
return el;
|
||||||
},
|
},
|
||||||
|
|
||||||
link: (node) => {
|
link: (node) => {
|
||||||
const a = doc.createElement('a');
|
const a = new Element('a', {
|
||||||
a.setAttribute('href', node.props.url);
|
href: node.props.url,
|
||||||
|
});
|
||||||
appendChildren(node.children, a);
|
appendChildren(node.children, a);
|
||||||
return a;
|
return a;
|
||||||
},
|
},
|
||||||
|
|
||||||
mention: (node) => {
|
mention: (node) => {
|
||||||
const a = doc.createElement('a');
|
|
||||||
const { username, host, acct } = node.props;
|
const { username, host, acct } = node.props;
|
||||||
const remoteUserInfo = mentionedRemoteUsers.find(remoteUser => remoteUser.username.toLowerCase() === username.toLowerCase() && remoteUser.host?.toLowerCase() === host?.toLowerCase());
|
const remoteUserInfo = mentionedRemoteUsers.find(remoteUser => remoteUser.username.toLowerCase() === username.toLowerCase() && remoteUser.host?.toLowerCase() === host?.toLowerCase());
|
||||||
a.setAttribute('href', remoteUserInfo
|
|
||||||
? (remoteUserInfo.url ? remoteUserInfo.url : remoteUserInfo.uri)
|
const a = new Element('a', {
|
||||||
: `${this.config.url}/${acct.endsWith(`@${this.config.url}`) ? acct.substring(0, acct.length - this.config.url.length - 1) : acct}`);
|
href: remoteUserInfo
|
||||||
a.className = 'u-url mention';
|
? (remoteUserInfo.url ? remoteUserInfo.url : remoteUserInfo.uri)
|
||||||
a.textContent = acct;
|
: `${this.config.url}/${acct.endsWith(`@${this.config.url}`) ? acct.substring(0, acct.length - this.config.url.length - 1) : acct}`,
|
||||||
|
class: 'u-url mention',
|
||||||
|
});
|
||||||
|
a.childNodes.push(new Text(acct));
|
||||||
return a;
|
return a;
|
||||||
},
|
},
|
||||||
|
|
||||||
quote: (node) => {
|
quote: (node) => {
|
||||||
const el = doc.createElement('blockquote');
|
const el = new Element('blockquote', {});
|
||||||
appendChildren(node.children, el);
|
appendChildren(node.children, el);
|
||||||
return el;
|
return el;
|
||||||
},
|
},
|
||||||
|
|
||||||
text: (node) => {
|
text: (node) => {
|
||||||
if (!node.props.text.match(/[\r\n]/)) {
|
if (!node.props.text.match(/[\r\n]/)) {
|
||||||
return doc.createTextNode(node.props.text);
|
return new Text(node.props.text);
|
||||||
}
|
}
|
||||||
|
|
||||||
const el = doc.createElement('span');
|
const el = new Element('span', {});
|
||||||
const nodes = node.props.text.split(/\r\n|\r|\n/).map(x => doc.createTextNode(x));
|
const nodes = node.props.text.split(/\r\n|\r|\n/).map(x => new Text(x));
|
||||||
|
|
||||||
for (const x of intersperse<FIXME | 'br'>('br', nodes)) {
|
for (const x of intersperse<FIXME | 'br'>('br', nodes)) {
|
||||||
el.appendChild(x === 'br' ? doc.createElement('br') : x);
|
el.childNodes.push(x === 'br' ? new Element('br', {}) : x);
|
||||||
}
|
}
|
||||||
|
|
||||||
return el;
|
return el;
|
||||||
},
|
},
|
||||||
|
|
||||||
url: (node) => {
|
url: (node) => {
|
||||||
const a = doc.createElement('a');
|
const a = new Element('a', {
|
||||||
a.setAttribute('href', node.props.url);
|
href: node.props.url,
|
||||||
a.textContent = node.props.url;
|
});
|
||||||
|
a.childNodes.push(new Text(node.props.url));
|
||||||
return a;
|
return a;
|
||||||
},
|
},
|
||||||
|
|
||||||
search: (node) => {
|
search: (node) => {
|
||||||
const a = doc.createElement('a');
|
const a = new Element('a', {
|
||||||
a.setAttribute('href', `https://www.google.com/search?q=${node.props.query}`);
|
href: `https://www.google.com/search?q=${node.props.query}`,
|
||||||
a.textContent = node.props.content;
|
});
|
||||||
|
a.childNodes.push(new Text(node.props.content));
|
||||||
return a;
|
return a;
|
||||||
},
|
},
|
||||||
|
|
||||||
plain: (node) => {
|
plain: (node) => {
|
||||||
const el = doc.createElement('span');
|
const el = new Element('span', {});
|
||||||
appendChildren(node.children, el);
|
appendChildren(node.children, el);
|
||||||
return el;
|
return el;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Utility function to make TypeScript behave
|
||||||
|
function handle<T extends mfm.MfmNode>(node: T): ChildNode {
|
||||||
|
const handler = handlers[node.type] as (node: T) => ChildNode;
|
||||||
|
return handler(node);
|
||||||
|
}
|
||||||
|
|
||||||
appendChildren(nodes, body);
|
appendChildren(nodes, body);
|
||||||
|
|
||||||
for (const additionalAppender of additionalAppenders) {
|
for (const additionalAppender of additionalAppenders) {
|
||||||
additionalAppender(doc, body);
|
additionalAppender(doc, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
const serialized = body.outerHTML;
|
return domserializer.render(body, {
|
||||||
|
encodeEntities: 'utf8'
|
||||||
happyDOM.close().catch(err => {});
|
});
|
||||||
|
|
||||||
return serialized;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// the toMastoApiHtml function was taken from Iceshrimp and written by zotan and modified by marie to work with the current MK version
|
// the toMastoApiHtml function was taken from Iceshrimp and written by zotan and modified by marie to work with the current MK version
|
||||||
|
@ -598,55 +602,55 @@ export class MfmService {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { happyDOM, window } = new Window();
|
const doc = new Document([]);
|
||||||
|
|
||||||
const doc = window.document;
|
const body = new Element('p', {});
|
||||||
|
doc.childNodes.push(body);
|
||||||
|
|
||||||
const body = doc.createElement('p');
|
function appendChildren(children: mfm.MfmNode[], targetElement: ParentNode): void {
|
||||||
|
for (const child of children) {
|
||||||
function appendChildren(children: mfm.MfmNode[], targetElement: any): void {
|
const result = handle(child);
|
||||||
if (children) {
|
targetElement.childNodes.push(result);
|
||||||
for (const child of children.map((x) => (handlers as any)[x.type](x))) targetElement.appendChild(child);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const handlers: {
|
const handlers: {
|
||||||
[K in mfm.MfmNode['type']]: (node: mfm.NodeType<K>) => any;
|
[K in mfm.MfmNode['type']]: (node: mfm.NodeType<K>) => ChildNode;
|
||||||
} = {
|
} = {
|
||||||
bold(node) {
|
bold(node) {
|
||||||
const el = doc.createElement('span');
|
const el = new Element('span', {});
|
||||||
el.textContent = '**';
|
el.childNodes.push(new Text('**'));
|
||||||
appendChildren(node.children, el);
|
appendChildren(node.children, el);
|
||||||
el.textContent += '**';
|
el.childNodes.push(new Text('**'));
|
||||||
return el;
|
return el;
|
||||||
},
|
},
|
||||||
|
|
||||||
small(node) {
|
small(node) {
|
||||||
const el = doc.createElement('small');
|
const el = new Element('small', {});
|
||||||
appendChildren(node.children, el);
|
appendChildren(node.children, el);
|
||||||
return el;
|
return el;
|
||||||
},
|
},
|
||||||
|
|
||||||
strike(node) {
|
strike(node) {
|
||||||
const el = doc.createElement('span');
|
const el = new Element('span', {});
|
||||||
el.textContent = '~~';
|
el.childNodes.push(new Text('~~'));
|
||||||
appendChildren(node.children, el);
|
appendChildren(node.children, el);
|
||||||
el.textContent += '~~';
|
el.childNodes.push(new Text('~~'));
|
||||||
return el;
|
return el;
|
||||||
},
|
},
|
||||||
|
|
||||||
italic(node) {
|
italic(node) {
|
||||||
const el = doc.createElement('span');
|
const el = new Element('span', {});
|
||||||
el.textContent = '*';
|
el.childNodes.push(new Text('*'));
|
||||||
appendChildren(node.children, el);
|
appendChildren(node.children, el);
|
||||||
el.textContent += '*';
|
el.childNodes.push(new Text('*'));
|
||||||
return el;
|
return el;
|
||||||
},
|
},
|
||||||
|
|
||||||
fn(node) {
|
fn(node) {
|
||||||
switch (node.props.name) {
|
switch (node.props.name) {
|
||||||
case 'group': { // hack for ruby
|
case 'group': { // hack for ruby
|
||||||
const el = doc.createElement('span');
|
const el = new Element('span', {});
|
||||||
appendChildren(node.children, el);
|
appendChildren(node.children, el);
|
||||||
return el;
|
return el;
|
||||||
}
|
}
|
||||||
|
@ -654,119 +658,121 @@ export class MfmService {
|
||||||
if (node.children.length === 1) {
|
if (node.children.length === 1) {
|
||||||
const child = node.children[0];
|
const child = node.children[0];
|
||||||
const text = child.type === 'text' ? child.props.text : '';
|
const text = child.type === 'text' ? child.props.text : '';
|
||||||
const rubyEl = doc.createElement('ruby');
|
const rubyEl = new Element('ruby', {});
|
||||||
const rtEl = doc.createElement('rt');
|
const rtEl = new Element('rt', {});
|
||||||
|
|
||||||
const rpStartEl = doc.createElement('rp');
|
const rpStartEl = new Element('rp', {});
|
||||||
rpStartEl.appendChild(doc.createTextNode('('));
|
rpStartEl.childNodes.push(new Text('('));
|
||||||
const rpEndEl = doc.createElement('rp');
|
const rpEndEl = new Element('rp', {});
|
||||||
rpEndEl.appendChild(doc.createTextNode(')'));
|
rpEndEl.childNodes.push(new Text(')'));
|
||||||
|
|
||||||
rubyEl.appendChild(doc.createTextNode(text.split(' ')[0]));
|
rubyEl.childNodes.push(new Text(text.split(' ')[0]));
|
||||||
rtEl.appendChild(doc.createTextNode(text.split(' ')[1]));
|
rtEl.childNodes.push(new Text(text.split(' ')[1]));
|
||||||
rubyEl.appendChild(rpStartEl);
|
rubyEl.childNodes.push(rpStartEl);
|
||||||
rubyEl.appendChild(rtEl);
|
rubyEl.childNodes.push(rtEl);
|
||||||
rubyEl.appendChild(rpEndEl);
|
rubyEl.childNodes.push(rpEndEl);
|
||||||
return rubyEl;
|
return rubyEl;
|
||||||
} else {
|
} else {
|
||||||
const rt = node.children.at(-1);
|
const rt = node.children.at(-1);
|
||||||
|
|
||||||
if (!rt) {
|
if (!rt) {
|
||||||
const el = doc.createElement('span');
|
const el = new Element('span', {});
|
||||||
appendChildren(node.children, el);
|
appendChildren(node.children, el);
|
||||||
return el;
|
return el;
|
||||||
}
|
}
|
||||||
|
|
||||||
const text = rt.type === 'text' ? rt.props.text : '';
|
const text = rt.type === 'text' ? rt.props.text : '';
|
||||||
const rubyEl = doc.createElement('ruby');
|
const rubyEl = new Element('ruby', {});
|
||||||
const rtEl = doc.createElement('rt');
|
const rtEl = new Element('rt', {});
|
||||||
|
|
||||||
const rpStartEl = doc.createElement('rp');
|
const rpStartEl = new Element('rp', {});
|
||||||
rpStartEl.appendChild(doc.createTextNode('('));
|
rpStartEl.childNodes.push(new Text('('));
|
||||||
const rpEndEl = doc.createElement('rp');
|
const rpEndEl = new Element('rp', {});
|
||||||
rpEndEl.appendChild(doc.createTextNode(')'));
|
rpEndEl.childNodes.push(new Text(')'));
|
||||||
|
|
||||||
appendChildren(node.children.slice(0, node.children.length - 1), rubyEl);
|
appendChildren(node.children.slice(0, node.children.length - 1), rubyEl);
|
||||||
rtEl.appendChild(doc.createTextNode(text.trim()));
|
rtEl.childNodes.push(new Text(text.trim()));
|
||||||
rubyEl.appendChild(rpStartEl);
|
rubyEl.childNodes.push(rpStartEl);
|
||||||
rubyEl.appendChild(rtEl);
|
rubyEl.childNodes.push(rtEl);
|
||||||
rubyEl.appendChild(rpEndEl);
|
rubyEl.childNodes.push(rpEndEl);
|
||||||
return rubyEl;
|
return rubyEl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
const el = doc.createElement('span');
|
const el = new Element('span', {});
|
||||||
el.textContent = '*';
|
el.childNodes.push(new Text('*'));
|
||||||
appendChildren(node.children, el);
|
appendChildren(node.children, el);
|
||||||
el.textContent += '*';
|
el.childNodes.push(new Text('*'));
|
||||||
return el;
|
return el;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
blockCode(node) {
|
blockCode(node) {
|
||||||
const pre = doc.createElement('pre');
|
const pre = new Element('pre', {});
|
||||||
const inner = doc.createElement('code');
|
const inner = new Element('code', {});
|
||||||
|
|
||||||
const nodes = node.props.code
|
const nodes = node.props.code
|
||||||
.split(/\r\n|\r|\n/)
|
.split(/\r\n|\r|\n/)
|
||||||
.map((x) => doc.createTextNode(x));
|
.map((x) => new Text(x));
|
||||||
|
|
||||||
for (const x of intersperse<FIXME | 'br'>('br', nodes)) {
|
for (const x of intersperse<FIXME | 'br'>('br', nodes)) {
|
||||||
inner.appendChild(x === 'br' ? doc.createElement('br') : x);
|
inner.childNodes.push(x === 'br' ? new Element('br', {}) : x);
|
||||||
}
|
}
|
||||||
|
|
||||||
pre.appendChild(inner);
|
pre.childNodes.push(inner);
|
||||||
return pre;
|
return pre;
|
||||||
},
|
},
|
||||||
|
|
||||||
center(node) {
|
center(node) {
|
||||||
const el = doc.createElement('div');
|
const el = new Element('div', {});
|
||||||
appendChildren(node.children, el);
|
appendChildren(node.children, el);
|
||||||
return el;
|
return el;
|
||||||
},
|
},
|
||||||
|
|
||||||
emojiCode(node) {
|
emojiCode(node) {
|
||||||
return doc.createTextNode(`\u200B:${node.props.name}:\u200B`);
|
return new Text(`\u200B:${node.props.name}:\u200B`);
|
||||||
},
|
},
|
||||||
|
|
||||||
unicodeEmoji(node) {
|
unicodeEmoji(node) {
|
||||||
return doc.createTextNode(node.props.emoji);
|
return new Text(node.props.emoji);
|
||||||
},
|
},
|
||||||
|
|
||||||
hashtag: (node) => {
|
hashtag: (node) => {
|
||||||
const a = doc.createElement('a');
|
const a = new Element('a', {
|
||||||
a.setAttribute('href', `${this.config.url}/tags/${node.props.hashtag}`);
|
href: `${this.config.url}/tags/${node.props.hashtag}`,
|
||||||
a.textContent = `#${node.props.hashtag}`;
|
rel: 'tag',
|
||||||
a.setAttribute('rel', 'tag');
|
class: 'hashtag',
|
||||||
a.setAttribute('class', 'hashtag');
|
});
|
||||||
|
a.childNodes.push(new Text(`#${node.props.hashtag}`));
|
||||||
return a;
|
return a;
|
||||||
},
|
},
|
||||||
|
|
||||||
inlineCode(node) {
|
inlineCode(node) {
|
||||||
const el = doc.createElement('code');
|
const el = new Element('code', {});
|
||||||
el.textContent = node.props.code;
|
el.childNodes.push(new Text(node.props.code));
|
||||||
return el;
|
return el;
|
||||||
},
|
},
|
||||||
|
|
||||||
mathInline(node) {
|
mathInline(node) {
|
||||||
const el = doc.createElement('code');
|
const el = new Element('code', {});
|
||||||
el.textContent = node.props.formula;
|
el.childNodes.push(new Text(node.props.formula));
|
||||||
return el;
|
return el;
|
||||||
},
|
},
|
||||||
|
|
||||||
mathBlock(node) {
|
mathBlock(node) {
|
||||||
const el = doc.createElement('code');
|
const el = new Element('code', {});
|
||||||
el.textContent = node.props.formula;
|
el.childNodes.push(new Text(node.props.formula));
|
||||||
return el;
|
return el;
|
||||||
},
|
},
|
||||||
|
|
||||||
link(node) {
|
link(node) {
|
||||||
const a = doc.createElement('a');
|
const a = new Element('a', {
|
||||||
a.setAttribute('rel', 'nofollow noopener noreferrer');
|
rel: 'nofollow noopener noreferrer',
|
||||||
a.setAttribute('target', '_blank');
|
target: '_blank',
|
||||||
a.setAttribute('href', node.props.url);
|
href: node.props.url,
|
||||||
|
});
|
||||||
appendChildren(node.children, a);
|
appendChildren(node.children, a);
|
||||||
return a;
|
return a;
|
||||||
},
|
},
|
||||||
|
@ -775,92 +781,107 @@ export class MfmService {
|
||||||
const { username, host, acct } = node.props;
|
const { username, host, acct } = node.props;
|
||||||
const resolved = mentionedRemoteUsers.find(remoteUser => remoteUser.username === username && remoteUser.host === host);
|
const resolved = mentionedRemoteUsers.find(remoteUser => remoteUser.username === username && remoteUser.host === host);
|
||||||
|
|
||||||
const el = doc.createElement('span');
|
const el = new Element('span', {});
|
||||||
if (!resolved) {
|
if (!resolved) {
|
||||||
el.textContent = acct;
|
el.childNodes.push(new Text(acct));
|
||||||
} else {
|
} else {
|
||||||
el.setAttribute('class', 'h-card');
|
el.attribs.class = 'h-card';
|
||||||
el.setAttribute('translate', 'no');
|
el.attribs.translate = 'no';
|
||||||
const a = doc.createElement('a');
|
const a = new Element('a', {
|
||||||
a.setAttribute('href', resolved.url ? resolved.url : resolved.uri);
|
href: resolved.url ? resolved.url : resolved.uri,
|
||||||
a.className = 'u-url mention';
|
class: 'u-url mention',
|
||||||
const span = doc.createElement('span');
|
});
|
||||||
span.textContent = resolved.username || username;
|
const span = new Element('span', {});
|
||||||
a.textContent = '@';
|
span.childNodes.push(new Text(resolved.username || username));
|
||||||
a.appendChild(span);
|
a.childNodes.push(new Text('@'));
|
||||||
el.appendChild(a);
|
a.childNodes.push(span);
|
||||||
|
el.childNodes.push(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
return el;
|
return el;
|
||||||
},
|
},
|
||||||
|
|
||||||
quote(node) {
|
quote(node) {
|
||||||
const el = doc.createElement('blockquote');
|
const el = new Element('blockquote', {});
|
||||||
appendChildren(node.children, el);
|
appendChildren(node.children, el);
|
||||||
return el;
|
return el;
|
||||||
},
|
},
|
||||||
|
|
||||||
text(node) {
|
text(node) {
|
||||||
const el = doc.createElement('span');
|
if (!node.props.text.match(/[\r\n]/)) {
|
||||||
|
return new Text(node.props.text);
|
||||||
|
}
|
||||||
|
|
||||||
|
const el = new Element('span', {});
|
||||||
const nodes = node.props.text
|
const nodes = node.props.text
|
||||||
.split(/\r\n|\r|\n/)
|
.split(/\r\n|\r|\n/)
|
||||||
.map((x) => doc.createTextNode(x));
|
.map((x) => new Text(x));
|
||||||
|
|
||||||
for (const x of intersperse<FIXME | 'br'>('br', nodes)) {
|
for (const x of intersperse<FIXME | 'br'>('br', nodes)) {
|
||||||
el.appendChild(x === 'br' ? doc.createElement('br') : x);
|
el.childNodes.push(x === 'br' ? new Element('br', {}) : x);
|
||||||
}
|
}
|
||||||
|
|
||||||
return el;
|
return el;
|
||||||
},
|
},
|
||||||
|
|
||||||
url(node) {
|
url(node) {
|
||||||
const a = doc.createElement('a');
|
const a = new Element('a', {
|
||||||
a.setAttribute('rel', 'nofollow noopener noreferrer');
|
rel: 'nofollow noopener noreferrer',
|
||||||
a.setAttribute('target', '_blank');
|
target: '_blank',
|
||||||
a.setAttribute('href', node.props.url);
|
href: node.props.url,
|
||||||
a.textContent = node.props.url.replace(/^https?:\/\//, '');
|
});
|
||||||
|
a.childNodes.push(new Text(node.props.url.replace(/^https?:\/\//, '')));
|
||||||
return a;
|
return a;
|
||||||
},
|
},
|
||||||
|
|
||||||
search: (node) => {
|
search: (node) => {
|
||||||
const a = doc.createElement('a');
|
const a = new Element('a', {
|
||||||
a.setAttribute('href', `https://www.google.com/search?q=${node.props.query}`);
|
href: `https://www.google.com/search?q=${node.props.query}`,
|
||||||
a.textContent = node.props.content;
|
});
|
||||||
|
a.childNodes.push(new Text(node.props.content));
|
||||||
return a;
|
return a;
|
||||||
},
|
},
|
||||||
|
|
||||||
plain(node) {
|
plain(node) {
|
||||||
const el = doc.createElement('span');
|
const el = new Element('span', {});
|
||||||
appendChildren(node.children, el);
|
appendChildren(node.children, el);
|
||||||
return el;
|
return el;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Utility function to make TypeScript behave
|
||||||
|
function handle<T extends mfm.MfmNode>(node: T): ChildNode {
|
||||||
|
const handler = handlers[node.type] as (node: T) => ChildNode;
|
||||||
|
return handler(node);
|
||||||
|
}
|
||||||
|
|
||||||
appendChildren(nodes, body);
|
appendChildren(nodes, body);
|
||||||
|
|
||||||
if (quoteUri !== null) {
|
if (quoteUri !== null) {
|
||||||
const a = doc.createElement('a');
|
const a = new Element('a', {
|
||||||
a.setAttribute('href', quoteUri);
|
href: quoteUri,
|
||||||
a.textContent = quoteUri.replace(/^https?:\/\//, '');
|
});
|
||||||
|
a.childNodes.push(new Text(quoteUri.replace(/^https?:\/\//, '')));
|
||||||
|
|
||||||
const quote = doc.createElement('span');
|
const quote = new Element('span', {
|
||||||
quote.setAttribute('class', 'quote-inline');
|
class: 'quote-inline',
|
||||||
quote.appendChild(doc.createElement('br'));
|
});
|
||||||
quote.appendChild(doc.createElement('br'));
|
quote.childNodes.push(new Element('br', {}));
|
||||||
quote.innerHTML += 'RE: ';
|
quote.childNodes.push(new Element('br', {}));
|
||||||
quote.appendChild(a);
|
quote.childNodes.push(new Text('RE: '));
|
||||||
|
quote.childNodes.push(a);
|
||||||
|
|
||||||
body.appendChild(quote);
|
body.childNodes.push(quote);
|
||||||
}
|
}
|
||||||
|
|
||||||
let result = body.outerHTML;
|
let result = domserializer.render(body, {
|
||||||
|
encodeEntities: 'utf8'
|
||||||
|
});
|
||||||
|
|
||||||
if (inline) {
|
if (inline) {
|
||||||
result = result.replace(/^<p>/, '').replace(/<\/p>$/, '');
|
result = result.replace(/^<p>/, '').replace(/<\/p>$/, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
happyDOM.close().catch(() => {});
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { setImmediate } from 'node:timers/promises';
|
import { setImmediate } from 'node:timers/promises';
|
||||||
import * as mfm from '@transfem-org/sfm-js';
|
import * as mfm from 'mfm-js';
|
||||||
import { In, DataSource, IsNull, LessThan } from 'typeorm';
|
import { In, DataSource, IsNull, LessThan } from 'typeorm';
|
||||||
import * as Redis from 'ioredis';
|
import * as Redis from 'ioredis';
|
||||||
import { Inject, Injectable, OnApplicationShutdown } from '@nestjs/common';
|
import { Inject, Injectable, OnApplicationShutdown } from '@nestjs/common';
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { setImmediate } from 'node:timers/promises';
|
import { setImmediate } from 'node:timers/promises';
|
||||||
import * as mfm from '@transfem-org/sfm-js';
|
import * as mfm from 'mfm-js';
|
||||||
import { DataSource, In, IsNull, LessThan } from 'typeorm';
|
import { DataSource, In, IsNull, LessThan } from 'typeorm';
|
||||||
import * as Redis from 'ioredis';
|
import * as Redis from 'ioredis';
|
||||||
import { Inject, Injectable, OnApplicationShutdown } from '@nestjs/common';
|
import { Inject, Injectable, OnApplicationShutdown } from '@nestjs/common';
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
import { URL } from 'node:url';
|
import { URL } from 'node:url';
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { XMLParser } from 'fast-xml-parser';
|
import { load as cheerio } from 'cheerio/slim';
|
||||||
import { HttpRequestService } from '@/core/HttpRequestService.js';
|
import { HttpRequestService } from '@/core/HttpRequestService.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import type Logger from '@/logger.js';
|
import type Logger from '@/logger.js';
|
||||||
|
@ -101,14 +101,12 @@ export class WebfingerService {
|
||||||
private async fetchWebFingerTemplateFromHostMeta(url: string): Promise<string | null> {
|
private async fetchWebFingerTemplateFromHostMeta(url: string): Promise<string | null> {
|
||||||
try {
|
try {
|
||||||
const res = await this.httpRequestService.getHtml(url, 'application/xrd+xml');
|
const res = await this.httpRequestService.getHtml(url, 'application/xrd+xml');
|
||||||
const options = {
|
const hostMeta = cheerio(res, {
|
||||||
ignoreAttributes: false,
|
xml: true,
|
||||||
isArray: (_name: string, jpath: string) => jpath === 'XRD.Link',
|
});
|
||||||
};
|
|
||||||
const parser = new XMLParser(options);
|
const template = hostMeta('XRD > Link[rel="lrdd"][template*="{uri}"]').attr('template');
|
||||||
const hostMeta = parser.parse(res);
|
return template ?? null;
|
||||||
const template = (hostMeta['XRD']['Link'] as Array<any>).filter(p => p['@_rel'] === 'lrdd')[0]['@_template'];
|
|
||||||
return template.indexOf('{uri}') < 0 ? null : template;
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.logger.error(`error while request host-meta for ${url}: ${renderInlineError(err)}`);
|
this.logger.error(`error while request host-meta for ${url}: ${renderInlineError(err)}`);
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import * as mfm from '@transfem-org/sfm-js';
|
import * as mfm from 'mfm-js';
|
||||||
import { MfmService, Appender } from '@/core/MfmService.js';
|
import { MfmService, Appender } from '@/core/MfmService.js';
|
||||||
import type { MiNote } from '@/models/Note.js';
|
import type { MiNote } from '@/models/Note.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
|
|
|
@ -6,8 +6,9 @@
|
||||||
import { createPublicKey, randomUUID } from 'node:crypto';
|
import { createPublicKey, randomUUID } from 'node:crypto';
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
import { In } from 'typeorm';
|
import { In } from 'typeorm';
|
||||||
import * as mfm from '@transfem-org/sfm-js';
|
import * as mfm from 'mfm-js';
|
||||||
import { UnrecoverableError } from 'bullmq';
|
import { UnrecoverableError } from 'bullmq';
|
||||||
|
import { Element, Text } from 'domhandler';
|
||||||
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 { MiPartialLocalUser, MiLocalUser, MiPartialRemoteUser, MiRemoteUser, MiUser } from '@/models/User.js';
|
import type { MiPartialLocalUser, MiLocalUser, MiPartialRemoteUser, MiRemoteUser, MiUser } from '@/models/User.js';
|
||||||
|
@ -475,16 +476,18 @@ export class ApRendererService {
|
||||||
// the claas name `quote-inline` is used in non-misskey clients for styling quote notes.
|
// the claas name `quote-inline` is used in non-misskey clients for styling quote notes.
|
||||||
// For compatibility, the span part should be kept as possible.
|
// For compatibility, the span part should be kept as possible.
|
||||||
apAppend.push((doc, body) => {
|
apAppend.push((doc, body) => {
|
||||||
body.appendChild(doc.createElement('br'));
|
body.childNodes.push(new Element('br', {}));
|
||||||
body.appendChild(doc.createElement('br'));
|
body.childNodes.push(new Element('br', {}));
|
||||||
const span = doc.createElement('span');
|
const span = new Element('span', {
|
||||||
span.className = 'quote-inline';
|
class: 'quote-inline',
|
||||||
span.appendChild(doc.createTextNode('RE: '));
|
});
|
||||||
const link = doc.createElement('a');
|
span.childNodes.push(new Text('RE: '));
|
||||||
link.setAttribute('href', quote);
|
const link = new Element('a', {
|
||||||
link.textContent = quote;
|
href: quote,
|
||||||
span.appendChild(link);
|
});
|
||||||
body.appendChild(span);
|
link.childNodes.push(new Text(quote));
|
||||||
|
span.childNodes.push(link);
|
||||||
|
body.childNodes.push(span);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -839,16 +842,18 @@ export class ApRendererService {
|
||||||
// the claas name `quote-inline` is used in non-misskey clients for styling quote notes.
|
// the claas name `quote-inline` is used in non-misskey clients for styling quote notes.
|
||||||
// For compatibility, the span part should be kept as possible.
|
// For compatibility, the span part should be kept as possible.
|
||||||
apAppend.push((doc, body) => {
|
apAppend.push((doc, body) => {
|
||||||
body.appendChild(doc.createElement('br'));
|
body.childNodes.push(new Element('br', {}));
|
||||||
body.appendChild(doc.createElement('br'));
|
body.childNodes.push(new Element('br', {}));
|
||||||
const span = doc.createElement('span');
|
const span = new Element('span', {
|
||||||
span.className = 'quote-inline';
|
class: 'quote-inline',
|
||||||
span.appendChild(doc.createTextNode('RE: '));
|
});
|
||||||
const link = doc.createElement('a');
|
span.childNodes.push(new Text('RE: '));
|
||||||
link.setAttribute('href', quote);
|
const link = new Element('a', {
|
||||||
link.textContent = quote;
|
href: quote,
|
||||||
span.appendChild(link);
|
});
|
||||||
body.appendChild(span);
|
link.childNodes.push(new Text(quote));
|
||||||
|
span.childNodes.push(link);
|
||||||
|
body.childNodes.push(span);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 { load as cheerio } from 'cheerio/slim';
|
||||||
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';
|
||||||
|
@ -18,6 +18,8 @@ import { bindThis } from '@/decorators.js';
|
||||||
import type Logger from '@/logger.js';
|
import type Logger from '@/logger.js';
|
||||||
import { validateContentTypeSetAsActivityPub } from '@/core/activitypub/misc/validator.js';
|
import { validateContentTypeSetAsActivityPub } from '@/core/activitypub/misc/validator.js';
|
||||||
import type { IObject, IObjectWithId } from './type.js';
|
import type { IObject, IObjectWithId } from './type.js';
|
||||||
|
import type { Cheerio, CheerioAPI } from 'cheerio/slim';
|
||||||
|
import type { AnyNode } from 'domhandler';
|
||||||
|
|
||||||
type Request = {
|
type Request = {
|
||||||
url: string;
|
url: string;
|
||||||
|
@ -219,53 +221,33 @@ export class ApRequestService {
|
||||||
(contentType ?? '').split(';')[0].trimEnd().toLowerCase() === 'text/html' &&
|
(contentType ?? '').split(';')[0].trimEnd().toLowerCase() === 'text/html' &&
|
||||||
_followAlternate === true
|
_followAlternate === true
|
||||||
) {
|
) {
|
||||||
const html = await res.text();
|
let alternate: Cheerio<AnyNode> | null;
|
||||||
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 document = window.document;
|
|
||||||
try {
|
try {
|
||||||
document.documentElement.innerHTML = html;
|
const html = await res.text();
|
||||||
|
const document = cheerio(html);
|
||||||
|
|
||||||
// Search for any matching value in priority order:
|
// Search for any matching value in priority order:
|
||||||
// 1. Type=AP > Type=none > Type=anything
|
// 1. Type=AP > Type=none > Type=anything
|
||||||
// 2. Alternate > Canonical
|
// 2. Alternate > Canonical
|
||||||
// 3. Page order (fallback)
|
// 3. Page order (fallback)
|
||||||
const alternate =
|
alternate = selectFirst(document, [
|
||||||
document.querySelector('head > link[href][rel="alternate"][type="application/activity+json"]') ??
|
'head > link[href][rel="alternate"][type="application/activity+json"]',
|
||||||
document.querySelector('head > link[href][rel="canonical"][type="application/activity+json"]') ??
|
'head > link[href][rel="canonical"][type="application/activity+json"]',
|
||||||
document.querySelector('head > link[href][rel="alternate"]:not([type])') ??
|
'head > link[href][rel="alternate"]:not([type])',
|
||||||
document.querySelector('head > link[href][rel="canonical"]:not([type])') ??
|
'head > link[href][rel="canonical"]:not([type])',
|
||||||
document.querySelector('head > link[href][rel="alternate"]') ??
|
'head > link[href][rel="alternate"]',
|
||||||
document.querySelector('head > link[href][rel="canonical"]');
|
'head > link[href][rel="canonical"]',
|
||||||
|
]);
|
||||||
if (alternate) {
|
|
||||||
const href = alternate.getAttribute('href');
|
|
||||||
if (href && this.apUtilityService.haveSameAuthority(url, href)) {
|
|
||||||
return await this.signedGet(href, user, allowAnonymous, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch {
|
} catch {
|
||||||
// something went wrong parsing the HTML, ignore the whole thing
|
// something went wrong parsing the HTML, ignore the whole thing
|
||||||
} finally {
|
alternate = null;
|
||||||
happyDOM.close().catch(err => {});
|
}
|
||||||
|
|
||||||
|
if (alternate) {
|
||||||
|
const href = alternate.attr('href');
|
||||||
|
if (href && this.apUtilityService.haveSameAuthority(url, href)) {
|
||||||
|
return await this.signedGet(href, user, allowAnonymous, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
|
@ -285,3 +267,14 @@ export class ApRequestService {
|
||||||
return activity as IObjectWithId;
|
return activity as IObjectWithId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function selectFirst($: CheerioAPI, selectors: string[]): Cheerio<AnyNode> | null {
|
||||||
|
for (const selector of selectors) {
|
||||||
|
const selection = $(selector);
|
||||||
|
if (selection.length > 0) {
|
||||||
|
return selection;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as mfm from '@transfem-org/sfm-js';
|
import * as mfm from 'mfm-js';
|
||||||
import { unique } from '@/misc/prelude/array.js';
|
import { unique } from '@/misc/prelude/array.js';
|
||||||
|
|
||||||
export function extractCustomEmojisFromMfm(nodes: mfm.MfmNode[]): string[] {
|
export function extractCustomEmojisFromMfm(nodes: mfm.MfmNode[]): string[] {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as mfm from '@transfem-org/sfm-js';
|
import * as mfm from 'mfm-js';
|
||||||
import { unique } from '@/misc/prelude/array.js';
|
import { unique } from '@/misc/prelude/array.js';
|
||||||
|
|
||||||
export function extractHashtags(nodes: mfm.MfmNode[]): string[] {
|
export function extractHashtags(nodes: mfm.MfmNode[]): string[] {
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
// test is located in test/extract-mentions
|
// test is located in test/extract-mentions
|
||||||
|
|
||||||
import * as mfm from '@transfem-org/sfm-js';
|
import * as mfm from 'mfm-js';
|
||||||
|
|
||||||
export function extractMentions(nodes: mfm.MfmNode[]): mfm.MfmMention['props'][] {
|
export function extractMentions(nodes: mfm.MfmNode[]): mfm.MfmMention['props'][] {
|
||||||
// TODO: 重複を削除
|
// TODO: 重複を削除
|
||||||
|
|
|
@ -3,14 +3,12 @@
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { substring } from 'stringz';
|
|
||||||
|
|
||||||
export function truncate(input: string, size: number): string;
|
export function truncate(input: string, size: number): string;
|
||||||
export function truncate(input: string | undefined, size: number): string | undefined;
|
export function truncate(input: string | undefined, size: number): string | undefined;
|
||||||
export function truncate(input: string | undefined, size: number): string | undefined {
|
export function truncate(input: string | undefined, size: number): string | undefined {
|
||||||
if (!input) {
|
if (!input) {
|
||||||
return input;
|
return input;
|
||||||
} else {
|
} else {
|
||||||
return substring(input, 0, size);
|
return input.slice(0, size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { load as cheerio } from 'cheerio';
|
import { load as cheerio } from 'cheerio/slim';
|
||||||
import type { HttpRequestService } from '@/core/HttpRequestService.js';
|
import type { HttpRequestService } from '@/core/HttpRequestService.js';
|
||||||
|
|
||||||
type Field = { name: string, value: string };
|
type Field = { name: string, value: string };
|
||||||
|
|
|
@ -3,12 +3,12 @@
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import Parser from 'rss-parser';
|
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { parseFeed } from 'htmlparser2';
|
||||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||||
import { HttpRequestService } from '@/core/HttpRequestService.js';
|
import { HttpRequestService } from '@/core/HttpRequestService.js';
|
||||||
|
import { ApiError } from '../error.js';
|
||||||
const rssParser = new Parser();
|
import type { FeedItem } from 'domutils';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
tags: ['meta'],
|
tags: ['meta'],
|
||||||
|
@ -17,52 +17,32 @@ export const meta = {
|
||||||
allowGet: true,
|
allowGet: true,
|
||||||
cacheSec: 60 * 3,
|
cacheSec: 60 * 3,
|
||||||
|
|
||||||
|
errors: {
|
||||||
|
fetchFailed: {
|
||||||
|
id: '88f4356f-719d-4715-b4fc-703a10a812d2',
|
||||||
|
code: 'FETCH_FAILED',
|
||||||
|
message: 'Failed to fetch RSS feed',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
res: {
|
res: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
image: {
|
type: {
|
||||||
type: 'object',
|
type: 'string',
|
||||||
optional: true,
|
optional: false,
|
||||||
properties: {
|
|
||||||
link: {
|
|
||||||
type: 'string',
|
|
||||||
optional: true,
|
|
||||||
},
|
|
||||||
url: {
|
|
||||||
type: 'string',
|
|
||||||
optional: false,
|
|
||||||
},
|
|
||||||
title: {
|
|
||||||
type: 'string',
|
|
||||||
optional: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
paginationLinks: {
|
id: {
|
||||||
type: 'object',
|
type: 'string',
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
updated: {
|
||||||
|
type: 'string',
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
author: {
|
||||||
|
type: 'string',
|
||||||
optional: true,
|
optional: true,
|
||||||
properties: {
|
|
||||||
self: {
|
|
||||||
type: 'string',
|
|
||||||
optional: true,
|
|
||||||
},
|
|
||||||
first: {
|
|
||||||
type: 'string',
|
|
||||||
optional: true,
|
|
||||||
},
|
|
||||||
next: {
|
|
||||||
type: 'string',
|
|
||||||
optional: true,
|
|
||||||
},
|
|
||||||
last: {
|
|
||||||
type: 'string',
|
|
||||||
optional: true,
|
|
||||||
},
|
|
||||||
prev: {
|
|
||||||
type: 'string',
|
|
||||||
optional: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
link: {
|
link: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
|
@ -94,113 +74,42 @@ export const meta = {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
creator: {
|
description: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
summary: {
|
media: {
|
||||||
type: 'string',
|
|
||||||
optional: true,
|
|
||||||
},
|
|
||||||
content: {
|
|
||||||
type: 'string',
|
|
||||||
optional: true,
|
|
||||||
},
|
|
||||||
isoDate: {
|
|
||||||
type: 'string',
|
|
||||||
optional: true,
|
|
||||||
},
|
|
||||||
categories: {
|
|
||||||
type: 'array',
|
type: 'array',
|
||||||
optional: true,
|
optional: false,
|
||||||
items: {
|
items: {
|
||||||
type: 'string',
|
type: 'object',
|
||||||
},
|
properties: {
|
||||||
},
|
medium: {
|
||||||
contentSnippet: {
|
type: 'string',
|
||||||
type: 'string',
|
optional: true,
|
||||||
optional: true,
|
},
|
||||||
},
|
url: {
|
||||||
enclosure: {
|
type: 'string',
|
||||||
type: 'object',
|
optional: true,
|
||||||
optional: true,
|
},
|
||||||
properties: {
|
type: {
|
||||||
url: {
|
type: 'string',
|
||||||
type: 'string',
|
optional: true,
|
||||||
optional: false,
|
},
|
||||||
},
|
lang: {
|
||||||
length: {
|
type: 'string',
|
||||||
type: 'number',
|
optional: true,
|
||||||
optional: true,
|
},
|
||||||
},
|
|
||||||
type: {
|
|
||||||
type: 'string',
|
|
||||||
optional: true,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
feedUrl: {
|
|
||||||
type: 'string',
|
|
||||||
optional: true,
|
|
||||||
},
|
|
||||||
description: {
|
description: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
itunes: {
|
|
||||||
type: 'object',
|
|
||||||
optional: true,
|
|
||||||
additionalProperties: true,
|
|
||||||
properties: {
|
|
||||||
image: {
|
|
||||||
type: 'string',
|
|
||||||
optional: true,
|
|
||||||
},
|
|
||||||
owner: {
|
|
||||||
type: 'object',
|
|
||||||
optional: true,
|
|
||||||
properties: {
|
|
||||||
name: {
|
|
||||||
type: 'string',
|
|
||||||
optional: true,
|
|
||||||
},
|
|
||||||
email: {
|
|
||||||
type: 'string',
|
|
||||||
optional: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
author: {
|
|
||||||
type: 'string',
|
|
||||||
optional: true,
|
|
||||||
},
|
|
||||||
summary: {
|
|
||||||
type: 'string',
|
|
||||||
optional: true,
|
|
||||||
},
|
|
||||||
explicit: {
|
|
||||||
type: 'string',
|
|
||||||
optional: true,
|
|
||||||
},
|
|
||||||
categories: {
|
|
||||||
type: 'array',
|
|
||||||
optional: true,
|
|
||||||
items: {
|
|
||||||
type: 'string',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
keywords: {
|
|
||||||
type: 'array',
|
|
||||||
optional: true,
|
|
||||||
items: {
|
|
||||||
type: 'string',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -224,7 +133,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
constructor(
|
constructor(
|
||||||
private httpRequestService: HttpRequestService,
|
private httpRequestService: HttpRequestService,
|
||||||
) {
|
) {
|
||||||
super(meta, paramDef, async (ps, me) => {
|
super(meta, paramDef, async (ps) => {
|
||||||
const res = await this.httpRequestService.send(ps.url, {
|
const res = await this.httpRequestService.send(ps.url, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
|
@ -234,8 +143,38 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
});
|
});
|
||||||
|
|
||||||
const text = await res.text();
|
const text = await res.text();
|
||||||
|
const feed = parseFeed(text, {
|
||||||
|
xmlMode: true,
|
||||||
|
});
|
||||||
|
|
||||||
return rssParser.parseString(text);
|
if (!feed) {
|
||||||
|
throw new ApiError(meta.errors.fetchFailed);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
type: feed.type,
|
||||||
|
id: feed.id,
|
||||||
|
title: feed.title,
|
||||||
|
link: feed.link,
|
||||||
|
description: feed.description,
|
||||||
|
updated: feed.updated?.toISOString(),
|
||||||
|
author: feed.author,
|
||||||
|
items: feed.items
|
||||||
|
.filter((item): item is FeedItem & { link: string, title: string } => !!item.link && !!item.title)
|
||||||
|
.map(item => ({
|
||||||
|
guid: item.id,
|
||||||
|
title: item.title,
|
||||||
|
link: item.link,
|
||||||
|
description: item.description,
|
||||||
|
pubDate: item.pubDate?.toISOString(),
|
||||||
|
media: item.media.map(media => ({
|
||||||
|
medium: media.medium,
|
||||||
|
url: media.url,
|
||||||
|
type: media.type,
|
||||||
|
lang: media.lang,
|
||||||
|
})),
|
||||||
|
})),
|
||||||
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as mfm from '@transfem-org/sfm-js';
|
import * as mfm from 'mfm-js';
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
import ms from 'ms';
|
import ms from 'ms';
|
||||||
import { extractCustomEmojisFromMfm } from '@/misc/extract-custom-emojis-from-mfm.js';
|
import { extractCustomEmojisFromMfm } from '@/misc/extract-custom-emojis-from-mfm.js';
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
import { Entity, MastodonEntity, MisskeyEntity } from 'megalodon';
|
import { Entity, MastodonEntity, MisskeyEntity } from 'megalodon';
|
||||||
import mfm from '@transfem-org/sfm-js';
|
import mfm from 'mfm-js';
|
||||||
import { MastodonNotificationType } from 'megalodon/lib/src/mastodon/notification.js';
|
import { MastodonNotificationType } from 'megalodon/lib/src/mastodon/notification.js';
|
||||||
import { NotificationType } from 'megalodon/lib/src/notification.js';
|
import { NotificationType } from 'megalodon/lib/src/notification.js';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
|
|
|
@ -15,7 +15,7 @@ import { DriveFileEntityService } from '@/core/entities/DriveFileEntityService.j
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import { IdService } from '@/core/IdService.js';
|
import { IdService } from '@/core/IdService.js';
|
||||||
import { MfmService } from "@/core/MfmService.js";
|
import { MfmService } from "@/core/MfmService.js";
|
||||||
import { parse as mfmParse } from '@transfem-org/sfm-js';
|
import { parse as mfmParse } from 'mfm-js';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class FeedService {
|
export class FeedService {
|
||||||
|
|
|
@ -19,7 +19,7 @@ import {
|
||||||
ResourceOwnerPassword,
|
ResourceOwnerPassword,
|
||||||
} from 'simple-oauth2';
|
} from 'simple-oauth2';
|
||||||
import pkceChallenge from 'pkce-challenge';
|
import pkceChallenge from 'pkce-challenge';
|
||||||
import { load as cheerio } from 'cheerio';
|
import { load as cheerio } from 'cheerio/slim';
|
||||||
import Fastify, { type FastifyInstance, type FastifyReply } from 'fastify';
|
import Fastify, { type FastifyInstance, type FastifyReply } from 'fastify';
|
||||||
import { api, port, sendEnvUpdateRequest, signup } from '../utils.js';
|
import { api, port, sendEnvUpdateRequest, signup } from '../utils.js';
|
||||||
import type * as misskey from 'misskey-js';
|
import type * as misskey from 'misskey-js';
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as assert from 'assert';
|
import * as assert from 'assert';
|
||||||
import * as mfm from '@transfem-org/sfm-js';
|
import * as mfm from 'mfm-js';
|
||||||
import { Test } from '@nestjs/testing';
|
import { Test } from '@nestjs/testing';
|
||||||
|
|
||||||
import { CoreModule } from '@/core/CoreModule.js';
|
import { CoreModule } from '@/core/CoreModule.js';
|
||||||
|
@ -86,7 +86,7 @@ describe('MfmService', () => {
|
||||||
|
|
||||||
test('ruby', async () => {
|
test('ruby', async () => {
|
||||||
const input = '$[ruby $[group *some* text] ignore me]';
|
const input = '$[ruby $[group *some* text] ignore me]';
|
||||||
const output = '<p><ruby><span><span>*some*</span><span> text</span></span><rp>(</rp><rt>ignore me</rt><rp>)</rp></ruby></p>';
|
const output = '<p><ruby><span><span>*some*</span> text</span><rp>(</rp><rt>ignore me</rt><rp>)</rp></ruby></p>';
|
||||||
assert.equal(await mfmService.toMastoApiHtml(mfm.parse(input)), output);
|
assert.equal(await mfmService.toMastoApiHtml(mfm.parse(input)), output);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
import * as assert from 'assert';
|
import * as assert from 'assert';
|
||||||
|
|
||||||
import { parse } from '@transfem-org/sfm-js';
|
import { parse } from 'mfm-js';
|
||||||
import { extractMentions } from '@/misc/extract-mentions.js';
|
import { extractMentions } from '@/misc/extract-mentions.js';
|
||||||
|
|
||||||
describe('Extract mentions', () => {
|
describe('Extract mentions', () => {
|
||||||
|
|
|
@ -11,12 +11,12 @@ import { inspect } from 'node:util';
|
||||||
import WebSocket, { ClientOptions } from 'ws';
|
import WebSocket, { ClientOptions } from 'ws';
|
||||||
import fetch, { File, RequestInit, type Headers } from 'node-fetch';
|
import fetch, { File, RequestInit, type Headers } from 'node-fetch';
|
||||||
import { DataSource } from 'typeorm';
|
import { DataSource } from 'typeorm';
|
||||||
import { load as cheerio } from 'cheerio';
|
import { load as cheerio } from 'cheerio/slim';
|
||||||
import { type Response } from 'node-fetch';
|
import { type Response } from 'node-fetch';
|
||||||
import Fastify from 'fastify';
|
import Fastify from 'fastify';
|
||||||
import { entities } from '../src/postgres.js';
|
import { entities } from '../src/postgres.js';
|
||||||
import { loadConfig } from '../src/config.js';
|
import { loadConfig } from '../src/config.js';
|
||||||
import type { CheerioAPI } from 'cheerio';
|
import type { CheerioAPI } from 'cheerio/slim';
|
||||||
import type * as misskey from 'misskey-js';
|
import type * as misskey from 'misskey-js';
|
||||||
import { DEFAULT_POLICIES } from '@/core/RoleService.js';
|
import { DEFAULT_POLICIES } from '@/core/RoleService.js';
|
||||||
import { validateContentTypeSetAsActivityPub } from '@/core/activitypub/misc/validator.js';
|
import { validateContentTypeSetAsActivityPub } from '@/core/activitypub/misc/validator.js';
|
||||||
|
|
|
@ -11,35 +11,25 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@discordapp/twemoji": "15.1.0",
|
"@discordapp/twemoji": "15.1.0",
|
||||||
"@phosphor-icons/web": "^2.0.3",
|
"@phosphor-icons/web": "2.1.2",
|
||||||
"@rollup/plugin-json": "6.1.0",
|
"mfm-js": "npm:@transfem-org/sfm-js@0.24.6",
|
||||||
"@rollup/plugin-replace": "6.0.2",
|
|
||||||
"@rollup/pluginutils": "5.1.4",
|
|
||||||
"@transfem-org/sfm-js": "0.24.5",
|
|
||||||
"@twemoji/parser": "15.1.1",
|
|
||||||
"@vitejs/plugin-vue": "5.2.3",
|
|
||||||
"@vue/compiler-sfc": "3.5.14",
|
|
||||||
"astring": "1.9.0",
|
|
||||||
"buraha": "0.0.1",
|
"buraha": "0.0.1",
|
||||||
"estree-walker": "3.0.3",
|
|
||||||
"frontend-shared": "workspace:*",
|
"frontend-shared": "workspace:*",
|
||||||
"json5": "2.2.3",
|
"json5": "2.2.3",
|
||||||
"misskey-js": "workspace:*",
|
"misskey-js": "workspace:*",
|
||||||
"punycode.js": "2.3.1",
|
"punycode.js": "2.3.1",
|
||||||
"rollup": "4.40.0",
|
|
||||||
"sass": "1.87.0",
|
|
||||||
"shiki": "3.3.0",
|
"shiki": "3.3.0",
|
||||||
"tinycolor2": "1.6.0",
|
"tinycolor2": "1.6.0",
|
||||||
"tsc-alias": "1.8.15",
|
|
||||||
"tsconfig-paths": "4.2.0",
|
|
||||||
"typescript": "5.8.3",
|
|
||||||
"uuid": "11.1.0",
|
"uuid": "11.1.0",
|
||||||
"vite": "6.3.3",
|
|
||||||
"vue": "3.5.14"
|
"vue": "3.5.14"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@misskey-dev/summaly": "5.2.1",
|
"@misskey-dev/summaly": "npm:@transfem-org/summaly@5.2.2",
|
||||||
|
"@rollup/plugin-json": "6.1.0",
|
||||||
|
"@rollup/plugin-replace": "6.0.2",
|
||||||
|
"@rollup/pluginutils": "5.1.4",
|
||||||
"@testing-library/vue": "8.1.0",
|
"@testing-library/vue": "8.1.0",
|
||||||
|
"@twemoji/parser": "15.1.1",
|
||||||
"@types/estree": "1.0.7",
|
"@types/estree": "1.0.7",
|
||||||
"@types/micromatch": "4.0.9",
|
"@types/micromatch": "4.0.9",
|
||||||
"@types/node": "22.15.2",
|
"@types/node": "22.15.2",
|
||||||
|
@ -48,12 +38,16 @@
|
||||||
"@types/ws": "8.18.1",
|
"@types/ws": "8.18.1",
|
||||||
"@typescript-eslint/eslint-plugin": "8.31.0",
|
"@typescript-eslint/eslint-plugin": "8.31.0",
|
||||||
"@typescript-eslint/parser": "8.31.0",
|
"@typescript-eslint/parser": "8.31.0",
|
||||||
|
"@vitejs/plugin-vue": "5.2.3",
|
||||||
"@vitest/coverage-v8": "3.1.2",
|
"@vitest/coverage-v8": "3.1.2",
|
||||||
|
"@vue/compiler-sfc": "3.5.14",
|
||||||
"@vue/runtime-core": "3.5.14",
|
"@vue/runtime-core": "3.5.14",
|
||||||
"acorn": "8.14.1",
|
"acorn": "8.14.1",
|
||||||
|
"astring": "1.9.0",
|
||||||
"cross-env": "7.0.3",
|
"cross-env": "7.0.3",
|
||||||
"eslint-plugin-import": "2.31.0",
|
"eslint-plugin-import": "2.31.0",
|
||||||
"eslint-plugin-vue": "10.0.0",
|
"eslint-plugin-vue": "10.0.0",
|
||||||
|
"estree-walker": "3.0.3",
|
||||||
"fast-glob": "3.3.3",
|
"fast-glob": "3.3.3",
|
||||||
"happy-dom": "17.4.4",
|
"happy-dom": "17.4.4",
|
||||||
"intersection-observer": "0.12.2",
|
"intersection-observer": "0.12.2",
|
||||||
|
@ -61,7 +55,13 @@
|
||||||
"msw": "2.7.5",
|
"msw": "2.7.5",
|
||||||
"nodemon": "3.1.10",
|
"nodemon": "3.1.10",
|
||||||
"prettier": "3.5.3",
|
"prettier": "3.5.3",
|
||||||
|
"rollup": "4.40.0",
|
||||||
|
"sass": "1.87.0",
|
||||||
"start-server-and-test": "2.0.11",
|
"start-server-and-test": "2.0.11",
|
||||||
|
"tsc-alias": "1.8.15",
|
||||||
|
"tsconfig-paths": "4.2.0",
|
||||||
|
"typescript": "5.8.3",
|
||||||
|
"vite": "6.3.3",
|
||||||
"vite-plugin-turbosnap": "1.0.3",
|
"vite-plugin-turbosnap": "1.0.3",
|
||||||
"vue-component-type-helpers": "2.2.10",
|
"vue-component-type-helpers": "2.2.10",
|
||||||
"vue-eslint-parser": "10.1.3",
|
"vue-eslint-parser": "10.1.3",
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
import { h, provide } from 'vue';
|
import { h, provide } from 'vue';
|
||||||
import type { VNode, SetupContext } from 'vue';
|
import type { VNode, SetupContext } from 'vue';
|
||||||
import * as mfm from '@transfem-org/sfm-js';
|
import * as mfm from 'mfm-js';
|
||||||
import * as Misskey from 'misskey-js';
|
import * as Misskey from 'misskey-js';
|
||||||
import { host } from '@@/js/config.js';
|
import { host } from '@@/js/config.js';
|
||||||
import EmUrl from '@/components/EmUrl.vue';
|
import EmUrl from '@/components/EmUrl.vue';
|
||||||
|
|
|
@ -105,7 +105,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, inject, ref, shallowRef } from 'vue';
|
import { computed, inject, ref, shallowRef } from 'vue';
|
||||||
import * as mfm from '@transfem-org/sfm-js';
|
import * as mfm from 'mfm-js';
|
||||||
import * as Misskey from 'misskey-js';
|
import * as Misskey from 'misskey-js';
|
||||||
import { shouldCollapsed } from '@@/js/collapsed.js';
|
import { shouldCollapsed } from '@@/js/collapsed.js';
|
||||||
import { url } from '@@/js/config.js';
|
import { url } from '@@/js/config.js';
|
||||||
|
|
|
@ -128,7 +128,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, inject, ref } from 'vue';
|
import { computed, inject, ref } from 'vue';
|
||||||
import * as mfm from '@transfem-org/sfm-js';
|
import * as mfm from 'mfm-js';
|
||||||
import * as Misskey from 'misskey-js';
|
import * as Misskey from 'misskey-js';
|
||||||
import { computeMergedCw } from '@@/js/compute-merged-cw.js';
|
import { computeMergedCw } from '@@/js/compute-merged-cw.js';
|
||||||
import I18n from '@/components/I18n.vue';
|
import I18n from '@/components/I18n.vue';
|
||||||
|
|
|
@ -35,7 +35,6 @@
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"misskey-js": "workspace:*",
|
"misskey-js": "workspace:*",
|
||||||
"nodemon": "3.1.7",
|
|
||||||
"vue": "3.5.13"
|
"vue": "3.5.13"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,19 +20,11 @@
|
||||||
"@github/webauthn-json": "2.1.1",
|
"@github/webauthn-json": "2.1.1",
|
||||||
"@mcaptcha/vanilla-glue": "0.1.0-alpha-3",
|
"@mcaptcha/vanilla-glue": "0.1.0-alpha-3",
|
||||||
"@misskey-dev/browser-image-resizer": "2024.1.0",
|
"@misskey-dev/browser-image-resizer": "2024.1.0",
|
||||||
"@phosphor-icons/web": "^2.0.3",
|
"@phosphor-icons/web": "2.1.2",
|
||||||
"@rollup/plugin-json": "6.1.0",
|
|
||||||
"@rollup/plugin-replace": "6.0.2",
|
|
||||||
"@rollup/pluginutils": "5.1.4",
|
|
||||||
"@ruffle-rs/ruffle": "0.1.0-nightly.2024.10.15",
|
"@ruffle-rs/ruffle": "0.1.0-nightly.2024.10.15",
|
||||||
"@sentry/vue": "9.14.0",
|
"@sentry/vue": "9.14.0",
|
||||||
"@syuilo/aiscript": "0.19.0",
|
"@syuilo/aiscript": "0.19.0",
|
||||||
"@transfem-org/sfm-js": "0.24.6",
|
|
||||||
"@twemoji/parser": "15.1.1",
|
|
||||||
"@vitejs/plugin-vue": "5.2.3",
|
|
||||||
"@vue/compiler-sfc": "3.5.14",
|
|
||||||
"aiscript-vscode": "github:aiscript-dev/aiscript-vscode#v0.1.15",
|
"aiscript-vscode": "github:aiscript-dev/aiscript-vscode#v0.1.15",
|
||||||
"astring": "1.9.0",
|
|
||||||
"broadcast-channel": "7.1.0",
|
"broadcast-channel": "7.1.0",
|
||||||
"buraha": "0.0.1",
|
"buraha": "0.0.1",
|
||||||
"canvas-confetti": "1.9.3",
|
"canvas-confetti": "1.9.3",
|
||||||
|
@ -45,38 +37,30 @@
|
||||||
"compare-versions": "6.1.1",
|
"compare-versions": "6.1.1",
|
||||||
"cropperjs": "2.0.0",
|
"cropperjs": "2.0.0",
|
||||||
"date-fns": "4.1.0",
|
"date-fns": "4.1.0",
|
||||||
"estree-walker": "3.0.3",
|
|
||||||
"eventemitter3": "5.0.1",
|
"eventemitter3": "5.0.1",
|
||||||
"frontend-shared": "workspace:*",
|
"frontend-shared": "workspace:*",
|
||||||
"idb-keyval": "6.2.1",
|
"idb-keyval": "6.2.1",
|
||||||
"insert-text-at-cursor": "0.3.0",
|
"insert-text-at-cursor": "0.3.0",
|
||||||
"is-file-animated": "1.0.2",
|
"is-file-animated": "1.0.2",
|
||||||
"json5": "2.2.3",
|
"json5": "2.2.3",
|
||||||
"katex": "0.16.10",
|
"katex": "0.16.22",
|
||||||
"magic-string": "0.30.17",
|
|
||||||
"matter-js": "0.20.0",
|
"matter-js": "0.20.0",
|
||||||
"misskey-bubble-game": "workspace:*",
|
"misskey-bubble-game": "workspace:*",
|
||||||
"misskey-js": "workspace:*",
|
"misskey-js": "workspace:*",
|
||||||
"misskey-reversi": "workspace:*",
|
"misskey-reversi": "workspace:*",
|
||||||
"moment": "^2.30.1",
|
"moment": "2.30.1",
|
||||||
"photoswipe": "5.4.4",
|
"photoswipe": "5.4.4",
|
||||||
"promise-limit": "2.7.0",
|
"promise-limit": "2.7.0",
|
||||||
"punycode.js": "2.3.1",
|
"punycode.js": "2.3.1",
|
||||||
"rollup": "4.40.0",
|
|
||||||
"sanitize-html": "2.16.0",
|
"sanitize-html": "2.16.0",
|
||||||
"sass": "1.87.0",
|
|
||||||
"shiki": "3.3.0",
|
"shiki": "3.3.0",
|
||||||
"strict-event-emitter-types": "2.0.0",
|
"strict-event-emitter-types": "2.0.0",
|
||||||
"textarea-caret": "3.1.0",
|
"textarea-caret": "3.1.0",
|
||||||
"three": "0.176.0",
|
|
||||||
"throttle-debounce": "5.0.2",
|
"throttle-debounce": "5.0.2",
|
||||||
"tinycolor2": "1.6.0",
|
"tinycolor2": "1.6.0",
|
||||||
"tsc-alias": "1.8.15",
|
|
||||||
"tsconfig-paths": "4.2.0",
|
|
||||||
"typescript": "5.8.3",
|
"typescript": "5.8.3",
|
||||||
"uuid": "11.1.0",
|
"uuid": "11.1.0",
|
||||||
"v-code-diff": "1.13.1",
|
"v-code-diff": "1.13.1",
|
||||||
"vite": "6.3.3",
|
|
||||||
"vue": "3.5.14",
|
"vue": "3.5.14",
|
||||||
"vuedraggable": "next",
|
"vuedraggable": "next",
|
||||||
"wanakana": "5.3.1"
|
"wanakana": "5.3.1"
|
||||||
|
@ -85,7 +69,10 @@
|
||||||
"cypress": "14.3.2"
|
"cypress": "14.3.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@misskey-dev/summaly": "5.2.1",
|
"@misskey-dev/summaly": "npm:@transfem-org/summaly@5.2.2",
|
||||||
|
"@rollup/plugin-json": "6.1.0",
|
||||||
|
"@rollup/plugin-replace": "6.0.2",
|
||||||
|
"@rollup/pluginutils": "5.1.4",
|
||||||
"@storybook/addon-actions": "8.6.12",
|
"@storybook/addon-actions": "8.6.12",
|
||||||
"@storybook/addon-essentials": "8.6.12",
|
"@storybook/addon-essentials": "8.6.12",
|
||||||
"@storybook/addon-interactions": "8.6.12",
|
"@storybook/addon-interactions": "8.6.12",
|
||||||
|
@ -105,9 +92,10 @@
|
||||||
"@storybook/vue3": "8.6.12",
|
"@storybook/vue3": "8.6.12",
|
||||||
"@storybook/vue3-vite": "8.6.12",
|
"@storybook/vue3-vite": "8.6.12",
|
||||||
"@testing-library/vue": "8.1.0",
|
"@testing-library/vue": "8.1.0",
|
||||||
|
"@twemoji/parser": "15.1.1",
|
||||||
"@types/canvas-confetti": "1.9.0",
|
"@types/canvas-confetti": "1.9.0",
|
||||||
"@types/estree": "1.0.7",
|
"@types/estree": "1.0.7",
|
||||||
"@types/katex": "^0.16.7",
|
"@types/katex": "0.16.7",
|
||||||
"@types/matter-js": "0.19.8",
|
"@types/matter-js": "0.19.8",
|
||||||
"@types/micromatch": "4.0.9",
|
"@types/micromatch": "4.0.9",
|
||||||
"@types/node": "22.15.2",
|
"@types/node": "22.15.2",
|
||||||
|
@ -119,16 +107,22 @@
|
||||||
"@types/ws": "8.18.1",
|
"@types/ws": "8.18.1",
|
||||||
"@typescript-eslint/eslint-plugin": "8.31.0",
|
"@typescript-eslint/eslint-plugin": "8.31.0",
|
||||||
"@typescript-eslint/parser": "8.31.0",
|
"@typescript-eslint/parser": "8.31.0",
|
||||||
|
"@vitejs/plugin-vue": "5.2.3",
|
||||||
"@vitest/coverage-v8": "3.1.2",
|
"@vitest/coverage-v8": "3.1.2",
|
||||||
"@vue/compiler-core": "3.5.14",
|
"@vue/compiler-core": "3.5.14",
|
||||||
|
"@vue/compiler-sfc": "3.5.14",
|
||||||
"@vue/runtime-core": "3.5.14",
|
"@vue/runtime-core": "3.5.14",
|
||||||
|
"mfm-js": "npm:@transfem-org/sfm-js@0.24.6",
|
||||||
"acorn": "8.14.1",
|
"acorn": "8.14.1",
|
||||||
|
"astring": "1.9.0",
|
||||||
"cross-env": "7.0.3",
|
"cross-env": "7.0.3",
|
||||||
"eslint-plugin-import": "2.31.0",
|
"eslint-plugin-import": "2.31.0",
|
||||||
"eslint-plugin-vue": "10.0.0",
|
"eslint-plugin-vue": "10.0.0",
|
||||||
|
"estree-walker": "3.0.3",
|
||||||
"fast-glob": "3.3.3",
|
"fast-glob": "3.3.3",
|
||||||
"happy-dom": "17.4.4",
|
"happy-dom": "17.4.4",
|
||||||
"intersection-observer": "0.12.2",
|
"intersection-observer": "0.12.2",
|
||||||
|
"magic-string": "0.30.17",
|
||||||
"micromatch": "4.0.8",
|
"micromatch": "4.0.8",
|
||||||
"minimatch": "10.0.1",
|
"minimatch": "10.0.1",
|
||||||
"msw": "2.7.5",
|
"msw": "2.7.5",
|
||||||
|
@ -137,10 +131,16 @@
|
||||||
"prettier": "3.5.3",
|
"prettier": "3.5.3",
|
||||||
"react": "19.1.0",
|
"react": "19.1.0",
|
||||||
"react-dom": "19.1.0",
|
"react-dom": "19.1.0",
|
||||||
|
"rollup": "4.40.0",
|
||||||
|
"sass": "1.87.0",
|
||||||
"seedrandom": "3.0.5",
|
"seedrandom": "3.0.5",
|
||||||
"start-server-and-test": "2.0.11",
|
"start-server-and-test": "2.0.11",
|
||||||
"storybook": "8.6.12",
|
"storybook": "8.6.12",
|
||||||
"storybook-addon-misskey-theme": "github:misskey-dev/storybook-addon-misskey-theme",
|
"storybook-addon-misskey-theme": "github:misskey-dev/storybook-addon-misskey-theme",
|
||||||
|
"three": "0.176.0",
|
||||||
|
"tsc-alias": "1.8.15",
|
||||||
|
"tsconfig-paths": "4.2.0",
|
||||||
|
"vite": "6.3.3",
|
||||||
"vite-plugin-turbosnap": "1.0.3",
|
"vite-plugin-turbosnap": "1.0.3",
|
||||||
"vitest": "3.1.2",
|
"vitest": "3.1.2",
|
||||||
"vitest-fetch-mock": "0.4.5",
|
"vitest-fetch-mock": "0.4.5",
|
||||||
|
|
|
@ -99,7 +99,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, provide, ref, watch } from 'vue';
|
import { computed, provide, ref, watch } from 'vue';
|
||||||
import * as Misskey from 'misskey-js';
|
import * as Misskey from 'misskey-js';
|
||||||
import * as mfm from '@transfem-org/sfm-js';
|
import * as mfm from 'mfm-js';
|
||||||
import MkButton from '@/components/MkButton.vue';
|
import MkButton from '@/components/MkButton.vue';
|
||||||
import MkSwitch from '@/components/MkSwitch.vue';
|
import MkSwitch from '@/components/MkSwitch.vue';
|
||||||
import MkKeyValue from '@/components/MkKeyValue.vue';
|
import MkKeyValue from '@/components/MkKeyValue.vue';
|
||||||
|
|
|
@ -180,7 +180,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, inject, onMounted, ref, useTemplateRef, watch, provide } from 'vue';
|
import { computed, inject, onMounted, ref, useTemplateRef, watch, provide } from 'vue';
|
||||||
import * as mfm from '@transfem-org/sfm-js';
|
import * as mfm from 'mfm-js';
|
||||||
import * as Misskey from 'misskey-js';
|
import * as Misskey from 'misskey-js';
|
||||||
import { isLink } from '@@/js/is-link.js';
|
import { isLink } from '@@/js/is-link.js';
|
||||||
import { shouldCollapsed } from '@@/js/collapsed.js';
|
import { shouldCollapsed } from '@@/js/collapsed.js';
|
||||||
|
|
|
@ -233,7 +233,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, inject, onMounted, provide, ref, useTemplateRef, watch } from 'vue';
|
import { computed, inject, onMounted, provide, ref, useTemplateRef, watch } from 'vue';
|
||||||
import * as mfm from '@transfem-org/sfm-js';
|
import * as mfm from 'mfm-js';
|
||||||
import * as Misskey from 'misskey-js';
|
import * as Misskey from 'misskey-js';
|
||||||
import { isLink } from '@@/js/is-link.js';
|
import { isLink } from '@@/js/is-link.js';
|
||||||
import * as config from '@@/js/config.js';
|
import * as config from '@@/js/config.js';
|
||||||
|
|
|
@ -107,7 +107,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { inject, watch, nextTick, onMounted, defineAsyncComponent, provide, shallowRef, ref, computed, useTemplateRef, toRaw } from 'vue';
|
import { inject, watch, nextTick, onMounted, defineAsyncComponent, provide, shallowRef, ref, computed, useTemplateRef, toRaw } from 'vue';
|
||||||
import * as mfm from '@transfem-org/sfm-js';
|
import * as mfm from 'mfm-js';
|
||||||
import * as Misskey from 'misskey-js';
|
import * as Misskey from 'misskey-js';
|
||||||
import insertTextAtCursor from 'insert-text-at-cursor';
|
import insertTextAtCursor from 'insert-text-at-cursor';
|
||||||
import { toASCII } from 'punycode.js';
|
import { toASCII } from 'punycode.js';
|
||||||
|
|
|
@ -35,7 +35,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, computed, watch } from 'vue';
|
import { ref, computed, watch } from 'vue';
|
||||||
import * as Misskey from 'misskey-js';
|
import * as Misskey from 'misskey-js';
|
||||||
import * as mfm from '@transfem-org/sfm-js';
|
import * as mfm from 'mfm-js';
|
||||||
import { shouldCollapsed } from '@@/js/collapsed.js';
|
import { shouldCollapsed } from '@@/js/collapsed.js';
|
||||||
import MkMediaList from '@/components/MkMediaList.vue';
|
import MkMediaList from '@/components/MkMediaList.vue';
|
||||||
import MkPoll from '@/components/MkPoll.vue';
|
import MkPoll from '@/components/MkPoll.vue';
|
||||||
|
|
|
@ -181,7 +181,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, inject, onMounted, ref, useTemplateRef, watch, provide } from 'vue';
|
import { computed, inject, onMounted, ref, useTemplateRef, watch, provide } from 'vue';
|
||||||
import * as mfm from '@transfem-org/sfm-js';
|
import * as mfm from 'mfm-js';
|
||||||
import * as Misskey from 'misskey-js';
|
import * as Misskey from 'misskey-js';
|
||||||
import { isLink } from '@@/js/is-link.js';
|
import { isLink } from '@@/js/is-link.js';
|
||||||
import { shouldCollapsed } from '@@/js/collapsed.js';
|
import { shouldCollapsed } from '@@/js/collapsed.js';
|
||||||
|
|
|
@ -238,7 +238,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, inject, onMounted, onUnmounted, onUpdated, provide, ref, useTemplateRef, watch } from 'vue';
|
import { computed, inject, onMounted, onUnmounted, onUpdated, provide, ref, useTemplateRef, watch } from 'vue';
|
||||||
import * as mfm from '@transfem-org/sfm-js';
|
import * as mfm from 'mfm-js';
|
||||||
import * as Misskey from 'misskey-js';
|
import * as Misskey from 'misskey-js';
|
||||||
import { isLink } from '@@/js/is-link.js';
|
import { isLink } from '@@/js/is-link.js';
|
||||||
import * as config from '@@/js/config.js';
|
import * as config from '@@/js/config.js';
|
||||||
|
|
|
@ -76,7 +76,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { inject, onMounted, ref, shallowRef, computed } from 'vue';
|
import { inject, onMounted, ref, shallowRef, computed } from 'vue';
|
||||||
import * as mfm from '@transfem-org/sfm-js';
|
import * as mfm from 'mfm-js';
|
||||||
import * as Misskey from 'misskey-js';
|
import * as Misskey from 'misskey-js';
|
||||||
import MkNoteSimple from '@/components/MkNoteSimple.vue';
|
import MkNoteSimple from '@/components/MkNoteSimple.vue';
|
||||||
import MkMediaList from '@/components/MkMediaList.vue';
|
import MkMediaList from '@/components/MkMediaList.vue';
|
||||||
|
|
|
@ -26,7 +26,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import * as Misskey from 'misskey-js';
|
import * as Misskey from 'misskey-js';
|
||||||
import * as mfm from '@transfem-org/sfm-js';
|
import * as mfm from 'mfm-js';
|
||||||
import { computed, ref, watch } from 'vue';
|
import { computed, ref, watch } from 'vue';
|
||||||
import { versatileLang } from '@@/js/intl-const';
|
import { versatileLang } from '@@/js/intl-const';
|
||||||
import promiseLimit from 'promise-limit';
|
import promiseLimit from 'promise-limit';
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { h, defineAsyncComponent } from 'vue';
|
import { h, defineAsyncComponent } from 'vue';
|
||||||
import * as mfm from '@transfem-org/sfm-js';
|
import * as mfm from 'mfm-js';
|
||||||
import * as Misskey from 'misskey-js';
|
import * as Misskey from 'misskey-js';
|
||||||
import { host } from '@@/js/config.js';
|
import { host } from '@@/js/config.js';
|
||||||
import CkFollowMouse from '../CkFollowMouse.vue';
|
import CkFollowMouse from '../CkFollowMouse.vue';
|
||||||
|
|
|
@ -53,7 +53,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, defineAsyncComponent, provide } from 'vue';
|
import { computed, defineAsyncComponent, provide } from 'vue';
|
||||||
import * as mfm from '@transfem-org/sfm-js';
|
import * as mfm from 'mfm-js';
|
||||||
import * as Misskey from 'misskey-js';
|
import * as Misskey from 'misskey-js';
|
||||||
import { url } from '@@/js/config.js';
|
import { url } from '@@/js/config.js';
|
||||||
import { isLink } from '@@/js/is-link.js';
|
import { isLink } from '@@/js/is-link.js';
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as mfm from '@transfem-org/sfm-js';
|
import * as mfm from 'mfm-js';
|
||||||
|
|
||||||
export function checkAnimationFromMfm(nodes: mfm.MfmNode[]): boolean {
|
export function checkAnimationFromMfm(nodes: mfm.MfmNode[]): boolean {
|
||||||
const animatedNodes = mfm.extract(nodes, (node) => {
|
const animatedNodes = mfm.extract(nodes, (node) => {
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
// test is located in test/extract-mentions
|
// test is located in test/extract-mentions
|
||||||
|
|
||||||
import * as mfm from '@transfem-org/sfm-js';
|
import * as mfm from 'mfm-js';
|
||||||
|
|
||||||
export function extractMentions(nodes: mfm.MfmNode[]): mfm.MfmMention['props'][] {
|
export function extractMentions(nodes: mfm.MfmNode[]): mfm.MfmMention['props'][] {
|
||||||
// TODO: 重複を削除
|
// TODO: 重複を削除
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type * as Misskey from 'misskey-js';
|
import type * as Misskey from 'misskey-js';
|
||||||
import type * as mfm from '@transfem-org/sfm-js';
|
import type * as mfm from 'mfm-js';
|
||||||
import { extractUrlFromMfm } from '@/utility/extract-url-from-mfm.js';
|
import { extractUrlFromMfm } from '@/utility/extract-url-from-mfm.js';
|
||||||
import { getNoteUrls } from '@/utility/getNoteUrls';
|
import { getNoteUrls } from '@/utility/getNoteUrls';
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as mfm from '@transfem-org/sfm-js';
|
import * as mfm from 'mfm-js';
|
||||||
|
|
||||||
// unique without hash
|
// unique without hash
|
||||||
// [ http://a/#1, http://a/#2, http://b/#3 ] => [ http://a/#1, http://b/#3 ]
|
// [ http://a/#1, http://a/#2, http://b/#3 ] => [ http://a/#1, http://b/#3 ]
|
||||||
|
|
|
@ -1,75 +1,69 @@
|
||||||
{
|
{
|
||||||
"name": "megalodon",
|
"name": "megalodon",
|
||||||
"version": "7.0.1",
|
"version": "7.0.1",
|
||||||
"description": "Mastodon API client for node.js and browser",
|
"description": "Mastodon API client for node.js and browser",
|
||||||
"main": "./lib/src/index.js",
|
"main": "./lib/src/index.js",
|
||||||
"typings": "./lib/src/index.d.ts",
|
"typings": "./lib/src/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc -p ./",
|
"build": "tsc -p ./",
|
||||||
"doc": "typedoc --out ../docs ./src",
|
"test": "cross-env NODE_ENV=test jest -u --maxWorkers=3"
|
||||||
"test": "cross-env NODE_ENV=test jest -u --maxWorkers=3"
|
},
|
||||||
},
|
"engines": {
|
||||||
"engines": {
|
"node": "^22.0.0"
|
||||||
"node": "^22.0.0"
|
},
|
||||||
},
|
"repository": {
|
||||||
"repository": {
|
"type": "git",
|
||||||
"type": "git",
|
"url": "git+https://github.com/h3poteto/megalodon.git"
|
||||||
"url": "git+https://github.com/h3poteto/megalodon.git"
|
},
|
||||||
},
|
"keywords": [
|
||||||
"keywords": [
|
"mastodon",
|
||||||
"mastodon",
|
"client",
|
||||||
"client",
|
"api",
|
||||||
"api",
|
"streaming",
|
||||||
"streaming",
|
"rest",
|
||||||
"rest",
|
"proxy"
|
||||||
"proxy"
|
],
|
||||||
],
|
"author": "h3poteto",
|
||||||
"author": "h3poteto",
|
"license": "MIT",
|
||||||
"license": "MIT",
|
"bugs": {
|
||||||
"bugs": {
|
"url": "https://github.com/h3poteto/megalodon/issues"
|
||||||
"url": "https://github.com/h3poteto/megalodon/issues"
|
},
|
||||||
},
|
"jest": {
|
||||||
"jest": {
|
"moduleFileExtensions": [
|
||||||
"moduleFileExtensions": [
|
"ts",
|
||||||
"ts",
|
"js"
|
||||||
"js"
|
],
|
||||||
],
|
"moduleNameMapper": {
|
||||||
"moduleNameMapper": {
|
"^@/(.+)": "<rootDir>/src/$1",
|
||||||
"^@/(.+)": "<rootDir>/src/$1",
|
"^~/(.+)": "<rootDir>/$1"
|
||||||
"^~/(.+)": "<rootDir>/$1"
|
},
|
||||||
},
|
"testMatch": [
|
||||||
"testMatch": [
|
"**/test/**/*.spec.ts"
|
||||||
"**/test/**/*.spec.ts"
|
],
|
||||||
],
|
"preset": "ts-jest/presets/default",
|
||||||
"preset": "ts-jest/presets/default",
|
"transform": {
|
||||||
"transform": {
|
"^.+\\.(ts|tsx)$": [
|
||||||
"^.+\\.(ts|tsx)$": [
|
"ts-jest",
|
||||||
"ts-jest",
|
{
|
||||||
{
|
"tsconfig": "tsconfig.json"
|
||||||
"tsconfig": "tsconfig.json"
|
}
|
||||||
}
|
]
|
||||||
]
|
},
|
||||||
},
|
"testEnvironment": "node"
|
||||||
"testEnvironment": "node"
|
},
|
||||||
},
|
"homepage": "https://github.com/h3poteto/megalodon#readme",
|
||||||
"homepage": "https://github.com/h3poteto/megalodon#readme",
|
"dependencies": {
|
||||||
"dependencies": {
|
"axios": "1.9.0",
|
||||||
"@types/jest": "^29.5.10",
|
"dayjs": "1.11.13",
|
||||||
"@types/oauth": "^0.9.4",
|
"form-data": "4.0.2",
|
||||||
"axios": "1.7.4",
|
"oauth": "0.10.2",
|
||||||
"dayjs": "^1.11.10",
|
|
||||||
"form-data": "4.0.2",
|
|
||||||
"oauth": "0.10.2",
|
|
||||||
"typescript": "5.8.3"
|
"typescript": "5.8.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@typescript-eslint/eslint-plugin": "8.31.0",
|
"@types/jest": "29.5.14",
|
||||||
"@typescript-eslint/parser": "8.31.0",
|
"@types/oauth": "0.9.6",
|
||||||
"eslint": "9.25.1",
|
"jest": "29.7.0",
|
||||||
"eslint-config-prettier": "^9.0.0",
|
"jest-worker": "29.7.0",
|
||||||
"jest": "29.7.0",
|
"ts-jest": "29.3.4"
|
||||||
"jest-worker": "29.7.0",
|
}
|
||||||
"prettier": "3.5.3",
|
|
||||||
"ts-jest": "^29.1.1"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,17 +12,17 @@ import MastodonEntity from './mastodon/entity';
|
||||||
import MisskeyEntity from './misskey/entity';
|
import MisskeyEntity from './misskey/entity';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
Response,
|
type Response,
|
||||||
OAuth,
|
OAuth,
|
||||||
RequestCanceledError,
|
RequestCanceledError,
|
||||||
isCancel,
|
isCancel,
|
||||||
detector,
|
detector,
|
||||||
MegalodonInterface,
|
type MegalodonInterface,
|
||||||
NotificationType,
|
NotificationType,
|
||||||
FilterContext,
|
FilterContext,
|
||||||
Misskey,
|
Misskey,
|
||||||
Entity,
|
type Entity,
|
||||||
Converter,
|
Converter,
|
||||||
MastodonEntity,
|
type MastodonEntity,
|
||||||
MisskeyEntity,
|
type MisskeyEntity,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,65 +1,105 @@
|
||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
/* Basic Options */
|
/* Basic Options */
|
||||||
"target": "ES2022", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
|
"target": "ES2022",
|
||||||
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
/* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
|
||||||
"lib": ["ES2022", "dom"], /* Specify library files to be included in the compilation. */
|
"module": "commonjs",
|
||||||
// "allowJs": true, /* Allow javascript files to be compiled. */
|
/* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
||||||
// "checkJs": true, /* Report errors in .js files. */
|
"lib": [
|
||||||
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
"ES2022",
|
||||||
"declaration": true, /* Generates corresponding '.d.ts' file. */
|
"dom"
|
||||||
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
],
|
||||||
// "sourceMap": true, /* Generates corresponding '.map' file. */
|
/* Specify library files to be included in the compilation. */
|
||||||
// "outFile": "./", /* Concatenate and emit output to single file. */
|
// "allowJs": true, /* Allow javascript files to be compiled. */
|
||||||
"outDir": "./lib", /* Redirect output structure to the directory. */
|
// "checkJs": true, /* Report errors in .js files. */
|
||||||
"rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
||||||
// "composite": true, /* Enable project compilation */
|
"declaration": true,
|
||||||
"removeComments": true, /* Do not emit comments to output. */
|
/* Generates corresponding '.d.ts' file. */
|
||||||
// "noEmit": true, /* Do not emit outputs. */
|
"declarationMap": true,
|
||||||
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
|
/* Generates a sourcemap for each corresponding '.d.ts' file. */
|
||||||
"downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
// "sourceMap": true, /* Generates corresponding '.map' file. */
|
||||||
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
// "outFile": "./", /* Concatenate and emit output to single file. */
|
||||||
|
"outDir": "./lib",
|
||||||
|
/* Redirect output structure to the directory. */
|
||||||
|
"rootDir": "./",
|
||||||
|
/* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
||||||
|
// "composite": true, /* Enable project compilation */
|
||||||
|
"removeComments": true,
|
||||||
|
/* Do not emit comments to output. */
|
||||||
|
// "noEmit": true, /* Do not emit outputs. */
|
||||||
|
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
|
||||||
|
"downlevelIteration": false,
|
||||||
|
/* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
||||||
|
"isolatedModules": true,
|
||||||
|
/* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
||||||
|
"incremental": true,
|
||||||
|
/* Strict Type-Checking Options */
|
||||||
|
"strict": true,
|
||||||
|
/* Enable all strict type-checking options. */
|
||||||
|
"noImplicitAny": true,
|
||||||
|
/* Raise error on expressions and declarations with an implied 'any' type. */
|
||||||
|
"strictNullChecks": true,
|
||||||
|
/* Enable strict null checks. */
|
||||||
|
"strictFunctionTypes": true,
|
||||||
|
/* Enable strict checking of function types. */
|
||||||
|
"strictPropertyInitialization": true,
|
||||||
|
/* Enable strict checking of property initialization in classes. */
|
||||||
|
"noImplicitThis": true,
|
||||||
|
/* Raise error on 'this' expressions with an implied 'any' type. */
|
||||||
|
"alwaysStrict": true,
|
||||||
|
/* Parse in strict mode and emit "use strict" for each source file. */
|
||||||
|
|
||||||
/* Strict Type-Checking Options */
|
/* Additional Checks */
|
||||||
"strict": true, /* Enable all strict type-checking options. */
|
"noUnusedLocals": true,
|
||||||
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
/* Report errors on unused locals. */
|
||||||
"strictNullChecks": true, /* Enable strict null checks. */
|
"noUnusedParameters": true,
|
||||||
"strictFunctionTypes": true, /* Enable strict checking of function types. */
|
/* Report errors on unused parameters. */
|
||||||
"strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
"noImplicitReturns": true,
|
||||||
"noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
/* Report error when not all code paths in function return a value. */
|
||||||
"alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
"noFallthroughCasesInSwitch": true,
|
||||||
|
/* Report errors for fallthrough cases in switch statement. */
|
||||||
/* Additional Checks */
|
|
||||||
"noUnusedLocals": true, /* Report errors on unused locals. */
|
|
||||||
"noUnusedParameters": true, /* Report errors on unused parameters. */
|
|
||||||
"noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
|
||||||
"noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
|
/* Module Resolution Options */
|
||||||
|
"moduleResolution": "node",
|
||||||
|
/* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
||||||
|
"baseUrl": "./",
|
||||||
|
/* Base directory to resolve non-absolute module names. */
|
||||||
|
"paths": {
|
||||||
|
"@*": [
|
||||||
|
"src*"
|
||||||
|
],
|
||||||
|
"~*": [
|
||||||
|
"./*"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
/* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
||||||
|
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
||||||
|
// "typeRoots": [], /* List of folders to include type definitions from. */
|
||||||
|
// "types": [], /* Type declaration files to be included in compilation. */
|
||||||
|
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
||||||
|
"esModuleInterop": true,
|
||||||
|
/* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
||||||
|
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
||||||
|
|
||||||
/* Module Resolution Options */
|
/* Source Map Options */
|
||||||
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
// "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
|
||||||
"baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
// "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */
|
||||||
"paths": {
|
"inlineSourceMap": false,
|
||||||
"@*": ["src*"],
|
/* Emit a single file with source maps instead of having a separate file. */
|
||||||
"~*": ["./*"]
|
"inlineSources": false,
|
||||||
}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
/* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
|
||||||
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
|
||||||
// "typeRoots": [], /* List of folders to include type definitions from. */
|
|
||||||
// "types": [], /* Type declaration files to be included in compilation. */
|
|
||||||
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
|
||||||
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
|
||||||
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
|
||||||
|
|
||||||
/* Source Map Options */
|
/* Experimental Options */
|
||||||
// "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
|
"experimentalDecorators": true
|
||||||
// "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */
|
/* Enables experimental support for ES7 decorators. */
|
||||||
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
|
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
||||||
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
|
},
|
||||||
|
"include": [
|
||||||
/* Experimental Options */
|
"./src",
|
||||||
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
|
"./test"
|
||||||
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
],
|
||||||
},
|
"exclude": [
|
||||||
"include": ["./src", "./test"],
|
"node_modules",
|
||||||
"exclude": ["node_modules", "example"]
|
"example"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@microsoft/api-extractor": "7.52.5",
|
"@microsoft/api-extractor": "7.52.5",
|
||||||
|
"@simplewebauthn/types": "12.0.0",
|
||||||
"@swc/jest": "0.2.38",
|
"@swc/jest": "0.2.38",
|
||||||
"@types/jest": "29.5.14",
|
"@types/jest": "29.5.14",
|
||||||
"@types/node": "22.15.2",
|
"@types/node": "22.15.2",
|
||||||
|
@ -47,7 +48,7 @@
|
||||||
"mock-socket": "9.3.1",
|
"mock-socket": "9.3.1",
|
||||||
"ncp": "2.0.0",
|
"ncp": "2.0.0",
|
||||||
"nodemon": "3.1.10",
|
"nodemon": "3.1.10",
|
||||||
"execa": "8.0.1",
|
"execa": "9.5.2",
|
||||||
"tsd": "0.32.0",
|
"tsd": "0.32.0",
|
||||||
"typescript": "5.8.3",
|
"typescript": "5.8.3",
|
||||||
"esbuild": "0.25.3",
|
"esbuild": "0.25.3",
|
||||||
|
@ -57,7 +58,6 @@
|
||||||
"built"
|
"built"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@simplewebauthn/types": "12.0.0",
|
|
||||||
"eventemitter3": "5.0.1",
|
"eventemitter3": "5.0.1",
|
||||||
"reconnecting-websocket": "4.4.0"
|
"reconnecting-websocket": "4.4.0"
|
||||||
}
|
}
|
||||||
|
|
|
@ -19581,18 +19581,10 @@ export type operations = {
|
||||||
200: {
|
200: {
|
||||||
content: {
|
content: {
|
||||||
'application/json': {
|
'application/json': {
|
||||||
image?: {
|
type: string;
|
||||||
link?: string;
|
id?: string;
|
||||||
url: string;
|
updated?: string;
|
||||||
title?: string;
|
author?: string;
|
||||||
};
|
|
||||||
paginationLinks?: {
|
|
||||||
self?: string;
|
|
||||||
first?: string;
|
|
||||||
next?: string;
|
|
||||||
last?: string;
|
|
||||||
prev?: string;
|
|
||||||
};
|
|
||||||
link?: string;
|
link?: string;
|
||||||
title?: string;
|
title?: string;
|
||||||
items: {
|
items: {
|
||||||
|
@ -19600,33 +19592,15 @@ export type operations = {
|
||||||
guid?: string;
|
guid?: string;
|
||||||
title?: string;
|
title?: string;
|
||||||
pubDate?: string;
|
pubDate?: string;
|
||||||
creator?: string;
|
description?: string;
|
||||||
summary?: string;
|
media: {
|
||||||
content?: string;
|
medium?: string;
|
||||||
isoDate?: string;
|
url?: string;
|
||||||
categories?: string[];
|
type?: string;
|
||||||
contentSnippet?: string;
|
lang?: string;
|
||||||
enclosure?: {
|
}[];
|
||||||
url: string;
|
|
||||||
length?: number;
|
|
||||||
type?: string;
|
|
||||||
};
|
|
||||||
}[];
|
}[];
|
||||||
feedUrl?: string;
|
|
||||||
description?: string;
|
description?: string;
|
||||||
itunes?: {
|
|
||||||
image?: string;
|
|
||||||
owner?: {
|
|
||||||
name?: string;
|
|
||||||
email?: string;
|
|
||||||
};
|
|
||||||
author?: string;
|
|
||||||
summary?: string;
|
|
||||||
explicit?: string;
|
|
||||||
categories?: string[];
|
|
||||||
keywords?: string[];
|
|
||||||
[key: string]: unknown;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
965
pnpm-lock.yaml
generated
965
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue