From 0b2e9511e211c9c4dcae2618eb27d4127bb64a9b Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Mon, 4 Dec 2023 20:29:59 +0100 Subject: [PATCH] [wip] standalone frontend stuff --- .pnp.cjs | 49 + ...eplace-npm-5.0.5-42f61be6e8-bcf106346f.zip | 3 + ...nutils-npm-5.1.0-6939820ef8-abb15eaec5.zip | 3 + packages/client/package.json | 5 +- packages/client/src/account.ts | 2 +- .../src/components/MkAbuseReportWindow.vue | 2 +- .../client/src/components/MkAutocomplete.vue | 2 +- .../client/src/components/MkChatPreview.vue | 2 +- .../client/src/components/MkCropperDialog.vue | 2 +- packages/client/src/components/MkCwButton.vue | 4 +- .../client/src/components/MkDrive.file.vue | 2 +- .../client/src/components/MkDrive.folder.vue | 2 +- .../src/components/MkDrive.navFolder.vue | 2 +- packages/client/src/components/MkDrive.vue | 2 +- .../src/components/MkDriveFileThumbnail.vue | 2 +- .../src/components/MkDriveSelectDialog.vue | 2 +- .../client/src/components/MkDriveWindow.vue | 2 +- .../client/src/components/MkEmojiPicker.vue | 2 +- .../src/components/MkFeaturedPhotos.vue | 2 +- .../src/components/MkFileListForAdmin.vue | 2 +- .../client/src/components/MkFollowButton.vue | 2 +- .../client/src/components/MkImageViewer.vue | 2 +- .../src/components/MkInstanceCardMini.vue | 2 +- .../src/components/MkInstanceSelectDialog.vue | 2 +- packages/client/src/components/MkMedia.vue | 2 +- .../client/src/components/MkMediaBanner.vue | 2 +- .../client/src/components/MkMediaList.vue | 2 +- packages/client/src/components/MkNote.vue | 2 +- .../client/src/components/MkNoteDetailed.vue | 4 +- .../client/src/components/MkNoteHeader.vue | 2 +- .../client/src/components/MkNoteSimple.vue | 2 +- packages/client/src/components/MkNoteSub.vue | 2 +- .../client/src/components/MkNotification.vue | 2 +- .../MkNotificationSettingWindow.vue | 2 +- .../client/src/components/MkNotifications.vue | 2 +- .../client/src/components/MkPagination.vue | 2 +- packages/client/src/components/MkPoll.vue | 2 +- packages/client/src/components/MkPostForm.vue | 4 +- .../src/components/MkPostFormDialog.vue | 2 +- .../client/src/components/MkQuoteButton.vue | 2 +- .../client/src/components/MkReactedUsers.vue | 2 +- .../components/MkReactionsViewer.reaction.vue | 2 +- .../src/components/MkReactionsViewer.vue | 2 +- .../client/src/components/MkRenoteButton.vue | 2 +- packages/client/src/components/MkSearch.vue | 2 +- .../client/src/components/MkStarButton.vue | 2 +- .../src/components/MkStarButtonNoEmoji.vue | 2 +- .../src/components/MkSubNoteContent.vue | 2 +- .../src/components/MkTokenGenerateWindow.vue | 2 +- .../client/src/components/MkUserCardMini.vue | 2 +- packages/client/src/components/MkUserInfo.vue | 2 +- .../src/components/MkUserOnlineIndicator.vue | 2 +- .../client/src/components/MkUserPreview.vue | 4 +- .../src/components/MkUserSelectDialog.vue | 2 +- .../components/MkUserSelectLocalDialog.vue | 2 +- .../src/components/MkVisibilityPicker.vue | 6 +- .../client/src/components/global/MkAcct.vue | 2 +- .../client/src/components/global/MkAvatar.vue | 2 +- .../client/src/components/global/MkEmoji.vue | 2 +- .../src/components/global/MkUserName.vue | 2 +- packages/client/src/config.ts | 8 +- packages/client/src/filters/user.ts | 9 +- packages/client/src/i18n.ts | 6 +- packages/client/src/iceshrimp-js/acct.ts | 32 + packages/client/src/iceshrimp-js/api.ts | 127 ++ packages/client/src/iceshrimp-js/api.types.ts | 1088 +++++++++++++++++ packages/client/src/iceshrimp-js/consts.ts | 58 + packages/client/src/iceshrimp-js/entities.ts | 494 ++++++++ packages/client/src/iceshrimp-js/index.ts | 21 + packages/client/src/iceshrimp-js/streaming.ts | 391 ++++++ .../src/iceshrimp-js/streaming.types.ts | 197 +++ packages/client/src/index.html | 15 + packages/client/src/init.ts | 25 +- packages/client/src/instance.ts | 2 +- packages/client/src/os.ts | 2 +- packages/client/src/pages/_error_.vue | 2 +- packages/client/src/pages/admin/files.vue | 2 +- .../client/src/pages/admin/overview.user.vue | 2 +- packages/client/src/pages/api-console.vue | 2 +- packages/client/src/pages/clip.vue | 2 +- packages/client/src/pages/follow.vue | 2 +- packages/client/src/pages/instance-info.vue | 2 +- packages/client/src/pages/messaging/index.vue | 2 +- .../pages/messaging/messaging-room.form.vue | 2 +- .../messaging/messaging-room.message.vue | 2 +- .../src/pages/messaging/messaging-room.vue | 4 +- .../client/src/pages/my-antennas/editor.vue | 2 +- packages/client/src/pages/note.vue | 2 +- packages/client/src/pages/notifications.vue | 2 +- .../client/src/pages/settings/general.vue | 1 + .../client/src/pages/settings/migration.vue | 4 +- .../src/pages/settings/notifications.vue | 2 +- packages/client/src/pages/share.vue | 6 +- packages/client/src/pages/user-info.vue | 2 +- packages/client/src/pages/user/clips.vue | 2 +- .../client/src/pages/user/follow-list.vue | 2 +- packages/client/src/pages/user/followers.vue | 4 +- packages/client/src/pages/user/following.vue | 4 +- packages/client/src/pages/user/gallery.vue | 2 +- packages/client/src/pages/user/home.vue | 2 +- .../client/src/pages/user/index.activity.vue | 2 +- .../client/src/pages/user/index.photos.vue | 2 +- .../client/src/pages/user/index.timeline.vue | 2 +- packages/client/src/pages/user/index.vue | 4 +- packages/client/src/pages/user/pages.vue | 2 +- packages/client/src/pages/user/reactions.vue | 2 +- .../client/src/scripts/gen-search-query.ts | 2 +- packages/client/src/scripts/get-note-menu.ts | 2 +- .../client/src/scripts/get-note-summary.ts | 2 +- packages/client/src/scripts/get-user-menu.ts | 2 +- packages/client/src/scripts/lookup-user.ts | 2 +- packages/client/src/scripts/page-metadata.ts | 2 +- packages/client/src/scripts/select-file.ts | 2 +- packages/client/src/scripts/upload.ts | 2 +- .../client/src/scripts/use-note-capture.ts | 2 +- packages/client/src/stream.ts | 2 +- packages/client/src/style.scss | 2 + packages/client/src/types/menu.ts | 2 +- .../src/ui/_common_/statusbar-federation.vue | 2 +- .../src/ui/_common_/statusbar-user-list.vue | 2 +- packages/client/src/ui/deck/deck-store.ts | 2 +- packages/client/src/ui/universal.vue | 2 +- packages/client/vite-dev.config.ts | 106 ++ yarn.lock | 35 +- 124 files changed, 2779 insertions(+), 128 deletions(-) create mode 100644 .yarn/cache/@rollup-plugin-replace-npm-5.0.5-42f61be6e8-bcf106346f.zip create mode 100644 .yarn/cache/@rollup-pluginutils-npm-5.1.0-6939820ef8-abb15eaec5.zip create mode 100644 packages/client/src/iceshrimp-js/acct.ts create mode 100644 packages/client/src/iceshrimp-js/api.ts create mode 100644 packages/client/src/iceshrimp-js/api.types.ts create mode 100644 packages/client/src/iceshrimp-js/consts.ts create mode 100644 packages/client/src/iceshrimp-js/entities.ts create mode 100644 packages/client/src/iceshrimp-js/index.ts create mode 100644 packages/client/src/iceshrimp-js/streaming.ts create mode 100644 packages/client/src/iceshrimp-js/streaming.types.ts create mode 100644 packages/client/src/index.html create mode 100644 packages/client/vite-dev.config.ts 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 @@