mirror of
https://github.com/misskey-dev/misskey
synced 2024-12-01 00:08:35 +09:00
wip
This commit is contained in:
parent
6dfeae9dcc
commit
bd5c862512
@ -160,9 +160,10 @@ export type Config = {
|
|||||||
authUrl: string;
|
authUrl: string;
|
||||||
driveUrl: string;
|
driveUrl: string;
|
||||||
userAgent: string;
|
userAgent: string;
|
||||||
clientEntry: string;
|
frontendEntry: string;
|
||||||
clientEmbedEntry: string;
|
frontendManifestExists: boolean;
|
||||||
clientManifestExists: boolean;
|
frontendEmbedEntry: string;
|
||||||
|
frontendEmbedManifestExists: boolean;
|
||||||
mediaProxy: string;
|
mediaProxy: string;
|
||||||
externalMediaProxyEnabled: boolean;
|
externalMediaProxyEnabled: boolean;
|
||||||
videoThumbnailGenerator: string | null;
|
videoThumbnailGenerator: string | null;
|
||||||
@ -197,10 +198,16 @@ const path = process.env.MISSKEY_CONFIG_YML
|
|||||||
|
|
||||||
export function loadConfig(): Config {
|
export function loadConfig(): Config {
|
||||||
const meta = JSON.parse(fs.readFileSync(`${_dirname}/../../../built/meta.json`, 'utf-8'));
|
const meta = JSON.parse(fs.readFileSync(`${_dirname}/../../../built/meta.json`, 'utf-8'));
|
||||||
const clientManifestExists = fs.existsSync(_dirname + '/../../../built/_vite_/manifest.json');
|
|
||||||
const clientManifest = clientManifestExists ?
|
const frontendManifestExists = fs.existsSync(_dirname + '/../../../built/_frontend_vite_/manifest.json');
|
||||||
JSON.parse(fs.readFileSync(`${_dirname}/../../../built/_vite_/manifest.json`, 'utf-8'))
|
const frontendEmbedManifestExists = fs.existsSync(_dirname + '/../../../built/_frontend_embed_vite_/manifest.json');
|
||||||
: { 'src/_boot_.ts': { file: 'src/_boot_.ts' }, 'src/_embed_boot_.ts': { file: 'src/_embed_boot_.ts' } };
|
const frontendManifest = frontendManifestExists ?
|
||||||
|
JSON.parse(fs.readFileSync(`${_dirname}/../../../built/_frontend_vite_/manifest.json`, 'utf-8'))
|
||||||
|
: { 'src/_boot_.ts': { file: 'src/_boot_.ts' } };
|
||||||
|
const frontendEmbedManifest = frontendEmbedManifestExists ?
|
||||||
|
JSON.parse(fs.readFileSync(`${_dirname}/../../../built/_frontend_embed_vite_/manifest.json`, 'utf-8'))
|
||||||
|
: { 'src/boot.ts': { file: 'src/boot.ts' } };
|
||||||
|
|
||||||
const config = yaml.load(fs.readFileSync(path, 'utf-8')) as Source;
|
const config = yaml.load(fs.readFileSync(path, 'utf-8')) as Source;
|
||||||
|
|
||||||
const url = tryCreateUrl(config.url ?? process.env.MISSKEY_URL ?? '');
|
const url = tryCreateUrl(config.url ?? process.env.MISSKEY_URL ?? '');
|
||||||
@ -271,9 +278,10 @@ export function loadConfig(): Config {
|
|||||||
config.videoThumbnailGenerator.endsWith('/') ? config.videoThumbnailGenerator.substring(0, config.videoThumbnailGenerator.length - 1) : config.videoThumbnailGenerator
|
config.videoThumbnailGenerator.endsWith('/') ? config.videoThumbnailGenerator.substring(0, config.videoThumbnailGenerator.length - 1) : config.videoThumbnailGenerator
|
||||||
: null,
|
: null,
|
||||||
userAgent: `Misskey/${version} (${config.url})`,
|
userAgent: `Misskey/${version} (${config.url})`,
|
||||||
clientEntry: clientManifest['src/_boot_.ts'],
|
frontendEntry: frontendManifest['src/_boot_.ts'],
|
||||||
clientEmbedEntry: clientManifest['src/_embed_boot_.ts'],
|
frontendManifestExists: frontendManifestExists,
|
||||||
clientManifestExists: clientManifestExists,
|
frontendEmbedEntry: frontendEmbedManifest['src/boot.ts'],
|
||||||
|
frontendEmbedManifestExists: frontendEmbedManifestExists,
|
||||||
perChannelMaxNoteCacheCount: config.perChannelMaxNoteCacheCount ?? 1000,
|
perChannelMaxNoteCacheCount: config.perChannelMaxNoteCacheCount ?? 1000,
|
||||||
perUserNotificationsMaxCount: config.perUserNotificationsMaxCount ?? 500,
|
perUserNotificationsMaxCount: config.perUserNotificationsMaxCount ?? 500,
|
||||||
deactivateAntennaThreshold: config.deactivateAntennaThreshold ?? (1000 * 60 * 60 * 24 * 7),
|
deactivateAntennaThreshold: config.deactivateAntennaThreshold ?? (1000 * 60 * 60 * 24 * 7),
|
||||||
|
@ -61,7 +61,8 @@ const staticAssets = `${_dirname}/../../../assets/`;
|
|||||||
const clientAssets = `${_dirname}/../../../../frontend/assets/`;
|
const clientAssets = `${_dirname}/../../../../frontend/assets/`;
|
||||||
const assets = `${_dirname}/../../../../../built/_frontend_dist_/`;
|
const assets = `${_dirname}/../../../../../built/_frontend_dist_/`;
|
||||||
const swAssets = `${_dirname}/../../../../../built/_sw_dist_/`;
|
const swAssets = `${_dirname}/../../../../../built/_sw_dist_/`;
|
||||||
const viteOut = `${_dirname}/../../../../../built/_vite_/`;
|
const frontendViteOut = `${_dirname}/../../../../../built/_frontend_vite_/`;
|
||||||
|
const frontendEmbedViteOut = `${_dirname}/../../../../../built/_frontend_embed_vite_/`;
|
||||||
const tarball = `${_dirname}/../../../../../built/tarball/`;
|
const tarball = `${_dirname}/../../../../../built/tarball/`;
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ -280,12 +281,19 @@ export class ClientServerService {
|
|||||||
if (this.config.clientManifestExists) {
|
if (this.config.clientManifestExists) {
|
||||||
fastify.register((fastify, options, done) => {
|
fastify.register((fastify, options, done) => {
|
||||||
fastify.register(fastifyStatic, {
|
fastify.register(fastifyStatic, {
|
||||||
root: viteOut,
|
root: frontendViteOut,
|
||||||
prefix: '/vite/',
|
prefix: '/vite/',
|
||||||
maxAge: ms('30 days'),
|
maxAge: ms('30 days'),
|
||||||
immutable: true,
|
immutable: true,
|
||||||
decorateReply: false,
|
decorateReply: false,
|
||||||
});
|
});
|
||||||
|
fastify.register(fastifyStatic, {
|
||||||
|
root: frontendEmbedViteOut,
|
||||||
|
prefix: '/embed_vite/',
|
||||||
|
maxAge: ms('30 days'),
|
||||||
|
immutable: true,
|
||||||
|
decorateReply: false,
|
||||||
|
});
|
||||||
fastify.addHook('onRequest', handleRequestRedirectToOmitSearch);
|
fastify.addHook('onRequest', handleRequestRedirectToOmitSearch);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@ -3,17 +3,6 @@
|
|||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* BOOT LOADER FOR EMBED PAGE
|
|
||||||
* サーバーからレスポンスされるHTMLに埋め込まれるスクリプトで、以下の役割を持ちます。
|
|
||||||
* - 翻訳ファイルをフェッチする。
|
|
||||||
* - バージョンに基づいて適切なメインスクリプトを読み込む。
|
|
||||||
* - キャッシュされたコンパイル済みテーマを適用する。
|
|
||||||
* - クライアントの設定値に基づいて対応するHTMLクラス等を設定する。
|
|
||||||
* テーマをこの段階で設定するのは、メインスクリプトが読み込まれる間もテーマを適用したいためです。
|
|
||||||
* 注: webpackは介さないため、このファイルではrequireやimportは使えません。
|
|
||||||
*/
|
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// ブロックの中に入れないと、定義した変数がブラウザのグローバルスコープに登録されてしまい邪魔なので
|
// ブロックの中に入れないと、定義した変数がブラウザのグローバルスコープに登録されてしまい邪魔なので
|
||||||
|
@ -1,22 +1,10 @@
|
|||||||
block vars
|
block vars
|
||||||
|
|
||||||
block loadClientEntry
|
block loadClientEntry
|
||||||
- const clientEntry = config.clientEmbedEntry;
|
- const entry = config.frontendEmbedEntry;
|
||||||
|
|
||||||
doctype html
|
doctype html
|
||||||
|
|
||||||
//
|
|
||||||
-
|
|
||||||
_____ _ _
|
|
||||||
| |_|___ ___| |_ ___ _ _
|
|
||||||
| | | | |_ -|_ -| '_| -_| | |
|
|
||||||
|_|_|_|_|___|___|_,_|___|_ |
|
|
||||||
|___|
|
|
||||||
Thank you for using Misskey!
|
|
||||||
If you are reading this message... how about joining the development?
|
|
||||||
https://github.com/misskey-dev/misskey
|
|
||||||
|
|
||||||
|
|
||||||
html(class='embed')
|
html(class='embed')
|
||||||
|
|
||||||
head
|
head
|
||||||
@ -25,23 +13,19 @@ html(class='embed')
|
|||||||
meta(name='referrer' content='origin')
|
meta(name='referrer' content='origin')
|
||||||
meta(name='theme-color' content= themeColor || '#86b300')
|
meta(name='theme-color' content= themeColor || '#86b300')
|
||||||
meta(name='theme-color-orig' content= themeColor || '#86b300')
|
meta(name='theme-color-orig' content= themeColor || '#86b300')
|
||||||
meta(property='instance_url' content= instanceUrl)
|
|
||||||
meta(name='viewport' content='width=device-width, initial-scale=1')
|
meta(name='viewport' content='width=device-width, initial-scale=1')
|
||||||
meta(name='format-detection' content='telephone=no,date=no,address=no,email=no,url=no')
|
meta(name='format-detection' content='telephone=no,date=no,address=no,email=no,url=no')
|
||||||
link(rel='icon' href= icon || '/favicon.ico')
|
link(rel='icon' href= icon || '/favicon.ico')
|
||||||
link(rel='apple-touch-icon' href= appleTouchIcon || '/apple-touch-icon.png')
|
link(rel='apple-touch-icon' href= appleTouchIcon || '/apple-touch-icon.png')
|
||||||
link(rel='prefetch' href=serverErrorImageUrl)
|
|
||||||
link(rel='prefetch' href=infoImageUrl)
|
|
||||||
link(rel='prefetch' href=notFoundImageUrl)
|
|
||||||
//- https://github.com/misskey-dev/misskey/issues/9842
|
//- https://github.com/misskey-dev/misskey/issues/9842
|
||||||
link(rel='stylesheet' href='/assets/tabler-icons/tabler-icons.min.css?v3.3.0')
|
link(rel='stylesheet' href='/assets/tabler-icons/tabler-icons.min.css?v3.3.0')
|
||||||
link(rel='modulepreload' href=`/vite/${clientEntry.file}`)
|
link(rel='modulepreload' href=`/vite/${entry.file}`)
|
||||||
|
|
||||||
if !config.clientManifestExists
|
if !config.clientManifestExists
|
||||||
script(type="module" src="/vite/@vite/client")
|
script(type="module" src="/vite/@vite/client")
|
||||||
|
|
||||||
if Array.isArray(clientEntry.css)
|
if Array.isArray(entry.css)
|
||||||
each href in clientEntry.css
|
each href in entry.css
|
||||||
link(rel='stylesheet' href=`/vite/${href}`)
|
link(rel='stylesheet' href=`/vite/${href}`)
|
||||||
|
|
||||||
title
|
title
|
||||||
@ -56,7 +40,7 @@ html(class='embed')
|
|||||||
|
|
||||||
script.
|
script.
|
||||||
var VERSION = "#{version}";
|
var VERSION = "#{version}";
|
||||||
var CLIENT_ENTRY = "#{clientEntry.file}";
|
var CLIENT_ENTRY = "#{entry.file}";
|
||||||
|
|
||||||
script(type='application/json' id='misskey_meta' data-generated-at=now)
|
script(type='application/json' id='misskey_meta' data-generated-at=now)
|
||||||
!= metaJson
|
!= metaJson
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
block vars
|
block vars
|
||||||
|
|
||||||
block loadClientEntry
|
block loadClientEntry
|
||||||
- const clientEntry = config.clientEntry;
|
- const entry = config.frontendEntry;
|
||||||
|
|
||||||
doctype html
|
doctype html
|
||||||
|
|
||||||
@ -38,13 +38,13 @@ html
|
|||||||
link(rel='prefetch' href=notFoundImageUrl)
|
link(rel='prefetch' href=notFoundImageUrl)
|
||||||
//- https://github.com/misskey-dev/misskey/issues/9842
|
//- https://github.com/misskey-dev/misskey/issues/9842
|
||||||
link(rel='stylesheet' href='/assets/tabler-icons/tabler-icons.min.css?v3.3.0')
|
link(rel='stylesheet' href='/assets/tabler-icons/tabler-icons.min.css?v3.3.0')
|
||||||
link(rel='modulepreload' href=`/vite/${clientEntry.file}`)
|
link(rel='modulepreload' href=`/vite/${entry.file}`)
|
||||||
|
|
||||||
if !config.clientManifestExists
|
if !config.clientManifestExists
|
||||||
script(type="module" src="/vite/@vite/client")
|
script(type="module" src="/vite/@vite/client")
|
||||||
|
|
||||||
if Array.isArray(clientEntry.css)
|
if Array.isArray(entry.css)
|
||||||
each href in clientEntry.css
|
each href in entry.css
|
||||||
link(rel='stylesheet' href=`/vite/${href}`)
|
link(rel='stylesheet' href=`/vite/${href}`)
|
||||||
|
|
||||||
title
|
title
|
||||||
@ -70,7 +70,7 @@ html
|
|||||||
|
|
||||||
script.
|
script.
|
||||||
var VERSION = "#{version}";
|
var VERSION = "#{version}";
|
||||||
var CLIENT_ENTRY = "#{clientEntry.file}";
|
var CLIENT_ENTRY = "#{entry.file}";
|
||||||
|
|
||||||
script(type='application/json' id='misskey_meta' data-generated-at=now)
|
script(type='application/json' id='misskey_meta' data-generated-at=now)
|
||||||
!= metaJson
|
!= metaJson
|
||||||
|
@ -131,7 +131,7 @@ export function getConfig(): UserConfig {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
cssCodeSplit: true,
|
cssCodeSplit: true,
|
||||||
outDir: __dirname + '/../../built/_vite_',
|
outDir: __dirname + '/../../built/_frontend_embed_vite_',
|
||||||
assetsDir: '.',
|
assetsDir: '.',
|
||||||
emptyOutDir: false,
|
emptyOutDir: false,
|
||||||
sourcemap: process.env.NODE_ENV === 'development',
|
sourcemap: process.env.NODE_ENV === 'development',
|
||||||
|
@ -151,7 +151,7 @@ export function getConfig(): UserConfig {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
cssCodeSplit: true,
|
cssCodeSplit: true,
|
||||||
outDir: __dirname + '/../../built/_vite_',
|
outDir: __dirname + '/../../built/_frontend_vite_',
|
||||||
assetsDir: '.',
|
assetsDir: '.',
|
||||||
emptyOutDir: false,
|
emptyOutDir: false,
|
||||||
sourcemap: process.env.NODE_ENV === 'development',
|
sourcemap: process.env.NODE_ENV === 'development',
|
||||||
|
Loading…
Reference in New Issue
Block a user