* wip * bump misskey-dev/eslint-plugin * lint fixes (backend) * lint fixes (frontend) * lint fixes (frontend-embed) * rollback nsfwjs to 4.2.0 ref: infinitered/nsfwjs#904 * rollback openapi-typescript to v6 v7でOpenAPIのバリデーションが入るようになった関係でスコープ外での変更が避けられないため一時的に戻した * lint fixes (misskey-js) * temporarily disable errored lint rule (frontend-shared) * fix lint * temporarily ignore errored file for lint (frontend-shared) * rollback simplewebauthn/server to 12.0.0 v13 contains breaking changes that require some decision making * lint fixes (frontend-shared) * build misskey-js with types * fix(backend): migrate simplewebauthn/server to v12 * fix(misskey-js/autogen): ignore indent rules to generate consistent output * attempt to fix test changes due to capricorn86/happy-dom#1617 (XMLSerializer now produces valid XML) * attempt to fix test changes due to capricorn86/happy-dom#1617 (XMLSerializer now produces valid XML) * fix test * fix test * fix test * Apply suggestions from code review Co-authored-by: anatawa12 <anatawa12@icloud.com> * bump summaly to v5.2.0 * update tabler-icons to v3.30.0-based --------- Co-authored-by: かっこかり <67428053+kakkokari-gtyih@users.noreply.github.com> Co-authored-by: anatawa12 <anatawa12@icloud.com>
50 lines
1.3 KiB
TypeScript
50 lines
1.3 KiB
TypeScript
/*
|
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
export const postMessageEventTypes = [
|
|
'misskey:embed:ready',
|
|
'misskey:embed:changeHeight',
|
|
] as const;
|
|
|
|
export type PostMessageEventType = typeof postMessageEventTypes[number];
|
|
|
|
export interface PostMessageEventPayload extends Record<PostMessageEventType, any> {
|
|
'misskey:embed:ready': undefined;
|
|
'misskey:embed:changeHeight': {
|
|
height: number;
|
|
};
|
|
}
|
|
|
|
export type MiPostMessageEvent<T extends PostMessageEventType = PostMessageEventType> = {
|
|
type: T;
|
|
iframeId?: string;
|
|
payload?: PostMessageEventPayload[T];
|
|
};
|
|
|
|
let defaultIframeId: string | null = null;
|
|
|
|
export function setIframeId(id: string): void {
|
|
if (defaultIframeId != null) return;
|
|
|
|
if (_DEV_) console.log('setIframeId', id);
|
|
defaultIframeId = id;
|
|
}
|
|
|
|
/**
|
|
* 親フレームにイベントを送信
|
|
*/
|
|
export function postMessageToParentWindow<T extends PostMessageEventType = PostMessageEventType>(type: T, payload?: PostMessageEventPayload[T], iframeId: string | null = null): void {
|
|
let _iframeId = iframeId;
|
|
if (_iframeId == null) {
|
|
_iframeId = defaultIframeId;
|
|
}
|
|
if (_DEV_) console.log('postMessageToParentWindow', type, _iframeId, payload);
|
|
window.parent.postMessage({
|
|
type,
|
|
iframeId: _iframeId,
|
|
payload,
|
|
}, '*');
|
|
}
|