1
0
forked from mirror/misskey
mi.moris.day/packages/frontend-embed/src/boot.ts

38 lines
1.0 KiB
TypeScript
Raw Normal View History

/*
* SPDX-FileCopyrightText: syuilo and misskey-project
* SPDX-License-Identifier: AGPL-3.0-only
*/
// https://vitejs.dev/config/build-options.html#build-modulepreload
import 'vite/modulepreload-polyfill';
import '@/style.scss';
import { createApp, defineAsyncComponent } from 'vue';
2024-08-25 20:45:28 +09:00
import { setIframeId } from '@/post-message.js';
2024-08-23 08:07:23 +09:00
import { parseEmbedParams } from '@/embed-page.js';
const params = new URLSearchParams(location.search);
const embedParams = parseEmbedParams(params);
// サイズの制限
document.documentElement.style.maxWidth = '500px';
// iframeIdの設定
function setIframeIdHandler(event: MessageEvent) {
if (event.data?.type === 'misskey:embedParent:registerIframeId' && event.data.payload?.iframeId != null) {
setIframeId(event.data.payload.iframeId);
window.removeEventListener('message', setIframeIdHandler);
}
}
2024-07-06 11:20:04 +09:00
window.addEventListener('message', setIframeIdHandler);
2024-08-22 17:32:24 +09:00
const app = createApp(
2024-08-22 17:19:36 +09:00
defineAsyncComponent(() => import('@/ui.vue')),
2024-08-22 17:32:24 +09:00
);
2024-08-22 17:32:24 +09:00
//#region Embed Provide
app.provide('embedParams', embedParams);
//#endregion
2024-07-06 13:03:21 +09:00