kill any from streaming API Implementation (#14251)
* chore: add JsonValue type * refactor: kill any from Connection.ts * refactor: fix StreamEventEmitter contains undefined instead of null * refactor: kill any from channels * docs(changelog): Fix: Steaming APIが不正なデータを受けた場合の動作が不安定である問題 * fix license header * fix lints
This commit is contained in:
@@ -8,6 +8,7 @@ import { isInstanceMuted } from '@/misc/is-instance-muted.js';
|
||||
import { isUserRelated } from '@/misc/is-user-related.js';
|
||||
import { isRenotePacked, isQuotePacked } from '@/misc/is-renote.js';
|
||||
import type { Packed } from '@/misc/json-schema.js';
|
||||
import type { JsonObject, JsonValue } from '@/misc/json-value.js';
|
||||
import type Connection from './Connection.js';
|
||||
|
||||
/**
|
||||
@@ -81,10 +82,12 @@ export default abstract class Channel {
|
||||
this.connection = connection;
|
||||
}
|
||||
|
||||
public send(payload: { type: string, body: JsonValue }): void
|
||||
public send(type: string, payload: JsonValue): void
|
||||
@bindThis
|
||||
public send(typeOrPayload: any, payload?: any) {
|
||||
const type = payload === undefined ? typeOrPayload.type : typeOrPayload;
|
||||
const body = payload === undefined ? typeOrPayload.body : payload;
|
||||
public send(typeOrPayload: { type: string, body: JsonValue } | string, payload?: JsonValue) {
|
||||
const type = payload === undefined ? (typeOrPayload as { type: string, body: JsonValue }).type : (typeOrPayload as string);
|
||||
const body = payload === undefined ? (typeOrPayload as { type: string, body: JsonValue }).body : payload;
|
||||
|
||||
this.connection.sendMessageToWs('channel', {
|
||||
id: this.id,
|
||||
@@ -93,11 +96,11 @@ export default abstract class Channel {
|
||||
});
|
||||
}
|
||||
|
||||
public abstract init(params: any): void;
|
||||
public abstract init(params: JsonObject): void;
|
||||
|
||||
public dispose?(): void;
|
||||
|
||||
public onMessage?(type: string, body: any): void;
|
||||
public onMessage?(type: string, body: JsonValue): void;
|
||||
}
|
||||
|
||||
export type MiChannelService<T extends boolean> = {
|
||||
|
Reference in New Issue
Block a user