1
1
mirror of https://github.com/kokonect-link/cherrypick synced 2024-12-15 07:08:56 +09:00
This commit is contained in:
syuilo 2021-06-19 23:07:08 +09:00
parent 091ef2e240
commit ce12fc2b67
5 changed files with 85 additions and 86 deletions

View File

@ -1,4 +1,4 @@
import { Endpoints } from './endpoints'; import { Endpoints } from './api.types';
const MK_API_ERROR = Symbol(); const MK_API_ERROR = Symbol();

View File

@ -1,4 +1,4 @@
import { Endpoints } from './endpoints'; import { Endpoints } from './api.types';
import Stream from './streaming'; import Stream from './streaming';
import { Acct } from './acct'; import { Acct } from './acct';

View File

@ -3,7 +3,7 @@ import { EventEmitter } from 'eventemitter3';
import ReconnectingWebsocket from 'reconnecting-websocket'; import ReconnectingWebsocket from 'reconnecting-websocket';
import { stringify } from 'querystring'; import { stringify } from 'querystring';
import { markRaw } from '@vue/reactivity'; import { markRaw } from '@vue/reactivity';
import { DriveFile, MeDetailed, MessagingMessage, Note, Notification, PageEvent, User } from './entities'; import { ChannelDef, NoteUpdatedEvent } from './streaming.types';
function urlQuery(obj: {}): string { function urlQuery(obj: {}): string {
return stringify(Object.entries(obj) return stringify(Object.entries(obj)
@ -11,89 +11,6 @@ function urlQuery(obj: {}): string {
.reduce((a, [k, v]) => (a[k] = v, a), {} as Record<string, any>)); .reduce((a, [k, v]) => (a[k] = v, a), {} as Record<string, any>));
} }
type FIXME = any;
type ChannelDef = {
main: {
events: {
notification: (payload: Notification) => void;
mention: (payload: Note) => void;
reply: (payload: Note) => void;
renote: (payload: Note) => void;
follow: (payload: User) => void; // 自分が他人をフォローしたとき
followed: (payload: User) => void; // 他人が自分をフォローしたとき
unfollow: (payload: User) => void; // 自分が他人をフォロー解除したとき
meUpdated: (payload: MeDetailed) => void;
pageEvent: (payload: PageEvent) => void;
urlUploadFinished: (payload: { marker: string; file: DriveFile; }) => void;
readAllNotifications: () => void;
unreadNotification: () => void;
unreadMention: () => void;
readAllUnreadMentions: () => void;
unreadSpecifiedNote: () => void;
readAllUnreadSpecifiedNotes: () => void;
readAllMessagingMessages: () => void;
unreadMessagingMessage: () => void;
readAllAntennas: () => void;
unreadAntenna: () => void;
readAllAnnouncements: () => void;
readAllChannels: () => void;
unreadChannel: () => void;
myTokenRegenerated: () => void;
};
};
homeTimeline: {
events: {
note: (payload: Note) => void;
};
};
localTimeline: {
events: {
note: (payload: Note) => void;
};
};
hybridTimeline: {
events: {
note: (payload: Note) => void;
};
};
globalTimeline: {
events: {
note: (payload: Note) => void;
};
};
messaging: {
events: {
message: (payload: MessagingMessage) => void;
deleted: (payload: MessagingMessage['id']) => void;
read: (payload: MessagingMessage['id'][]) => void;
typers: (payload: User[]) => void;
};
};
};
type NoteUpdatedEvent = {
id: Note['id'];
type: 'reacted';
body: {
reaction: string;
userId: User['id'];
};
} | {
id: Note['id'];
type: 'deleted';
body: {
deletedAt: string;
};
} | {
id: Note['id'];
type: 'pollVoted';
body: {
choice: number;
userId: User['id'];
};
};
type StreamEvents = { type StreamEvents = {
_connected_: void; _connected_: void;
_disconnected_: void; _disconnected_: void;

82
src/streaming.types.ts Normal file
View File

@ -0,0 +1,82 @@
import { DriveFile, MeDetailed, MessagingMessage, Note, Notification, PageEvent, User } from './entities';
export type ChannelDef = {
main: {
events: {
notification: (payload: Notification) => void;
mention: (payload: Note) => void;
reply: (payload: Note) => void;
renote: (payload: Note) => void;
follow: (payload: User) => void; // 自分が他人をフォローしたとき
followed: (payload: User) => void; // 他人が自分をフォローしたとき
unfollow: (payload: User) => void; // 自分が他人をフォロー解除したとき
meUpdated: (payload: MeDetailed) => void;
pageEvent: (payload: PageEvent) => void;
urlUploadFinished: (payload: { marker: string; file: DriveFile; }) => void;
readAllNotifications: () => void;
unreadNotification: () => void;
unreadMention: () => void;
readAllUnreadMentions: () => void;
unreadSpecifiedNote: () => void;
readAllUnreadSpecifiedNotes: () => void;
readAllMessagingMessages: () => void;
unreadMessagingMessage: () => void;
readAllAntennas: () => void;
unreadAntenna: () => void;
readAllAnnouncements: () => void;
readAllChannels: () => void;
unreadChannel: () => void;
myTokenRegenerated: () => void;
};
};
homeTimeline: {
events: {
note: (payload: Note) => void;
};
};
localTimeline: {
events: {
note: (payload: Note) => void;
};
};
hybridTimeline: {
events: {
note: (payload: Note) => void;
};
};
globalTimeline: {
events: {
note: (payload: Note) => void;
};
};
messaging: {
events: {
message: (payload: MessagingMessage) => void;
deleted: (payload: MessagingMessage['id']) => void;
read: (payload: MessagingMessage['id'][]) => void;
typers: (payload: User[]) => void;
};
};
};
export type NoteUpdatedEvent = {
id: Note['id'];
type: 'reacted';
body: {
reaction: string;
userId: User['id'];
};
} | {
id: Note['id'];
type: 'deleted';
body: {
deletedAt: string;
};
} | {
id: Note['id'];
type: 'pollVoted';
body: {
choice: number;
userId: User['id'];
};
};