2023-07-27 05:31:52 +00:00
|
|
|
/*
|
2024-02-13 15:59:27 +00:00
|
|
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
2023-07-27 05:31:52 +00:00
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2023-05-15 10:08:46 +00:00
|
|
|
// https://vitejs.dev/config/build-options.html#build-modulepreload
|
|
|
|
import 'vite/modulepreload-polyfill';
|
|
|
|
|
|
|
|
import '@/style.scss';
|
2024-06-01 15:03:46 +00:00
|
|
|
import type { CommonBootOptions } from '@/boot/common.js';
|
2023-09-19 07:37:43 +00:00
|
|
|
import { mainBoot } from '@/boot/main-boot.js';
|
|
|
|
import { subBoot } from '@/boot/sub-boot.js';
|
2024-06-01 12:03:39 +00:00
|
|
|
import { isEmbedPage } from '@/scripts/embed-page.js';
|
2024-06-01 15:03:46 +00:00
|
|
|
import { setIframeId, postMessageToParentWindow } from '@/scripts/post-message.js';
|
2023-05-15 10:08:46 +00:00
|
|
|
|
2024-06-01 15:03:46 +00:00
|
|
|
const subBootPaths = ['/share', '/auth', '/miauth', '/signup-complete'];
|
2023-05-24 00:43:38 +00:00
|
|
|
|
2024-06-01 15:03:46 +00:00
|
|
|
if (isEmbedPage()) {
|
|
|
|
const bootOptions: Partial<CommonBootOptions> = {};
|
|
|
|
|
|
|
|
const params = new URLSearchParams(location.search);
|
2024-06-01 15:20:35 +00:00
|
|
|
const color = params.get('colorMode');
|
2024-06-01 15:03:46 +00:00
|
|
|
if (color && ['light', 'dark'].includes(color)) {
|
|
|
|
bootOptions.forceColorMode = color as 'light' | 'dark';
|
2024-06-01 12:03:39 +00:00
|
|
|
}
|
2024-06-01 15:03:46 +00:00
|
|
|
|
|
|
|
window.addEventListener('message', event => {
|
|
|
|
if (event.data?.type === 'misskey:embedParent:registerIframeId' && event.data.payload?.iframeId != null) {
|
|
|
|
setIframeId(event.data.payload.iframeId);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
subBoot(bootOptions, true).then(() => {
|
|
|
|
postMessageToParentWindow('misskey:embed:ready');
|
|
|
|
});
|
|
|
|
} else if (subBootPaths.some(i => location.pathname === i || location.pathname.startsWith(i + '/'))) {
|
2023-05-15 10:08:46 +00:00
|
|
|
subBoot();
|
|
|
|
} else {
|
|
|
|
mainBoot();
|
|
|
|
}
|