Skip to content

Commit

Permalink
fix(frontend): frontend / frontend-embedにあるtsconfig.jsonのmoduleをES202…
Browse files Browse the repository at this point in the history
…2にする (#15215)

* fix(frontend): frontend / frontend-embedにあるtsconfig.jsonのmoduleをES2022にする

* fixed errors

* fixed errors

* fixed errors
  • Loading branch information
samunohito authored Jan 7, 2025
1 parent 99ba7eb commit f7da2ba
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
4 changes: 2 additions & 2 deletions packages/frontend-embed/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"declaration": false,
"sourceMap": false,
"target": "ES2022",
"module": "nodenext",
"moduleResolution": "nodenext",
"module": "ES2022",
"moduleResolution": "Bundler",
"removeComments": false,
"noLib": false,
"strict": true,
Expand Down
4 changes: 2 additions & 2 deletions packages/frontend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"declaration": false,
"sourceMap": false,
"target": "ES2022",
"module": "nodenext",
"moduleResolution": "nodenext",
"module": "ES2022",
"moduleResolution": "Bundler",
"removeComments": false,
"noLib": false,
"strict": true,
Expand Down
4 changes: 2 additions & 2 deletions packages/misskey-js/etc/misskey-js.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

import type { AuthenticationResponseJSON } from '@simplewebauthn/types';
import { EventEmitter } from 'eventemitter3';
import { Options } from 'reconnecting-websocket';
import type { PublicKeyCredentialRequestOptionsJSON } from '@simplewebauthn/types';
import _ReconnectingWebsocket from 'reconnecting-websocket';

// Warning: (ae-forgotten-export) The symbol "components" needs to be exported by the entry point index.d.ts
//
Expand Down Expand Up @@ -3150,7 +3150,7 @@ export class Stream extends EventEmitter<StreamEvents> implements IStream {
constructor(origin: string, user: {
token: string;
} | null, options?: {
WebSocket?: _ReconnectingWebsocket.Options['WebSocket'];
WebSocket?: Options['WebSocket'];
});
// (undocumented)
close(): void;
Expand Down
12 changes: 7 additions & 5 deletions packages/misskey-js/src/streaming.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { EventEmitter } from 'eventemitter3';
import _ReconnectingWebsocket from 'reconnecting-websocket';
import _ReconnectingWebSocket, { Options } from 'reconnecting-websocket';
import type { BroadcastEvents, Channels } from './streaming.types.js';

const ReconnectingWebsocket = _ReconnectingWebsocket as unknown as typeof _ReconnectingWebsocket['default'];
// コンストラクタとクラスそのものの定義が上手く解決出来ないため再定義
const ReconnectingWebSocketConstructor = _ReconnectingWebSocket as unknown as typeof _ReconnectingWebSocket.default;
type ReconnectingWebSocket = _ReconnectingWebSocket.default;

export function urlQuery(obj: Record<string, string | number | boolean | undefined>): string {
const params = Object.entries(obj)
Expand Down Expand Up @@ -43,15 +45,15 @@ export interface IStream extends EventEmitter<StreamEvents> {
*/
// eslint-disable-next-line import/no-default-export
export default class Stream extends EventEmitter<StreamEvents> implements IStream {
private stream: _ReconnectingWebsocket.default;
private stream: ReconnectingWebSocket;
public state: 'initializing' | 'reconnecting' | 'connected' = 'initializing';
private sharedConnectionPools: Pool[] = [];
private sharedConnections: SharedConnection[] = [];
private nonSharedConnections: NonSharedConnection[] = [];
private idCounter = 0;

constructor(origin: string, user: { token: string; } | null, options?: {
WebSocket?: _ReconnectingWebsocket.Options['WebSocket'];
WebSocket?: Options['WebSocket'];
}) {
super();

Expand Down Expand Up @@ -80,7 +82,7 @@ export default class Stream extends EventEmitter<StreamEvents> implements IStrea

const wsOrigin = origin.replace('http://', 'ws://').replace('https://', 'wss://');

this.stream = new ReconnectingWebsocket(`${wsOrigin}/streaming?${query}`, '', {
this.stream = new ReconnectingWebSocketConstructor(`${wsOrigin}/streaming?${query}`, '', {
minReconnectionDelay: 1, // https://github.com/pladaria/reconnecting-websocket/issues/91
WebSocket: options.WebSocket,
});
Expand Down

0 comments on commit f7da2ba

Please sign in to comment.