feat(frontend): ノート・ユーザータイムライン埋め込み (#13929)
* fix * navhookをbootに移動 * サーバーサイドのbootも分けるように * 埋め込みページかどうかの判定は最初の一回だけに * tooltipは出せるように * fix design * 埋め込み独自のtooltipを削除 * ロジックの分岐が多かったMkNoteDetailedを分離 * fix indent * プレビュー用iframeにフォーカスが当たるのを修正 * popupの制御を出す側で行うように * パラメータが逆になっていたのを修正 * Update MkEmbedCodeGenDialog.vue * fix * eliminate misskey-js lint warns * fix * add appropriate attributes to embed html * enhance: サーバーサイドのembed系をさらに分離 * enhance: embed routerを分離(route定義をboot時に変更できるようにする改修を含む) * type * lint * fix indent * server-side styleを完全に分離 * Revert "refactor: 画面サイズのしきい値をconstにまとめる" This reverts commit05ca36f400
. * fix * revert all changes in base.pug * embedドメインをまとめた * embedドメインをまとめた * prevent calling contextmenu in embed page by stopping at the caller * fix import * fix import * improve directory structure * fix import * register timeline ui as a container * wa- * rename * wa- * Update EmMediaList.vue * Update EmMediaList.vue * Update EmMediaList.vue * Update EmMediaImage.vue * Update EmNote.vue * revert mkmedialist changes * 戻し漏れ * wip * tweak embed media ui * revert original media components * Update boot.embed.js * rename * wip * Update MkNote.vue * wip * Update MkSubNoteContent.vue * Update EmNote.vue * Update packages/frontend/src/router/definition.ts * Revert "Update packages/frontend/src/router/definition.ts" This reverts commit937ae44521
. * refactor EmMediaImage * fix import * remove unused imports * Update router.ts * wip * Update boot.ts * wip * wip * wip * wip * Update EmNote.vue * Update EmNote.vue * Create EmA.vue * Create EmAvatar.vue * Update EmAvatar.vue * wip * wip * wip * Create EmImgWithBlurhash.vue * Update EmImgWithBlurhash.vue * Create EmPagination.vue * wip * Update boot.ts * wip * wip * wi@p * wip * wip * wiop * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * Update boot.ts * wip * Update MkMisskeyFlavoredMarkdown.ts * wip * wip * wip * wip * wip * Update post-message.ts * wip * Update EmNoteDetailed.vue * Update EmNoteDetailed.vue * Create instance.ts * Update EmNoteDetailed.vue * wip * Update EmNoteDetailed.vue * wip * wip * wip * Update pnpm-lock.yaml * wip * wip * wp * wip * Update ClientServerService.ts * wip * Update boot.ts * Update vite.config.local-dev.ts * Update vite.config.ts * Create index.html * wa- * wip * Update boot.ts * wip * wip * wip * wip * wip * wip * wip * wip * wip * Create EmLink.vue * Create EmMention.vue * Update EmMfm.ts * wip * wip * wip * wip * Update vite.config.ts * Update boot.ts * Update EmA.vue * うぃp * wip * wip * Create EmError.vue * wip * Update MkEmbedCodeGenDialog.vue * Update EmNote.vue * wip * wip * Update user-timeline.vue * Update check-spdx-license-id.yml * wip * wip * style(frontend-shared): lint fixes on build.js * fix(frontend-shared): include `*.{js,json}` files in js-built * wip * use alias * refactor * refactor * Update scroll.ts * refactor * refactor * refactor * wip * wip * wip * wip * Update roles.vue * Update branding.vue * wip * wip * wip * Update page.vue * wip * fix import * add missing css variables * 絵文字をtwemojiに変更 クライアントデフォルトにあわせるため * force empoll readonly * fix compiler error * fix broken imports * tweak button style * run api extractor * fix storybook theme preloads * fix storybook instance imports * Update preview.ts * Update preview.ts * Update preview.ts * Revert "Update preview.ts" This reverts commit12bab1c6fb
. * Revert "Update preview.ts" This reverts commit5c0ce01dbd
. * Revert "Update preview.ts" This reverts commitf4863524d7
. * Revert "fix storybook instance imports" This reverts commited8eabb246
. * Revert "wip" This reverts commitd3c1926519
. * Revert "Update page.vue" This reverts commit27c7900b0c
. * Revert "Update branding.vue" This reverts commitc08ccb65ba
. * Revert "Update roles.vue" This reverts commit1488b67066
. * Revert "wip" This reverts commitaab1c76981
. * refactor: use common media proxy * fix imports * fix * fix: MediaProxyの初期化を保証する(storybook対策?) * enhance(frontend-embed): improve embedParams provide * fix(backend): MK_DEV_PREFER=backendのときにembed viteが読み込めないのを修正 * fix * embed-pageを共通化 * fix import * fix import * fix import * const.jsを共通化 (たぶんrevertしすぎた) * fix type error * fix duplicated import * fix lint * fix * コメントとして残す * sharedとembedをlint対象にする * lint * attempt to fix eslint (frontend-shared) * lint fixes --------- Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com> Co-authored-by: zyoshoka <107108195+zyoshoka@users.noreply.github.com>
This commit is contained in:
@@ -551,7 +551,7 @@ type Channel = components['schemas']['Channel'];
|
||||
// Warning: (ae-forgotten-export) The symbol "AnyOf" needs to be exported by the entry point index.d.ts
|
||||
//
|
||||
// @public (undocumented)
|
||||
export abstract class ChannelConnection<Channel extends AnyOf<Channels> = AnyOf<Channels>> extends EventEmitter<Channel['events']> {
|
||||
export abstract class ChannelConnection<Channel extends AnyOf<Channels> = AnyOf<Channels>> extends EventEmitter<Channel['events']> implements IChannelConnection<Channel> {
|
||||
constructor(stream: Stream, channel: string, name?: string);
|
||||
// (undocumented)
|
||||
channel: string;
|
||||
@@ -2119,6 +2119,24 @@ type IAuthorizedAppsResponse = operations['i___authorized-apps']['responses']['2
|
||||
// @public (undocumented)
|
||||
type IChangePasswordRequest = operations['i___change-password']['requestBody']['content']['application/json'];
|
||||
|
||||
// @public (undocumented)
|
||||
export interface IChannelConnection<Channel extends AnyOf<Channels> = AnyOf<Channels>> extends EventEmitter<Channel['events']> {
|
||||
// (undocumented)
|
||||
channel: string;
|
||||
// (undocumented)
|
||||
dispose(): void;
|
||||
// (undocumented)
|
||||
id: string;
|
||||
// (undocumented)
|
||||
inCount: number;
|
||||
// (undocumented)
|
||||
name?: string;
|
||||
// (undocumented)
|
||||
outCount: number;
|
||||
// (undocumented)
|
||||
send<T extends keyof Channel['receives']>(type: T, body: Channel['receives'][T]): void;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
type IClaimAchievementRequest = operations['i___claim-achievement']['requestBody']['content']['application/json'];
|
||||
|
||||
@@ -2281,6 +2299,40 @@ type ISigninHistoryResponse = operations['i___signin-history']['responses']['200
|
||||
// @public (undocumented)
|
||||
function isPureRenote(note: Note): note is PureRenote;
|
||||
|
||||
// @public (undocumented)
|
||||
export interface IStream extends EventEmitter<StreamEvents> {
|
||||
// (undocumented)
|
||||
close(): void;
|
||||
// Warning: (ae-forgotten-export) The symbol "NonSharedConnection" needs to be exported by the entry point index.d.ts
|
||||
//
|
||||
// (undocumented)
|
||||
disconnectToChannel(connection: NonSharedConnection): void;
|
||||
// (undocumented)
|
||||
heartbeat(): void;
|
||||
// (undocumented)
|
||||
ping(): void;
|
||||
// Warning: (ae-forgotten-export) The symbol "SharedConnection" needs to be exported by the entry point index.d.ts
|
||||
//
|
||||
// (undocumented)
|
||||
removeSharedConnection(connection: SharedConnection): void;
|
||||
// Warning: (ae-forgotten-export) The symbol "Pool" needs to be exported by the entry point index.d.ts
|
||||
//
|
||||
// (undocumented)
|
||||
removeSharedConnectionPool(pool: Pool): void;
|
||||
// (undocumented)
|
||||
send(typeOrPayload: string): void;
|
||||
// (undocumented)
|
||||
send(typeOrPayload: string, payload: unknown): void;
|
||||
// (undocumented)
|
||||
send(typeOrPayload: Record<string, unknown> | unknown[]): void;
|
||||
// (undocumented)
|
||||
send(typeOrPayload: string | Record<string, unknown> | unknown[], payload?: unknown): void;
|
||||
// (undocumented)
|
||||
state: 'initializing' | 'reconnecting' | 'connected';
|
||||
// (undocumented)
|
||||
useChannel<C extends keyof Channels>(channel: C, params?: Channels[C]['params'], name?: string): IChannelConnection<Channels[C]>;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
type IUnpinRequest = operations['i___unpin']['requestBody']['content']['application/json'];
|
||||
|
||||
@@ -2707,6 +2759,9 @@ type NotificationsCreateRequest = operations['notifications___create']['requestB
|
||||
// @public (undocumented)
|
||||
export const notificationTypes: readonly ["note", "follow", "mention", "reply", "renote", "quote", "reaction", "pollVote", "pollEnded", "receiveFollowRequest", "followRequestAccepted", "groupInvited", "app", "roleAssigned", "achievementEarned"];
|
||||
|
||||
// @public (undocumented)
|
||||
export function nyaize(text: string): string;
|
||||
|
||||
// @public (undocumented)
|
||||
type Page = components['schemas']['Page'];
|
||||
|
||||
@@ -2997,10 +3052,8 @@ type SignupResponse = MeDetailed & {
|
||||
// @public (undocumented)
|
||||
type StatsResponse = operations['stats']['responses']['200']['content']['application/json'];
|
||||
|
||||
// Warning: (ae-forgotten-export) The symbol "StreamEvents" needs to be exported by the entry point index.d.ts
|
||||
//
|
||||
// @public (undocumented)
|
||||
export class Stream extends EventEmitter<StreamEvents> {
|
||||
export class Stream extends EventEmitter<StreamEvents> implements IStream {
|
||||
constructor(origin: string, user: {
|
||||
token: string;
|
||||
} | null, options?: {
|
||||
@@ -3008,20 +3061,14 @@ export class Stream extends EventEmitter<StreamEvents> {
|
||||
});
|
||||
// (undocumented)
|
||||
close(): void;
|
||||
// Warning: (ae-forgotten-export) The symbol "NonSharedConnection" needs to be exported by the entry point index.d.ts
|
||||
//
|
||||
// (undocumented)
|
||||
disconnectToChannel(connection: NonSharedConnection): void;
|
||||
// (undocumented)
|
||||
heartbeat(): void;
|
||||
// (undocumented)
|
||||
ping(): void;
|
||||
// Warning: (ae-forgotten-export) The symbol "SharedConnection" needs to be exported by the entry point index.d.ts
|
||||
//
|
||||
// (undocumented)
|
||||
removeSharedConnection(connection: SharedConnection): void;
|
||||
// Warning: (ae-forgotten-export) The symbol "Pool" needs to be exported by the entry point index.d.ts
|
||||
//
|
||||
// (undocumented)
|
||||
removeSharedConnectionPool(pool: Pool): void;
|
||||
// (undocumented)
|
||||
@@ -3036,6 +3083,14 @@ export class Stream extends EventEmitter<StreamEvents> {
|
||||
useChannel<C extends keyof Channels>(channel: C, params?: Channels[C]['params'], name?: string): ChannelConnection<Channels[C]>;
|
||||
}
|
||||
|
||||
// Warning: (ae-forgotten-export) The symbol "BroadcastEvents" needs to be exported by the entry point index.d.ts
|
||||
//
|
||||
// @public (undocumented)
|
||||
export type StreamEvents = {
|
||||
_connected_: void;
|
||||
_disconnected_: void;
|
||||
} & BroadcastEvents;
|
||||
|
||||
// Warning: (ae-forgotten-export) The symbol "SwitchCase" needs to be exported by the entry point index.d.ts
|
||||
// Warning: (ae-forgotten-export) The symbol "IsCaseMatched" needs to be exported by the entry point index.d.ts
|
||||
// Warning: (ae-forgotten-export) The symbol "GetCaseResult" needs to be exported by the entry point index.d.ts
|
||||
|
@@ -1,15 +1,6 @@
|
||||
import { type Endpoints } from './api.types.js';
|
||||
import Stream, { Connection } from './streaming.js';
|
||||
import { type Channels } from './streaming.types.js';
|
||||
import { type Acct } from './acct.js';
|
||||
import * as consts from './consts.js';
|
||||
|
||||
export type {
|
||||
Endpoints,
|
||||
Channels,
|
||||
Acct,
|
||||
};
|
||||
|
||||
export {
|
||||
Stream,
|
||||
Connection as ChannelConnection,
|
||||
@@ -31,4 +22,21 @@ import * as api from './api.js';
|
||||
import * as entities from './entities.js';
|
||||
import * as acct from './acct.js';
|
||||
import * as note from './note.js';
|
||||
export { api, entities, acct, note };
|
||||
import { nyaize } from './nyaize.js';
|
||||
export { api, entities, acct, note, nyaize };
|
||||
|
||||
//#region standalone types
|
||||
import type { Endpoints } from './api.types.js';
|
||||
import type { StreamEvents, IStream, IChannelConnection } from './streaming.js';
|
||||
import type { Channels } from './streaming.types.js';
|
||||
import type { Acct } from './acct.js';
|
||||
|
||||
export type {
|
||||
Endpoints,
|
||||
Channels,
|
||||
Acct,
|
||||
StreamEvents,
|
||||
IStream,
|
||||
IChannelConnection,
|
||||
};
|
||||
//#endregion
|
||||
|
27
packages/misskey-js/src/nyaize.ts
Normal file
27
packages/misskey-js/src/nyaize.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
const enRegex1 = /(?<=n)a/gi;
|
||||
const enRegex2 = /(?<=morn)ing/gi;
|
||||
const enRegex3 = /(?<=every)one/gi;
|
||||
const koRegex1 = /[나-낳]/g;
|
||||
const koRegex2 = /(다$)|(다(?=\.))|(다(?= ))|(다(?=!))|(다(?=\?))/gm;
|
||||
const koRegex3 = /(야(?=\?))|(야$)|(야(?= ))/gm;
|
||||
|
||||
export function nyaize(text: string): string {
|
||||
return text
|
||||
// ja-JP
|
||||
.replaceAll('な', 'にゃ').replaceAll('ナ', 'ニャ').replaceAll('ナ', 'ニャ')
|
||||
// en-US
|
||||
.replace(enRegex1, x => x === 'A' ? 'YA' : 'ya')
|
||||
.replace(enRegex2, x => x === 'ING' ? 'YAN' : 'yan')
|
||||
.replace(enRegex3, x => x === 'ONE' ? 'NYAN' : 'nyan')
|
||||
// ko-KR
|
||||
.replace(koRegex1, match => !isNaN(match.charCodeAt(0)) ? String.fromCharCode(
|
||||
match.charCodeAt(0) + '냐'.charCodeAt(0) - '나'.charCodeAt(0),
|
||||
) : match)
|
||||
.replace(koRegex2, '다냥')
|
||||
.replace(koRegex3, '냥');
|
||||
}
|
@@ -17,16 +17,32 @@ export function urlQuery(obj: Record<string, string | number | boolean | undefin
|
||||
|
||||
type AnyOf<T extends Record<PropertyKey, unknown>> = T[keyof T];
|
||||
|
||||
type StreamEvents = {
|
||||
export type StreamEvents = {
|
||||
_connected_: void;
|
||||
_disconnected_: void;
|
||||
} & BroadcastEvents;
|
||||
|
||||
export interface IStream extends EventEmitter<StreamEvents> {
|
||||
state: 'initializing' | 'reconnecting' | 'connected';
|
||||
|
||||
useChannel<C extends keyof Channels>(channel: C, params?: Channels[C]['params'], name?: string): IChannelConnection<Channels[C]>;
|
||||
removeSharedConnection(connection: SharedConnection): void;
|
||||
removeSharedConnectionPool(pool: Pool): void;
|
||||
disconnectToChannel(connection: NonSharedConnection): void;
|
||||
send(typeOrPayload: string): void;
|
||||
send(typeOrPayload: string, payload: unknown): void;
|
||||
send(typeOrPayload: Record<string, unknown> | unknown[]): void;
|
||||
send(typeOrPayload: string | Record<string, unknown> | unknown[], payload?: unknown): void;
|
||||
ping(): void;
|
||||
heartbeat(): void;
|
||||
close(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Misskey stream connection
|
||||
*/
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default class Stream extends EventEmitter<StreamEvents> {
|
||||
export default class Stream extends EventEmitter<StreamEvents> implements IStream {
|
||||
private stream: _ReconnectingWebsocket.default;
|
||||
public state: 'initializing' | 'reconnecting' | 'connected' = 'initializing';
|
||||
private sharedConnectionPools: Pool[] = [];
|
||||
@@ -277,7 +293,18 @@ class Pool {
|
||||
}
|
||||
}
|
||||
|
||||
export abstract class Connection<Channel extends AnyOf<Channels> = AnyOf<Channels>> extends EventEmitter<Channel['events']> {
|
||||
export interface IChannelConnection<Channel extends AnyOf<Channels> = AnyOf<Channels>> extends EventEmitter<Channel['events']> {
|
||||
id: string;
|
||||
name?: string;
|
||||
inCount: number;
|
||||
outCount: number;
|
||||
channel: string;
|
||||
|
||||
send<T extends keyof Channel['receives']>(type: T, body: Channel['receives'][T]): void;
|
||||
dispose(): void;
|
||||
}
|
||||
|
||||
export abstract class Connection<Channel extends AnyOf<Channels> = AnyOf<Channels>> extends EventEmitter<Channel['events']> implements IChannelConnection<Channel> {
|
||||
public channel: string;
|
||||
protected stream: Stream;
|
||||
public abstract id: string;
|
||||
|
Reference in New Issue
Block a user