From f5f88430228225fcd150e0a90d9fd5b9f72c767d Mon Sep 17 00:00:00 2001 From: tamaina Date: Sat, 23 Apr 2022 01:50:20 +0900 Subject: [PATCH] wip --- gulpfile.js | 1 - packages/backend/src/config/load.ts | 2 ++ packages/backend/src/config/types.ts | 1 + packages/backend/src/server/web/boot.js | 3 +- .../backend/src/server/web/views/base.pug | 4 +++ packages/client/@types/theme.d.ts | 5 +++ packages/client/package.json | 4 +-- packages/client/src/store.ts | 7 ++-- packages/client/vite.config.ts | 11 +++++-- packages/client/yarn.lock | 32 +------------------ 10 files changed, 30 insertions(+), 40 deletions(-) create mode 100644 packages/client/@types/theme.d.ts diff --git a/gulpfile.js b/gulpfile.js index b7aa4e328e..90f8ebaabe 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -37,7 +37,6 @@ gulp.task('copy:client:locales', cb => { gulp.task('build:backend:script', () => { return gulp.src(['./packages/backend/src/server/web/boot.js', './packages/backend/src/server/web/bios.js', './packages/backend/src/server/web/cli.js']) - .pipe(replace('VERSION', JSON.stringify(meta.version))) .pipe(replace('LANGS', JSON.stringify(Object.keys(locales)))) .pipe(terser({ toplevel: true diff --git a/packages/backend/src/config/load.ts b/packages/backend/src/config/load.ts index 7f765463e4..1b18612e98 100644 --- a/packages/backend/src/config/load.ts +++ b/packages/backend/src/config/load.ts @@ -25,6 +25,7 @@ const path = process.env.NODE_ENV === 'test' export default function load() { const meta = JSON.parse(fs.readFileSync(`${_dirname}/../../../../built/meta.json`, 'utf-8')); + const clientManifest = JSON.parse(fs.readFileSync(`${_dirname}/../../../../built/manifest.json`, 'utf-8')); const config = yaml.load(fs.readFileSync(path, 'utf-8')) as Source; const mixin = {} as Mixin; @@ -45,6 +46,7 @@ export default function load() { mixin.authUrl = `${mixin.scheme}://${mixin.host}/auth`; mixin.driveUrl = `${mixin.scheme}://${mixin.host}/files`; mixin.userAgent = `Misskey/${meta.version} (${config.url})`; + mixin.clientEntry = clientManifest['src/init.ts'].file.replace(/^_client_dist_\//, ''); if (!config.redis.prefix) config.redis.prefix = mixin.host; diff --git a/packages/backend/src/config/types.ts b/packages/backend/src/config/types.ts index 58a27803cb..948545db7a 100644 --- a/packages/backend/src/config/types.ts +++ b/packages/backend/src/config/types.ts @@ -80,6 +80,7 @@ export type Mixin = { authUrl: string; driveUrl: string; userAgent: string; + clientEntry: string; }; export type Config = Source & Mixin; diff --git a/packages/backend/src/server/web/boot.js b/packages/backend/src/server/web/boot.js index 751e8619bf..01a27595ee 100644 --- a/packages/backend/src/server/web/boot.js +++ b/packages/backend/src/server/web/boot.js @@ -59,9 +59,10 @@ : ''; const script = document.createElement('script'); - script.setAttribute('src', `/assets/app.${v}.js${salt}`); + script.setAttribute('src', `/assets/${CLIENT_ENTRY}${salt}`); script.setAttribute('async', 'true'); script.setAttribute('defer', 'true'); + script.setAttribute('type', 'module'); script.addEventListener('error', async () => { await checkUpdate(); renderError('APP_FETCH_FAILED'); diff --git a/packages/backend/src/server/web/views/base.pug b/packages/backend/src/server/web/views/base.pug index 1513208310..a0fe55289f 100644 --- a/packages/backend/src/server/web/views/base.pug +++ b/packages/backend/src/server/web/views/base.pug @@ -50,6 +50,10 @@ html style include ../style.css + script. + var VERSION = "#{version}"; + var CLIENT_ENTRY = "#{config.clientEntry}"; + script include ../boot.js diff --git a/packages/client/@types/theme.d.ts b/packages/client/@types/theme.d.ts new file mode 100644 index 0000000000..b8b906b82e --- /dev/null +++ b/packages/client/@types/theme.d.ts @@ -0,0 +1,5 @@ +import { Theme } from '../src/scripts/theme'; + +declare module '@/themes/*.json5' { + export = Theme; +} diff --git a/packages/client/package.json b/packages/client/package.json index 06e5d41057..58968b4f07 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,8 +1,8 @@ { "private": true, "scripts": { - "watch": "vite build --emptyOutDir --watch", - "build": "vite build --emptyOutDir", + "watch": "vite build --watch", + "build": "vite build", "lint": "eslint --quiet 'src/**/*.{ts,vue}'" }, "resolutions": { diff --git a/packages/client/src/store.ts b/packages/client/src/store.ts index b9800ec607..975159df0f 100644 --- a/packages/client/src/store.ts +++ b/packages/client/src/store.ts @@ -255,10 +255,13 @@ type Plugin = { /** * 常にメモリにロードしておく必要がないような設定情報を保管するストレージ(非リアクティブ) */ +import lightTheme from '@/themes/l-light.json5'; +import darkTheme from '@/themes/l-dark.json5'; + export class ColdDeviceStorage { public static default = { - lightTheme: require('@/themes/l-light.json5') as Theme, - darkTheme: require('@/themes/d-dark.json5') as Theme, + lightTheme, + darkTheme, syncDeviceDarkMode: true, plugins: [] as Plugin[], mediaVolume: 0.5, diff --git a/packages/client/vite.config.ts b/packages/client/vite.config.ts index 6c0b565cce..0c425376c4 100644 --- a/packages/client/vite.config.ts +++ b/packages/client/vite.config.ts @@ -45,7 +45,11 @@ export default defineConfig(({ command, mode }) => { }, build: { - target: 'esnext', + target: [ + 'chrome100', + 'firefox100', + 'safari15', + ], manifest: true, rollupOptions: { input: { @@ -57,8 +61,9 @@ export default defineConfig(({ command, mode }) => { }, }, }, - outDir: __dirname + '/../../built/_client_dist_', - assetsDir: 'dest', + outDir: __dirname + '/../../built', + assetsDir: '_client_dist_', + emptyOutDir: false, }, } }); diff --git a/packages/client/yarn.lock b/packages/client/yarn.lock index 8f6df039e1..4c9f616418 100644 --- a/packages/client/yarn.lock +++ b/packages/client/yarn.lock @@ -56,11 +56,6 @@ lodash "^4.17.19" to-fast-properties "^2.0.0" -"@cush/relative@^1.0.0": - version "1.0.0" - resolved "https://registry.yarnpkg.com/@cush/relative/-/relative-1.0.0.tgz#8cd1769bf9bde3bb27dac356b1bc94af40f6cc16" - integrity sha512-RpfLEtTlyIxeNPGKcokS+p3BZII/Q3bYxryFRglh5H3A3T8q9fsLYm72VYAMEOOIBLEa8o93kFLiBDUWKrwXZA== - "@cypress/request@^2.88.10": version "2.88.10" resolved "https://registry.yarnpkg.com/@cypress/request/-/request-2.88.10.tgz#b66d76b07f860d3a4b8d7a0604d020c662752cce" @@ -3058,11 +3053,6 @@ glob-parent@^6.0.1: dependencies: is-glob "^4.0.3" -glob-regex@^0.3.0: - version "0.3.2" - resolved "https://registry.yarnpkg.com/glob-regex/-/glob-regex-0.3.2.tgz#27348f2f60648ec32a4a53137090b9fb934f3425" - integrity sha512-m5blUd3/OqDTWwzBBtWBPrGlAzatRywHameHeekAZyZrskYouOGdNB8T/q6JucucvJXtOuyHIn0/Yia7iDasDw== - glob-to-regexp@^0.4.1: version "0.4.1" resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz#c75297087c851b9a578bd217dd59a92f59fe546e" @@ -3145,11 +3135,6 @@ globby@^11.0.4: merge2 "^1.3.0" slash "^3.0.0" -globrex@^0.1.2: - version "0.1.2" - resolved "https://registry.yarnpkg.com/globrex/-/globrex-0.1.2.tgz#dd5d9ec826232730cd6793a5e33a9302985e6098" - integrity sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg== - graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.4: version "4.2.4" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.4.tgz#2256bde14d3632958c465ebc96dc467ca07a29fb" @@ -5054,16 +5039,6 @@ reconnecting-websocket@^4.4.0: resolved "https://registry.yarnpkg.com/reconnecting-websocket/-/reconnecting-websocket-4.4.0.tgz#3b0e5b96ef119e78a03135865b8bb0af1b948783" integrity sha512-D2E33ceRPga0NvTDhJmphEgJ7FUYF0v4lr1ki0csq06OdlxKfugGzN0dSkxM/NfqCxYELK4KcaTOUOjTV6Dcng== -recrawl-sync@^2.0.3: - version "2.2.2" - resolved "https://registry.yarnpkg.com/recrawl-sync/-/recrawl-sync-2.2.2.tgz#a5a8664c77267d603d601825af544d6716d69e15" - integrity sha512-E2sI4F25Fu2nrfV+KsnC7/qfk/spQIYXlonfQoS4rwxeNK5BjxnLPbWiRXHVXPwYBOTWtPX5765kTm/zJiL+LQ== - dependencies: - "@cush/relative" "^1.0.0" - glob-regex "^0.3.0" - slash "^3.0.0" - tslib "^1.9.3" - reflect-metadata@0.1.13: version "0.1.13" resolved "https://registry.yarnpkg.com/reflect-metadata/-/reflect-metadata-0.1.13.tgz#67ae3ca57c972a2aa1642b10fe363fe32d49dc08" @@ -5776,7 +5751,7 @@ tsc-alias@1.5.0: mylas "^2.1.6" normalize-path "^3.0.0" -tsconfig-paths@3.14.1, tsconfig-paths@^3.14.1, tsconfig-paths@^3.9.0: +tsconfig-paths@3.14.1, tsconfig-paths@^3.14.1: version "3.14.1" resolved "https://registry.yarnpkg.com/tsconfig-paths/-/tsconfig-paths-3.14.1.tgz#ba0734599e8ea36c862798e920bcf163277b137a" integrity sha512-fxDhWnFSLt3VuTwtvJt5fpwxBHg5AdKWMsgcPOOIilyjymcYVZoCQF8fvFRezCNfblEXmi+PcM1eYHeOAgXCOQ== @@ -5791,11 +5766,6 @@ tslib@^1.8.1, tslib@^1.9.0: resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.11.1.tgz#eb15d128827fbee2841549e171f45ed338ac7e35" integrity sha512-aZW88SY8kQbU7gpV19lN24LtXh/yD4ZZg6qieAJDDg+YBsJcSmLGK9QpnUjAKVG/xefmvJGd1WUmfpT/g6AJGA== -tslib@^1.9.3: - version "1.14.1" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" - integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== - tslib@~2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.1.0.tgz#da60860f1c2ecaa5703ab7d39bc05b6bf988b97a"