mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-07-27 00:34:35 +02:00
* wip * bump misskey-dev/eslint-plugin * lint fixes (backend) * lint fixes (frontend) * lint fixes (frontend-embed) * rollback nsfwjs to 4.2.0 ref: infinitered/nsfwjs#904 * rollback openapi-typescript to v6 v7でOpenAPIのバリデーションが入るようになった関係でスコープ外での変更が避けられないため一時的に戻した * lint fixes (misskey-js) * temporarily disable errored lint rule (frontend-shared) * fix lint * temporarily ignore errored file for lint (frontend-shared) * rollback simplewebauthn/server to 12.0.0 v13 contains breaking changes that require some decision making * lint fixes (frontend-shared) * build misskey-js with types * fix(backend): migrate simplewebauthn/server to v12 * fix(misskey-js/autogen): ignore indent rules to generate consistent output * attempt to fix test changes due to capricorn86/happy-dom#1617 (XMLSerializer now produces valid XML) * attempt to fix test changes due to capricorn86/happy-dom#1617 (XMLSerializer now produces valid XML) * fix test * fix test * fix test * Apply suggestions from code review Co-authored-by: anatawa12 <anatawa12@icloud.com> * bump summaly to v5.2.0 * update tabler-icons to v3.30.0-based --------- Co-authored-by: かっこかり <67428053+kakkokari-gtyih@users.noreply.github.com> Co-authored-by: anatawa12 <anatawa12@icloud.com>
82 lines
2.1 KiB
TypeScript
82 lines
2.1 KiB
TypeScript
/*
|
||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||
* SPDX-License-Identifier: AGPL-3.0-only
|
||
*/
|
||
|
||
import { EventEmitter } from 'eventemitter3';
|
||
import * as Misskey from 'misskey-js';
|
||
import type { Channels, StreamEvents, IStream, IChannelConnection } from 'misskey-js';
|
||
|
||
type AnyOf<T extends Record<any, any>> = T[keyof T];
|
||
type OmitFirst<T extends any[]> = T extends [any, ...infer R] ? R : never;
|
||
|
||
/**
|
||
* Websocket無効化時に使うStreamのモック(なにもしない)
|
||
*/
|
||
export class StreamMock extends EventEmitter<StreamEvents> implements IStream {
|
||
public readonly state = 'initializing';
|
||
|
||
constructor(...args: ConstructorParameters<typeof Misskey.Stream>) {
|
||
super();
|
||
// do nothing
|
||
}
|
||
|
||
public useChannel<C extends keyof Channels>(channel: C, params?: Channels[C]['params'], name?: string): ChannelConnectionMock<Channels[C]> {
|
||
return new ChannelConnectionMock(this, channel, name);
|
||
}
|
||
|
||
public removeSharedConnection(connection: any): void {
|
||
// do nothing
|
||
}
|
||
|
||
public removeSharedConnectionPool(pool: any): void {
|
||
// do nothing
|
||
}
|
||
|
||
public disconnectToChannel(): void {
|
||
// do nothing
|
||
}
|
||
|
||
public send(typeOrPayload: string): void;
|
||
public send(typeOrPayload: string, payload: any): void;
|
||
public send(typeOrPayload: Record<string, any> | any[]): void;
|
||
public send(typeOrPayload: string | Record<string, any> | any[], payload?: any): void {
|
||
// do nothing
|
||
}
|
||
|
||
public ping(): void {
|
||
// do nothing
|
||
}
|
||
|
||
public heartbeat(): void {
|
||
// do nothing
|
||
}
|
||
|
||
public close(): void {
|
||
// do nothing
|
||
}
|
||
}
|
||
|
||
class ChannelConnectionMock<Channel extends AnyOf<Channels> = any> extends EventEmitter<Channel['events']> implements IChannelConnection<Channel> {
|
||
public id = '';
|
||
public name?: string; // for debug
|
||
public inCount = 0; // for debug
|
||
public outCount = 0; // for debug
|
||
public channel: string;
|
||
|
||
constructor(stream: IStream, ...args: OmitFirst<ConstructorParameters<typeof Misskey.ChannelConnection<Channel>>>) {
|
||
super();
|
||
|
||
this.channel = args[0];
|
||
this.name = args[1];
|
||
}
|
||
|
||
public send<T extends keyof Channel['receives']>(type: T, body: Channel['receives'][T]): void {
|
||
// do nothing
|
||
}
|
||
|
||
public dispose(): void {
|
||
// do nothing
|
||
}
|
||
}
|