diff --git a/.pnp.cjs b/.pnp.cjs index f8335ea2c..dc9390781 100755 --- a/.pnp.cjs +++ b/.pnp.cjs @@ -3239,6 +3239,30 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["@rollup/plugin-replace", [\ + ["npm:5.0.5", {\ + "packageLocation": "./.yarn/cache/@rollup-plugin-replace-npm-5.0.5-42f61be6e8-bcf106346f.zip/node_modules/@rollup/plugin-replace/",\ + "packageDependencies": [\ + ["@rollup/plugin-replace", "npm:5.0.5"]\ + ],\ + "linkType": "SOFT"\ + }],\ + ["virtual:658502eb4296e93abedc18b6aa9b26978f434f08d98e21ebb0e725354b8bb54b62db9c4a1893e460c694ff7500ff5cbafa4457b0dfd26b5838868666c861e990#npm:5.0.5", {\ + "packageLocation": "./.yarn/__virtual__/@rollup-plugin-replace-virtual-bb6943b0cc/0/cache/@rollup-plugin-replace-npm-5.0.5-42f61be6e8-bcf106346f.zip/node_modules/@rollup/plugin-replace/",\ + "packageDependencies": [\ + ["@rollup/plugin-replace", "virtual:658502eb4296e93abedc18b6aa9b26978f434f08d98e21ebb0e725354b8bb54b62db9c4a1893e460c694ff7500ff5cbafa4457b0dfd26b5838868666c861e990#npm:5.0.5"],\ + ["@rollup/pluginutils", "virtual:bb6943b0cca2c422f7a7afd65919f64a13f4e8693f7906299796ebe01591897f1a7622cbd9bd4db684f8c6acc1f55e4a4d48e34b460bcd763b5121a2b479f420#npm:5.1.0"],\ + ["@types/rollup", null],\ + ["magic-string", "npm:0.30.5"],\ + ["rollup", "npm:3.26.2"]\ + ],\ + "packagePeers": [\ + "@types/rollup",\ + "rollup"\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["@rollup/pluginutils", [\ ["npm:3.1.0", {\ "packageLocation": "./.yarn/cache/@rollup-pluginutils-npm-3.1.0-b44b222e7d-3b69f02893.zip/node_modules/@rollup/pluginutils/",\ @@ -3256,6 +3280,29 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "HARD"\ }],\ + ["npm:5.1.0", {\ + "packageLocation": "./.yarn/cache/@rollup-pluginutils-npm-5.1.0-6939820ef8-abb15eaec5.zip/node_modules/@rollup/pluginutils/",\ + "packageDependencies": [\ + ["@rollup/pluginutils", "npm:5.1.0"]\ + ],\ + "linkType": "SOFT"\ + }],\ + ["virtual:bb6943b0cca2c422f7a7afd65919f64a13f4e8693f7906299796ebe01591897f1a7622cbd9bd4db684f8c6acc1f55e4a4d48e34b460bcd763b5121a2b479f420#npm:5.1.0", {\ + "packageLocation": "./.yarn/__virtual__/@rollup-pluginutils-virtual-2c209a0117/0/cache/@rollup-pluginutils-npm-5.1.0-6939820ef8-abb15eaec5.zip/node_modules/@rollup/pluginutils/",\ + "packageDependencies": [\ + ["@rollup/pluginutils", "virtual:bb6943b0cca2c422f7a7afd65919f64a13f4e8693f7906299796ebe01591897f1a7622cbd9bd4db684f8c6acc1f55e4a4d48e34b460bcd763b5121a2b479f420#npm:5.1.0"],\ + ["@types/estree", "npm:1.0.1"],\ + ["@types/rollup", null],\ + ["estree-walker", "npm:2.0.2"],\ + ["picomatch", "npm:2.3.1"],\ + ["rollup", "npm:3.26.2"]\ + ],\ + "packagePeers": [\ + "@types/rollup",\ + "rollup"\ + ],\ + "linkType": "HARD"\ + }],\ ["virtual:cf1428485ac6d7495e234c120f3000a61db869813c88397f285b8f9691f2488035a4fa06e3d208d181d90d55925c550cd96d3b139f098a04a0ef06802bcb7775#npm:3.1.0", {\ "packageLocation": "./.yarn/__virtual__/@rollup-pluginutils-virtual-228ea72560/0/cache/@rollup-pluginutils-npm-3.1.0-b44b222e7d-3b69f02893.zip/node_modules/@rollup/pluginutils/",\ "packageDependencies": [\ @@ -8537,6 +8584,7 @@ const RAW_RUNTIME_STATE = ["@phosphor-icons/web", "npm:2.0.3"],\ ["@rollup/plugin-alias", "virtual:658502eb4296e93abedc18b6aa9b26978f434f08d98e21ebb0e725354b8bb54b62db9c4a1893e460c694ff7500ff5cbafa4457b0dfd26b5838868666c861e990#npm:3.1.9"],\ ["@rollup/plugin-json", "virtual:658502eb4296e93abedc18b6aa9b26978f434f08d98e21ebb0e725354b8bb54b62db9c4a1893e460c694ff7500ff5cbafa4457b0dfd26b5838868666c861e990#npm:4.1.0"],\ + ["@rollup/plugin-replace", "virtual:658502eb4296e93abedc18b6aa9b26978f434f08d98e21ebb0e725354b8bb54b62db9c4a1893e460c694ff7500ff5cbafa4457b0dfd26b5838868666c861e990#npm:5.0.5"],\ ["@rollup/pluginutils", "npm:4.2.1"],\ ["@syuilo/aiscript", "npm:0.11.1"],\ ["@types/escape-regexp", "npm:0.0.1"],\ @@ -8592,6 +8640,7 @@ const RAW_RUNTIME_STATE = ["prismjs", "npm:1.29.0"],\ ["punycode", "npm:2.3.0"],\ ["querystring", "npm:0.2.1"],\ + ["reconnecting-websocket", "npm:4.4.0"],\ ["rndstr", "npm:1.0.0"],\ ["rollup", "npm:3.26.2"],\ ["s-age", "npm:1.1.2"],\ diff --git a/.yarn/cache/@rollup-plugin-replace-npm-5.0.5-42f61be6e8-bcf106346f.zip b/.yarn/cache/@rollup-plugin-replace-npm-5.0.5-42f61be6e8-bcf106346f.zip new file mode 100644 index 000000000..45bb7f3fe --- /dev/null +++ b/.yarn/cache/@rollup-plugin-replace-npm-5.0.5-42f61be6e8-bcf106346f.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7f7e562121e6cd883012bae2587e99f26d0196ae166f7ea0c2f4e34da1a9bfc3 +size 11565 diff --git a/.yarn/cache/@rollup-pluginutils-npm-5.1.0-6939820ef8-abb15eaec5.zip b/.yarn/cache/@rollup-pluginutils-npm-5.1.0-6939820ef8-abb15eaec5.zip new file mode 100644 index 000000000..021af611e --- /dev/null +++ b/.yarn/cache/@rollup-pluginutils-npm-5.1.0-6939820ef8-abb15eaec5.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:46f2eba24d2321fd90ae300b7eee5b0a36be9466479134f02256230c148f37ff +size 16261 diff --git a/packages/client/package.json b/packages/client/package.json index 92c55cb3c..a11369dd3 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -17,6 +17,7 @@ "@phosphor-icons/web": "^2.0.3", "@rollup/plugin-alias": "3.1.9", "@rollup/plugin-json": "4.1.0", + "@rollup/plugin-replace": "^5.0.5", "@rollup/pluginutils": "^4.2.1", "@syuilo/aiscript": "0.11.1", "@types/escape-regexp": "0.0.1", @@ -57,7 +58,6 @@ "focus-trap": "^7.5.2", "focus-trap-vue": "^4.0.2", "gsap": "^3.12.2", - "iceshrimp-js": "workspace:*", "idb-keyval": "6.2.1", "insert-text-at-cursor": "0.3.0", "json5": "2.2.3", @@ -103,6 +103,7 @@ }, "dependencies": { "@babel/core": "^7.23.2", - "eslint": "^8.45.0" + "eslint": "^8.45.0", + "reconnecting-websocket": "^4.4.0" } } diff --git a/packages/client/src/account.ts b/packages/client/src/account.ts index c51ef8a2e..2ed22d13e 100644 --- a/packages/client/src/account.ts +++ b/packages/client/src/account.ts @@ -1,5 +1,5 @@ import { defineAsyncComponent, reactive } from "vue"; -import * as misskey from "iceshrimp-js"; +import * as misskey from "@/iceshrimp-js"; import { i18n } from "./i18n"; import { del, get, set } from "@/scripts/idb-proxy"; import { apiUrl } from "@/config"; diff --git a/packages/client/src/components/MkAbuseReportWindow.vue b/packages/client/src/components/MkAbuseReportWindow.vue index 6e5171d57..73092b48c 100644 --- a/packages/client/src/components/MkAbuseReportWindow.vue +++ b/packages/client/src/components/MkAbuseReportWindow.vue @@ -41,7 +41,7 @@ + + + diff --git a/packages/client/src/init.ts b/packages/client/src/init.ts index b244002a7..b159ec6eb 100644 --- a/packages/client/src/init.ts +++ b/packages/client/src/init.ts @@ -32,10 +32,10 @@ import { compareVersions } from "compare-versions"; import widgets from "@/widgets"; import directives from "@/directives"; import components from "@/components"; -import { version, ui, lang, setHost, setSearchEngine } from "@/config"; +import { version, ui, lang, setHost, setSearchEngine, updateLocale } from "@/config"; import { applyTheme } from "@/scripts/theme"; import { isDeviceDarkmode } from "@/scripts/is-device-darkmode"; -import { i18n } from "@/i18n"; +import { i18n, updateI18n } from "@/i18n"; import { confirm, alert, post, popup, toast, api } from "@/os"; import { stream } from "@/stream"; import * as sound from "@/scripts/sound"; @@ -96,6 +96,23 @@ function checkForSplash() { }); } + + //#region Detect language & fetch translations + const localeVersion = localStorage.getItem('localeVersion'); + const localeOutdated = (localeVersion == null || localeVersion !== version); + if (localeOutdated) { + const res = await window.fetch(`/assets/locales/${lang}.${version}.json`); + if (res.status === 200) { + const newLocale = await res.text(); + const parsedNewLocale = JSON.parse(newLocale); + localStorage.setItem('locale', newLocale); + localStorage.setItem('localeVersion', version); + updateLocale(parsedNewLocale); + updateI18n(parsedNewLocale); + } + } + //#endregion + // タッチデバイスでCSSの:hoverを機能させる document.addEventListener("touchend", () => {}, { passive: true }); @@ -363,6 +380,10 @@ function checkForSplash() { JSON.parse(instance.defaultDarkTheme), ); defaultStore.set("themeInitial", false); + } else if (defaultStore.state.darkMode) { + applyTheme(darkTheme.value); + } else { + applyTheme(lightTheme.value); } }); diff --git a/packages/client/src/instance.ts b/packages/client/src/instance.ts index d335dde74..e2663fe39 100644 --- a/packages/client/src/instance.ts +++ b/packages/client/src/instance.ts @@ -1,6 +1,6 @@ import { computed, reactive } from "vue"; import { api } from "./os"; -import type * as Misskey from "iceshrimp-js"; +import type * as Misskey from "@/iceshrimp-js"; // TODO: 他のタブと永続化されたstateを同期 diff --git a/packages/client/src/os.ts b/packages/client/src/os.ts index 0e1e82b07..26259030a 100644 --- a/packages/client/src/os.ts +++ b/packages/client/src/os.ts @@ -3,7 +3,7 @@ import { Component, markRaw, Ref, ref, defineAsyncComponent } from "vue"; import { EventEmitter } from "eventemitter3"; import insertTextAtCursor from "insert-text-at-cursor"; -import * as Misskey from "iceshrimp-js"; +import * as Misskey from "@/iceshrimp-js"; import { apiUrl, url } from "@/config"; import MkPostFormDialog from "@/components/MkPostFormDialog.vue"; import MkWaitingDialog from "@/components/MkWaitingDialog.vue"; diff --git a/packages/client/src/pages/_error_.vue b/packages/client/src/pages/_error_.vue index 4f536c2b5..9ada95937 100644 --- a/packages/client/src/pages/_error_.vue +++ b/packages/client/src/pages/_error_.vue @@ -36,7 +36,7 @@