refactor8frontend9: anyを除去 (#16778)
This commit is contained in:
parent
73bcd330f7
commit
fd2fe34270
|
|
@ -13,17 +13,16 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
</MkPagination>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
<script lang="ts" setup generic="P extends IPaginator">
|
||||
import * as Misskey from 'misskey-js';
|
||||
import type { IPaginator } from '@/utility/paginator.js';
|
||||
import type { IPaginator, ExtractorFunction } from '@/utility/paginator.js';
|
||||
import MkChannelPreview from '@/components/MkChannelPreview.vue';
|
||||
import MkPagination from '@/components/MkPagination.vue';
|
||||
import { i18n } from '@/i18n.js';
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
paginator: IPaginator;
|
||||
paginator: P;
|
||||
noGap?: boolean;
|
||||
extractor?: (item: any) => Misskey.entities.Channel;
|
||||
extractor?: ExtractorFunction<P, Misskey.entities.Channel>;
|
||||
}>(), {
|
||||
extractor: (item) => item,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -15,17 +15,17 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
</MkPagination>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
<script lang="ts" setup generic="P extends IPaginator">
|
||||
import * as Misskey from 'misskey-js';
|
||||
import type { IPaginator } from '@/utility/paginator.js';
|
||||
import type { IPaginator, ExtractorFunction } from '@/utility/paginator.js';
|
||||
import MkUserInfo from '@/components/MkUserInfo.vue';
|
||||
import MkPagination from '@/components/MkPagination.vue';
|
||||
import { i18n } from '@/i18n.js';
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
paginator: IPaginator;
|
||||
paginator: P;
|
||||
noGap?: boolean;
|
||||
extractor?: (item: any) => Misskey.entities.UserDetailed;
|
||||
extractor?: ExtractorFunction<P, Misskey.entities.UserDetailed>;
|
||||
}>(), {
|
||||
extractor: (item) => item,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -19,10 +19,13 @@ export function useForm<T extends Record<string, any>>(initialState: T, save: (n
|
|||
const currentState = reactive<T>(copy(initialState));
|
||||
const previousState = reactive<T>(copy(initialState));
|
||||
|
||||
const modifiedStates = reactive<Record<keyof T, boolean>>({} as any);
|
||||
for (const key in currentState) {
|
||||
modifiedStates[key] = false;
|
||||
const modifiedStates = reactive<Record<keyof T, boolean>>((() => {
|
||||
const obj: Record<keyof T, boolean> = {} as Record<keyof T, boolean>;
|
||||
for (const key in initialState) {
|
||||
obj[key] = false;
|
||||
}
|
||||
return obj;
|
||||
})());
|
||||
const modified = computed(() => Object.values(modifiedStates).some(v => v));
|
||||
const modifiedCount = computed(() => Object.values(modifiedStates).filter(v => v).length);
|
||||
|
||||
|
|
|
|||
|
|
@ -4,13 +4,14 @@
|
|||
*/
|
||||
|
||||
import type { InjectionKey, Ref } from 'vue';
|
||||
import type { PageMetadata } from '@/page.js';
|
||||
import type { Router } from '@/router.js';
|
||||
|
||||
export const DI = {
|
||||
routerCurrentDepth: Symbol() as InjectionKey<number>,
|
||||
router: Symbol() as InjectionKey<Router>,
|
||||
mock: Symbol() as InjectionKey<boolean>,
|
||||
pageMetadata: Symbol() as InjectionKey<Ref<Record<string, any> | null>>,
|
||||
pageMetadata: Symbol() as InjectionKey<Ref<PageMetadata | null>>,
|
||||
viewId: Symbol() as InjectionKey<string>,
|
||||
currentStickyTop: Symbol() as InjectionKey<Ref<number>>,
|
||||
currentStickyBottom: Symbol() as InjectionKey<Ref<number>>,
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import type { Directive } from 'vue';
|
|||
import { getBgColor } from '@/utility/get-bg-color.js';
|
||||
import { globalEvents } from '@/events.js';
|
||||
|
||||
const handlerMap = new WeakMap<any, any>();
|
||||
const handlerMap = new WeakMap<HTMLElement, () => void>();
|
||||
|
||||
export const adaptiveBorderDirective = {
|
||||
mounted(src) {
|
||||
|
|
|
|||
|
|
@ -119,9 +119,9 @@ export const userPreviewDirective = {
|
|||
|
||||
// TODO: 新たにプロパティを作るのをやめMapを使う
|
||||
// ただメモリ的には↓の方が省メモリかもしれないので検討中
|
||||
const self = (el as any)._userPreviewDirective_ = {} as any;
|
||||
|
||||
self.preview = new UserPreview(el, binding.value);
|
||||
el._userPreviewDirective_ = {
|
||||
preview: new UserPreview(el, binding.value),
|
||||
};
|
||||
},
|
||||
|
||||
unmounted(el, binding) {
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ export class Pizzax<T extends StateDef> {
|
|||
private pizzaxChannel: BroadcastChannel<PizzaxChannelMessage<T>>;
|
||||
|
||||
// 簡易的にキューイングして占有ロックとする
|
||||
private currentIdbJob: Promise<any> = Promise.resolve();
|
||||
private currentIdbJob: Promise<unknown> = Promise.resolve();
|
||||
private addIdbSetJob<T>(job: () => Promise<T>) {
|
||||
const promise = this.currentIdbJob.then(job, err => {
|
||||
console.error('Pizzax failed to save data to idb!', err);
|
||||
|
|
|
|||
|
|
@ -257,7 +257,7 @@ const {
|
|||
const user = ref(result.user);
|
||||
const info = ref(result.info);
|
||||
const ips = ref(result.ips);
|
||||
const ap = ref<any>(null);
|
||||
const ap = ref<Misskey.entities.ApGetResponse | null>(null);
|
||||
const moderator = ref(info.value.isModerator);
|
||||
const silenced = ref(info.value.isSilenced);
|
||||
const suspended = ref(info.value.isSuspended);
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ async function addRelay() {
|
|||
if (canceled || inbox == null) return;
|
||||
misskeyApi('admin/relays/add', {
|
||||
inbox,
|
||||
}).then((relay: any) => {
|
||||
}).then(() => {
|
||||
refresh();
|
||||
}).catch((err: any) => {
|
||||
os.alert({
|
||||
|
|
|
|||
|
|
@ -161,7 +161,11 @@ async function _fetch_() {
|
|||
},
|
||||
raw: res.data,
|
||||
};
|
||||
} catch (err: any) {
|
||||
} catch (err) {
|
||||
if (!(err instanceof Error)) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
switch (err.message.toLowerCase()) {
|
||||
case 'this theme is already installed':
|
||||
errorKV.value = {
|
||||
|
|
|
|||
|
|
@ -7,8 +7,6 @@ import * as Misskey from 'misskey-js';
|
|||
import { markRaw } from 'vue';
|
||||
import { $i } from '@/i.js';
|
||||
import { wsOrigin } from '@@/js/config.js';
|
||||
// TODO: No WebsocketモードでStreamMockが使えそう
|
||||
//import { StreamMock } from '@/utility/stream-mock.js';
|
||||
|
||||
// heart beat interval in ms
|
||||
const HEART_BEAT_INTERVAL = 1000 * 60;
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ export function uploadFile(file: File | Blob, options: {
|
|||
const driveFile = JSON.parse(ev.target.response);
|
||||
globalEvents.emit('driveFileCreated', driveFile);
|
||||
resolve(driveFile);
|
||||
}) as (ev: ProgressEvent<EventTarget>) => any;
|
||||
}) as (ev: ProgressEvent<EventTarget>) => void;
|
||||
|
||||
if (options.onProgress) {
|
||||
xhr.upload.onprogress = ev => {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ interface CommonParamDef {
|
|||
type: string;
|
||||
label?: string;
|
||||
caption?: string;
|
||||
default: any;
|
||||
default: unknown;
|
||||
}
|
||||
|
||||
interface NumberParamDef extends CommonParamDef {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
import { ref, shallowRef, triggerRef } from 'vue';
|
||||
import * as Misskey from 'misskey-js';
|
||||
import type { ComputedRef, Ref, ShallowRef } from 'vue';
|
||||
import type { ComputedRef, Ref, ShallowRef, UnwrapRef } from 'vue';
|
||||
import { misskeyApi } from '@/utility/misskey-api.js';
|
||||
|
||||
const MAX_ITEMS = 30;
|
||||
|
|
@ -19,7 +19,12 @@ export type MisskeyEntity = {
|
|||
_shouldInsertAd_?: boolean;
|
||||
};
|
||||
|
||||
type FilterByEpRes<E extends Record<string, any>> = {
|
||||
type AbsEndpointType = {
|
||||
req: unknown;
|
||||
res: unknown;
|
||||
};
|
||||
|
||||
type FilterByEpRes<E extends Record<string, AbsEndpointType>> = {
|
||||
[K in keyof E]: E[K]['res'] extends Array<{ id: string }> ? K : never
|
||||
}[keyof E];
|
||||
export type PaginatorCompatibleEndpointPaths = FilterByEpRes<Misskey.Endpoints>;
|
||||
|
|
@ -27,6 +32,8 @@ export type PaginatorCompatibleEndpoints = {
|
|||
[K in PaginatorCompatibleEndpointPaths]: Misskey.Endpoints[K];
|
||||
};
|
||||
|
||||
export type ExtractorFunction<P extends IPaginator, T> = (item: UnwrapRef<P['items']>[number]) => T;
|
||||
|
||||
export interface IPaginator<T = unknown, _T = T & MisskeyEntity> {
|
||||
/**
|
||||
* 外部から直接操作しないでください
|
||||
|
|
|
|||
|
|
@ -1,81 +0,0 @@
|
|||
/*
|
||||
* 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
|
||||
}
|
||||
}
|
||||
|
|
@ -222,7 +222,8 @@ export class WatermarkRenderer {
|
|||
},
|
||||
});
|
||||
} else {
|
||||
throw new Error(`Unrecognized layer type: ${(layer as any).type}`);
|
||||
// @ts-expect-error Should be unreachable
|
||||
throw new Error(`Unrecognized layer type: ${layer.type}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue