From 0e4a111f81cceed275d9bec2695f6e401fb654d8 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 12 Nov 2021 02:02:25 +0900 Subject: refactoring Resolve #7779 --- packages/client/src/account.ts | 211 +++ .../client/src/components/abuse-report-window.vue | 79 + packages/client/src/components/analog-clock.vue | 150 ++ packages/client/src/components/autocomplete.vue | 501 ++++++ packages/client/src/components/avatars.vue | 30 + packages/client/src/components/captcha.vue | 123 ++ .../src/components/channel-follow-button.vue | 140 ++ packages/client/src/components/channel-preview.vue | 165 ++ packages/client/src/components/chart.vue | 691 ++++++++ packages/client/src/components/code-core.vue | 35 + packages/client/src/components/code.vue | 27 + packages/client/src/components/cw-button.vue | 70 + .../client/src/components/date-separated-list.vue | 188 +++ packages/client/src/components/debobigego/base.vue | 65 + .../client/src/components/debobigego/button.vue | 81 + .../src/components/debobigego/debobigego.scss | 52 + .../client/src/components/debobigego/group.vue | 78 + packages/client/src/components/debobigego/info.vue | 47 + .../client/src/components/debobigego/input.vue | 292 ++++ .../src/components/debobigego/key-value-view.vue | 38 + packages/client/src/components/debobigego/link.vue | 103 ++ .../src/components/debobigego/object-view.vue | 102 ++ .../src/components/debobigego/pagination.vue | 42 + .../client/src/components/debobigego/radios.vue | 112 ++ .../client/src/components/debobigego/range.vue | 122 ++ .../client/src/components/debobigego/select.vue | 145 ++ .../client/src/components/debobigego/suspense.vue | 101 ++ .../client/src/components/debobigego/switch.vue | 132 ++ .../client/src/components/debobigego/textarea.vue | 161 ++ .../client/src/components/debobigego/tuple.vue | 36 + packages/client/src/components/dialog.vue | 212 +++ .../client/src/components/drive-file-thumbnail.vue | 108 ++ .../client/src/components/drive-select-dialog.vue | 70 + packages/client/src/components/drive-window.vue | 44 + packages/client/src/components/drive.file.vue | 374 +++++ packages/client/src/components/drive.folder.vue | 326 ++++ .../client/src/components/drive.nav-folder.vue | 135 ++ packages/client/src/components/drive.vue | 784 +++++++++ .../client/src/components/emoji-picker-dialog.vue | 76 + .../client/src/components/emoji-picker-window.vue | 197 +++ .../client/src/components/emoji-picker.section.vue | 50 + packages/client/src/components/emoji-picker.vue | 501 ++++++ packages/client/src/components/featured-photos.vue | 32 + packages/client/src/components/file-type-icon.vue | 28 + packages/client/src/components/follow-button.vue | 210 +++ packages/client/src/components/forgot-password.vue | 84 + packages/client/src/components/form-dialog.vue | 125 ++ packages/client/src/components/form/input.vue | 315 ++++ packages/client/src/components/form/radio.vue | 122 ++ packages/client/src/components/form/radios.vue | 54 + packages/client/src/components/form/range.vue | 139 ++ packages/client/src/components/form/section.vue | 31 + packages/client/src/components/form/select.vue | 312 ++++ packages/client/src/components/form/slot.vue | 50 + packages/client/src/components/form/switch.vue | 150 ++ packages/client/src/components/form/textarea.vue | 252 +++ packages/client/src/components/formula-core.vue | 34 + packages/client/src/components/formula.vue | 23 + .../client/src/components/gallery-post-preview.vue | 126 ++ packages/client/src/components/global/a.vue | 138 ++ packages/client/src/components/global/acct.vue | 38 + packages/client/src/components/global/ad.vue | 200 +++ packages/client/src/components/global/avatar.vue | 163 ++ packages/client/src/components/global/ellipsis.vue | 34 + packages/client/src/components/global/emoji.vue | 125 ++ packages/client/src/components/global/error.vue | 46 + packages/client/src/components/global/header.vue | 360 ++++ packages/client/src/components/global/i18n.ts | 42 + packages/client/src/components/global/loading.vue | 92 + .../global/misskey-flavored-markdown.vue | 157 ++ packages/client/src/components/global/spacer.vue | 76 + .../src/components/global/sticky-container.vue | 74 + packages/client/src/components/global/time.vue | 73 + packages/client/src/components/global/url.vue | 142 ++ .../client/src/components/global/user-name.vue | 20 + packages/client/src/components/google.vue | 64 + packages/client/src/components/image-viewer.vue | 85 + .../client/src/components/img-with-blurhash.vue | 100 ++ packages/client/src/components/index.ts | 37 + packages/client/src/components/instance-stats.vue | 80 + packages/client/src/components/instance-ticker.vue | 62 + packages/client/src/components/launch-pad.vue | 152 ++ packages/client/src/components/link.vue | 92 + packages/client/src/components/media-banner.vue | 107 ++ packages/client/src/components/media-caption.vue | 259 +++ packages/client/src/components/media-image.vue | 155 ++ packages/client/src/components/media-list.vue | 167 ++ packages/client/src/components/media-video.vue | 97 ++ packages/client/src/components/mention.vue | 84 + packages/client/src/components/mfm.ts | 321 ++++ packages/client/src/components/mini-chart.vue | 90 + .../client/src/components/modal-page-window.vue | 223 +++ packages/client/src/components/note-detailed.vue | 1229 ++++++++++++++ packages/client/src/components/note-header.vue | 115 ++ packages/client/src/components/note-preview.vue | 98 ++ packages/client/src/components/note-simple.vue | 113 ++ packages/client/src/components/note.sub.vue | 146 ++ packages/client/src/components/note.vue | 1228 ++++++++++++++ packages/client/src/components/notes.vue | 130 ++ .../src/components/notification-setting-window.vue | 99 ++ packages/client/src/components/notification.vue | 362 ++++ packages/client/src/components/notifications.vue | 159 ++ packages/client/src/components/number-diff.vue | 47 + packages/client/src/components/page-preview.vue | 162 ++ packages/client/src/components/page-window.vue | 167 ++ packages/client/src/components/page/page.block.vue | 44 + .../client/src/components/page/page.button.vue | 66 + .../client/src/components/page/page.canvas.vue | 49 + .../client/src/components/page/page.counter.vue | 52 + packages/client/src/components/page/page.if.vue | 31 + packages/client/src/components/page/page.image.vue | 40 + packages/client/src/components/page/page.note.vue | 47 + .../src/components/page/page.number-input.vue | 55 + packages/client/src/components/page/page.post.vue | 109 ++ .../src/components/page/page.radio-button.vue | 45 + .../client/src/components/page/page.section.vue | 60 + .../client/src/components/page/page.switch.vue | 55 + .../client/src/components/page/page.text-input.vue | 55 + packages/client/src/components/page/page.text.vue | 68 + .../src/components/page/page.textarea-input.vue | 47 + .../client/src/components/page/page.textarea.vue | 39 + packages/client/src/components/page/page.vue | 86 + packages/client/src/components/particle.vue | 114 ++ packages/client/src/components/poll-editor.vue | 251 +++ packages/client/src/components/poll.vue | 174 ++ .../client/src/components/post-form-attaches.vue | 193 +++ .../client/src/components/post-form-dialog.vue | 19 + packages/client/src/components/post-form.vue | 980 +++++++++++ packages/client/src/components/queue-chart.vue | 232 +++ packages/client/src/components/reaction-icon.vue | 25 + .../client/src/components/reaction-tooltip.vue | 51 + .../src/components/reactions-viewer.details.vue | 91 + .../src/components/reactions-viewer.reaction.vue | 183 ++ .../client/src/components/reactions-viewer.vue | 48 + packages/client/src/components/remote-caution.vue | 35 + packages/client/src/components/sample.vue | 116 ++ packages/client/src/components/signin-dialog.vue | 42 + packages/client/src/components/signin.vue | 240 +++ packages/client/src/components/signup-dialog.vue | 50 + packages/client/src/components/signup.vue | 268 +++ packages/client/src/components/sparkle.vue | 179 ++ .../client/src/components/sub-note-content.vue | 62 + packages/client/src/components/tab.vue | 73 + .../src/components/taskmanager.api-window.vue | 72 + packages/client/src/components/taskmanager.vue | 233 +++ packages/client/src/components/timeline.vue | 183 ++ packages/client/src/components/toast.vue | 73 + .../src/components/token-generate-window.vue | 117 ++ packages/client/src/components/ui/button.vue | 262 +++ packages/client/src/components/ui/container.vue | 262 +++ packages/client/src/components/ui/context-menu.vue | 97 ++ packages/client/src/components/ui/folder.vue | 156 ++ packages/client/src/components/ui/hr.vue | 16 + packages/client/src/components/ui/info.vue | 45 + packages/client/src/components/ui/menu.vue | 278 ++++ packages/client/src/components/ui/modal-window.vue | 148 ++ packages/client/src/components/ui/modal.vue | 292 ++++ packages/client/src/components/ui/pagination.vue | 69 + packages/client/src/components/ui/popup-menu.vue | 42 + packages/client/src/components/ui/popup.vue | 213 +++ packages/client/src/components/ui/super-menu.vue | 148 ++ packages/client/src/components/ui/tooltip.vue | 92 + packages/client/src/components/ui/window.vue | 525 ++++++ packages/client/src/components/updated.vue | 62 + .../client/src/components/url-preview-popup.vue | 60 + packages/client/src/components/url-preview.vue | 334 ++++ packages/client/src/components/user-info.vue | 142 ++ packages/client/src/components/user-list.vue | 91 + .../src/components/user-online-indicator.vue | 50 + packages/client/src/components/user-preview.vue | 192 +++ .../client/src/components/user-select-dialog.vue | 199 +++ packages/client/src/components/users-dialog.vue | 147 ++ .../client/src/components/visibility-picker.vue | 167 ++ packages/client/src/components/waiting-dialog.vue | 92 + packages/client/src/components/widgets.vue | 152 ++ packages/client/src/config.ts | 15 + packages/client/src/directives/anim.ts | 18 + packages/client/src/directives/appear.ts | 22 + packages/client/src/directives/click-anime.ts | 29 + packages/client/src/directives/follow-append.ts | 35 + packages/client/src/directives/get-size.ts | 34 + packages/client/src/directives/hotkey.ts | 24 + packages/client/src/directives/index.ts | 26 + packages/client/src/directives/particle.ts | 18 + packages/client/src/directives/size.ts | 68 + packages/client/src/directives/sticky-container.ts | 15 + packages/client/src/directives/tooltip.ts | 87 + packages/client/src/directives/user-preview.ts | 118 ++ packages/client/src/emojilist.json | 1749 ++++++++++++++++++++ packages/client/src/events.ts | 4 + packages/client/src/filters/bytes.ts | 9 + packages/client/src/filters/note.ts | 3 + packages/client/src/filters/number.ts | 1 + packages/client/src/filters/user.ts | 15 + packages/client/src/i18n.ts | 13 + packages/client/src/init.ts | 420 +++++ packages/client/src/instance.ts | 52 + packages/client/src/menu.ts | 224 +++ packages/client/src/os.ts | 501 ++++++ packages/client/src/pages/_error_.vue | 94 ++ packages/client/src/pages/_loading_.vue | 10 + packages/client/src/pages/about-misskey.vue | 238 +++ packages/client/src/pages/about.vue | 123 ++ packages/client/src/pages/admin/abuses.vue | 170 ++ packages/client/src/pages/admin/ads.vue | 138 ++ packages/client/src/pages/admin/announcements.vue | 125 ++ packages/client/src/pages/admin/bot-protection.vue | 138 ++ packages/client/src/pages/admin/database.vue | 61 + packages/client/src/pages/admin/email-settings.vue | 128 ++ .../client/src/pages/admin/emoji-edit-dialog.vue | 120 ++ packages/client/src/pages/admin/emojis.vue | 263 +++ packages/client/src/pages/admin/file-dialog.vue | 129 ++ packages/client/src/pages/admin/files-settings.vue | 93 ++ packages/client/src/pages/admin/files.vue | 209 +++ packages/client/src/pages/admin/index.vue | 388 +++++ packages/client/src/pages/admin/instance-block.vue | 72 + packages/client/src/pages/admin/instance.vue | 321 ++++ .../src/pages/admin/integrations-discord.vue | 85 + .../client/src/pages/admin/integrations-github.vue | 85 + .../src/pages/admin/integrations-twitter.vue | 85 + packages/client/src/pages/admin/integrations.vue | 74 + packages/client/src/pages/admin/metrics.vue | 472 ++++++ packages/client/src/pages/admin/object-storage.vue | 155 ++ packages/client/src/pages/admin/other-settings.vue | 83 + packages/client/src/pages/admin/overview.vue | 236 +++ packages/client/src/pages/admin/proxy-account.vue | 87 + packages/client/src/pages/admin/queue.chart.vue | 102 ++ packages/client/src/pages/admin/queue.vue | 73 + packages/client/src/pages/admin/relays.vue | 99 ++ packages/client/src/pages/admin/security.vue | 83 + packages/client/src/pages/admin/service-worker.vue | 85 + packages/client/src/pages/admin/settings.vue | 151 ++ packages/client/src/pages/admin/users.vue | 254 +++ .../client/src/pages/advanced-theme-editor.vue | 352 ++++ packages/client/src/pages/announcements.vue | 74 + packages/client/src/pages/antenna-timeline.vue | 147 ++ packages/client/src/pages/api-console.vue | 93 ++ packages/client/src/pages/auth.form.vue | 60 + packages/client/src/pages/auth.vue | 95 ++ packages/client/src/pages/channel-editor.vue | 129 ++ packages/client/src/pages/channel.vue | 186 +++ packages/client/src/pages/channels.vue | 77 + packages/client/src/pages/clip.vue | 154 ++ packages/client/src/pages/drive.vue | 28 + packages/client/src/pages/emojis.category.vue | 135 ++ packages/client/src/pages/emojis.emoji.vue | 94 ++ packages/client/src/pages/emojis.vue | 36 + packages/client/src/pages/explore.vue | 261 +++ packages/client/src/pages/favorites.vue | 60 + packages/client/src/pages/featured.vue | 43 + packages/client/src/pages/federation.vue | 265 +++ packages/client/src/pages/follow-requests.vue | 153 ++ packages/client/src/pages/follow.vue | 65 + packages/client/src/pages/gallery/edit.vue | 168 ++ packages/client/src/pages/gallery/index.vue | 152 ++ packages/client/src/pages/gallery/post.vue | 282 ++++ packages/client/src/pages/instance-info.vue | 238 +++ packages/client/src/pages/mentions.vue | 42 + packages/client/src/pages/messages.vue | 45 + packages/client/src/pages/messaging/index.vue | 307 ++++ .../src/pages/messaging/messaging-room.form.vue | 348 ++++ .../src/pages/messaging/messaging-room.message.vue | 350 ++++ .../client/src/pages/messaging/messaging-room.vue | 470 ++++++ packages/client/src/pages/mfm-cheat-sheet.vue | 365 ++++ packages/client/src/pages/miauth.vue | 100 ++ packages/client/src/pages/my-antennas/create.vue | 51 + packages/client/src/pages/my-antennas/edit.vue | 56 + packages/client/src/pages/my-antennas/editor.vue | 190 +++ packages/client/src/pages/my-antennas/index.vue | 71 + packages/client/src/pages/my-clips/index.vue | 104 ++ packages/client/src/pages/my-groups/group.vue | 184 ++ packages/client/src/pages/my-groups/index.vue | 121 ++ packages/client/src/pages/my-lists/index.vue | 88 + packages/client/src/pages/my-lists/list.vue | 170 ++ packages/client/src/pages/not-found.vue | 25 + packages/client/src/pages/note.vue | 209 +++ packages/client/src/pages/notifications.vue | 88 + .../page-editor/els/page-editor.el.button.vue | 84 + .../page-editor/els/page-editor.el.canvas.vue | 50 + .../page-editor/els/page-editor.el.counter.vue | 46 + .../pages/page-editor/els/page-editor.el.if.vue | 84 + .../pages/page-editor/els/page-editor.el.image.vue | 72 + .../pages/page-editor/els/page-editor.el.note.vue | 65 + .../els/page-editor.el.number-input.vue | 46 + .../pages/page-editor/els/page-editor.el.post.vue | 43 + .../els/page-editor.el.radio-button.vue | 50 + .../page-editor/els/page-editor.el.section.vue | 96 ++ .../page-editor/els/page-editor.el.switch.vue | 46 + .../page-editor/els/page-editor.el.text-input.vue | 39 + .../pages/page-editor/els/page-editor.el.text.vue | 57 + .../els/page-editor.el.textarea-input.vue | 40 + .../page-editor/els/page-editor.el.textarea.vue | 57 + .../src/pages/page-editor/page-editor.blocks.vue | 78 + .../pages/page-editor/page-editor.container.vue | 159 ++ .../pages/page-editor/page-editor.script-block.vue | 281 ++++ .../client/src/pages/page-editor/page-editor.vue | 561 +++++++ packages/client/src/pages/page.vue | 311 ++++ packages/client/src/pages/pages.vue | 96 ++ packages/client/src/pages/preview.vue | 32 + packages/client/src/pages/reset-password.vue | 69 + packages/client/src/pages/reversi/game.board.vue | 528 ++++++ packages/client/src/pages/reversi/game.setting.vue | 390 +++++ packages/client/src/pages/reversi/game.vue | 76 + packages/client/src/pages/reversi/index.vue | 279 ++++ packages/client/src/pages/room/preview.vue | 107 ++ packages/client/src/pages/room/room.vue | 285 ++++ packages/client/src/pages/scratchpad.vue | 149 ++ packages/client/src/pages/search.vue | 53 + packages/client/src/pages/settings/2fa.vue | 247 +++ .../client/src/pages/settings/account-info.vue | 185 +++ packages/client/src/pages/settings/accounts.vue | 149 ++ packages/client/src/pages/settings/api.vue | 65 + packages/client/src/pages/settings/apps.vue | 113 ++ packages/client/src/pages/settings/custom-css.vue | 73 + packages/client/src/pages/settings/deck.vue | 107 ++ .../client/src/pages/settings/delete-account.vue | 68 + packages/client/src/pages/settings/drive.vue | 147 ++ .../client/src/pages/settings/email-address.vue | 70 + .../src/pages/settings/email-notification.vue | 91 + packages/client/src/pages/settings/email.vue | 66 + .../src/pages/settings/experimental-features.vue | 52 + packages/client/src/pages/settings/general.vue | 223 +++ .../client/src/pages/settings/import-export.vue | 112 ++ packages/client/src/pages/settings/index.vue | 326 ++++ packages/client/src/pages/settings/integration.vue | 141 ++ packages/client/src/pages/settings/menu.vue | 117 ++ packages/client/src/pages/settings/mute-block.vue | 85 + .../client/src/pages/settings/notifications.vue | 77 + packages/client/src/pages/settings/other.vue | 97 ++ .../client/src/pages/settings/plugin.install.vue | 147 ++ .../client/src/pages/settings/plugin.manage.vue | 115 ++ packages/client/src/pages/settings/plugin.vue | 44 + packages/client/src/pages/settings/privacy.vue | 120 ++ packages/client/src/pages/settings/profile.vue | 281 ++++ packages/client/src/pages/settings/reaction.vue | 152 ++ .../client/src/pages/settings/registry.keys.vue | 114 ++ .../client/src/pages/settings/registry.value.vue | 149 ++ packages/client/src/pages/settings/registry.vue | 90 + packages/client/src/pages/settings/security.vue | 158 ++ packages/client/src/pages/settings/sounds.vue | 155 ++ .../client/src/pages/settings/theme.install.vue | 105 ++ .../client/src/pages/settings/theme.manage.vue | 105 ++ packages/client/src/pages/settings/theme.vue | 424 +++++ packages/client/src/pages/settings/update.vue | 95 ++ packages/client/src/pages/settings/word-mute.vue | 110 ++ packages/client/src/pages/share.vue | 184 ++ packages/client/src/pages/signup-complete.vue | 50 + packages/client/src/pages/tag.vue | 57 + packages/client/src/pages/test.vue | 259 +++ packages/client/src/pages/theme-editor.vue | 306 ++++ packages/client/src/pages/timeline.tutorial.vue | 131 ++ packages/client/src/pages/timeline.vue | 225 +++ packages/client/src/pages/user-ap-info.vue | 124 ++ packages/client/src/pages/user-info.vue | 245 +++ packages/client/src/pages/user-list-timeline.vue | 147 ++ packages/client/src/pages/user/clips.vue | 50 + packages/client/src/pages/user/follow-list.vue | 65 + packages/client/src/pages/user/gallery.vue | 56 + packages/client/src/pages/user/index.activity.vue | 34 + packages/client/src/pages/user/index.photos.vue | 107 ++ packages/client/src/pages/user/index.timeline.vue | 68 + packages/client/src/pages/user/index.vue | 829 ++++++++++ packages/client/src/pages/user/pages.vue | 49 + packages/client/src/pages/user/reactions.vue | 81 + packages/client/src/pages/v.vue | 29 + packages/client/src/pages/welcome.entrance.a.vue | 320 ++++ packages/client/src/pages/welcome.entrance.b.vue | 236 +++ packages/client/src/pages/welcome.entrance.c.vue | 305 ++++ packages/client/src/pages/welcome.setup.vue | 102 ++ packages/client/src/pages/welcome.timeline.vue | 99 ++ packages/client/src/pages/welcome.vue | 38 + packages/client/src/pizzax.ts | 153 ++ packages/client/src/plugin.ts | 124 ++ packages/client/src/router.ts | 149 ++ packages/client/src/scripts/2fa.ts | 33 + packages/client/src/scripts/aiscript/api.ts | 44 + packages/client/src/scripts/array.ts | 138 ++ packages/client/src/scripts/autocomplete.ts | 276 +++ packages/client/src/scripts/check-word-mute.ts | 26 + packages/client/src/scripts/collect-page-vars.ts | 48 + packages/client/src/scripts/contains.ts | 9 + packages/client/src/scripts/copy-to-clipboard.ts | 33 + packages/client/src/scripts/emojilist.ts | 7 + .../src/scripts/extract-avg-color-from-blurhash.ts | 9 + packages/client/src/scripts/extract-mentions.ts | 11 + .../client/src/scripts/extract-url-from-mfm.ts | 19 + packages/client/src/scripts/focus.ts | 27 + packages/client/src/scripts/form.ts | 31 + packages/client/src/scripts/format-time-string.ts | 50 + packages/client/src/scripts/games/reversi/core.ts | 263 +++ packages/client/src/scripts/games/reversi/maps.ts | 896 ++++++++++ .../client/src/scripts/games/reversi/package.json | 18 + .../client/src/scripts/games/reversi/tsconfig.json | 21 + packages/client/src/scripts/gen-search-query.ts | 31 + packages/client/src/scripts/get-account-from-id.ts | 7 + packages/client/src/scripts/get-md5.ts | 10 + packages/client/src/scripts/get-note-summary.ts | 55 + .../client/src/scripts/get-static-image-url.ts | 16 + packages/client/src/scripts/get-user-menu.ts | 205 +++ packages/client/src/scripts/hotkey.ts | 88 + packages/client/src/scripts/hpml/block.ts | 109 ++ packages/client/src/scripts/hpml/evaluator.ts | 234 +++ packages/client/src/scripts/hpml/expr.ts | 79 + packages/client/src/scripts/hpml/index.ts | 103 ++ packages/client/src/scripts/hpml/lib.ts | 246 +++ packages/client/src/scripts/hpml/type-checker.ts | 189 +++ packages/client/src/scripts/i18n.ts | 29 + packages/client/src/scripts/idb-proxy.ts | 37 + packages/client/src/scripts/initialize-sw.ts | 68 + packages/client/src/scripts/is-device-darkmode.ts | 3 + packages/client/src/scripts/is-device-touch.ts | 1 + packages/client/src/scripts/is-mobile.ts | 2 + packages/client/src/scripts/keycode.ts | 33 + packages/client/src/scripts/loading.ts | 11 + packages/client/src/scripts/login-id.ts | 11 + packages/client/src/scripts/lookup-user.ts | 37 + packages/client/src/scripts/mfm-tags.ts | 1 + packages/client/src/scripts/paging.ts | 246 +++ packages/client/src/scripts/physics.ts | 152 ++ packages/client/src/scripts/please-login.ts | 14 + packages/client/src/scripts/popout.ts | 22 + packages/client/src/scripts/reaction-picker.ts | 41 + packages/client/src/scripts/room/furniture.ts | 21 + packages/client/src/scripts/room/furnitures.json5 | 407 +++++ packages/client/src/scripts/room/room.ts | 775 +++++++++ packages/client/src/scripts/scroll.ts | 80 + packages/client/src/scripts/search.ts | 64 + packages/client/src/scripts/select-file.ts | 89 + .../client/src/scripts/show-suspended-dialog.ts | 10 + packages/client/src/scripts/sound.ts | 34 + packages/client/src/scripts/sticky-sidebar.ts | 50 + packages/client/src/scripts/theme-editor.ts | 81 + packages/client/src/scripts/theme.ts | 127 ++ packages/client/src/scripts/time.ts | 39 + packages/client/src/scripts/twemoji-base.ts | 1 + packages/client/src/scripts/unison-reload.ts | 15 + packages/client/src/scripts/url.ts | 13 + packages/client/src/store.ts | 318 ++++ packages/client/src/style.scss | 562 +++++++ packages/client/src/sw/compose-notification.ts | 103 ++ packages/client/src/sw/sw.ts | 123 ++ packages/client/src/symbols.ts | 1 + packages/client/src/theme-store.ts | 34 + packages/client/src/themes/_dark.json5 | 90 + packages/client/src/themes/_light.json5 | 90 + packages/client/src/themes/d-astro.json5 | 78 + packages/client/src/themes/d-black.json5 | 17 + packages/client/src/themes/d-botanical.json5 | 26 + packages/client/src/themes/d-dark.json5 | 26 + packages/client/src/themes/d-future.json5 | 27 + packages/client/src/themes/d-persimmon.json5 | 25 + packages/client/src/themes/d-pumpkin.json5 | 88 + packages/client/src/themes/l-apricot.json5 | 22 + packages/client/src/themes/l-light.json5 | 20 + packages/client/src/themes/l-rainy.json5 | 21 + packages/client/src/themes/l-sushi.json5 | 18 + packages/client/src/themes/l-vivid.json5 | 82 + packages/client/src/ui/_common_/common.vue | 89 + packages/client/src/ui/_common_/sidebar.vue | 388 +++++ .../client/src/ui/_common_/stream-indicator.vue | 70 + packages/client/src/ui/_common_/upload.vue | 134 ++ .../client/src/ui/chat/date-separated-list.vue | 163 ++ packages/client/src/ui/chat/header-clock.vue | 62 + packages/client/src/ui/chat/index.vue | 467 ++++++ packages/client/src/ui/chat/note-header.vue | 112 ++ packages/client/src/ui/chat/note-preview.vue | 112 ++ packages/client/src/ui/chat/note.sub.vue | 137 ++ packages/client/src/ui/chat/note.vue | 1144 +++++++++++++ packages/client/src/ui/chat/notes.vue | 94 ++ packages/client/src/ui/chat/pages/channel.vue | 259 +++ packages/client/src/ui/chat/pages/timeline.vue | 221 +++ packages/client/src/ui/chat/post-form.vue | 772 +++++++++ packages/client/src/ui/chat/side.vue | 157 ++ packages/client/src/ui/chat/store.ts | 17 + packages/client/src/ui/chat/sub-note-content.vue | 62 + packages/client/src/ui/chat/widgets.vue | 62 + packages/client/src/ui/classic.header.vue | 210 +++ packages/client/src/ui/classic.side.vue | 158 ++ packages/client/src/ui/classic.sidebar.vue | 263 +++ packages/client/src/ui/classic.vue | 471 ++++++ packages/client/src/ui/classic.widgets.vue | 84 + packages/client/src/ui/deck.vue | 229 +++ packages/client/src/ui/deck/antenna-column.vue | 80 + packages/client/src/ui/deck/column-core.vue | 52 + packages/client/src/ui/deck/column.vue | 408 +++++ packages/client/src/ui/deck/deck-store.ts | 298 ++++ packages/client/src/ui/deck/direct-column.vue | 55 + packages/client/src/ui/deck/list-column.vue | 80 + packages/client/src/ui/deck/main-column.vue | 91 + packages/client/src/ui/deck/mentions-column.vue | 52 + .../client/src/ui/deck/notifications-column.vue | 53 + packages/client/src/ui/deck/tl-column.vue | 137 ++ packages/client/src/ui/deck/widgets-column.vue | 71 + packages/client/src/ui/desktop.vue | 70 + packages/client/src/ui/universal.vue | 402 +++++ packages/client/src/ui/universal.widgets.vue | 79 + packages/client/src/ui/visitor.vue | 19 + packages/client/src/ui/visitor/a.vue | 260 +++ packages/client/src/ui/visitor/b.vue | 282 ++++ packages/client/src/ui/visitor/header.vue | 228 +++ packages/client/src/ui/visitor/kanban.vue | 256 +++ packages/client/src/ui/zen.vue | 106 ++ packages/client/src/widgets/activity.calendar.vue | 85 + packages/client/src/widgets/activity.chart.vue | 107 ++ packages/client/src/widgets/activity.vue | 82 + packages/client/src/widgets/aichan.vue | 59 + packages/client/src/widgets/aiscript.vue | 163 ++ packages/client/src/widgets/button.vue | 95 ++ packages/client/src/widgets/calendar.vue | 204 +++ packages/client/src/widgets/clock.vue | 55 + packages/client/src/widgets/define.ts | 75 + packages/client/src/widgets/digital-clock.vue | 79 + packages/client/src/widgets/federation.vue | 145 ++ packages/client/src/widgets/index.ts | 45 + packages/client/src/widgets/job-queue.vue | 183 ++ packages/client/src/widgets/memo.vue | 106 ++ packages/client/src/widgets/notifications.vue | 65 + packages/client/src/widgets/online-users.vue | 67 + packages/client/src/widgets/photos.vue | 113 ++ packages/client/src/widgets/post-form.vue | 23 + packages/client/src/widgets/rss.vue | 89 + .../client/src/widgets/server-metric/cpu-mem.vue | 174 ++ packages/client/src/widgets/server-metric/cpu.vue | 76 + packages/client/src/widgets/server-metric/disk.vue | 70 + .../client/src/widgets/server-metric/index.vue | 82 + packages/client/src/widgets/server-metric/mem.vue | 85 + packages/client/src/widgets/server-metric/net.vue | 148 ++ packages/client/src/widgets/server-metric/pie.vue | 65 + packages/client/src/widgets/slideshow.vue | 167 ++ packages/client/src/widgets/timeline.vue | 116 ++ packages/client/src/widgets/trends.vue | 111 ++ 531 files changed, 75230 insertions(+) create mode 100644 packages/client/src/account.ts create mode 100644 packages/client/src/components/abuse-report-window.vue create mode 100644 packages/client/src/components/analog-clock.vue create mode 100644 packages/client/src/components/autocomplete.vue create mode 100644 packages/client/src/components/avatars.vue create mode 100644 packages/client/src/components/captcha.vue create mode 100644 packages/client/src/components/channel-follow-button.vue create mode 100644 packages/client/src/components/channel-preview.vue create mode 100644 packages/client/src/components/chart.vue create mode 100644 packages/client/src/components/code-core.vue create mode 100644 packages/client/src/components/code.vue create mode 100644 packages/client/src/components/cw-button.vue create mode 100644 packages/client/src/components/date-separated-list.vue create mode 100644 packages/client/src/components/debobigego/base.vue create mode 100644 packages/client/src/components/debobigego/button.vue create mode 100644 packages/client/src/components/debobigego/debobigego.scss create mode 100644 packages/client/src/components/debobigego/group.vue create mode 100644 packages/client/src/components/debobigego/info.vue create mode 100644 packages/client/src/components/debobigego/input.vue create mode 100644 packages/client/src/components/debobigego/key-value-view.vue create mode 100644 packages/client/src/components/debobigego/link.vue create mode 100644 packages/client/src/components/debobigego/object-view.vue create mode 100644 packages/client/src/components/debobigego/pagination.vue create mode 100644 packages/client/src/components/debobigego/radios.vue create mode 100644 packages/client/src/components/debobigego/range.vue create mode 100644 packages/client/src/components/debobigego/select.vue create mode 100644 packages/client/src/components/debobigego/suspense.vue create mode 100644 packages/client/src/components/debobigego/switch.vue create mode 100644 packages/client/src/components/debobigego/textarea.vue create mode 100644 packages/client/src/components/debobigego/tuple.vue create mode 100644 packages/client/src/components/dialog.vue create mode 100644 packages/client/src/components/drive-file-thumbnail.vue create mode 100644 packages/client/src/components/drive-select-dialog.vue create mode 100644 packages/client/src/components/drive-window.vue create mode 100644 packages/client/src/components/drive.file.vue create mode 100644 packages/client/src/components/drive.folder.vue create mode 100644 packages/client/src/components/drive.nav-folder.vue create mode 100644 packages/client/src/components/drive.vue create mode 100644 packages/client/src/components/emoji-picker-dialog.vue create mode 100644 packages/client/src/components/emoji-picker-window.vue create mode 100644 packages/client/src/components/emoji-picker.section.vue create mode 100644 packages/client/src/components/emoji-picker.vue create mode 100644 packages/client/src/components/featured-photos.vue create mode 100644 packages/client/src/components/file-type-icon.vue create mode 100644 packages/client/src/components/follow-button.vue create mode 100644 packages/client/src/components/forgot-password.vue create mode 100644 packages/client/src/components/form-dialog.vue create mode 100644 packages/client/src/components/form/input.vue create mode 100644 packages/client/src/components/form/radio.vue create mode 100644 packages/client/src/components/form/radios.vue create mode 100644 packages/client/src/components/form/range.vue create mode 100644 packages/client/src/components/form/section.vue create mode 100644 packages/client/src/components/form/select.vue create mode 100644 packages/client/src/components/form/slot.vue create mode 100644 packages/client/src/components/form/switch.vue create mode 100644 packages/client/src/components/form/textarea.vue create mode 100644 packages/client/src/components/formula-core.vue create mode 100644 packages/client/src/components/formula.vue create mode 100644 packages/client/src/components/gallery-post-preview.vue create mode 100644 packages/client/src/components/global/a.vue create mode 100644 packages/client/src/components/global/acct.vue create mode 100644 packages/client/src/components/global/ad.vue create mode 100644 packages/client/src/components/global/avatar.vue create mode 100644 packages/client/src/components/global/ellipsis.vue create mode 100644 packages/client/src/components/global/emoji.vue create mode 100644 packages/client/src/components/global/error.vue create mode 100644 packages/client/src/components/global/header.vue create mode 100644 packages/client/src/components/global/i18n.ts create mode 100644 packages/client/src/components/global/loading.vue create mode 100644 packages/client/src/components/global/misskey-flavored-markdown.vue create mode 100644 packages/client/src/components/global/spacer.vue create mode 100644 packages/client/src/components/global/sticky-container.vue create mode 100644 packages/client/src/components/global/time.vue create mode 100644 packages/client/src/components/global/url.vue create mode 100644 packages/client/src/components/global/user-name.vue create mode 100644 packages/client/src/components/google.vue create mode 100644 packages/client/src/components/image-viewer.vue create mode 100644 packages/client/src/components/img-with-blurhash.vue create mode 100644 packages/client/src/components/index.ts create mode 100644 packages/client/src/components/instance-stats.vue create mode 100644 packages/client/src/components/instance-ticker.vue create mode 100644 packages/client/src/components/launch-pad.vue create mode 100644 packages/client/src/components/link.vue create mode 100644 packages/client/src/components/media-banner.vue create mode 100644 packages/client/src/components/media-caption.vue create mode 100644 packages/client/src/components/media-image.vue create mode 100644 packages/client/src/components/media-list.vue create mode 100644 packages/client/src/components/media-video.vue create mode 100644 packages/client/src/components/mention.vue create mode 100644 packages/client/src/components/mfm.ts create mode 100644 packages/client/src/components/mini-chart.vue create mode 100644 packages/client/src/components/modal-page-window.vue create mode 100644 packages/client/src/components/note-detailed.vue create mode 100644 packages/client/src/components/note-header.vue create mode 100644 packages/client/src/components/note-preview.vue create mode 100644 packages/client/src/components/note-simple.vue create mode 100644 packages/client/src/components/note.sub.vue create mode 100644 packages/client/src/components/note.vue create mode 100644 packages/client/src/components/notes.vue create mode 100644 packages/client/src/components/notification-setting-window.vue create mode 100644 packages/client/src/components/notification.vue create mode 100644 packages/client/src/components/notifications.vue create mode 100644 packages/client/src/components/number-diff.vue create mode 100644 packages/client/src/components/page-preview.vue create mode 100644 packages/client/src/components/page-window.vue create mode 100644 packages/client/src/components/page/page.block.vue create mode 100644 packages/client/src/components/page/page.button.vue create mode 100644 packages/client/src/components/page/page.canvas.vue create mode 100644 packages/client/src/components/page/page.counter.vue create mode 100644 packages/client/src/components/page/page.if.vue create mode 100644 packages/client/src/components/page/page.image.vue create mode 100644 packages/client/src/components/page/page.note.vue create mode 100644 packages/client/src/components/page/page.number-input.vue create mode 100644 packages/client/src/components/page/page.post.vue create mode 100644 packages/client/src/components/page/page.radio-button.vue create mode 100644 packages/client/src/components/page/page.section.vue create mode 100644 packages/client/src/components/page/page.switch.vue create mode 100644 packages/client/src/components/page/page.text-input.vue create mode 100644 packages/client/src/components/page/page.text.vue create mode 100644 packages/client/src/components/page/page.textarea-input.vue create mode 100644 packages/client/src/components/page/page.textarea.vue create mode 100644 packages/client/src/components/page/page.vue create mode 100644 packages/client/src/components/particle.vue create mode 100644 packages/client/src/components/poll-editor.vue create mode 100644 packages/client/src/components/poll.vue create mode 100644 packages/client/src/components/post-form-attaches.vue create mode 100644 packages/client/src/components/post-form-dialog.vue create mode 100644 packages/client/src/components/post-form.vue create mode 100644 packages/client/src/components/queue-chart.vue create mode 100644 packages/client/src/components/reaction-icon.vue create mode 100644 packages/client/src/components/reaction-tooltip.vue create mode 100644 packages/client/src/components/reactions-viewer.details.vue create mode 100644 packages/client/src/components/reactions-viewer.reaction.vue create mode 100644 packages/client/src/components/reactions-viewer.vue create mode 100644 packages/client/src/components/remote-caution.vue create mode 100644 packages/client/src/components/sample.vue create mode 100644 packages/client/src/components/signin-dialog.vue create mode 100644 packages/client/src/components/signin.vue create mode 100644 packages/client/src/components/signup-dialog.vue create mode 100644 packages/client/src/components/signup.vue create mode 100644 packages/client/src/components/sparkle.vue create mode 100644 packages/client/src/components/sub-note-content.vue create mode 100644 packages/client/src/components/tab.vue create mode 100644 packages/client/src/components/taskmanager.api-window.vue create mode 100644 packages/client/src/components/taskmanager.vue create mode 100644 packages/client/src/components/timeline.vue create mode 100644 packages/client/src/components/toast.vue create mode 100644 packages/client/src/components/token-generate-window.vue create mode 100644 packages/client/src/components/ui/button.vue create mode 100644 packages/client/src/components/ui/container.vue create mode 100644 packages/client/src/components/ui/context-menu.vue create mode 100644 packages/client/src/components/ui/folder.vue create mode 100644 packages/client/src/components/ui/hr.vue create mode 100644 packages/client/src/components/ui/info.vue create mode 100644 packages/client/src/components/ui/menu.vue create mode 100644 packages/client/src/components/ui/modal-window.vue create mode 100644 packages/client/src/components/ui/modal.vue create mode 100644 packages/client/src/components/ui/pagination.vue create mode 100644 packages/client/src/components/ui/popup-menu.vue create mode 100644 packages/client/src/components/ui/popup.vue create mode 100644 packages/client/src/components/ui/super-menu.vue create mode 100644 packages/client/src/components/ui/tooltip.vue create mode 100644 packages/client/src/components/ui/window.vue create mode 100644 packages/client/src/components/updated.vue create mode 100644 packages/client/src/components/url-preview-popup.vue create mode 100644 packages/client/src/components/url-preview.vue create mode 100644 packages/client/src/components/user-info.vue create mode 100644 packages/client/src/components/user-list.vue create mode 100644 packages/client/src/components/user-online-indicator.vue create mode 100644 packages/client/src/components/user-preview.vue create mode 100644 packages/client/src/components/user-select-dialog.vue create mode 100644 packages/client/src/components/users-dialog.vue create mode 100644 packages/client/src/components/visibility-picker.vue create mode 100644 packages/client/src/components/waiting-dialog.vue create mode 100644 packages/client/src/components/widgets.vue create mode 100644 packages/client/src/config.ts create mode 100644 packages/client/src/directives/anim.ts create mode 100644 packages/client/src/directives/appear.ts create mode 100644 packages/client/src/directives/click-anime.ts create mode 100644 packages/client/src/directives/follow-append.ts create mode 100644 packages/client/src/directives/get-size.ts create mode 100644 packages/client/src/directives/hotkey.ts create mode 100644 packages/client/src/directives/index.ts create mode 100644 packages/client/src/directives/particle.ts create mode 100644 packages/client/src/directives/size.ts create mode 100644 packages/client/src/directives/sticky-container.ts create mode 100644 packages/client/src/directives/tooltip.ts create mode 100644 packages/client/src/directives/user-preview.ts create mode 100644 packages/client/src/emojilist.json create mode 100644 packages/client/src/events.ts create mode 100644 packages/client/src/filters/bytes.ts create mode 100644 packages/client/src/filters/note.ts create mode 100644 packages/client/src/filters/number.ts create mode 100644 packages/client/src/filters/user.ts create mode 100644 packages/client/src/i18n.ts create mode 100644 packages/client/src/init.ts create mode 100644 packages/client/src/instance.ts create mode 100644 packages/client/src/menu.ts create mode 100644 packages/client/src/os.ts create mode 100644 packages/client/src/pages/_error_.vue create mode 100644 packages/client/src/pages/_loading_.vue create mode 100644 packages/client/src/pages/about-misskey.vue create mode 100644 packages/client/src/pages/about.vue create mode 100644 packages/client/src/pages/admin/abuses.vue create mode 100644 packages/client/src/pages/admin/ads.vue create mode 100644 packages/client/src/pages/admin/announcements.vue create mode 100644 packages/client/src/pages/admin/bot-protection.vue create mode 100644 packages/client/src/pages/admin/database.vue create mode 100644 packages/client/src/pages/admin/email-settings.vue create mode 100644 packages/client/src/pages/admin/emoji-edit-dialog.vue create mode 100644 packages/client/src/pages/admin/emojis.vue create mode 100644 packages/client/src/pages/admin/file-dialog.vue create mode 100644 packages/client/src/pages/admin/files-settings.vue create mode 100644 packages/client/src/pages/admin/files.vue create mode 100644 packages/client/src/pages/admin/index.vue create mode 100644 packages/client/src/pages/admin/instance-block.vue create mode 100644 packages/client/src/pages/admin/instance.vue create mode 100644 packages/client/src/pages/admin/integrations-discord.vue create mode 100644 packages/client/src/pages/admin/integrations-github.vue create mode 100644 packages/client/src/pages/admin/integrations-twitter.vue create mode 100644 packages/client/src/pages/admin/integrations.vue create mode 100644 packages/client/src/pages/admin/metrics.vue create mode 100644 packages/client/src/pages/admin/object-storage.vue create mode 100644 packages/client/src/pages/admin/other-settings.vue create mode 100644 packages/client/src/pages/admin/overview.vue create mode 100644 packages/client/src/pages/admin/proxy-account.vue create mode 100644 packages/client/src/pages/admin/queue.chart.vue create mode 100644 packages/client/src/pages/admin/queue.vue create mode 100644 packages/client/src/pages/admin/relays.vue create mode 100644 packages/client/src/pages/admin/security.vue create mode 100644 packages/client/src/pages/admin/service-worker.vue create mode 100644 packages/client/src/pages/admin/settings.vue create mode 100644 packages/client/src/pages/admin/users.vue create mode 100644 packages/client/src/pages/advanced-theme-editor.vue create mode 100644 packages/client/src/pages/announcements.vue create mode 100644 packages/client/src/pages/antenna-timeline.vue create mode 100644 packages/client/src/pages/api-console.vue create mode 100644 packages/client/src/pages/auth.form.vue create mode 100644 packages/client/src/pages/auth.vue create mode 100644 packages/client/src/pages/channel-editor.vue create mode 100644 packages/client/src/pages/channel.vue create mode 100644 packages/client/src/pages/channels.vue create mode 100644 packages/client/src/pages/clip.vue create mode 100644 packages/client/src/pages/drive.vue create mode 100644 packages/client/src/pages/emojis.category.vue create mode 100644 packages/client/src/pages/emojis.emoji.vue create mode 100644 packages/client/src/pages/emojis.vue create mode 100644 packages/client/src/pages/explore.vue create mode 100644 packages/client/src/pages/favorites.vue create mode 100644 packages/client/src/pages/featured.vue create mode 100644 packages/client/src/pages/federation.vue create mode 100644 packages/client/src/pages/follow-requests.vue create mode 100644 packages/client/src/pages/follow.vue create mode 100644 packages/client/src/pages/gallery/edit.vue create mode 100644 packages/client/src/pages/gallery/index.vue create mode 100644 packages/client/src/pages/gallery/post.vue create mode 100644 packages/client/src/pages/instance-info.vue create mode 100644 packages/client/src/pages/mentions.vue create mode 100644 packages/client/src/pages/messages.vue create mode 100644 packages/client/src/pages/messaging/index.vue create mode 100644 packages/client/src/pages/messaging/messaging-room.form.vue create mode 100644 packages/client/src/pages/messaging/messaging-room.message.vue create mode 100644 packages/client/src/pages/messaging/messaging-room.vue create mode 100644 packages/client/src/pages/mfm-cheat-sheet.vue create mode 100644 packages/client/src/pages/miauth.vue create mode 100644 packages/client/src/pages/my-antennas/create.vue create mode 100644 packages/client/src/pages/my-antennas/edit.vue create mode 100644 packages/client/src/pages/my-antennas/editor.vue create mode 100644 packages/client/src/pages/my-antennas/index.vue create mode 100644 packages/client/src/pages/my-clips/index.vue create mode 100644 packages/client/src/pages/my-groups/group.vue create mode 100644 packages/client/src/pages/my-groups/index.vue create mode 100644 packages/client/src/pages/my-lists/index.vue create mode 100644 packages/client/src/pages/my-lists/list.vue create mode 100644 packages/client/src/pages/not-found.vue create mode 100644 packages/client/src/pages/note.vue create mode 100644 packages/client/src/pages/notifications.vue create mode 100644 packages/client/src/pages/page-editor/els/page-editor.el.button.vue create mode 100644 packages/client/src/pages/page-editor/els/page-editor.el.canvas.vue create mode 100644 packages/client/src/pages/page-editor/els/page-editor.el.counter.vue create mode 100644 packages/client/src/pages/page-editor/els/page-editor.el.if.vue create mode 100644 packages/client/src/pages/page-editor/els/page-editor.el.image.vue create mode 100644 packages/client/src/pages/page-editor/els/page-editor.el.note.vue create mode 100644 packages/client/src/pages/page-editor/els/page-editor.el.number-input.vue create mode 100644 packages/client/src/pages/page-editor/els/page-editor.el.post.vue create mode 100644 packages/client/src/pages/page-editor/els/page-editor.el.radio-button.vue create mode 100644 packages/client/src/pages/page-editor/els/page-editor.el.section.vue create mode 100644 packages/client/src/pages/page-editor/els/page-editor.el.switch.vue create mode 100644 packages/client/src/pages/page-editor/els/page-editor.el.text-input.vue create mode 100644 packages/client/src/pages/page-editor/els/page-editor.el.text.vue create mode 100644 packages/client/src/pages/page-editor/els/page-editor.el.textarea-input.vue create mode 100644 packages/client/src/pages/page-editor/els/page-editor.el.textarea.vue create mode 100644 packages/client/src/pages/page-editor/page-editor.blocks.vue create mode 100644 packages/client/src/pages/page-editor/page-editor.container.vue create mode 100644 packages/client/src/pages/page-editor/page-editor.script-block.vue create mode 100644 packages/client/src/pages/page-editor/page-editor.vue create mode 100644 packages/client/src/pages/page.vue create mode 100644 packages/client/src/pages/pages.vue create mode 100644 packages/client/src/pages/preview.vue create mode 100644 packages/client/src/pages/reset-password.vue create mode 100644 packages/client/src/pages/reversi/game.board.vue create mode 100644 packages/client/src/pages/reversi/game.setting.vue create mode 100644 packages/client/src/pages/reversi/game.vue create mode 100644 packages/client/src/pages/reversi/index.vue create mode 100644 packages/client/src/pages/room/preview.vue create mode 100644 packages/client/src/pages/room/room.vue create mode 100644 packages/client/src/pages/scratchpad.vue create mode 100644 packages/client/src/pages/search.vue create mode 100644 packages/client/src/pages/settings/2fa.vue create mode 100644 packages/client/src/pages/settings/account-info.vue create mode 100644 packages/client/src/pages/settings/accounts.vue create mode 100644 packages/client/src/pages/settings/api.vue create mode 100644 packages/client/src/pages/settings/apps.vue create mode 100644 packages/client/src/pages/settings/custom-css.vue create mode 100644 packages/client/src/pages/settings/deck.vue create mode 100644 packages/client/src/pages/settings/delete-account.vue create mode 100644 packages/client/src/pages/settings/drive.vue create mode 100644 packages/client/src/pages/settings/email-address.vue create mode 100644 packages/client/src/pages/settings/email-notification.vue create mode 100644 packages/client/src/pages/settings/email.vue create mode 100644 packages/client/src/pages/settings/experimental-features.vue create mode 100644 packages/client/src/pages/settings/general.vue create mode 100644 packages/client/src/pages/settings/import-export.vue create mode 100644 packages/client/src/pages/settings/index.vue create mode 100644 packages/client/src/pages/settings/integration.vue create mode 100644 packages/client/src/pages/settings/menu.vue create mode 100644 packages/client/src/pages/settings/mute-block.vue create mode 100644 packages/client/src/pages/settings/notifications.vue create mode 100644 packages/client/src/pages/settings/other.vue create mode 100644 packages/client/src/pages/settings/plugin.install.vue create mode 100644 packages/client/src/pages/settings/plugin.manage.vue create mode 100644 packages/client/src/pages/settings/plugin.vue create mode 100644 packages/client/src/pages/settings/privacy.vue create mode 100644 packages/client/src/pages/settings/profile.vue create mode 100644 packages/client/src/pages/settings/reaction.vue create mode 100644 packages/client/src/pages/settings/registry.keys.vue create mode 100644 packages/client/src/pages/settings/registry.value.vue create mode 100644 packages/client/src/pages/settings/registry.vue create mode 100644 packages/client/src/pages/settings/security.vue create mode 100644 packages/client/src/pages/settings/sounds.vue create mode 100644 packages/client/src/pages/settings/theme.install.vue create mode 100644 packages/client/src/pages/settings/theme.manage.vue create mode 100644 packages/client/src/pages/settings/theme.vue create mode 100644 packages/client/src/pages/settings/update.vue create mode 100644 packages/client/src/pages/settings/word-mute.vue create mode 100644 packages/client/src/pages/share.vue create mode 100644 packages/client/src/pages/signup-complete.vue create mode 100644 packages/client/src/pages/tag.vue create mode 100644 packages/client/src/pages/test.vue create mode 100644 packages/client/src/pages/theme-editor.vue create mode 100644 packages/client/src/pages/timeline.tutorial.vue create mode 100644 packages/client/src/pages/timeline.vue create mode 100644 packages/client/src/pages/user-ap-info.vue create mode 100644 packages/client/src/pages/user-info.vue create mode 100644 packages/client/src/pages/user-list-timeline.vue create mode 100644 packages/client/src/pages/user/clips.vue create mode 100644 packages/client/src/pages/user/follow-list.vue create mode 100644 packages/client/src/pages/user/gallery.vue create mode 100644 packages/client/src/pages/user/index.activity.vue create mode 100644 packages/client/src/pages/user/index.photos.vue create mode 100644 packages/client/src/pages/user/index.timeline.vue create mode 100644 packages/client/src/pages/user/index.vue create mode 100644 packages/client/src/pages/user/pages.vue create mode 100644 packages/client/src/pages/user/reactions.vue create mode 100644 packages/client/src/pages/v.vue create mode 100644 packages/client/src/pages/welcome.entrance.a.vue create mode 100644 packages/client/src/pages/welcome.entrance.b.vue create mode 100644 packages/client/src/pages/welcome.entrance.c.vue create mode 100644 packages/client/src/pages/welcome.setup.vue create mode 100644 packages/client/src/pages/welcome.timeline.vue create mode 100644 packages/client/src/pages/welcome.vue create mode 100644 packages/client/src/pizzax.ts create mode 100644 packages/client/src/plugin.ts create mode 100644 packages/client/src/router.ts create mode 100644 packages/client/src/scripts/2fa.ts create mode 100644 packages/client/src/scripts/aiscript/api.ts create mode 100644 packages/client/src/scripts/array.ts create mode 100644 packages/client/src/scripts/autocomplete.ts create mode 100644 packages/client/src/scripts/check-word-mute.ts create mode 100644 packages/client/src/scripts/collect-page-vars.ts create mode 100644 packages/client/src/scripts/contains.ts create mode 100644 packages/client/src/scripts/copy-to-clipboard.ts create mode 100644 packages/client/src/scripts/emojilist.ts create mode 100644 packages/client/src/scripts/extract-avg-color-from-blurhash.ts create mode 100644 packages/client/src/scripts/extract-mentions.ts create mode 100644 packages/client/src/scripts/extract-url-from-mfm.ts create mode 100644 packages/client/src/scripts/focus.ts create mode 100644 packages/client/src/scripts/form.ts create mode 100644 packages/client/src/scripts/format-time-string.ts create mode 100644 packages/client/src/scripts/games/reversi/core.ts create mode 100644 packages/client/src/scripts/games/reversi/maps.ts create mode 100644 packages/client/src/scripts/games/reversi/package.json create mode 100644 packages/client/src/scripts/games/reversi/tsconfig.json create mode 100644 packages/client/src/scripts/gen-search-query.ts create mode 100644 packages/client/src/scripts/get-account-from-id.ts create mode 100644 packages/client/src/scripts/get-md5.ts create mode 100644 packages/client/src/scripts/get-note-summary.ts create mode 100644 packages/client/src/scripts/get-static-image-url.ts create mode 100644 packages/client/src/scripts/get-user-menu.ts create mode 100644 packages/client/src/scripts/hotkey.ts create mode 100644 packages/client/src/scripts/hpml/block.ts create mode 100644 packages/client/src/scripts/hpml/evaluator.ts create mode 100644 packages/client/src/scripts/hpml/expr.ts create mode 100644 packages/client/src/scripts/hpml/index.ts create mode 100644 packages/client/src/scripts/hpml/lib.ts create mode 100644 packages/client/src/scripts/hpml/type-checker.ts create mode 100644 packages/client/src/scripts/i18n.ts create mode 100644 packages/client/src/scripts/idb-proxy.ts create mode 100644 packages/client/src/scripts/initialize-sw.ts create mode 100644 packages/client/src/scripts/is-device-darkmode.ts create mode 100644 packages/client/src/scripts/is-device-touch.ts create mode 100644 packages/client/src/scripts/is-mobile.ts create mode 100644 packages/client/src/scripts/keycode.ts create mode 100644 packages/client/src/scripts/loading.ts create mode 100644 packages/client/src/scripts/login-id.ts create mode 100644 packages/client/src/scripts/lookup-user.ts create mode 100644 packages/client/src/scripts/mfm-tags.ts create mode 100644 packages/client/src/scripts/paging.ts create mode 100644 packages/client/src/scripts/physics.ts create mode 100644 packages/client/src/scripts/please-login.ts create mode 100644 packages/client/src/scripts/popout.ts create mode 100644 packages/client/src/scripts/reaction-picker.ts create mode 100644 packages/client/src/scripts/room/furniture.ts create mode 100644 packages/client/src/scripts/room/furnitures.json5 create mode 100644 packages/client/src/scripts/room/room.ts create mode 100644 packages/client/src/scripts/scroll.ts create mode 100644 packages/client/src/scripts/search.ts create mode 100644 packages/client/src/scripts/select-file.ts create mode 100644 packages/client/src/scripts/show-suspended-dialog.ts create mode 100644 packages/client/src/scripts/sound.ts create mode 100644 packages/client/src/scripts/sticky-sidebar.ts create mode 100644 packages/client/src/scripts/theme-editor.ts create mode 100644 packages/client/src/scripts/theme.ts create mode 100644 packages/client/src/scripts/time.ts create mode 100644 packages/client/src/scripts/twemoji-base.ts create mode 100644 packages/client/src/scripts/unison-reload.ts create mode 100644 packages/client/src/scripts/url.ts create mode 100644 packages/client/src/store.ts create mode 100644 packages/client/src/style.scss create mode 100644 packages/client/src/sw/compose-notification.ts create mode 100644 packages/client/src/sw/sw.ts create mode 100644 packages/client/src/symbols.ts create mode 100644 packages/client/src/theme-store.ts create mode 100644 packages/client/src/themes/_dark.json5 create mode 100644 packages/client/src/themes/_light.json5 create mode 100644 packages/client/src/themes/d-astro.json5 create mode 100644 packages/client/src/themes/d-black.json5 create mode 100644 packages/client/src/themes/d-botanical.json5 create mode 100644 packages/client/src/themes/d-dark.json5 create mode 100644 packages/client/src/themes/d-future.json5 create mode 100644 packages/client/src/themes/d-persimmon.json5 create mode 100644 packages/client/src/themes/d-pumpkin.json5 create mode 100644 packages/client/src/themes/l-apricot.json5 create mode 100644 packages/client/src/themes/l-light.json5 create mode 100644 packages/client/src/themes/l-rainy.json5 create mode 100644 packages/client/src/themes/l-sushi.json5 create mode 100644 packages/client/src/themes/l-vivid.json5 create mode 100644 packages/client/src/ui/_common_/common.vue create mode 100644 packages/client/src/ui/_common_/sidebar.vue create mode 100644 packages/client/src/ui/_common_/stream-indicator.vue create mode 100644 packages/client/src/ui/_common_/upload.vue create mode 100644 packages/client/src/ui/chat/date-separated-list.vue create mode 100644 packages/client/src/ui/chat/header-clock.vue create mode 100644 packages/client/src/ui/chat/index.vue create mode 100644 packages/client/src/ui/chat/note-header.vue create mode 100644 packages/client/src/ui/chat/note-preview.vue create mode 100644 packages/client/src/ui/chat/note.sub.vue create mode 100644 packages/client/src/ui/chat/note.vue create mode 100644 packages/client/src/ui/chat/notes.vue create mode 100644 packages/client/src/ui/chat/pages/channel.vue create mode 100644 packages/client/src/ui/chat/pages/timeline.vue create mode 100644 packages/client/src/ui/chat/post-form.vue create mode 100644 packages/client/src/ui/chat/side.vue create mode 100644 packages/client/src/ui/chat/store.ts create mode 100644 packages/client/src/ui/chat/sub-note-content.vue create mode 100644 packages/client/src/ui/chat/widgets.vue create mode 100644 packages/client/src/ui/classic.header.vue create mode 100644 packages/client/src/ui/classic.side.vue create mode 100644 packages/client/src/ui/classic.sidebar.vue create mode 100644 packages/client/src/ui/classic.vue create mode 100644 packages/client/src/ui/classic.widgets.vue create mode 100644 packages/client/src/ui/deck.vue create mode 100644 packages/client/src/ui/deck/antenna-column.vue create mode 100644 packages/client/src/ui/deck/column-core.vue create mode 100644 packages/client/src/ui/deck/column.vue create mode 100644 packages/client/src/ui/deck/deck-store.ts create mode 100644 packages/client/src/ui/deck/direct-column.vue create mode 100644 packages/client/src/ui/deck/list-column.vue create mode 100644 packages/client/src/ui/deck/main-column.vue create mode 100644 packages/client/src/ui/deck/mentions-column.vue create mode 100644 packages/client/src/ui/deck/notifications-column.vue create mode 100644 packages/client/src/ui/deck/tl-column.vue create mode 100644 packages/client/src/ui/deck/widgets-column.vue create mode 100644 packages/client/src/ui/desktop.vue create mode 100644 packages/client/src/ui/universal.vue create mode 100644 packages/client/src/ui/universal.widgets.vue create mode 100644 packages/client/src/ui/visitor.vue create mode 100644 packages/client/src/ui/visitor/a.vue create mode 100644 packages/client/src/ui/visitor/b.vue create mode 100644 packages/client/src/ui/visitor/header.vue create mode 100644 packages/client/src/ui/visitor/kanban.vue create mode 100644 packages/client/src/ui/zen.vue create mode 100644 packages/client/src/widgets/activity.calendar.vue create mode 100644 packages/client/src/widgets/activity.chart.vue create mode 100644 packages/client/src/widgets/activity.vue create mode 100644 packages/client/src/widgets/aichan.vue create mode 100644 packages/client/src/widgets/aiscript.vue create mode 100644 packages/client/src/widgets/button.vue create mode 100644 packages/client/src/widgets/calendar.vue create mode 100644 packages/client/src/widgets/clock.vue create mode 100644 packages/client/src/widgets/define.ts create mode 100644 packages/client/src/widgets/digital-clock.vue create mode 100644 packages/client/src/widgets/federation.vue create mode 100644 packages/client/src/widgets/index.ts create mode 100644 packages/client/src/widgets/job-queue.vue create mode 100644 packages/client/src/widgets/memo.vue create mode 100644 packages/client/src/widgets/notifications.vue create mode 100644 packages/client/src/widgets/online-users.vue create mode 100644 packages/client/src/widgets/photos.vue create mode 100644 packages/client/src/widgets/post-form.vue create mode 100644 packages/client/src/widgets/rss.vue create mode 100644 packages/client/src/widgets/server-metric/cpu-mem.vue create mode 100644 packages/client/src/widgets/server-metric/cpu.vue create mode 100644 packages/client/src/widgets/server-metric/disk.vue create mode 100644 packages/client/src/widgets/server-metric/index.vue create mode 100644 packages/client/src/widgets/server-metric/mem.vue create mode 100644 packages/client/src/widgets/server-metric/net.vue create mode 100644 packages/client/src/widgets/server-metric/pie.vue create mode 100644 packages/client/src/widgets/slideshow.vue create mode 100644 packages/client/src/widgets/timeline.vue create mode 100644 packages/client/src/widgets/trends.vue (limited to 'packages/client/src') diff --git a/packages/client/src/account.ts b/packages/client/src/account.ts new file mode 100644 index 0000000000..ef7eb8f60a --- /dev/null +++ b/packages/client/src/account.ts @@ -0,0 +1,211 @@ +import { del, get, set } from '@/scripts/idb-proxy'; +import { reactive } from 'vue'; +import { apiUrl } from '@/config'; +import { waiting, api, popup, popupMenu, success } from '@/os'; +import { unisonReload, reloadChannel } from '@/scripts/unison-reload'; +import { showSuspendedDialog } from './scripts/show-suspended-dialog'; +import { i18n } from './i18n'; + +// TODO: 他のタブと永続化されたstateを同期 + +type Account = { + id: string; + token: string; + isModerator: boolean; + isAdmin: boolean; + isDeleted: boolean; +}; + +const data = localStorage.getItem('account'); + +// TODO: 外部からはreadonlyに +export const $i = data ? reactive(JSON.parse(data) as Account) : null; + +export async function signout() { + waiting(); + localStorage.removeItem('account'); + + //#region Remove account + const accounts = await getAccounts(); + accounts.splice(accounts.findIndex(x => x.id === $i.id), 1); + + if (accounts.length > 0) await set('accounts', accounts); + else await del('accounts'); + //#endregion + + //#region Remove service worker registration + try { + if (navigator.serviceWorker.controller) { + const registration = await navigator.serviceWorker.ready; + const push = await registration.pushManager.getSubscription(); + if (push) { + await fetch(`${apiUrl}/sw/unregister`, { + method: 'POST', + body: JSON.stringify({ + i: $i.token, + endpoint: push.endpoint, + }), + }); + } + } + + if (accounts.length === 0) { + await navigator.serviceWorker.getRegistrations() + .then(registrations => { + return Promise.all(registrations.map(registration => registration.unregister())); + }); + } + } catch (e) {} + //#endregion + + document.cookie = `igi=; path=/`; + + if (accounts.length > 0) login(accounts[0].token); + else unisonReload('/'); +} + +export async function getAccounts(): Promise<{ id: Account['id'], token: Account['token'] }[]> { + return (await get('accounts')) || []; +} + +export async function addAccount(id: Account['id'], token: Account['token']) { + const accounts = await getAccounts(); + if (!accounts.some(x => x.id === id)) { + await set('accounts', accounts.concat([{ id, token }])); + } +} + +function fetchAccount(token): Promise { + return new Promise((done, fail) => { + // Fetch user + fetch(`${apiUrl}/i`, { + method: 'POST', + body: JSON.stringify({ + i: token + }) + }) + .then(res => res.json()) + .then(res => { + if (res.error) { + if (res.error.id === 'a8c724b3-6e9c-4b46-b1a8-bc3ed6258370') { + showSuspendedDialog().then(() => { + signout(); + }); + } else { + signout(); + } + } else { + res.token = token; + done(res); + } + }) + .catch(fail); + }); +} + +export function updateAccount(data) { + for (const [key, value] of Object.entries(data)) { + $i[key] = value; + } + localStorage.setItem('account', JSON.stringify($i)); +} + +export function refreshAccount() { + return fetchAccount($i.token).then(updateAccount); +} + +export async function login(token: Account['token'], redirect?: string) { + waiting(); + if (_DEV_) console.log('logging as token ', token); + const me = await fetchAccount(token); + localStorage.setItem('account', JSON.stringify(me)); + await addAccount(me.id, token); + + if (redirect) { + // 他のタブは再読み込みするだけ + reloadChannel.postMessage(null); + // このページはredirectで指定された先に移動 + location.href = redirect; + return; + } + + unisonReload(); +} + +export async function openAccountMenu(ev: MouseEvent) { + function showSigninDialog() { + popup(import('@/components/signin-dialog.vue'), {}, { + done: res => { + addAccount(res.id, res.i); + success(); + }, + }, 'closed'); + } + + function createAccount() { + popup(import('@/components/signup-dialog.vue'), {}, { + done: res => { + addAccount(res.id, res.i); + switchAccountWithToken(res.i); + }, + }, 'closed'); + } + + async function switchAccount(account: any) { + const storedAccounts = await getAccounts(); + const token = storedAccounts.find(x => x.id === account.id).token; + switchAccountWithToken(token); + } + + function switchAccountWithToken(token: string) { + login(token); + } + + const storedAccounts = await getAccounts().then(accounts => accounts.filter(x => x.id !== $i.id)); + const accountsPromise = api('users/show', { userIds: storedAccounts.map(x => x.id) }); + + const accountItemPromises = storedAccounts.map(a => new Promise(res => { + accountsPromise.then(accounts => { + const account = accounts.find(x => x.id === a.id); + if (account == null) return res(null); + res({ + type: 'user', + user: account, + action: () => { switchAccount(account); } + }); + }); + })); + + popupMenu([...[{ + type: 'link', + text: i18n.locale.profile, + to: `/@${ $i.username }`, + avatar: $i, + }, null, ...accountItemPromises, { + icon: 'fas fa-plus', + text: i18n.locale.addAccount, + action: () => { + popupMenu([{ + text: i18n.locale.existingAccount, + action: () => { showSigninDialog(); }, + }, { + text: i18n.locale.createAccount, + action: () => { createAccount(); }, + }], ev.currentTarget || ev.target); + }, + }, { + type: 'link', + icon: 'fas fa-users', + text: i18n.locale.manageAccounts, + to: `/settings/accounts`, + }]], ev.currentTarget || ev.target, { + align: 'left' + }); +} + +// このファイルに書きたくないけどここに書かないと何故かVeturが認識しない +declare module '@vue/runtime-core' { + interface ComponentCustomProperties { + $i: typeof $i; + } +} diff --git a/packages/client/src/components/abuse-report-window.vue b/packages/client/src/components/abuse-report-window.vue new file mode 100644 index 0000000000..700ce30bb2 --- /dev/null +++ b/packages/client/src/components/abuse-report-window.vue @@ -0,0 +1,79 @@ + + + + + diff --git a/packages/client/src/components/analog-clock.vue b/packages/client/src/components/analog-clock.vue new file mode 100644 index 0000000000..bc572e5fff --- /dev/null +++ b/packages/client/src/components/analog-clock.vue @@ -0,0 +1,150 @@ + + + + + diff --git a/packages/client/src/components/autocomplete.vue b/packages/client/src/components/autocomplete.vue new file mode 100644 index 0000000000..a7d2d507e0 --- /dev/null +++ b/packages/client/src/components/autocomplete.vue @@ -0,0 +1,501 @@ + + + + + diff --git a/packages/client/src/components/avatars.vue b/packages/client/src/components/avatars.vue new file mode 100644 index 0000000000..e843d26daa --- /dev/null +++ b/packages/client/src/components/avatars.vue @@ -0,0 +1,30 @@ + + + diff --git a/packages/client/src/components/captcha.vue b/packages/client/src/components/captcha.vue new file mode 100644 index 0000000000..baa922506e --- /dev/null +++ b/packages/client/src/components/captcha.vue @@ -0,0 +1,123 @@ + + + diff --git a/packages/client/src/components/channel-follow-button.vue b/packages/client/src/components/channel-follow-button.vue new file mode 100644 index 0000000000..9af65325bb --- /dev/null +++ b/packages/client/src/components/channel-follow-button.vue @@ -0,0 +1,140 @@ + + + + + diff --git a/packages/client/src/components/channel-preview.vue b/packages/client/src/components/channel-preview.vue new file mode 100644 index 0000000000..eb00052a78 --- /dev/null +++ b/packages/client/src/components/channel-preview.vue @@ -0,0 +1,165 @@ + + + + + diff --git a/packages/client/src/components/chart.vue b/packages/client/src/components/chart.vue new file mode 100644 index 0000000000..c4d0eb85dd --- /dev/null +++ b/packages/client/src/components/chart.vue @@ -0,0 +1,691 @@ + + + + + diff --git a/packages/client/src/components/code-core.vue b/packages/client/src/components/code-core.vue new file mode 100644 index 0000000000..9cff7b4448 --- /dev/null +++ b/packages/client/src/components/code-core.vue @@ -0,0 +1,35 @@ + + + diff --git a/packages/client/src/components/code.vue b/packages/client/src/components/code.vue new file mode 100644 index 0000000000..f5d6c5673a --- /dev/null +++ b/packages/client/src/components/code.vue @@ -0,0 +1,27 @@ + + + diff --git a/packages/client/src/components/cw-button.vue b/packages/client/src/components/cw-button.vue new file mode 100644 index 0000000000..4bec7b511e --- /dev/null +++ b/packages/client/src/components/cw-button.vue @@ -0,0 +1,70 @@ + + + + + diff --git a/packages/client/src/components/date-separated-list.vue b/packages/client/src/components/date-separated-list.vue new file mode 100644 index 0000000000..1aea9fd353 --- /dev/null +++ b/packages/client/src/components/date-separated-list.vue @@ -0,0 +1,188 @@ + + + diff --git a/packages/client/src/components/debobigego/base.vue b/packages/client/src/components/debobigego/base.vue new file mode 100644 index 0000000000..f551a3478b --- /dev/null +++ b/packages/client/src/components/debobigego/base.vue @@ -0,0 +1,65 @@ + + + + + diff --git a/packages/client/src/components/debobigego/button.vue b/packages/client/src/components/debobigego/button.vue new file mode 100644 index 0000000000..b883e817a4 --- /dev/null +++ b/packages/client/src/components/debobigego/button.vue @@ -0,0 +1,81 @@ + + + + + diff --git a/packages/client/src/components/debobigego/debobigego.scss b/packages/client/src/components/debobigego/debobigego.scss new file mode 100644 index 0000000000..833b656b66 --- /dev/null +++ b/packages/client/src/components/debobigego/debobigego.scss @@ -0,0 +1,52 @@ +._debobigegoPanel { + background: var(--panel); + border-radius: var(--radius); + transition: background 0.2s ease; + + &._debobigegoClickable { + &:hover { + //background: var(--panelHighlight); + } + + &:active { + background: var(--panelHighlight); + transition: background 0s; + } + } +} + +._debobigegoLabel, +._debobigegoCaption { + font-size: 80%; + color: var(--fgTransparentWeak); + + &:empty { + display: none; + } +} + +._debobigegoLabel { + position: sticky; + top: var(--stickyTop, 0px); + z-index: 2; + margin: -8px calc(var(--debobigegoXPadding) * -1) 0 calc(var(--debobigegoXPadding) * -1); + padding: 8px calc(var(--debobigegoContentHMargin) + var(--debobigegoXPadding)) 8px calc(var(--debobigegoContentHMargin) + var(--debobigegoXPadding)); + background: var(--X17); + -webkit-backdrop-filter: var(--blur, blur(10px)); + backdrop-filter: var(--blur, blur(10px)); +} + +._themeChanging_ ._debobigegoLabel { + transition: none !important; + background: transparent; +} + +._debobigegoCaption { + padding: 8px var(--debobigegoContentHMargin) 0 var(--debobigegoContentHMargin); +} + +._debobigegoItem { + & + ._debobigegoItem { + margin-top: 24px; + } +} diff --git a/packages/client/src/components/debobigego/group.vue b/packages/client/src/components/debobigego/group.vue new file mode 100644 index 0000000000..cba2c6ec94 --- /dev/null +++ b/packages/client/src/components/debobigego/group.vue @@ -0,0 +1,78 @@ + + + + + diff --git a/packages/client/src/components/debobigego/info.vue b/packages/client/src/components/debobigego/info.vue new file mode 100644 index 0000000000..41afb03304 --- /dev/null +++ b/packages/client/src/components/debobigego/info.vue @@ -0,0 +1,47 @@ + + + + + diff --git a/packages/client/src/components/debobigego/input.vue b/packages/client/src/components/debobigego/input.vue new file mode 100644 index 0000000000..d113f04d27 --- /dev/null +++ b/packages/client/src/components/debobigego/input.vue @@ -0,0 +1,292 @@ + + + + + diff --git a/packages/client/src/components/debobigego/key-value-view.vue b/packages/client/src/components/debobigego/key-value-view.vue new file mode 100644 index 0000000000..0e034a2d54 --- /dev/null +++ b/packages/client/src/components/debobigego/key-value-view.vue @@ -0,0 +1,38 @@ + + + + + diff --git a/packages/client/src/components/debobigego/link.vue b/packages/client/src/components/debobigego/link.vue new file mode 100644 index 0000000000..885579eadf --- /dev/null +++ b/packages/client/src/components/debobigego/link.vue @@ -0,0 +1,103 @@ + + + + + diff --git a/packages/client/src/components/debobigego/object-view.vue b/packages/client/src/components/debobigego/object-view.vue new file mode 100644 index 0000000000..ea79daa915 --- /dev/null +++ b/packages/client/src/components/debobigego/object-view.vue @@ -0,0 +1,102 @@ + + + + + diff --git a/packages/client/src/components/debobigego/pagination.vue b/packages/client/src/components/debobigego/pagination.vue new file mode 100644 index 0000000000..07012cb759 --- /dev/null +++ b/packages/client/src/components/debobigego/pagination.vue @@ -0,0 +1,42 @@ + + + + + diff --git a/packages/client/src/components/debobigego/radios.vue b/packages/client/src/components/debobigego/radios.vue new file mode 100644 index 0000000000..b4c5841337 --- /dev/null +++ b/packages/client/src/components/debobigego/radios.vue @@ -0,0 +1,112 @@ + + + diff --git a/packages/client/src/components/debobigego/range.vue b/packages/client/src/components/debobigego/range.vue new file mode 100644 index 0000000000..26fb0f37c6 --- /dev/null +++ b/packages/client/src/components/debobigego/range.vue @@ -0,0 +1,122 @@ + + + + + diff --git a/packages/client/src/components/debobigego/select.vue b/packages/client/src/components/debobigego/select.vue new file mode 100644 index 0000000000..7a31371afc --- /dev/null +++ b/packages/client/src/components/debobigego/select.vue @@ -0,0 +1,145 @@ + + + + + diff --git a/packages/client/src/components/debobigego/suspense.vue b/packages/client/src/components/debobigego/suspense.vue new file mode 100644 index 0000000000..b5ba63b4b5 --- /dev/null +++ b/packages/client/src/components/debobigego/suspense.vue @@ -0,0 +1,101 @@ + + + + + diff --git a/packages/client/src/components/debobigego/switch.vue b/packages/client/src/components/debobigego/switch.vue new file mode 100644 index 0000000000..9a69e18302 --- /dev/null +++ b/packages/client/src/components/debobigego/switch.vue @@ -0,0 +1,132 @@ + + + + + diff --git a/packages/client/src/components/debobigego/textarea.vue b/packages/client/src/components/debobigego/textarea.vue new file mode 100644 index 0000000000..64e8d47126 --- /dev/null +++ b/packages/client/src/components/debobigego/textarea.vue @@ -0,0 +1,161 @@ + + + + + diff --git a/packages/client/src/components/debobigego/tuple.vue b/packages/client/src/components/debobigego/tuple.vue new file mode 100644 index 0000000000..8a4599fd64 --- /dev/null +++ b/packages/client/src/components/debobigego/tuple.vue @@ -0,0 +1,36 @@ + + + + + diff --git a/packages/client/src/components/dialog.vue b/packages/client/src/components/dialog.vue new file mode 100644 index 0000000000..90086fd430 --- /dev/null +++ b/packages/client/src/components/dialog.vue @@ -0,0 +1,212 @@ + + + + + diff --git a/packages/client/src/components/drive-file-thumbnail.vue b/packages/client/src/components/drive-file-thumbnail.vue new file mode 100644 index 0000000000..9b6a0c9a0d --- /dev/null +++ b/packages/client/src/components/drive-file-thumbnail.vue @@ -0,0 +1,108 @@ + + + + + diff --git a/packages/client/src/components/drive-select-dialog.vue b/packages/client/src/components/drive-select-dialog.vue new file mode 100644 index 0000000000..f9a4025452 --- /dev/null +++ b/packages/client/src/components/drive-select-dialog.vue @@ -0,0 +1,70 @@ + + + diff --git a/packages/client/src/components/drive-window.vue b/packages/client/src/components/drive-window.vue new file mode 100644 index 0000000000..43f07ebe76 --- /dev/null +++ b/packages/client/src/components/drive-window.vue @@ -0,0 +1,44 @@ + + + diff --git a/packages/client/src/components/drive.file.vue b/packages/client/src/components/drive.file.vue new file mode 100644 index 0000000000..86f4ee0f8d --- /dev/null +++ b/packages/client/src/components/drive.file.vue @@ -0,0 +1,374 @@ + + + + + diff --git a/packages/client/src/components/drive.folder.vue b/packages/client/src/components/drive.folder.vue new file mode 100644 index 0000000000..91e27cc8a1 --- /dev/null +++ b/packages/client/src/components/drive.folder.vue @@ -0,0 +1,326 @@ + + + + + diff --git a/packages/client/src/components/drive.nav-folder.vue b/packages/client/src/components/drive.nav-folder.vue new file mode 100644 index 0000000000..4f0e6ce0e9 --- /dev/null +++ b/packages/client/src/components/drive.nav-folder.vue @@ -0,0 +1,135 @@ + + + + + diff --git a/packages/client/src/components/drive.vue b/packages/client/src/components/drive.vue new file mode 100644 index 0000000000..2b72a0a1c6 --- /dev/null +++ b/packages/client/src/components/drive.vue @@ -0,0 +1,784 @@ + + + + + diff --git a/packages/client/src/components/emoji-picker-dialog.vue b/packages/client/src/components/emoji-picker-dialog.vue new file mode 100644 index 0000000000..1d48bbb8a3 --- /dev/null +++ b/packages/client/src/components/emoji-picker-dialog.vue @@ -0,0 +1,76 @@ + + + + + diff --git a/packages/client/src/components/emoji-picker-window.vue b/packages/client/src/components/emoji-picker-window.vue new file mode 100644 index 0000000000..0ffa0c1187 --- /dev/null +++ b/packages/client/src/components/emoji-picker-window.vue @@ -0,0 +1,197 @@ + + + + + diff --git a/packages/client/src/components/emoji-picker.section.vue b/packages/client/src/components/emoji-picker.section.vue new file mode 100644 index 0000000000..2401eca2a5 --- /dev/null +++ b/packages/client/src/components/emoji-picker.section.vue @@ -0,0 +1,50 @@ + + + + + diff --git a/packages/client/src/components/emoji-picker.vue b/packages/client/src/components/emoji-picker.vue new file mode 100644 index 0000000000..015e201269 --- /dev/null +++ b/packages/client/src/components/emoji-picker.vue @@ -0,0 +1,501 @@ + + + + + diff --git a/packages/client/src/components/featured-photos.vue b/packages/client/src/components/featured-photos.vue new file mode 100644 index 0000000000..276344dfb4 --- /dev/null +++ b/packages/client/src/components/featured-photos.vue @@ -0,0 +1,32 @@ + + + + + diff --git a/packages/client/src/components/file-type-icon.vue b/packages/client/src/components/file-type-icon.vue new file mode 100644 index 0000000000..be1af5e501 --- /dev/null +++ b/packages/client/src/components/file-type-icon.vue @@ -0,0 +1,28 @@ + + + diff --git a/packages/client/src/components/follow-button.vue b/packages/client/src/components/follow-button.vue new file mode 100644 index 0000000000..a96899027f --- /dev/null +++ b/packages/client/src/components/follow-button.vue @@ -0,0 +1,210 @@ + + + + + diff --git a/packages/client/src/components/forgot-password.vue b/packages/client/src/components/forgot-password.vue new file mode 100644 index 0000000000..a42ea5864a --- /dev/null +++ b/packages/client/src/components/forgot-password.vue @@ -0,0 +1,84 @@ + + + + + diff --git a/packages/client/src/components/form-dialog.vue b/packages/client/src/components/form-dialog.vue new file mode 100644 index 0000000000..172e6a5138 --- /dev/null +++ b/packages/client/src/components/form-dialog.vue @@ -0,0 +1,125 @@ + + + + + diff --git a/packages/client/src/components/form/input.vue b/packages/client/src/components/form/input.vue new file mode 100644 index 0000000000..f2c1ead00c --- /dev/null +++ b/packages/client/src/components/form/input.vue @@ -0,0 +1,315 @@ + + + + + diff --git a/packages/client/src/components/form/radio.vue b/packages/client/src/components/form/radio.vue new file mode 100644 index 0000000000..0f31d8fa0a --- /dev/null +++ b/packages/client/src/components/form/radio.vue @@ -0,0 +1,122 @@ + + + + + diff --git a/packages/client/src/components/form/radios.vue b/packages/client/src/components/form/radios.vue new file mode 100644 index 0000000000..998a738202 --- /dev/null +++ b/packages/client/src/components/form/radios.vue @@ -0,0 +1,54 @@ + + + diff --git a/packages/client/src/components/form/range.vue b/packages/client/src/components/form/range.vue new file mode 100644 index 0000000000..4cfe66a8fc --- /dev/null +++ b/packages/client/src/components/form/range.vue @@ -0,0 +1,139 @@ + + + + + diff --git a/packages/client/src/components/form/section.vue b/packages/client/src/components/form/section.vue new file mode 100644 index 0000000000..8eac40a0db --- /dev/null +++ b/packages/client/src/components/form/section.vue @@ -0,0 +1,31 @@ + + + + + diff --git a/packages/client/src/components/form/select.vue b/packages/client/src/components/form/select.vue new file mode 100644 index 0000000000..f7eb5cd14d --- /dev/null +++ b/packages/client/src/components/form/select.vue @@ -0,0 +1,312 @@ + + + + + diff --git a/packages/client/src/components/form/slot.vue b/packages/client/src/components/form/slot.vue new file mode 100644 index 0000000000..8580c1307d --- /dev/null +++ b/packages/client/src/components/form/slot.vue @@ -0,0 +1,50 @@ + + + + + diff --git a/packages/client/src/components/form/switch.vue b/packages/client/src/components/form/switch.vue new file mode 100644 index 0000000000..85f8b7c870 --- /dev/null +++ b/packages/client/src/components/form/switch.vue @@ -0,0 +1,150 @@ + + + + + diff --git a/packages/client/src/components/form/textarea.vue b/packages/client/src/components/form/textarea.vue new file mode 100644 index 0000000000..fdb24f1e2b --- /dev/null +++ b/packages/client/src/components/form/textarea.vue @@ -0,0 +1,252 @@ + + + + + diff --git a/packages/client/src/components/formula-core.vue b/packages/client/src/components/formula-core.vue new file mode 100644 index 0000000000..cf8dee872b --- /dev/null +++ b/packages/client/src/components/formula-core.vue @@ -0,0 +1,34 @@ + + + + + + diff --git a/packages/client/src/components/formula.vue b/packages/client/src/components/formula.vue new file mode 100644 index 0000000000..fbb40bace7 --- /dev/null +++ b/packages/client/src/components/formula.vue @@ -0,0 +1,23 @@ + + + diff --git a/packages/client/src/components/gallery-post-preview.vue b/packages/client/src/components/gallery-post-preview.vue new file mode 100644 index 0000000000..8245902976 --- /dev/null +++ b/packages/client/src/components/gallery-post-preview.vue @@ -0,0 +1,126 @@ + + + + + diff --git a/packages/client/src/components/global/a.vue b/packages/client/src/components/global/a.vue new file mode 100644 index 0000000000..5db61203c6 --- /dev/null +++ b/packages/client/src/components/global/a.vue @@ -0,0 +1,138 @@ + + + diff --git a/packages/client/src/components/global/acct.vue b/packages/client/src/components/global/acct.vue new file mode 100644 index 0000000000..b0c41c99c0 --- /dev/null +++ b/packages/client/src/components/global/acct.vue @@ -0,0 +1,38 @@ + + + + + diff --git a/packages/client/src/components/global/ad.vue b/packages/client/src/components/global/ad.vue new file mode 100644 index 0000000000..71cb16740c --- /dev/null +++ b/packages/client/src/components/global/ad.vue @@ -0,0 +1,200 @@ + + + + + diff --git a/packages/client/src/components/global/avatar.vue b/packages/client/src/components/global/avatar.vue new file mode 100644 index 0000000000..e509e893da --- /dev/null +++ b/packages/client/src/components/global/avatar.vue @@ -0,0 +1,163 @@ + + + + + diff --git a/packages/client/src/components/global/ellipsis.vue b/packages/client/src/components/global/ellipsis.vue new file mode 100644 index 0000000000..0a46f486d6 --- /dev/null +++ b/packages/client/src/components/global/ellipsis.vue @@ -0,0 +1,34 @@ + + + diff --git a/packages/client/src/components/global/emoji.vue b/packages/client/src/components/global/emoji.vue new file mode 100644 index 0000000000..67a3dea2c5 --- /dev/null +++ b/packages/client/src/components/global/emoji.vue @@ -0,0 +1,125 @@ + + + + + diff --git a/packages/client/src/components/global/error.vue b/packages/client/src/components/global/error.vue new file mode 100644 index 0000000000..8ce5d16ac6 --- /dev/null +++ b/packages/client/src/components/global/error.vue @@ -0,0 +1,46 @@ + + + + + diff --git a/packages/client/src/components/global/header.vue b/packages/client/src/components/global/header.vue new file mode 100644 index 0000000000..7d5e426f2b --- /dev/null +++ b/packages/client/src/components/global/header.vue @@ -0,0 +1,360 @@ + + + + + diff --git a/packages/client/src/components/global/i18n.ts b/packages/client/src/components/global/i18n.ts new file mode 100644 index 0000000000..abf0c96856 --- /dev/null +++ b/packages/client/src/components/global/i18n.ts @@ -0,0 +1,42 @@ +import { h, defineComponent } from 'vue'; + +export default defineComponent({ + props: { + src: { + type: String, + required: true, + }, + tag: { + type: String, + required: false, + default: 'span', + }, + textTag: { + type: String, + required: false, + default: null, + }, + }, + render() { + let str = this.src; + const parsed = [] as (string | { arg: string; })[]; + while (true) { + const nextBracketOpen = str.indexOf('{'); + const nextBracketClose = str.indexOf('}'); + + if (nextBracketOpen === -1) { + parsed.push(str); + break; + } else { + if (nextBracketOpen > 0) parsed.push(str.substr(0, nextBracketOpen)); + parsed.push({ + arg: str.substring(nextBracketOpen + 1, nextBracketClose) + }); + } + + str = str.substr(nextBracketClose + 1); + } + + return h(this.tag, parsed.map(x => typeof x === 'string' ? (this.textTag ? h(this.textTag, x) : x) : this.$slots[x.arg]())); + } +}); diff --git a/packages/client/src/components/global/loading.vue b/packages/client/src/components/global/loading.vue new file mode 100644 index 0000000000..7bde53c12e --- /dev/null +++ b/packages/client/src/components/global/loading.vue @@ -0,0 +1,92 @@ + + + + + diff --git a/packages/client/src/components/global/misskey-flavored-markdown.vue b/packages/client/src/components/global/misskey-flavored-markdown.vue new file mode 100644 index 0000000000..ab20404909 --- /dev/null +++ b/packages/client/src/components/global/misskey-flavored-markdown.vue @@ -0,0 +1,157 @@ + + + + + + + diff --git a/packages/client/src/components/global/spacer.vue b/packages/client/src/components/global/spacer.vue new file mode 100644 index 0000000000..1129d54c71 --- /dev/null +++ b/packages/client/src/components/global/spacer.vue @@ -0,0 +1,76 @@ + + + + + diff --git a/packages/client/src/components/global/sticky-container.vue b/packages/client/src/components/global/sticky-container.vue new file mode 100644 index 0000000000..859b2c1d73 --- /dev/null +++ b/packages/client/src/components/global/sticky-container.vue @@ -0,0 +1,74 @@ + + + + + diff --git a/packages/client/src/components/global/time.vue b/packages/client/src/components/global/time.vue new file mode 100644 index 0000000000..6a330a2307 --- /dev/null +++ b/packages/client/src/components/global/time.vue @@ -0,0 +1,73 @@ + + + diff --git a/packages/client/src/components/global/url.vue b/packages/client/src/components/global/url.vue new file mode 100644 index 0000000000..092fe6620c --- /dev/null +++ b/packages/client/src/components/global/url.vue @@ -0,0 +1,142 @@ + + + + + diff --git a/packages/client/src/components/global/user-name.vue b/packages/client/src/components/global/user-name.vue new file mode 100644 index 0000000000..bc93a8ea30 --- /dev/null +++ b/packages/client/src/components/global/user-name.vue @@ -0,0 +1,20 @@ + + + diff --git a/packages/client/src/components/google.vue b/packages/client/src/components/google.vue new file mode 100644 index 0000000000..c48feffbf1 --- /dev/null +++ b/packages/client/src/components/google.vue @@ -0,0 +1,64 @@ + + + + + diff --git a/packages/client/src/components/image-viewer.vue b/packages/client/src/components/image-viewer.vue new file mode 100644 index 0000000000..fc28c30b56 --- /dev/null +++ b/packages/client/src/components/image-viewer.vue @@ -0,0 +1,85 @@ + + + + + diff --git a/packages/client/src/components/img-with-blurhash.vue b/packages/client/src/components/img-with-blurhash.vue new file mode 100644 index 0000000000..7e80b00208 --- /dev/null +++ b/packages/client/src/components/img-with-blurhash.vue @@ -0,0 +1,100 @@ + + + + + diff --git a/packages/client/src/components/index.ts b/packages/client/src/components/index.ts new file mode 100644 index 0000000000..2340b228f8 --- /dev/null +++ b/packages/client/src/components/index.ts @@ -0,0 +1,37 @@ +import { App } from 'vue'; + +import mfm from './global/misskey-flavored-markdown.vue'; +import a from './global/a.vue'; +import acct from './global/acct.vue'; +import avatar from './global/avatar.vue'; +import emoji from './global/emoji.vue'; +import userName from './global/user-name.vue'; +import ellipsis from './global/ellipsis.vue'; +import time from './global/time.vue'; +import url from './global/url.vue'; +import i18n from './global/i18n'; +import loading from './global/loading.vue'; +import error from './global/error.vue'; +import ad from './global/ad.vue'; +import header from './global/header.vue'; +import spacer from './global/spacer.vue'; +import stickyContainer from './global/sticky-container.vue'; + +export default function(app: App) { + app.component('I18n', i18n); + app.component('Mfm', mfm); + app.component('MkA', a); + app.component('MkAcct', acct); + app.component('MkAvatar', avatar); + app.component('MkEmoji', emoji); + app.component('MkUserName', userName); + app.component('MkEllipsis', ellipsis); + app.component('MkTime', time); + app.component('MkUrl', url); + app.component('MkLoading', loading); + app.component('MkError', error); + app.component('MkAd', ad); + app.component('MkHeader', header); + app.component('MkSpacer', spacer); + app.component('MkStickyContainer', stickyContainer); +} diff --git a/packages/client/src/components/instance-stats.vue b/packages/client/src/components/instance-stats.vue new file mode 100644 index 0000000000..bc62998a4a --- /dev/null +++ b/packages/client/src/components/instance-stats.vue @@ -0,0 +1,80 @@ + + + + + diff --git a/packages/client/src/components/instance-ticker.vue b/packages/client/src/components/instance-ticker.vue new file mode 100644 index 0000000000..1ce5a1c2c1 --- /dev/null +++ b/packages/client/src/components/instance-ticker.vue @@ -0,0 +1,62 @@ + + + + + diff --git a/packages/client/src/components/launch-pad.vue b/packages/client/src/components/launch-pad.vue new file mode 100644 index 0000000000..09f5f89f90 --- /dev/null +++ b/packages/client/src/components/launch-pad.vue @@ -0,0 +1,152 @@ + + + + + diff --git a/packages/client/src/components/link.vue b/packages/client/src/components/link.vue new file mode 100644 index 0000000000..a8e096e0a0 --- /dev/null +++ b/packages/client/src/components/link.vue @@ -0,0 +1,92 @@ + + + + + diff --git a/packages/client/src/components/media-banner.vue b/packages/client/src/components/media-banner.vue new file mode 100644 index 0000000000..2cf8c772e5 --- /dev/null +++ b/packages/client/src/components/media-banner.vue @@ -0,0 +1,107 @@ + + + + + diff --git a/packages/client/src/components/media-caption.vue b/packages/client/src/components/media-caption.vue new file mode 100644 index 0000000000..08a3ca2b4c --- /dev/null +++ b/packages/client/src/components/media-caption.vue @@ -0,0 +1,259 @@ + + + + + diff --git a/packages/client/src/components/media-image.vue b/packages/client/src/components/media-image.vue new file mode 100644 index 0000000000..8843b63207 --- /dev/null +++ b/packages/client/src/components/media-image.vue @@ -0,0 +1,155 @@ + + + + + diff --git a/packages/client/src/components/media-list.vue b/packages/client/src/components/media-list.vue new file mode 100644 index 0000000000..51eaa86f35 --- /dev/null +++ b/packages/client/src/components/media-list.vue @@ -0,0 +1,167 @@ + + + + + diff --git a/packages/client/src/components/media-video.vue b/packages/client/src/components/media-video.vue new file mode 100644 index 0000000000..aa885bd564 --- /dev/null +++ b/packages/client/src/components/media-video.vue @@ -0,0 +1,97 @@ + + + + + diff --git a/packages/client/src/components/mention.vue b/packages/client/src/components/mention.vue new file mode 100644 index 0000000000..a5be3fab22 --- /dev/null +++ b/packages/client/src/components/mention.vue @@ -0,0 +1,84 @@ + + + + + diff --git a/packages/client/src/components/mfm.ts b/packages/client/src/components/mfm.ts new file mode 100644 index 0000000000..d41cf6fc2b --- /dev/null +++ b/packages/client/src/components/mfm.ts @@ -0,0 +1,321 @@ +import { VNode, defineComponent, h } from 'vue'; +import * as mfm from 'mfm-js'; +import MkUrl from '@/components/global/url.vue'; +import MkLink from '@/components/link.vue'; +import MkMention from '@/components/mention.vue'; +import MkEmoji from '@/components/global/emoji.vue'; +import { concat } from '@/scripts/array'; +import MkFormula from '@/components/formula.vue'; +import MkCode from '@/components/code.vue'; +import MkGoogle from '@/components/google.vue'; +import MkSparkle from '@/components/sparkle.vue'; +import MkA from '@/components/global/a.vue'; +import { host } from '@/config'; +import { MFM_TAGS } from '@/scripts/mfm-tags'; + +export default defineComponent({ + props: { + text: { + type: String, + required: true + }, + plain: { + type: Boolean, + default: false + }, + nowrap: { + type: Boolean, + default: false + }, + author: { + type: Object, + default: null + }, + i: { + type: Object, + default: null + }, + customEmojis: { + required: false, + }, + isNote: { + type: Boolean, + default: true + }, + }, + + render() { + if (this.text == null || this.text == '') return; + + const ast = (this.plain ? mfm.parsePlain : mfm.parse)(this.text, { fnNameList: MFM_TAGS }); + + const validTime = (t: string | null | undefined) => { + if (t == null) return null; + return t.match(/^[0-9.]+s$/) ? t : null; + }; + + const genEl = (ast: mfm.MfmNode[]) => concat(ast.map((token): VNode[] => { + switch (token.type) { + case 'text': { + const text = token.props.text.replace(/(\r\n|\n|\r)/g, '\n'); + + if (!this.plain) { + const res = []; + for (const t of text.split('\n')) { + res.push(h('br')); + res.push(t); + } + res.shift(); + return res; + } else { + return [text.replace(/\n/g, ' ')]; + } + } + + case 'bold': { + return [h('b', genEl(token.children))]; + } + + case 'strike': { + return [h('del', genEl(token.children))]; + } + + case 'italic': { + return h('i', { + style: 'font-style: oblique;' + }, genEl(token.children)); + } + + case 'fn': { + // TODO: CSSを文字列で組み立てていくと token.props.args.~~~ 経由でCSSインジェクションできるのでよしなにやる + let style; + switch (token.props.name) { + case 'tada': { + style = `font-size: 150%;` + (this.$store.state.animatedMfm ? 'animation: tada 1s linear infinite both;' : ''); + break; + } + case 'jelly': { + const speed = validTime(token.props.args.speed) || '1s'; + style = (this.$store.state.animatedMfm ? `animation: mfm-rubberBand ${speed} linear infinite both;` : ''); + break; + } + case 'twitch': { + const speed = validTime(token.props.args.speed) || '0.5s'; + style = this.$store.state.animatedMfm ? `animation: mfm-twitch ${speed} ease infinite;` : ''; + break; + } + case 'shake': { + const speed = validTime(token.props.args.speed) || '0.5s'; + style = this.$store.state.animatedMfm ? `animation: mfm-shake ${speed} ease infinite;` : ''; + break; + } + case 'spin': { + const direction = + token.props.args.left ? 'reverse' : + token.props.args.alternate ? 'alternate' : + 'normal'; + const anime = + token.props.args.x ? 'mfm-spinX' : + token.props.args.y ? 'mfm-spinY' : + 'mfm-spin'; + const speed = validTime(token.props.args.speed) || '1.5s'; + style = this.$store.state.animatedMfm ? `animation: ${anime} ${speed} linear infinite; animation-direction: ${direction};` : ''; + break; + } + case 'jump': { + style = this.$store.state.animatedMfm ? 'animation: mfm-jump 0.75s linear infinite;' : ''; + break; + } + case 'bounce': { + style = this.$store.state.animatedMfm ? 'animation: mfm-bounce 0.75s linear infinite; transform-origin: center bottom;' : ''; + break; + } + case 'flip': { + const transform = + (token.props.args.h && token.props.args.v) ? 'scale(-1, -1)' : + token.props.args.v ? 'scaleY(-1)' : + 'scaleX(-1)'; + style = `transform: ${transform};`; + break; + } + case 'x2': { + style = `font-size: 200%;`; + break; + } + case 'x3': { + style = `font-size: 400%;`; + break; + } + case 'x4': { + style = `font-size: 600%;`; + break; + } + case 'font': { + const family = + token.props.args.serif ? 'serif' : + token.props.args.monospace ? 'monospace' : + token.props.args.cursive ? 'cursive' : + token.props.args.fantasy ? 'fantasy' : + token.props.args.emoji ? 'emoji' : + token.props.args.math ? 'math' : + null; + if (family) style = `font-family: ${family};`; + break; + } + case 'blur': { + return h('span', { + class: '_mfm_blur_', + }, genEl(token.children)); + } + case 'rainbow': { + style = this.$store.state.animatedMfm ? 'animation: mfm-rainbow 1s linear infinite;' : ''; + break; + } + case 'sparkle': { + if (!this.$store.state.animatedMfm) { + return genEl(token.children); + } + let count = token.props.args.count ? parseInt(token.props.args.count) : 10; + if (count > 100) { + count = 100; + } + const speed = token.props.args.speed ? parseFloat(token.props.args.speed) : 1; + return h(MkSparkle, { + count, speed, + }, genEl(token.children)); + } + } + if (style == null) { + return h('span', {}, ['$[', token.props.name, ' ', ...genEl(token.children), ']']); + } else { + return h('span', { + style: 'display: inline-block;' + style, + }, genEl(token.children)); + } + } + + case 'small': { + return [h('small', { + style: 'opacity: 0.7;' + }, genEl(token.children))]; + } + + case 'center': { + return [h('div', { + style: 'text-align:center;' + }, genEl(token.children))]; + } + + case 'url': { + return [h(MkUrl, { + key: Math.random(), + url: token.props.url, + rel: 'nofollow noopener', + })]; + } + + case 'link': { + return [h(MkLink, { + key: Math.random(), + url: token.props.url, + rel: 'nofollow noopener', + }, genEl(token.children))]; + } + + case 'mention': { + return [h(MkMention, { + key: Math.random(), + host: (token.props.host == null && this.author && this.author.host != null ? this.author.host : token.props.host) || host, + username: token.props.username + })]; + } + + case 'hashtag': { + return [h(MkA, { + key: Math.random(), + to: this.isNote ? `/tags/${encodeURIComponent(token.props.hashtag)}` : `/explore/tags/${encodeURIComponent(token.props.hashtag)}`, + style: 'color:var(--hashtag);' + }, `#${token.props.hashtag}`)]; + } + + case 'blockCode': { + return [h(MkCode, { + key: Math.random(), + code: token.props.code, + lang: token.props.lang, + })]; + } + + case 'inlineCode': { + return [h(MkCode, { + key: Math.random(), + code: token.props.code, + inline: true + })]; + } + + case 'quote': { + if (!this.nowrap) { + return [h('div', { + class: 'quote' + }, genEl(token.children))]; + } else { + return [h('span', { + class: 'quote' + }, genEl(token.children))]; + } + } + + case 'emojiCode': { + return [h(MkEmoji, { + key: Math.random(), + emoji: `:${token.props.name}:`, + customEmojis: this.customEmojis, + normal: this.plain + })]; + } + + case 'unicodeEmoji': { + return [h(MkEmoji, { + key: Math.random(), + emoji: token.props.emoji, + customEmojis: this.customEmojis, + normal: this.plain + })]; + } + + case 'mathInline': { + return [h(MkFormula, { + key: Math.random(), + formula: token.props.formula, + block: false + })]; + } + + case 'mathBlock': { + return [h(MkFormula, { + key: Math.random(), + formula: token.props.formula, + block: true + })]; + } + + case 'search': { + return [h(MkGoogle, { + key: Math.random(), + q: token.props.query + })]; + } + + default: { + console.error('unrecognized ast type:', token.type); + + return []; + } + } + })); + + // Parse ast to DOM + return h('span', genEl(ast)); + } +}); diff --git a/packages/client/src/components/mini-chart.vue b/packages/client/src/components/mini-chart.vue new file mode 100644 index 0000000000..2eb9ae8cbe --- /dev/null +++ b/packages/client/src/components/mini-chart.vue @@ -0,0 +1,90 @@ + + + diff --git a/packages/client/src/components/modal-page-window.vue b/packages/client/src/components/modal-page-window.vue new file mode 100644 index 0000000000..2086736683 --- /dev/null +++ b/packages/client/src/components/modal-page-window.vue @@ -0,0 +1,223 @@ + + + + + diff --git a/packages/client/src/components/note-detailed.vue b/packages/client/src/components/note-detailed.vue new file mode 100644 index 0000000000..8b6905a0e4 --- /dev/null +++ b/packages/client/src/components/note-detailed.vue @@ -0,0 +1,1229 @@ + + + + + diff --git a/packages/client/src/components/note-header.vue b/packages/client/src/components/note-header.vue new file mode 100644 index 0000000000..c61ec41dd1 --- /dev/null +++ b/packages/client/src/components/note-header.vue @@ -0,0 +1,115 @@ + + + + + diff --git a/packages/client/src/components/note-preview.vue b/packages/client/src/components/note-preview.vue new file mode 100644 index 0000000000..a474a01341 --- /dev/null +++ b/packages/client/src/components/note-preview.vue @@ -0,0 +1,98 @@ + + + + + diff --git a/packages/client/src/components/note-simple.vue b/packages/client/src/components/note-simple.vue new file mode 100644 index 0000000000..2f19bd6e0b --- /dev/null +++ b/packages/client/src/components/note-simple.vue @@ -0,0 +1,113 @@ + + + + + diff --git a/packages/client/src/components/note.sub.vue b/packages/client/src/components/note.sub.vue new file mode 100644 index 0000000000..45204854be --- /dev/null +++ b/packages/client/src/components/note.sub.vue @@ -0,0 +1,146 @@ + + + + + diff --git a/packages/client/src/components/note.vue b/packages/client/src/components/note.vue new file mode 100644 index 0000000000..b1ec674b67 --- /dev/null +++ b/packages/client/src/components/note.vue @@ -0,0 +1,1228 @@ + + + + + diff --git a/packages/client/src/components/notes.vue b/packages/client/src/components/notes.vue new file mode 100644 index 0000000000..1e7da7a2b0 --- /dev/null +++ b/packages/client/src/components/notes.vue @@ -0,0 +1,130 @@ + + + + + diff --git a/packages/client/src/components/notification-setting-window.vue b/packages/client/src/components/notification-setting-window.vue new file mode 100644 index 0000000000..ec1efec261 --- /dev/null +++ b/packages/client/src/components/notification-setting-window.vue @@ -0,0 +1,99 @@ + + + diff --git a/packages/client/src/components/notification.vue b/packages/client/src/components/notification.vue new file mode 100644 index 0000000000..b629820043 --- /dev/null +++ b/packages/client/src/components/notification.vue @@ -0,0 +1,362 @@ + + + + + diff --git a/packages/client/src/components/notifications.vue b/packages/client/src/components/notifications.vue new file mode 100644 index 0000000000..4ebb12c44b --- /dev/null +++ b/packages/client/src/components/notifications.vue @@ -0,0 +1,159 @@ + + + + + diff --git a/packages/client/src/components/number-diff.vue b/packages/client/src/components/number-diff.vue new file mode 100644 index 0000000000..9889c97ec3 --- /dev/null +++ b/packages/client/src/components/number-diff.vue @@ -0,0 +1,47 @@ + + + + + diff --git a/packages/client/src/components/page-preview.vue b/packages/client/src/components/page-preview.vue new file mode 100644 index 0000000000..05df1dc16e --- /dev/null +++ b/packages/client/src/components/page-preview.vue @@ -0,0 +1,162 @@ + + + + + diff --git a/packages/client/src/components/page-window.vue b/packages/client/src/components/page-window.vue new file mode 100644 index 0000000000..b6be114cd7 --- /dev/null +++ b/packages/client/src/components/page-window.vue @@ -0,0 +1,167 @@ + + + + + diff --git a/packages/client/src/components/page/page.block.vue b/packages/client/src/components/page/page.block.vue new file mode 100644 index 0000000000..54b8b30276 --- /dev/null +++ b/packages/client/src/components/page/page.block.vue @@ -0,0 +1,44 @@ + + + diff --git a/packages/client/src/components/page/page.button.vue b/packages/client/src/components/page/page.button.vue new file mode 100644 index 0000000000..51da84bd49 --- /dev/null +++ b/packages/client/src/components/page/page.button.vue @@ -0,0 +1,66 @@ + + + + + diff --git a/packages/client/src/components/page/page.canvas.vue b/packages/client/src/components/page/page.canvas.vue new file mode 100644 index 0000000000..8f49b88e5e --- /dev/null +++ b/packages/client/src/components/page/page.canvas.vue @@ -0,0 +1,49 @@ + + + + + diff --git a/packages/client/src/components/page/page.counter.vue b/packages/client/src/components/page/page.counter.vue new file mode 100644 index 0000000000..b1af8954b0 --- /dev/null +++ b/packages/client/src/components/page/page.counter.vue @@ -0,0 +1,52 @@ + + + + + diff --git a/packages/client/src/components/page/page.if.vue b/packages/client/src/components/page/page.if.vue new file mode 100644 index 0000000000..ec25332db0 --- /dev/null +++ b/packages/client/src/components/page/page.if.vue @@ -0,0 +1,31 @@ + + + diff --git a/packages/client/src/components/page/page.image.vue b/packages/client/src/components/page/page.image.vue new file mode 100644 index 0000000000..04ce74bd7c --- /dev/null +++ b/packages/client/src/components/page/page.image.vue @@ -0,0 +1,40 @@ + + + + + diff --git a/packages/client/src/components/page/page.note.vue b/packages/client/src/components/page/page.note.vue new file mode 100644 index 0000000000..925844c1bd --- /dev/null +++ b/packages/client/src/components/page/page.note.vue @@ -0,0 +1,47 @@ + + + + + diff --git a/packages/client/src/components/page/page.number-input.vue b/packages/client/src/components/page/page.number-input.vue new file mode 100644 index 0000000000..b5120d0f85 --- /dev/null +++ b/packages/client/src/components/page/page.number-input.vue @@ -0,0 +1,55 @@ + + + + + diff --git a/packages/client/src/components/page/page.post.vue b/packages/client/src/components/page/page.post.vue new file mode 100644 index 0000000000..1b86ea1ab9 --- /dev/null +++ b/packages/client/src/components/page/page.post.vue @@ -0,0 +1,109 @@ + + + + + diff --git a/packages/client/src/components/page/page.radio-button.vue b/packages/client/src/components/page/page.radio-button.vue new file mode 100644 index 0000000000..4d3c03291e --- /dev/null +++ b/packages/client/src/components/page/page.radio-button.vue @@ -0,0 +1,45 @@ + + + diff --git a/packages/client/src/components/page/page.section.vue b/packages/client/src/components/page/page.section.vue new file mode 100644 index 0000000000..d32f5dc732 --- /dev/null +++ b/packages/client/src/components/page/page.section.vue @@ -0,0 +1,60 @@ + + + + + diff --git a/packages/client/src/components/page/page.switch.vue b/packages/client/src/components/page/page.switch.vue new file mode 100644 index 0000000000..1ece88157f --- /dev/null +++ b/packages/client/src/components/page/page.switch.vue @@ -0,0 +1,55 @@ + + + + + diff --git a/packages/client/src/components/page/page.text-input.vue b/packages/client/src/components/page/page.text-input.vue new file mode 100644 index 0000000000..e4d3f6039a --- /dev/null +++ b/packages/client/src/components/page/page.text-input.vue @@ -0,0 +1,55 @@ + + + + + diff --git a/packages/client/src/components/page/page.text.vue b/packages/client/src/components/page/page.text.vue new file mode 100644 index 0000000000..7dd41ed869 --- /dev/null +++ b/packages/client/src/components/page/page.text.vue @@ -0,0 +1,68 @@ + + + + + diff --git a/packages/client/src/components/page/page.textarea-input.vue b/packages/client/src/components/page/page.textarea-input.vue new file mode 100644 index 0000000000..6e082b2bef --- /dev/null +++ b/packages/client/src/components/page/page.textarea-input.vue @@ -0,0 +1,47 @@ + + + diff --git a/packages/client/src/components/page/page.textarea.vue b/packages/client/src/components/page/page.textarea.vue new file mode 100644 index 0000000000..5b4ee2b452 --- /dev/null +++ b/packages/client/src/components/page/page.textarea.vue @@ -0,0 +1,39 @@ + + + diff --git a/packages/client/src/components/page/page.vue b/packages/client/src/components/page/page.vue new file mode 100644 index 0000000000..6d1c419a40 --- /dev/null +++ b/packages/client/src/components/page/page.vue @@ -0,0 +1,86 @@ + + + + + diff --git a/packages/client/src/components/particle.vue b/packages/client/src/components/particle.vue new file mode 100644 index 0000000000..d82705c1e8 --- /dev/null +++ b/packages/client/src/components/particle.vue @@ -0,0 +1,114 @@ + + + + + diff --git a/packages/client/src/components/poll-editor.vue b/packages/client/src/components/poll-editor.vue new file mode 100644 index 0000000000..aa213cfe49 --- /dev/null +++ b/packages/client/src/components/poll-editor.vue @@ -0,0 +1,251 @@ + + + + + diff --git a/packages/client/src/components/poll.vue b/packages/client/src/components/poll.vue new file mode 100644 index 0000000000..049fe3a435 --- /dev/null +++ b/packages/client/src/components/poll.vue @@ -0,0 +1,174 @@ + + + + + diff --git a/packages/client/src/components/post-form-attaches.vue b/packages/client/src/components/post-form-attaches.vue new file mode 100644 index 0000000000..dff0dec21e --- /dev/null +++ b/packages/client/src/components/post-form-attaches.vue @@ -0,0 +1,193 @@ + + + + + diff --git a/packages/client/src/components/post-form-dialog.vue b/packages/client/src/components/post-form-dialog.vue new file mode 100644 index 0000000000..ae1cd7f01e --- /dev/null +++ b/packages/client/src/components/post-form-dialog.vue @@ -0,0 +1,19 @@ + + + diff --git a/packages/client/src/components/post-form.vue b/packages/client/src/components/post-form.vue new file mode 100644 index 0000000000..ce6b7db3ee --- /dev/null +++ b/packages/client/src/components/post-form.vue @@ -0,0 +1,980 @@ + + + + + diff --git a/packages/client/src/pages/messaging/messaging-room.message.vue b/packages/client/src/pages/messaging/messaging-room.message.vue new file mode 100644 index 0000000000..432d11add8 --- /dev/null +++ b/packages/client/src/pages/messaging/messaging-room.message.vue @@ -0,0 +1,350 @@ + + + + + diff --git a/packages/client/src/pages/messaging/messaging-room.vue b/packages/client/src/pages/messaging/messaging-room.vue new file mode 100644 index 0000000000..3a19b12762 --- /dev/null +++ b/packages/client/src/pages/messaging/messaging-room.vue @@ -0,0 +1,470 @@ + + + + + diff --git a/packages/client/src/pages/mfm-cheat-sheet.vue b/packages/client/src/pages/mfm-cheat-sheet.vue new file mode 100644 index 0000000000..e9a3b6debc --- /dev/null +++ b/packages/client/src/pages/mfm-cheat-sheet.vue @@ -0,0 +1,365 @@ + + + + + diff --git a/packages/client/src/pages/miauth.vue b/packages/client/src/pages/miauth.vue new file mode 100644 index 0000000000..6430588c46 --- /dev/null +++ b/packages/client/src/pages/miauth.vue @@ -0,0 +1,100 @@ + + + + + diff --git a/packages/client/src/pages/my-antennas/create.vue b/packages/client/src/pages/my-antennas/create.vue new file mode 100644 index 0000000000..173807475a --- /dev/null +++ b/packages/client/src/pages/my-antennas/create.vue @@ -0,0 +1,51 @@ + + + + + diff --git a/packages/client/src/pages/my-antennas/edit.vue b/packages/client/src/pages/my-antennas/edit.vue new file mode 100644 index 0000000000..04928c81a3 --- /dev/null +++ b/packages/client/src/pages/my-antennas/edit.vue @@ -0,0 +1,56 @@ + + + + + diff --git a/packages/client/src/pages/my-antennas/editor.vue b/packages/client/src/pages/my-antennas/editor.vue new file mode 100644 index 0000000000..5ad3d50486 --- /dev/null +++ b/packages/client/src/pages/my-antennas/editor.vue @@ -0,0 +1,190 @@ + + + + + diff --git a/packages/client/src/pages/my-antennas/index.vue b/packages/client/src/pages/my-antennas/index.vue new file mode 100644 index 0000000000..029f1949d7 --- /dev/null +++ b/packages/client/src/pages/my-antennas/index.vue @@ -0,0 +1,71 @@ + + + + + diff --git a/packages/client/src/pages/my-clips/index.vue b/packages/client/src/pages/my-clips/index.vue new file mode 100644 index 0000000000..cbcdb85fa5 --- /dev/null +++ b/packages/client/src/pages/my-clips/index.vue @@ -0,0 +1,104 @@ + + + + + diff --git a/packages/client/src/pages/my-groups/group.vue b/packages/client/src/pages/my-groups/group.vue new file mode 100644 index 0000000000..9548c374d2 --- /dev/null +++ b/packages/client/src/pages/my-groups/group.vue @@ -0,0 +1,184 @@ + + + + + diff --git a/packages/client/src/pages/my-groups/index.vue b/packages/client/src/pages/my-groups/index.vue new file mode 100644 index 0000000000..77e7d6088e --- /dev/null +++ b/packages/client/src/pages/my-groups/index.vue @@ -0,0 +1,121 @@ + + + + + diff --git a/packages/client/src/pages/my-lists/index.vue b/packages/client/src/pages/my-lists/index.vue new file mode 100644 index 0000000000..adb59db665 --- /dev/null +++ b/packages/client/src/pages/my-lists/index.vue @@ -0,0 +1,88 @@ + + + + + diff --git a/packages/client/src/pages/my-lists/list.vue b/packages/client/src/pages/my-lists/list.vue new file mode 100644 index 0000000000..f2a02cadc9 --- /dev/null +++ b/packages/client/src/pages/my-lists/list.vue @@ -0,0 +1,170 @@ + + + + + diff --git a/packages/client/src/pages/not-found.vue b/packages/client/src/pages/not-found.vue new file mode 100644 index 0000000000..92d3f399f7 --- /dev/null +++ b/packages/client/src/pages/not-found.vue @@ -0,0 +1,25 @@ + + + diff --git a/packages/client/src/pages/note.vue b/packages/client/src/pages/note.vue new file mode 100644 index 0000000000..ecd391dfbf --- /dev/null +++ b/packages/client/src/pages/note.vue @@ -0,0 +1,209 @@ + + + + + diff --git a/packages/client/src/pages/notifications.vue b/packages/client/src/pages/notifications.vue new file mode 100644 index 0000000000..f8e610a719 --- /dev/null +++ b/packages/client/src/pages/notifications.vue @@ -0,0 +1,88 @@ + + + + + diff --git a/packages/client/src/pages/page-editor/els/page-editor.el.button.vue b/packages/client/src/pages/page-editor/els/page-editor.el.button.vue new file mode 100644 index 0000000000..a25a892eaa --- /dev/null +++ b/packages/client/src/pages/page-editor/els/page-editor.el.button.vue @@ -0,0 +1,84 @@ + + + + + diff --git a/packages/client/src/pages/page-editor/els/page-editor.el.canvas.vue b/packages/client/src/pages/page-editor/els/page-editor.el.canvas.vue new file mode 100644 index 0000000000..5d009561e2 --- /dev/null +++ b/packages/client/src/pages/page-editor/els/page-editor.el.canvas.vue @@ -0,0 +1,50 @@ + + + diff --git a/packages/client/src/pages/page-editor/els/page-editor.el.counter.vue b/packages/client/src/pages/page-editor/els/page-editor.el.counter.vue new file mode 100644 index 0000000000..3704c64250 --- /dev/null +++ b/packages/client/src/pages/page-editor/els/page-editor.el.counter.vue @@ -0,0 +1,46 @@ + + + diff --git a/packages/client/src/pages/page-editor/els/page-editor.el.if.vue b/packages/client/src/pages/page-editor/els/page-editor.el.if.vue new file mode 100644 index 0000000000..f76d59abe3 --- /dev/null +++ b/packages/client/src/pages/page-editor/els/page-editor.el.if.vue @@ -0,0 +1,84 @@ + + + + + diff --git a/packages/client/src/pages/page-editor/els/page-editor.el.image.vue b/packages/client/src/pages/page-editor/els/page-editor.el.image.vue new file mode 100644 index 0000000000..396c83f512 --- /dev/null +++ b/packages/client/src/pages/page-editor/els/page-editor.el.image.vue @@ -0,0 +1,72 @@ + + + + + diff --git a/packages/client/src/pages/page-editor/els/page-editor.el.note.vue b/packages/client/src/pages/page-editor/els/page-editor.el.note.vue new file mode 100644 index 0000000000..263b60d3e0 --- /dev/null +++ b/packages/client/src/pages/page-editor/els/page-editor.el.note.vue @@ -0,0 +1,65 @@ + + + diff --git a/packages/client/src/pages/page-editor/els/page-editor.el.number-input.vue b/packages/client/src/pages/page-editor/els/page-editor.el.number-input.vue new file mode 100644 index 0000000000..3a2f4a762b --- /dev/null +++ b/packages/client/src/pages/page-editor/els/page-editor.el.number-input.vue @@ -0,0 +1,46 @@ + + + diff --git a/packages/client/src/pages/page-editor/els/page-editor.el.post.vue b/packages/client/src/pages/page-editor/els/page-editor.el.post.vue new file mode 100644 index 0000000000..780786144e --- /dev/null +++ b/packages/client/src/pages/page-editor/els/page-editor.el.post.vue @@ -0,0 +1,43 @@ + + + diff --git a/packages/client/src/pages/page-editor/els/page-editor.el.radio-button.vue b/packages/client/src/pages/page-editor/els/page-editor.el.radio-button.vue new file mode 100644 index 0000000000..f01a47c54a --- /dev/null +++ b/packages/client/src/pages/page-editor/els/page-editor.el.radio-button.vue @@ -0,0 +1,50 @@ + + + diff --git a/packages/client/src/pages/page-editor/els/page-editor.el.section.vue b/packages/client/src/pages/page-editor/els/page-editor.el.section.vue new file mode 100644 index 0000000000..16e32d8400 --- /dev/null +++ b/packages/client/src/pages/page-editor/els/page-editor.el.section.vue @@ -0,0 +1,96 @@ + + + + + diff --git a/packages/client/src/pages/page-editor/els/page-editor.el.switch.vue b/packages/client/src/pages/page-editor/els/page-editor.el.switch.vue new file mode 100644 index 0000000000..e72f7b44d0 --- /dev/null +++ b/packages/client/src/pages/page-editor/els/page-editor.el.switch.vue @@ -0,0 +1,46 @@ + + + + + diff --git a/packages/client/src/pages/page-editor/els/page-editor.el.text-input.vue b/packages/client/src/pages/page-editor/els/page-editor.el.text-input.vue new file mode 100644 index 0000000000..908862cf07 --- /dev/null +++ b/packages/client/src/pages/page-editor/els/page-editor.el.text-input.vue @@ -0,0 +1,39 @@ + + + diff --git a/packages/client/src/pages/page-editor/els/page-editor.el.text.vue b/packages/client/src/pages/page-editor/els/page-editor.el.text.vue new file mode 100644 index 0000000000..05b1a9c67d --- /dev/null +++ b/packages/client/src/pages/page-editor/els/page-editor.el.text.vue @@ -0,0 +1,57 @@ + + + + + diff --git a/packages/client/src/pages/page-editor/els/page-editor.el.textarea-input.vue b/packages/client/src/pages/page-editor/els/page-editor.el.textarea-input.vue new file mode 100644 index 0000000000..bb37158ecb --- /dev/null +++ b/packages/client/src/pages/page-editor/els/page-editor.el.textarea-input.vue @@ -0,0 +1,40 @@ + + + diff --git a/packages/client/src/pages/page-editor/els/page-editor.el.textarea.vue b/packages/client/src/pages/page-editor/els/page-editor.el.textarea.vue new file mode 100644 index 0000000000..4ca83da17c --- /dev/null +++ b/packages/client/src/pages/page-editor/els/page-editor.el.textarea.vue @@ -0,0 +1,57 @@ + + + + + diff --git a/packages/client/src/pages/page-editor/page-editor.blocks.vue b/packages/client/src/pages/page-editor/page-editor.blocks.vue new file mode 100644 index 0000000000..b91d9abae8 --- /dev/null +++ b/packages/client/src/pages/page-editor/page-editor.blocks.vue @@ -0,0 +1,78 @@ + + + diff --git a/packages/client/src/pages/page-editor/page-editor.container.vue b/packages/client/src/pages/page-editor/page-editor.container.vue new file mode 100644 index 0000000000..afd261fac7 --- /dev/null +++ b/packages/client/src/pages/page-editor/page-editor.container.vue @@ -0,0 +1,159 @@ + + + + + diff --git a/packages/client/src/pages/page-editor/page-editor.script-block.vue b/packages/client/src/pages/page-editor/page-editor.script-block.vue new file mode 100644 index 0000000000..07958c902b --- /dev/null +++ b/packages/client/src/pages/page-editor/page-editor.script-block.vue @@ -0,0 +1,281 @@ + + + + + diff --git a/packages/client/src/pages/page-editor/page-editor.vue b/packages/client/src/pages/page-editor/page-editor.vue new file mode 100644 index 0000000000..684b1f8c75 --- /dev/null +++ b/packages/client/src/pages/page-editor/page-editor.vue @@ -0,0 +1,561 @@ + + + + + diff --git a/packages/client/src/pages/page.vue b/packages/client/src/pages/page.vue new file mode 100644 index 0000000000..1eff1a98cb --- /dev/null +++ b/packages/client/src/pages/page.vue @@ -0,0 +1,311 @@ + + + + + diff --git a/packages/client/src/pages/pages.vue b/packages/client/src/pages/pages.vue new file mode 100644 index 0000000000..d66fc2ad5b --- /dev/null +++ b/packages/client/src/pages/pages.vue @@ -0,0 +1,96 @@ + + + + + diff --git a/packages/client/src/pages/preview.vue b/packages/client/src/pages/preview.vue new file mode 100644 index 0000000000..9d1ebb74ed --- /dev/null +++ b/packages/client/src/pages/preview.vue @@ -0,0 +1,32 @@ + + + + + diff --git a/packages/client/src/pages/reset-password.vue b/packages/client/src/pages/reset-password.vue new file mode 100644 index 0000000000..f9a2500840 --- /dev/null +++ b/packages/client/src/pages/reset-password.vue @@ -0,0 +1,69 @@ + + + + + diff --git a/packages/client/src/pages/reversi/game.board.vue b/packages/client/src/pages/reversi/game.board.vue new file mode 100644 index 0000000000..529e00d969 --- /dev/null +++ b/packages/client/src/pages/reversi/game.board.vue @@ -0,0 +1,528 @@ + + + + + diff --git a/packages/client/src/pages/reversi/game.setting.vue b/packages/client/src/pages/reversi/game.setting.vue new file mode 100644 index 0000000000..e6a6661f16 --- /dev/null +++ b/packages/client/src/pages/reversi/game.setting.vue @@ -0,0 +1,390 @@ + + + + + diff --git a/packages/client/src/pages/reversi/game.vue b/packages/client/src/pages/reversi/game.vue new file mode 100644 index 0000000000..b1ed632904 --- /dev/null +++ b/packages/client/src/pages/reversi/game.vue @@ -0,0 +1,76 @@ + + + diff --git a/packages/client/src/pages/reversi/index.vue b/packages/client/src/pages/reversi/index.vue new file mode 100644 index 0000000000..1b8f1ffb71 --- /dev/null +++ b/packages/client/src/pages/reversi/index.vue @@ -0,0 +1,279 @@ + + + + + diff --git a/packages/client/src/pages/room/preview.vue b/packages/client/src/pages/room/preview.vue new file mode 100644 index 0000000000..b0e600d4fb --- /dev/null +++ b/packages/client/src/pages/room/preview.vue @@ -0,0 +1,107 @@ + + + diff --git a/packages/client/src/pages/room/room.vue b/packages/client/src/pages/room/room.vue new file mode 100644 index 0000000000..1671bcd587 --- /dev/null +++ b/packages/client/src/pages/room/room.vue @@ -0,0 +1,285 @@ + + + + + diff --git a/packages/client/src/pages/scratchpad.vue b/packages/client/src/pages/scratchpad.vue new file mode 100644 index 0000000000..c26658cbc4 --- /dev/null +++ b/packages/client/src/pages/scratchpad.vue @@ -0,0 +1,149 @@ + + + + + diff --git a/packages/client/src/pages/search.vue b/packages/client/src/pages/search.vue new file mode 100644 index 0000000000..c7da3fe1c1 --- /dev/null +++ b/packages/client/src/pages/search.vue @@ -0,0 +1,53 @@ + + + diff --git a/packages/client/src/pages/settings/2fa.vue b/packages/client/src/pages/settings/2fa.vue new file mode 100644 index 0000000000..dce217559a --- /dev/null +++ b/packages/client/src/pages/settings/2fa.vue @@ -0,0 +1,247 @@ + + + diff --git a/packages/client/src/pages/settings/account-info.vue b/packages/client/src/pages/settings/account-info.vue new file mode 100644 index 0000000000..f3d5e2f2c3 --- /dev/null +++ b/packages/client/src/pages/settings/account-info.vue @@ -0,0 +1,185 @@ + + + diff --git a/packages/client/src/pages/settings/accounts.vue b/packages/client/src/pages/settings/accounts.vue new file mode 100644 index 0000000000..94a3c9483d --- /dev/null +++ b/packages/client/src/pages/settings/accounts.vue @@ -0,0 +1,149 @@ + + + + + diff --git a/packages/client/src/pages/settings/api.vue b/packages/client/src/pages/settings/api.vue new file mode 100644 index 0000000000..1def0189ec --- /dev/null +++ b/packages/client/src/pages/settings/api.vue @@ -0,0 +1,65 @@ + + + diff --git a/packages/client/src/pages/settings/apps.vue b/packages/client/src/pages/settings/apps.vue new file mode 100644 index 0000000000..6eec80d805 --- /dev/null +++ b/packages/client/src/pages/settings/apps.vue @@ -0,0 +1,113 @@ + + + + + diff --git a/packages/client/src/pages/settings/custom-css.vue b/packages/client/src/pages/settings/custom-css.vue new file mode 100644 index 0000000000..8c878fb084 --- /dev/null +++ b/packages/client/src/pages/settings/custom-css.vue @@ -0,0 +1,73 @@ + + + diff --git a/packages/client/src/pages/settings/deck.vue b/packages/client/src/pages/settings/deck.vue new file mode 100644 index 0000000000..a96c6cd685 --- /dev/null +++ b/packages/client/src/pages/settings/deck.vue @@ -0,0 +1,107 @@ + + + diff --git a/packages/client/src/pages/settings/delete-account.vue b/packages/client/src/pages/settings/delete-account.vue new file mode 100644 index 0000000000..018f7c795e --- /dev/null +++ b/packages/client/src/pages/settings/delete-account.vue @@ -0,0 +1,68 @@ + + + diff --git a/packages/client/src/pages/settings/drive.vue b/packages/client/src/pages/settings/drive.vue new file mode 100644 index 0000000000..ed5282e23d --- /dev/null +++ b/packages/client/src/pages/settings/drive.vue @@ -0,0 +1,147 @@ + + + + + diff --git a/packages/client/src/pages/settings/email-address.vue b/packages/client/src/pages/settings/email-address.vue new file mode 100644 index 0000000000..476d0c0e17 --- /dev/null +++ b/packages/client/src/pages/settings/email-address.vue @@ -0,0 +1,70 @@ + + + diff --git a/packages/client/src/pages/settings/email-notification.vue b/packages/client/src/pages/settings/email-notification.vue new file mode 100644 index 0000000000..c1735a0728 --- /dev/null +++ b/packages/client/src/pages/settings/email-notification.vue @@ -0,0 +1,91 @@ + + + diff --git a/packages/client/src/pages/settings/email.vue b/packages/client/src/pages/settings/email.vue new file mode 100644 index 0000000000..d1dda20f00 --- /dev/null +++ b/packages/client/src/pages/settings/email.vue @@ -0,0 +1,66 @@ + + + diff --git a/packages/client/src/pages/settings/experimental-features.vue b/packages/client/src/pages/settings/experimental-features.vue new file mode 100644 index 0000000000..5a7bcb3b41 --- /dev/null +++ b/packages/client/src/pages/settings/experimental-features.vue @@ -0,0 +1,52 @@ + + + diff --git a/packages/client/src/pages/settings/general.vue b/packages/client/src/pages/settings/general.vue new file mode 100644 index 0000000000..8e3dcc3e41 --- /dev/null +++ b/packages/client/src/pages/settings/general.vue @@ -0,0 +1,223 @@ + + + diff --git a/packages/client/src/pages/settings/import-export.vue b/packages/client/src/pages/settings/import-export.vue new file mode 100644 index 0000000000..8923483b98 --- /dev/null +++ b/packages/client/src/pages/settings/import-export.vue @@ -0,0 +1,112 @@ + + + + + diff --git a/packages/client/src/pages/settings/index.vue b/packages/client/src/pages/settings/index.vue new file mode 100644 index 0000000000..b9d3903269 --- /dev/null +++ b/packages/client/src/pages/settings/index.vue @@ -0,0 +1,326 @@ + + + + + diff --git a/packages/client/src/pages/settings/integration.vue b/packages/client/src/pages/settings/integration.vue new file mode 100644 index 0000000000..405f93b779 --- /dev/null +++ b/packages/client/src/pages/settings/integration.vue @@ -0,0 +1,141 @@ + + + diff --git a/packages/client/src/pages/settings/menu.vue b/packages/client/src/pages/settings/menu.vue new file mode 100644 index 0000000000..e40740a3a4 --- /dev/null +++ b/packages/client/src/pages/settings/menu.vue @@ -0,0 +1,117 @@ + + + diff --git a/packages/client/src/pages/settings/mute-block.vue b/packages/client/src/pages/settings/mute-block.vue new file mode 100644 index 0000000000..4a9633a20d --- /dev/null +++ b/packages/client/src/pages/settings/mute-block.vue @@ -0,0 +1,85 @@ + + + diff --git a/packages/client/src/pages/settings/notifications.vue b/packages/client/src/pages/settings/notifications.vue new file mode 100644 index 0000000000..7de10a182c --- /dev/null +++ b/packages/client/src/pages/settings/notifications.vue @@ -0,0 +1,77 @@ + + + diff --git a/packages/client/src/pages/settings/other.vue b/packages/client/src/pages/settings/other.vue new file mode 100644 index 0000000000..fbc895a07d --- /dev/null +++ b/packages/client/src/pages/settings/other.vue @@ -0,0 +1,97 @@ + + + diff --git a/packages/client/src/pages/settings/plugin.install.vue b/packages/client/src/pages/settings/plugin.install.vue new file mode 100644 index 0000000000..9958f98f58 --- /dev/null +++ b/packages/client/src/pages/settings/plugin.install.vue @@ -0,0 +1,147 @@ + + + diff --git a/packages/client/src/pages/settings/plugin.manage.vue b/packages/client/src/pages/settings/plugin.manage.vue new file mode 100644 index 0000000000..3a0168d13d --- /dev/null +++ b/packages/client/src/pages/settings/plugin.manage.vue @@ -0,0 +1,115 @@ + + + + + diff --git a/packages/client/src/pages/settings/plugin.vue b/packages/client/src/pages/settings/plugin.vue new file mode 100644 index 0000000000..50e53f459f --- /dev/null +++ b/packages/client/src/pages/settings/plugin.vue @@ -0,0 +1,44 @@ + + + + + diff --git a/packages/client/src/pages/settings/privacy.vue b/packages/client/src/pages/settings/privacy.vue new file mode 100644 index 0000000000..94afba9aa4 --- /dev/null +++ b/packages/client/src/pages/settings/privacy.vue @@ -0,0 +1,120 @@ + + + diff --git a/packages/client/src/pages/settings/profile.vue b/packages/client/src/pages/settings/profile.vue new file mode 100644 index 0000000000..a7ddc6d178 --- /dev/null +++ b/packages/client/src/pages/settings/profile.vue @@ -0,0 +1,281 @@ + + + + + diff --git a/packages/client/src/pages/settings/reaction.vue b/packages/client/src/pages/settings/reaction.vue new file mode 100644 index 0000000000..905a3e4957 --- /dev/null +++ b/packages/client/src/pages/settings/reaction.vue @@ -0,0 +1,152 @@ + + + + + diff --git a/packages/client/src/pages/settings/registry.keys.vue b/packages/client/src/pages/settings/registry.keys.vue new file mode 100644 index 0000000000..ca4d01cc94 --- /dev/null +++ b/packages/client/src/pages/settings/registry.keys.vue @@ -0,0 +1,114 @@ + + + diff --git a/packages/client/src/pages/settings/registry.value.vue b/packages/client/src/pages/settings/registry.value.vue new file mode 100644 index 0000000000..36f989dbc5 --- /dev/null +++ b/packages/client/src/pages/settings/registry.value.vue @@ -0,0 +1,149 @@ + + + diff --git a/packages/client/src/pages/settings/registry.vue b/packages/client/src/pages/settings/registry.vue new file mode 100644 index 0000000000..0bfed0ddb7 --- /dev/null +++ b/packages/client/src/pages/settings/registry.vue @@ -0,0 +1,90 @@ + + + diff --git a/packages/client/src/pages/settings/security.vue b/packages/client/src/pages/settings/security.vue new file mode 100644 index 0000000000..4d81bf1b9e --- /dev/null +++ b/packages/client/src/pages/settings/security.vue @@ -0,0 +1,158 @@ + + + + + diff --git a/packages/client/src/pages/settings/sounds.vue b/packages/client/src/pages/settings/sounds.vue new file mode 100644 index 0000000000..ea3daced9d --- /dev/null +++ b/packages/client/src/pages/settings/sounds.vue @@ -0,0 +1,155 @@ + + + diff --git a/packages/client/src/pages/settings/theme.install.vue b/packages/client/src/pages/settings/theme.install.vue new file mode 100644 index 0000000000..59ad3ad9b7 --- /dev/null +++ b/packages/client/src/pages/settings/theme.install.vue @@ -0,0 +1,105 @@ + + + diff --git a/packages/client/src/pages/settings/theme.manage.vue b/packages/client/src/pages/settings/theme.manage.vue new file mode 100644 index 0000000000..8a24481ae2 --- /dev/null +++ b/packages/client/src/pages/settings/theme.manage.vue @@ -0,0 +1,105 @@ + + + diff --git a/packages/client/src/pages/settings/theme.vue b/packages/client/src/pages/settings/theme.vue new file mode 100644 index 0000000000..a9cca40f3c --- /dev/null +++ b/packages/client/src/pages/settings/theme.vue @@ -0,0 +1,424 @@ + + + + + diff --git a/packages/client/src/pages/settings/update.vue b/packages/client/src/pages/settings/update.vue new file mode 100644 index 0000000000..aa4050fe9f --- /dev/null +++ b/packages/client/src/pages/settings/update.vue @@ -0,0 +1,95 @@ + + + diff --git a/packages/client/src/pages/settings/word-mute.vue b/packages/client/src/pages/settings/word-mute.vue new file mode 100644 index 0000000000..c2162bb1f3 --- /dev/null +++ b/packages/client/src/pages/settings/word-mute.vue @@ -0,0 +1,110 @@ + + + diff --git a/packages/client/src/pages/share.vue b/packages/client/src/pages/share.vue new file mode 100644 index 0000000000..c0af44fdd1 --- /dev/null +++ b/packages/client/src/pages/share.vue @@ -0,0 +1,184 @@ + + + + + diff --git a/packages/client/src/pages/signup-complete.vue b/packages/client/src/pages/signup-complete.vue new file mode 100644 index 0000000000..3bbc9938dd --- /dev/null +++ b/packages/client/src/pages/signup-complete.vue @@ -0,0 +1,50 @@ + + + + + diff --git a/packages/client/src/pages/tag.vue b/packages/client/src/pages/tag.vue new file mode 100644 index 0000000000..f4709659e3 --- /dev/null +++ b/packages/client/src/pages/tag.vue @@ -0,0 +1,57 @@ + + + diff --git a/packages/client/src/pages/test.vue b/packages/client/src/pages/test.vue new file mode 100644 index 0000000000..9dd9ae5e0c --- /dev/null +++ b/packages/client/src/pages/test.vue @@ -0,0 +1,259 @@ + + + diff --git a/packages/client/src/pages/theme-editor.vue b/packages/client/src/pages/theme-editor.vue new file mode 100644 index 0000000000..d1a892629b --- /dev/null +++ b/packages/client/src/pages/theme-editor.vue @@ -0,0 +1,306 @@ + + + + + diff --git a/packages/client/src/pages/timeline.tutorial.vue b/packages/client/src/pages/timeline.tutorial.vue new file mode 100644 index 0000000000..4d6dd0af41 --- /dev/null +++ b/packages/client/src/pages/timeline.tutorial.vue @@ -0,0 +1,131 @@ + + + + + diff --git a/packages/client/src/pages/timeline.vue b/packages/client/src/pages/timeline.vue new file mode 100644 index 0000000000..911d6f5c6a --- /dev/null +++ b/packages/client/src/pages/timeline.vue @@ -0,0 +1,225 @@ + + + + + diff --git a/packages/client/src/pages/user-ap-info.vue b/packages/client/src/pages/user-ap-info.vue new file mode 100644 index 0000000000..6253faa242 --- /dev/null +++ b/packages/client/src/pages/user-ap-info.vue @@ -0,0 +1,124 @@ + + + diff --git a/packages/client/src/pages/user-info.vue b/packages/client/src/pages/user-info.vue new file mode 100644 index 0000000000..b77d879a7e --- /dev/null +++ b/packages/client/src/pages/user-info.vue @@ -0,0 +1,245 @@ + + + + + diff --git a/packages/client/src/pages/user-list-timeline.vue b/packages/client/src/pages/user-list-timeline.vue new file mode 100644 index 0000000000..2fc2476fba --- /dev/null +++ b/packages/client/src/pages/user-list-timeline.vue @@ -0,0 +1,147 @@ + + + + + diff --git a/packages/client/src/pages/user/clips.vue b/packages/client/src/pages/user/clips.vue new file mode 100644 index 0000000000..2ec96d2286 --- /dev/null +++ b/packages/client/src/pages/user/clips.vue @@ -0,0 +1,50 @@ + + + + + diff --git a/packages/client/src/pages/user/follow-list.vue b/packages/client/src/pages/user/follow-list.vue new file mode 100644 index 0000000000..fec4431419 --- /dev/null +++ b/packages/client/src/pages/user/follow-list.vue @@ -0,0 +1,65 @@ + + + + + diff --git a/packages/client/src/pages/user/gallery.vue b/packages/client/src/pages/user/gallery.vue new file mode 100644 index 0000000000..fb99cdff19 --- /dev/null +++ b/packages/client/src/pages/user/gallery.vue @@ -0,0 +1,56 @@ + + + + + diff --git a/packages/client/src/pages/user/index.activity.vue b/packages/client/src/pages/user/index.activity.vue new file mode 100644 index 0000000000..e51d6c6090 --- /dev/null +++ b/packages/client/src/pages/user/index.activity.vue @@ -0,0 +1,34 @@ + + + diff --git a/packages/client/src/pages/user/index.photos.vue b/packages/client/src/pages/user/index.photos.vue new file mode 100644 index 0000000000..4c52dceae6 --- /dev/null +++ b/packages/client/src/pages/user/index.photos.vue @@ -0,0 +1,107 @@ + + + + + diff --git a/packages/client/src/pages/user/index.timeline.vue b/packages/client/src/pages/user/index.timeline.vue new file mode 100644 index 0000000000..eff38ec3c8 --- /dev/null +++ b/packages/client/src/pages/user/index.timeline.vue @@ -0,0 +1,68 @@ + + + + + diff --git a/packages/client/src/pages/user/index.vue b/packages/client/src/pages/user/index.vue new file mode 100644 index 0000000000..d2531c0d1b --- /dev/null +++ b/packages/client/src/pages/user/index.vue @@ -0,0 +1,829 @@ + + + + + diff --git a/packages/client/src/pages/user/pages.vue b/packages/client/src/pages/user/pages.vue new file mode 100644 index 0000000000..0bf925d7d5 --- /dev/null +++ b/packages/client/src/pages/user/pages.vue @@ -0,0 +1,49 @@ + + + + + diff --git a/packages/client/src/pages/user/reactions.vue b/packages/client/src/pages/user/reactions.vue new file mode 100644 index 0000000000..3ca3b2aac8 --- /dev/null +++ b/packages/client/src/pages/user/reactions.vue @@ -0,0 +1,81 @@ + + + + + diff --git a/packages/client/src/pages/v.vue b/packages/client/src/pages/v.vue new file mode 100644 index 0000000000..3b1bb20861 --- /dev/null +++ b/packages/client/src/pages/v.vue @@ -0,0 +1,29 @@ + + + diff --git a/packages/client/src/pages/welcome.entrance.a.vue b/packages/client/src/pages/welcome.entrance.a.vue new file mode 100644 index 0000000000..2e0c520bc6 --- /dev/null +++ b/packages/client/src/pages/welcome.entrance.a.vue @@ -0,0 +1,320 @@ + + + + + diff --git a/packages/client/src/pages/welcome.entrance.b.vue b/packages/client/src/pages/welcome.entrance.b.vue new file mode 100644 index 0000000000..efb8b09360 --- /dev/null +++ b/packages/client/src/pages/welcome.entrance.b.vue @@ -0,0 +1,236 @@ + + + + + diff --git a/packages/client/src/pages/welcome.entrance.c.vue b/packages/client/src/pages/welcome.entrance.c.vue new file mode 100644 index 0000000000..2b0ff7a31c --- /dev/null +++ b/packages/client/src/pages/welcome.entrance.c.vue @@ -0,0 +1,305 @@ + + + + + diff --git a/packages/client/src/pages/welcome.setup.vue b/packages/client/src/pages/welcome.setup.vue new file mode 100644 index 0000000000..8c88720cf3 --- /dev/null +++ b/packages/client/src/pages/welcome.setup.vue @@ -0,0 +1,102 @@ + + + + + diff --git a/packages/client/src/pages/welcome.timeline.vue b/packages/client/src/pages/welcome.timeline.vue new file mode 100644 index 0000000000..46e3dbb5ed --- /dev/null +++ b/packages/client/src/pages/welcome.timeline.vue @@ -0,0 +1,99 @@ + + + + + diff --git a/packages/client/src/pages/welcome.vue b/packages/client/src/pages/welcome.vue new file mode 100644 index 0000000000..4c038b5113 --- /dev/null +++ b/packages/client/src/pages/welcome.vue @@ -0,0 +1,38 @@ + + + diff --git a/packages/client/src/pizzax.ts b/packages/client/src/pizzax.ts new file mode 100644 index 0000000000..396abc2418 --- /dev/null +++ b/packages/client/src/pizzax.ts @@ -0,0 +1,153 @@ +import { onUnmounted, Ref, ref, watch } from 'vue'; +import { $i } from './account'; +import { api } from './os'; + +type StateDef = Record; + +type ArrayElement = A extends readonly (infer T)[] ? T : never; + +export class Storage { + public readonly key: string; + public readonly keyForLocalStorage: string; + + public readonly def: T; + + // TODO: これが実装されたらreadonlyにしたい: https://github.com/microsoft/TypeScript/issues/37487 + public readonly state: { [K in keyof T]: T[K]['default'] }; + public readonly reactiveState: { [K in keyof T]: Ref }; + + constructor(key: string, def: T) { + this.key = key; + this.keyForLocalStorage = 'pizzax::' + key; + this.def = def; + + // TODO: indexedDBにする + const deviceState = JSON.parse(localStorage.getItem(this.keyForLocalStorage) || '{}'); + const deviceAccountState = $i ? JSON.parse(localStorage.getItem(this.keyForLocalStorage + '::' + $i.id) || '{}') : {}; + const registryCache = $i ? JSON.parse(localStorage.getItem(this.keyForLocalStorage + '::cache::' + $i.id) || '{}') : {}; + + const state = {}; + const reactiveState = {}; + for (const [k, v] of Object.entries(def)) { + if (v.where === 'device' && Object.prototype.hasOwnProperty.call(deviceState, k)) { + state[k] = deviceState[k]; + } else if (v.where === 'account' && $i && Object.prototype.hasOwnProperty.call(registryCache, k)) { + state[k] = registryCache[k]; + } else if (v.where === 'deviceAccount' && Object.prototype.hasOwnProperty.call(deviceAccountState, k)) { + state[k] = deviceAccountState[k]; + } else { + state[k] = v.default; + if (_DEV_) console.log('Use default value', k, v.default); + } + } + for (const [k, v] of Object.entries(state)) { + reactiveState[k] = ref(v); + } + this.state = state as any; + this.reactiveState = reactiveState as any; + + if ($i) { + // なぜかsetTimeoutしないとapi関数内でエラーになる(おそらく循環参照してることに原因がありそう) + setTimeout(() => { + api('i/registry/get-all', { scope: ['client', this.key] }).then(kvs => { + const cache = {}; + for (const [k, v] of Object.entries(def)) { + if (v.where === 'account') { + if (Object.prototype.hasOwnProperty.call(kvs, k)) { + state[k] = kvs[k]; + reactiveState[k].value = kvs[k]; + cache[k] = kvs[k]; + } else { + state[k] = v.default; + reactiveState[k].value = v.default; + } + } + } + localStorage.setItem(this.keyForLocalStorage + '::cache::' + $i.id, JSON.stringify(cache)); + }); + }, 1); + + // TODO: streamingのuser storage updateイベントを監視して更新 + } + } + + public set(key: K, value: T[K]['default']): void { + if (_DEV_) console.log('set', key, value); + + this.state[key] = value; + this.reactiveState[key].value = value; + + switch (this.def[key].where) { + case 'device': { + const deviceState = JSON.parse(localStorage.getItem(this.keyForLocalStorage) || '{}'); + deviceState[key] = value; + localStorage.setItem(this.keyForLocalStorage, JSON.stringify(deviceState)); + break; + } + case 'deviceAccount': { + if ($i == null) break; + const deviceAccountState = JSON.parse(localStorage.getItem(this.keyForLocalStorage + '::' + $i.id) || '{}'); + deviceAccountState[key] = value; + localStorage.setItem(this.keyForLocalStorage + '::' + $i.id, JSON.stringify(deviceAccountState)); + break; + } + case 'account': { + if ($i == null) break; + const cache = JSON.parse(localStorage.getItem(this.keyForLocalStorage + '::cache::' + $i.id) || '{}'); + cache[key] = value; + localStorage.setItem(this.keyForLocalStorage + '::cache::' + $i.id, JSON.stringify(cache)); + api('i/registry/set', { + scope: ['client', this.key], + key: key, + value: value + }); + break; + } + } + } + + public push(key: K, value: ArrayElement): void { + const currentState = this.state[key]; + this.set(key, [...currentState, value]); + } + + public reset(key: keyof T) { + this.set(key, this.def[key].default); + } + + /** + * 特定のキーの、簡易的なgetter/setterを作ります + * 主にvue場で設定コントロールのmodelとして使う用 + */ + public makeGetterSetter(key: K, getter?: (v: T[K]) => unknown, setter?: (v: unknown) => T[K]) { + const valueRef = ref(this.state[key]); + + const stop = watch(this.reactiveState[key], val => { + valueRef.value = val; + }); + + // NOTE: vueコンポーネント内で呼ばれない限りは、onUnmounted は無意味なのでメモリリークする + onUnmounted(() => { + stop(); + }); + + // TODO: VueのcustomRef使うと良い感じになるかも + return { + get: () => { + if (getter) { + return getter(valueRef.value); + } else { + return valueRef.value; + } + }, + set: (value: unknown) => { + const val = setter ? setter(value) : value; + this.set(key, val); + valueRef.value = val; + } + }; + } +} diff --git a/packages/client/src/plugin.ts b/packages/client/src/plugin.ts new file mode 100644 index 0000000000..c56ee1eb25 --- /dev/null +++ b/packages/client/src/plugin.ts @@ -0,0 +1,124 @@ +import { AiScript, utils, values } from '@syuilo/aiscript'; +import { deserialize } from '@syuilo/aiscript/built/serializer'; +import { jsToVal } from '@syuilo/aiscript/built/interpreter/util'; +import { createAiScriptEnv } from '@/scripts/aiscript/api'; +import { dialog } from '@/os'; +import { noteActions, notePostInterruptors, noteViewInterruptors, postFormActions, userActions } from '@/store'; + +const pluginContexts = new Map(); + +export function install(plugin) { + console.info('Plugin installed:', plugin.name, 'v' + plugin.version); + + const aiscript = new AiScript(createPluginEnv({ + plugin: plugin, + storageKey: 'plugins:' + plugin.id + }), { + in: (q) => { + return new Promise(ok => { + dialog({ + title: q, + input: {} + }).then(({ canceled, result: a }) => { + ok(a); + }); + }); + }, + out: (value) => { + console.log(value); + }, + log: (type, params) => { + }, + }); + + initPlugin({ plugin, aiscript }); + + aiscript.exec(deserialize(plugin.ast)); +} + +function createPluginEnv(opts) { + const config = new Map(); + for (const [k, v] of Object.entries(opts.plugin.config || {})) { + config.set(k, jsToVal(opts.plugin.configData.hasOwnProperty(k) ? opts.plugin.configData[k] : v.default)); + } + + return { + ...createAiScriptEnv({ ...opts, token: opts.plugin.token }), + //#region Deprecated + 'Mk:register_post_form_action': values.FN_NATIVE(([title, handler]) => { + registerPostFormAction({ pluginId: opts.plugin.id, title: title.value, handler }); + }), + 'Mk:register_user_action': values.FN_NATIVE(([title, handler]) => { + registerUserAction({ pluginId: opts.plugin.id, title: title.value, handler }); + }), + 'Mk:register_note_action': values.FN_NATIVE(([title, handler]) => { + registerNoteAction({ pluginId: opts.plugin.id, title: title.value, handler }); + }), + //#endregion + 'Plugin:register_post_form_action': values.FN_NATIVE(([title, handler]) => { + registerPostFormAction({ pluginId: opts.plugin.id, title: title.value, handler }); + }), + 'Plugin:register_user_action': values.FN_NATIVE(([title, handler]) => { + registerUserAction({ pluginId: opts.plugin.id, title: title.value, handler }); + }), + 'Plugin:register_note_action': values.FN_NATIVE(([title, handler]) => { + registerNoteAction({ pluginId: opts.plugin.id, title: title.value, handler }); + }), + 'Plugin:register_note_view_interruptor': values.FN_NATIVE(([handler]) => { + registerNoteViewInterruptor({ pluginId: opts.plugin.id, handler }); + }), + 'Plugin:register_note_post_interruptor': values.FN_NATIVE(([handler]) => { + registerNotePostInterruptor({ pluginId: opts.plugin.id, handler }); + }), + 'Plugin:open_url': values.FN_NATIVE(([url]) => { + window.open(url.value, '_blank'); + }), + 'Plugin:config': values.OBJ(config), + }; +} + +function initPlugin({ plugin, aiscript }) { + pluginContexts.set(plugin.id, aiscript); +} + +function registerPostFormAction({ pluginId, title, handler }) { + postFormActions.push({ + title, handler: (form, update) => { + pluginContexts.get(pluginId).execFn(handler, [utils.jsToVal(form), values.FN_NATIVE(([key, value]) => { + update(key.value, value.value); + })]); + } + }); +} + +function registerUserAction({ pluginId, title, handler }) { + userActions.push({ + title, handler: (user) => { + pluginContexts.get(pluginId).execFn(handler, [utils.jsToVal(user)]); + } + }); +} + +function registerNoteAction({ pluginId, title, handler }) { + noteActions.push({ + title, handler: (note) => { + pluginContexts.get(pluginId).execFn(handler, [utils.jsToVal(note)]); + } + }); +} + +function registerNoteViewInterruptor({ pluginId, handler }) { + noteViewInterruptors.push({ + handler: async (note) => { + return utils.valToJs(await pluginContexts.get(pluginId).execFn(handler, [utils.jsToVal(note)])); + } + }); +} + +function registerNotePostInterruptor({ pluginId, handler }) { + notePostInterruptors.push({ + handler: async (note) => { + return utils.valToJs(await pluginContexts.get(pluginId).execFn(handler, [utils.jsToVal(note)])); + } + }); +} diff --git a/packages/client/src/router.ts b/packages/client/src/router.ts new file mode 100644 index 0000000000..9b4dd162f3 --- /dev/null +++ b/packages/client/src/router.ts @@ -0,0 +1,149 @@ +import { defineAsyncComponent, markRaw } from 'vue'; +import { createRouter, createWebHistory } from 'vue-router'; +import MkLoading from '@/pages/_loading_.vue'; +import MkError from '@/pages/_error_.vue'; +import MkTimeline from '@/pages/timeline.vue'; +import { $i } from './account'; +import { ui } from '@/config'; + +const page = (path: string, ui?: string) => defineAsyncComponent({ + loader: ui ? () => import(`./ui/${ui}/pages/${path}.vue`) : () => import(`./pages/${path}.vue`), + loadingComponent: MkLoading, + errorComponent: MkError, +}); + +let indexScrollPos = 0; + +const defaultRoutes = [ + // NOTE: MkTimelineをdynamic importするとAsyncComponentWrapperが間に入るせいでkeep-aliveのコンポーネント指定が効かなくなる + { path: '/', name: 'index', component: $i ? MkTimeline : page('welcome') }, + { path: '/@:acct/:page?', name: 'user', component: page('user/index'), props: route => ({ acct: route.params.acct, page: route.params.page || 'index' }) }, + { path: '/@:user/pages/:page', component: page('page'), props: route => ({ pageName: route.params.page, username: route.params.user }) }, + { path: '/@:user/pages/:pageName/view-source', component: page('page-editor/page-editor'), props: route => ({ initUser: route.params.user, initPageName: route.params.pageName }) }, + { path: '/@:acct/room', props: true, component: page('room/room') }, + { path: '/settings/:page(.*)?', name: 'settings', component: page('settings/index'), props: route => ({ initialPage: route.params.page || null }) }, + { path: '/reset-password/:token?', component: page('reset-password'), props: route => ({ token: route.params.token }) }, + { path: '/signup-complete/:code', component: page('signup-complete'), props: route => ({ code: route.params.code }) }, + { path: '/announcements', component: page('announcements') }, + { path: '/about', component: page('about') }, + { path: '/about-misskey', component: page('about-misskey') }, + { path: '/featured', component: page('featured') }, + { path: '/theme-editor', component: page('theme-editor') }, + { path: '/advanced-theme-editor', component: page('advanced-theme-editor') }, + { path: '/explore', component: page('explore') }, + { path: '/explore/tags/:tag', props: true, component: page('explore') }, + { path: '/federation', component: page('federation') }, + { path: '/emojis', component: page('emojis') }, + { path: '/search', component: page('search') }, + { path: '/pages', name: 'pages', component: page('pages') }, + { path: '/pages/new', component: page('page-editor/page-editor') }, + { path: '/pages/edit/:pageId', component: page('page-editor/page-editor'), props: route => ({ initPageId: route.params.pageId }) }, + { path: '/gallery', component: page('gallery/index') }, + { path: '/gallery/new', component: page('gallery/edit') }, + { path: '/gallery/:postId/edit', component: page('gallery/edit'), props: route => ({ postId: route.params.postId }) }, + { path: '/gallery/:postId', component: page('gallery/post'), props: route => ({ postId: route.params.postId }) }, + { path: '/channels', component: page('channels') }, + { path: '/channels/new', component: page('channel-editor') }, + { path: '/channels/:channelId/edit', component: page('channel-editor'), props: true }, + { path: '/channels/:channelId', component: page('channel'), props: route => ({ channelId: route.params.channelId }) }, + { path: '/clips/:clipId', component: page('clip'), props: route => ({ clipId: route.params.clipId }) }, + { path: '/timeline/list/:listId', component: page('user-list-timeline'), props: route => ({ listId: route.params.listId }) }, + { path: '/timeline/antenna/:antennaId', component: page('antenna-timeline'), props: route => ({ antennaId: route.params.antennaId }) }, + { path: '/my/notifications', component: page('notifications') }, + { path: '/my/favorites', component: page('favorites') }, + { path: '/my/messages', component: page('messages') }, + { path: '/my/mentions', component: page('mentions') }, + { path: '/my/messaging', name: 'messaging', component: page('messaging/index') }, + { path: '/my/messaging/:user', component: page('messaging/messaging-room'), props: route => ({ userAcct: route.params.user }) }, + { path: '/my/messaging/group/:group', component: page('messaging/messaging-room'), props: route => ({ groupId: route.params.group }) }, + { path: '/my/drive', name: 'drive', component: page('drive') }, + { path: '/my/drive/folder/:folder', component: page('drive') }, + { path: '/my/follow-requests', component: page('follow-requests') }, + { path: '/my/lists', component: page('my-lists/index') }, + { path: '/my/lists/:list', component: page('my-lists/list') }, + { path: '/my/groups', component: page('my-groups/index') }, + { path: '/my/groups/:group', component: page('my-groups/group'), props: route => ({ groupId: route.params.group }) }, + { path: '/my/antennas', component: page('my-antennas/index') }, + { path: '/my/antennas/create', component: page('my-antennas/create') }, + { path: '/my/antennas/:antennaId', component: page('my-antennas/edit'), props: true }, + { path: '/my/clips', component: page('my-clips/index') }, + { path: '/scratchpad', component: page('scratchpad') }, + { path: '/admin/:page(.*)?', component: page('admin/index'), props: route => ({ initialPage: route.params.page || null }) }, + { path: '/admin', component: page('admin/index') }, + { path: '/notes/:note', name: 'note', component: page('note'), props: route => ({ noteId: route.params.note }) }, + { path: '/tags/:tag', component: page('tag'), props: route => ({ tag: route.params.tag }) }, + { path: '/user-info/:user', component: page('user-info'), props: route => ({ userId: route.params.user }) }, + { path: '/user-ap-info/:user', component: page('user-ap-info'), props: route => ({ userId: route.params.user }) }, + { path: '/instance-info/:host', component: page('instance-info'), props: route => ({ host: route.params.host }) }, + { path: '/games/reversi', component: page('reversi/index') }, + { path: '/games/reversi/:gameId', component: page('reversi/game'), props: route => ({ gameId: route.params.gameId }) }, + { path: '/mfm-cheat-sheet', component: page('mfm-cheat-sheet') }, + { path: '/api-console', component: page('api-console') }, + { path: '/preview', component: page('preview') }, + { path: '/test', component: page('test') }, + { path: '/auth/:token', component: page('auth') }, + { path: '/miauth/:session', component: page('miauth') }, + { path: '/authorize-follow', component: page('follow') }, + { path: '/share', component: page('share') }, + { path: '/:catchAll(.*)', component: page('not-found') } +]; + +const chatRoutes = [ + { path: '/timeline', component: page('timeline', 'chat'), props: route => ({ src: 'home' }) }, + { path: '/timeline/home', component: page('timeline', 'chat'), props: route => ({ src: 'home' }) }, + { path: '/timeline/local', component: page('timeline', 'chat'), props: route => ({ src: 'local' }) }, + { path: '/timeline/social', component: page('timeline', 'chat'), props: route => ({ src: 'social' }) }, + { path: '/timeline/global', component: page('timeline', 'chat'), props: route => ({ src: 'global' }) }, + { path: '/channels/:channelId', component: page('channel', 'chat'), props: route => ({ channelId: route.params.channelId }) }, +]; + +function margeRoutes(routes: any[]) { + const result = defaultRoutes; + for (const route of routes) { + const found = result.findIndex(x => x.path === route.path); + if (found > -1) { + result[found] = route; + } else { + result.unshift(route); + } + } + return result; +} + +export const router = createRouter({ + history: createWebHistory(), + routes: margeRoutes(ui === 'chat' ? chatRoutes : []), + // なんかHacky + // 通常の使い方をすると scroll メソッドの behavior を設定できないため、自前で window.scroll するようにする + scrollBehavior(to) { + window._scroll = () => { // さらにHacky + if (to.name === 'index') { + window.scroll({ top: indexScrollPos, behavior: 'instant' }); + const i = setInterval(() => { + window.scroll({ top: indexScrollPos, behavior: 'instant' }); + }, 10); + setTimeout(() => { + clearInterval(i); + }, 500); + } else { + window.scroll({ top: 0, behavior: 'instant' }); + } + }; + } +}); + +router.afterEach((to, from) => { + if (from.name === 'index') { + indexScrollPos = window.scrollY; + } +}); + +export function resolve(path: string) { + const resolved = router.resolve(path); + const route = resolved.matched[0]; + return { + component: markRaw(route.components.default), + // TODO: route.propsには関数以外も入る可能性があるのでよしなにハンドリングする + props: route.props?.default ? route.props.default(resolved) : resolved.params + }; +} diff --git a/packages/client/src/scripts/2fa.ts b/packages/client/src/scripts/2fa.ts new file mode 100644 index 0000000000..00363cffa6 --- /dev/null +++ b/packages/client/src/scripts/2fa.ts @@ -0,0 +1,33 @@ +export function byteify(data: string, encoding: 'ascii' | 'base64' | 'hex') { + switch (encoding) { + case 'ascii': + return Uint8Array.from(data, c => c.charCodeAt(0)); + case 'base64': + return Uint8Array.from( + atob( + data + .replace(/-/g, '+') + .replace(/_/g, '/') + ), + c => c.charCodeAt(0) + ); + case 'hex': + return new Uint8Array( + data + .match(/.{1,2}/g) + .map(byte => parseInt(byte, 16)) + ); + } +} + +export function hexify(buffer: ArrayBuffer) { + return Array.from(new Uint8Array(buffer)) + .reduce( + (str, byte) => str + byte.toString(16).padStart(2, '0'), + '' + ); +} + +export function stringify(buffer: ArrayBuffer) { + return String.fromCharCode(... new Uint8Array(buffer)); +} diff --git a/packages/client/src/scripts/aiscript/api.ts b/packages/client/src/scripts/aiscript/api.ts new file mode 100644 index 0000000000..20c15d809e --- /dev/null +++ b/packages/client/src/scripts/aiscript/api.ts @@ -0,0 +1,44 @@ +import { utils, values } from '@syuilo/aiscript'; +import * as os from '@/os'; +import { $i } from '@/account'; + +export function createAiScriptEnv(opts) { + let apiRequests = 0; + return { + USER_ID: $i ? values.STR($i.id) : values.NULL, + USER_NAME: $i ? values.STR($i.name) : values.NULL, + USER_USERNAME: $i ? values.STR($i.username) : values.NULL, + 'Mk:dialog': values.FN_NATIVE(async ([title, text, type]) => { + await os.dialog({ + type: type ? type.value : 'info', + title: title.value, + text: text.value, + }); + }), + 'Mk:confirm': values.FN_NATIVE(async ([title, text, type]) => { + const confirm = await os.dialog({ + type: type ? type.value : 'question', + showCancelButton: true, + title: title.value, + text: text.value, + }); + return confirm.canceled ? values.FALSE : values.TRUE; + }), + 'Mk:api': values.FN_NATIVE(async ([ep, param, token]) => { + if (token) utils.assertString(token); + apiRequests++; + if (apiRequests > 16) return values.NULL; + const res = await os.api(ep.value, utils.valToJs(param), token ? token.value : (opts.token || null)); + return utils.jsToVal(res); + }), + 'Mk:save': values.FN_NATIVE(([key, value]) => { + utils.assertString(key); + localStorage.setItem('aiscript:' + opts.storageKey + ':' + key.value, JSON.stringify(utils.valToJs(value))); + return values.NULL; + }), + 'Mk:load': values.FN_NATIVE(([key]) => { + utils.assertString(key); + return utils.jsToVal(JSON.parse(localStorage.getItem('aiscript:' + opts.storageKey + ':' + key.value))); + }), + }; +} diff --git a/packages/client/src/scripts/array.ts b/packages/client/src/scripts/array.ts new file mode 100644 index 0000000000..d63f0475d0 --- /dev/null +++ b/packages/client/src/scripts/array.ts @@ -0,0 +1,138 @@ +import { EndoRelation, Predicate } from './relation'; + +/** + * Count the number of elements that satisfy the predicate + */ + +export function countIf(f: Predicate, xs: T[]): number { + return xs.filter(f).length; +} + +/** + * Count the number of elements that is equal to the element + */ +export function count(a: T, xs: T[]): number { + return countIf(x => x === a, xs); +} + +/** + * Concatenate an array of arrays + */ +export function concat(xss: T[][]): T[] { + return ([] as T[]).concat(...xss); +} + +/** + * Intersperse the element between the elements of the array + * @param sep The element to be interspersed + */ +export function intersperse(sep: T, xs: T[]): T[] { + return concat(xs.map(x => [sep, x])).slice(1); +} + +/** + * Returns the array of elements that is not equal to the element + */ +export function erase(a: T, xs: T[]): T[] { + return xs.filter(x => x !== a); +} + +/** + * Finds the array of all elements in the first array not contained in the second array. + * The order of result values are determined by the first array. + */ +export function difference(xs: T[], ys: T[]): T[] { + return xs.filter(x => !ys.includes(x)); +} + +/** + * Remove all but the first element from every group of equivalent elements + */ +export function unique(xs: T[]): T[] { + return [...new Set(xs)]; +} + +export function sum(xs: number[]): number { + return xs.reduce((a, b) => a + b, 0); +} + +export function maximum(xs: number[]): number { + return Math.max(...xs); +} + +/** + * Splits an array based on the equivalence relation. + * The concatenation of the result is equal to the argument. + */ +export function groupBy(f: EndoRelation, xs: T[]): T[][] { + const groups = [] as T[][]; + for (const x of xs) { + if (groups.length !== 0 && f(groups[groups.length - 1][0], x)) { + groups[groups.length - 1].push(x); + } else { + groups.push([x]); + } + } + return groups; +} + +/** + * Splits an array based on the equivalence relation induced by the function. + * The concatenation of the result is equal to the argument. + */ +export function groupOn(f: (x: T) => S, xs: T[]): T[][] { + return groupBy((a, b) => f(a) === f(b), xs); +} + +export function groupByX(collections: T[], keySelector: (x: T) => string) { + return collections.reduce((obj: Record, item: T) => { + const key = keySelector(item); + if (!obj.hasOwnProperty(key)) { + obj[key] = []; + } + + obj[key].push(item); + + return obj; + }, {}); +} + +/** + * Compare two arrays by lexicographical order + */ +export function lessThan(xs: number[], ys: number[]): boolean { + for (let i = 0; i < Math.min(xs.length, ys.length); i++) { + if (xs[i] < ys[i]) return true; + if (xs[i] > ys[i]) return false; + } + return xs.length < ys.length; +} + +/** + * Returns the longest prefix of elements that satisfy the predicate + */ +export function takeWhile(f: Predicate, xs: T[]): T[] { + const ys = []; + for (const x of xs) { + if (f(x)) { + ys.push(x); + } else { + break; + } + } + return ys; +} + +export function cumulativeSum(xs: number[]): number[] { + const ys = Array.from(xs); // deep copy + for (let i = 1; i < ys.length; i++) ys[i] += ys[i - 1]; + return ys; +} + +export function toArray(x: T | T[] | undefined): T[] { + return Array.isArray(x) ? x : x != null ? [x] : []; +} + +export function toSingle(x: T | T[] | undefined): T | undefined { + return Array.isArray(x) ? x[0] : x; +} diff --git a/packages/client/src/scripts/autocomplete.ts b/packages/client/src/scripts/autocomplete.ts new file mode 100644 index 0000000000..f2d5806484 --- /dev/null +++ b/packages/client/src/scripts/autocomplete.ts @@ -0,0 +1,276 @@ +import { Ref, ref } from 'vue'; +import * as getCaretCoordinates from 'textarea-caret'; +import { toASCII } from 'punycode/'; +import { popup } from '@/os'; + +export class Autocomplete { + private suggestion: { + x: Ref; + y: Ref; + q: Ref; + close: Function; + } | null; + private textarea: any; + private vm: any; + private currentType: string; + private opts: { + model: string; + }; + private opening: boolean; + + private get text(): string { + return this.vm[this.opts.model]; + } + + private set text(text: string) { + this.vm[this.opts.model] = text; + } + + /** + * 対象のテキストエリアを与えてインスタンスを初期化します。 + */ + constructor(textarea, vm, opts) { + //#region BIND + this.onInput = this.onInput.bind(this); + this.complete = this.complete.bind(this); + this.close = this.close.bind(this); + //#endregion + + this.suggestion = null; + this.textarea = textarea; + this.vm = vm; + this.opts = opts; + this.opening = false; + + this.attach(); + } + + /** + * このインスタンスにあるテキストエリアの入力のキャプチャを開始します。 + */ + public attach() { + this.textarea.addEventListener('input', this.onInput); + } + + /** + * このインスタンスにあるテキストエリアの入力のキャプチャを解除します。 + */ + public detach() { + this.textarea.removeEventListener('input', this.onInput); + this.close(); + } + + /** + * テキスト入力時 + */ + private onInput() { + const caretPos = this.textarea.selectionStart; + const text = this.text.substr(0, caretPos).split('\n').pop()!; + + const mentionIndex = text.lastIndexOf('@'); + const hashtagIndex = text.lastIndexOf('#'); + const emojiIndex = text.lastIndexOf(':'); + const mfmTagIndex = text.lastIndexOf('$'); + + const max = Math.max( + mentionIndex, + hashtagIndex, + emojiIndex, + mfmTagIndex); + + if (max == -1) { + this.close(); + return; + } + + const isMention = mentionIndex != -1; + const isHashtag = hashtagIndex != -1; + const isMfmTag = mfmTagIndex != -1; + const isEmoji = emojiIndex != -1 && text.split(/:[a-z0-9_+\-]+:/).pop()!.includes(':'); + + let opened = false; + + if (isMention) { + const username = text.substr(mentionIndex + 1); + if (username != '' && username.match(/^[a-zA-Z0-9_]+$/)) { + this.open('user', username); + opened = true; + } else if (username === '') { + this.open('user', null); + opened = true; + } + } + + if (isHashtag && !opened) { + const hashtag = text.substr(hashtagIndex + 1); + if (!hashtag.includes(' ')) { + this.open('hashtag', hashtag); + opened = true; + } + } + + if (isEmoji && !opened) { + const emoji = text.substr(emojiIndex + 1); + if (!emoji.includes(' ')) { + this.open('emoji', emoji); + opened = true; + } + } + + if (isMfmTag && !opened) { + const mfmTag = text.substr(mfmTagIndex + 1); + if (!mfmTag.includes(' ')) { + this.open('mfmTag', mfmTag.replace('[', '')); + opened = true; + } + } + + if (!opened) { + this.close(); + } + } + + /** + * サジェストを提示します。 + */ + private async open(type: string, q: string | null) { + if (type != this.currentType) { + this.close(); + } + if (this.opening) return; + this.opening = true; + this.currentType = type; + + //#region サジェストを表示すべき位置を計算 + const caretPosition = getCaretCoordinates(this.textarea, this.textarea.selectionStart); + + const rect = this.textarea.getBoundingClientRect(); + + const x = rect.left + caretPosition.left - this.textarea.scrollLeft; + const y = rect.top + caretPosition.top - this.textarea.scrollTop; + //#endregion + + if (this.suggestion) { + this.suggestion.x.value = x; + this.suggestion.y.value = y; + this.suggestion.q.value = q; + + this.opening = false; + } else { + const _x = ref(x); + const _y = ref(y); + const _q = ref(q); + + const { dispose } = await popup(import('@/components/autocomplete.vue'), { + textarea: this.textarea, + close: this.close, + type: type, + q: _q, + x: _x, + y: _y, + }, { + done: (res) => { + this.complete(res); + } + }); + + this.suggestion = { + q: _q, + x: _x, + y: _y, + close: () => dispose(), + }; + + this.opening = false; + } + } + + /** + * サジェストを閉じます。 + */ + private close() { + if (this.suggestion == null) return; + + this.suggestion.close(); + this.suggestion = null; + + this.textarea.focus(); + } + + /** + * オートコンプリートする + */ + private complete({ type, value }) { + this.close(); + + const caret = this.textarea.selectionStart; + + if (type == 'user') { + const source = this.text; + + const before = source.substr(0, caret); + const trimmedBefore = before.substring(0, before.lastIndexOf('@')); + const after = source.substr(caret); + + const acct = value.host === null ? value.username : `${value.username}@${toASCII(value.host)}`; + + // 挿入 + this.text = `${trimmedBefore}@${acct} ${after}`; + + // キャレットを戻す + this.vm.$nextTick(() => { + this.textarea.focus(); + const pos = trimmedBefore.length + (acct.length + 2); + this.textarea.setSelectionRange(pos, pos); + }); + } else if (type == 'hashtag') { + const source = this.text; + + const before = source.substr(0, caret); + const trimmedBefore = before.substring(0, before.lastIndexOf('#')); + const after = source.substr(caret); + + // 挿入 + this.text = `${trimmedBefore}#${value} ${after}`; + + // キャレットを戻す + this.vm.$nextTick(() => { + this.textarea.focus(); + const pos = trimmedBefore.length + (value.length + 2); + this.textarea.setSelectionRange(pos, pos); + }); + } else if (type == 'emoji') { + const source = this.text; + + const before = source.substr(0, caret); + const trimmedBefore = before.substring(0, before.lastIndexOf(':')); + const after = source.substr(caret); + + // 挿入 + this.text = trimmedBefore + value + after; + + // キャレットを戻す + this.vm.$nextTick(() => { + this.textarea.focus(); + const pos = trimmedBefore.length + value.length; + this.textarea.setSelectionRange(pos, pos); + }); + } else if (type == 'mfmTag') { + const source = this.text; + + const before = source.substr(0, caret); + const trimmedBefore = before.substring(0, before.lastIndexOf('$')); + const after = source.substr(caret); + + // 挿入 + this.text = `${trimmedBefore}$[${value} ]${after}`; + + // キャレットを戻す + this.vm.$nextTick(() => { + this.textarea.focus(); + const pos = trimmedBefore.length + (value.length + 3); + this.textarea.setSelectionRange(pos, pos); + }); + } + } +} diff --git a/packages/client/src/scripts/check-word-mute.ts b/packages/client/src/scripts/check-word-mute.ts new file mode 100644 index 0000000000..3b1fa75b1e --- /dev/null +++ b/packages/client/src/scripts/check-word-mute.ts @@ -0,0 +1,26 @@ +export async function checkWordMute(note: Record, me: Record | null | undefined, mutedWords: string[][]): Promise { + // 自分自身 + if (me && (note.userId === me.id)) return false; + + const words = mutedWords + // Clean up + .map(xs => xs.filter(x => x !== '')) + .filter(xs => xs.length > 0); + + if (words.length > 0) { + if (note.text == null) return false; + + const matched = words.some(and => + and.every(keyword => { + const regexp = keyword.match(/^\/(.+)\/(.*)$/); + if (regexp) { + return new RegExp(regexp[1], regexp[2]).test(note.text!); + } + return note.text!.includes(keyword); + })); + + if (matched) return true; + } + + return false; +} diff --git a/packages/client/src/scripts/collect-page-vars.ts b/packages/client/src/scripts/collect-page-vars.ts new file mode 100644 index 0000000000..a4096fb2c2 --- /dev/null +++ b/packages/client/src/scripts/collect-page-vars.ts @@ -0,0 +1,48 @@ +export function collectPageVars(content) { + const pageVars = []; + const collect = (xs: any[]) => { + for (const x of xs) { + if (x.type === 'textInput') { + pageVars.push({ + name: x.name, + type: 'string', + value: x.default || '' + }); + } else if (x.type === 'textareaInput') { + pageVars.push({ + name: x.name, + type: 'string', + value: x.default || '' + }); + } else if (x.type === 'numberInput') { + pageVars.push({ + name: x.name, + type: 'number', + value: x.default || 0 + }); + } else if (x.type === 'switch') { + pageVars.push({ + name: x.name, + type: 'boolean', + value: x.default || false + }); + } else if (x.type === 'counter') { + pageVars.push({ + name: x.name, + type: 'number', + value: 0 + }); + } else if (x.type === 'radioButton') { + pageVars.push({ + name: x.name, + type: 'string', + value: x.default || '' + }); + } else if (x.children) { + collect(x.children); + } + } + }; + collect(content); + return pageVars; +} diff --git a/packages/client/src/scripts/contains.ts b/packages/client/src/scripts/contains.ts new file mode 100644 index 0000000000..770bda63bb --- /dev/null +++ b/packages/client/src/scripts/contains.ts @@ -0,0 +1,9 @@ +export default (parent, child, checkSame = true) => { + if (checkSame && parent === child) return true; + let node = child.parentNode; + while (node) { + if (node == parent) return true; + node = node.parentNode; + } + return false; +}; diff --git a/packages/client/src/scripts/copy-to-clipboard.ts b/packages/client/src/scripts/copy-to-clipboard.ts new file mode 100644 index 0000000000..ab13cab970 --- /dev/null +++ b/packages/client/src/scripts/copy-to-clipboard.ts @@ -0,0 +1,33 @@ +/** + * Clipboardに値をコピー(TODO: 文字列以外も対応) + */ +export default val => { + // 空div 生成 + const tmp = document.createElement('div'); + // 選択用のタグ生成 + const pre = document.createElement('pre'); + + // 親要素のCSSで user-select: none だとコピーできないので書き換える + pre.style.webkitUserSelect = 'auto'; + pre.style.userSelect = 'auto'; + + tmp.appendChild(pre).textContent = val; + + // 要素を画面外へ + const s = tmp.style; + s.position = 'fixed'; + s.right = '200%'; + + // body に追加 + document.body.appendChild(tmp); + // 要素を選択 + document.getSelection().selectAllChildren(tmp); + + // クリップボードにコピー + const result = document.execCommand('copy'); + + // 要素削除 + document.body.removeChild(tmp); + + return result; +}; diff --git a/packages/client/src/scripts/emojilist.ts b/packages/client/src/scripts/emojilist.ts new file mode 100644 index 0000000000..de7591f5a0 --- /dev/null +++ b/packages/client/src/scripts/emojilist.ts @@ -0,0 +1,7 @@ +// initial converted from https://github.com/muan/emojilib/commit/242fe68be86ed6536843b83f7e32f376468b38fb +export const emojilist = require('../emojilist.json') as { + name: string; + keywords: string[]; + char: string; + category: 'people' | 'animals_and_nature' | 'food_and_drink' | 'activity' | 'travel_and_places' | 'objects' | 'symbols' | 'flags'; +}[]; diff --git a/packages/client/src/scripts/extract-avg-color-from-blurhash.ts b/packages/client/src/scripts/extract-avg-color-from-blurhash.ts new file mode 100644 index 0000000000..123ab7a06d --- /dev/null +++ b/packages/client/src/scripts/extract-avg-color-from-blurhash.ts @@ -0,0 +1,9 @@ +export function extractAvgColorFromBlurhash(hash: string) { + return typeof hash == 'string' + ? '#' + [...hash.slice(2, 6)] + .map(x => '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz#$%*+,-.:;=?@[]^_{|}~'.indexOf(x)) + .reduce((a, c) => a * 83 + c, 0) + .toString(16) + .padStart(6, '0') + : undefined; +} diff --git a/packages/client/src/scripts/extract-mentions.ts b/packages/client/src/scripts/extract-mentions.ts new file mode 100644 index 0000000000..cc19b161a8 --- /dev/null +++ b/packages/client/src/scripts/extract-mentions.ts @@ -0,0 +1,11 @@ +// test is located in test/extract-mentions + +import * as mfm from 'mfm-js'; + +export function extractMentions(nodes: mfm.MfmNode[]): mfm.MfmMention['props'][] { + // TODO: 重複を削除 + const mentionNodes = mfm.extract(nodes, (node) => node.type === 'mention'); + const mentions = mentionNodes.map(x => x.props); + + return mentions; +} diff --git a/packages/client/src/scripts/extract-url-from-mfm.ts b/packages/client/src/scripts/extract-url-from-mfm.ts new file mode 100644 index 0000000000..34e3eb6c19 --- /dev/null +++ b/packages/client/src/scripts/extract-url-from-mfm.ts @@ -0,0 +1,19 @@ +import * as mfm from 'mfm-js'; +import { unique } from '@/scripts/array'; + +// unique without hash +// [ http://a/#1, http://a/#2, http://b/#3 ] => [ http://a/#1, http://b/#3 ] +const removeHash = (x: string) => x.replace(/#[^#]*$/, ''); + +export function extractUrlFromMfm(nodes: mfm.MfmNode[], respectSilentFlag = true): string[] { + const urlNodes = mfm.extract(nodes, (node) => { + return (node.type === 'url') || (node.type === 'link' && (!respectSilentFlag || !node.props.silent)); + }); + const urls: string[] = unique(urlNodes.map(x => x.props.url)); + + return urls.reduce((array, url) => { + const urlWithoutHash = removeHash(url); + if (!array.map(x => removeHash(x)).includes(urlWithoutHash)) array.push(url); + return array; + }, [] as string[]); +} diff --git a/packages/client/src/scripts/focus.ts b/packages/client/src/scripts/focus.ts new file mode 100644 index 0000000000..0894877820 --- /dev/null +++ b/packages/client/src/scripts/focus.ts @@ -0,0 +1,27 @@ +export function focusPrev(el: Element | null, self = false, scroll = true) { + if (el == null) return; + if (!self) el = el.previousElementSibling; + if (el) { + if (el.hasAttribute('tabindex')) { + (el as HTMLElement).focus({ + preventScroll: !scroll + }); + } else { + focusPrev(el.previousElementSibling, true); + } + } +} + +export function focusNext(el: Element | null, self = false, scroll = true) { + if (el == null) return; + if (!self) el = el.nextElementSibling; + if (el) { + if (el.hasAttribute('tabindex')) { + (el as HTMLElement).focus({ + preventScroll: !scroll + }); + } else { + focusPrev(el.nextElementSibling, true); + } + } +} diff --git a/packages/client/src/scripts/form.ts b/packages/client/src/scripts/form.ts new file mode 100644 index 0000000000..7bf6cec452 --- /dev/null +++ b/packages/client/src/scripts/form.ts @@ -0,0 +1,31 @@ +export type FormItem = { + label?: string; + type: 'string'; + default: string | null; + hidden?: boolean; + multiline?: boolean; +} | { + label?: string; + type: 'number'; + default: number | null; + hidden?: boolean; + step?: number; +} | { + label?: string; + type: 'boolean'; + default: boolean | null; + hidden?: boolean; +} | { + label?: string; + type: 'enum'; + default: string | null; + hidden?: boolean; + enum: string[]; +} | { + label?: string; + type: 'array'; + default: unknown[] | null; + hidden?: boolean; +}; + +export type Form = Record; diff --git a/packages/client/src/scripts/format-time-string.ts b/packages/client/src/scripts/format-time-string.ts new file mode 100644 index 0000000000..bfb2c397ae --- /dev/null +++ b/packages/client/src/scripts/format-time-string.ts @@ -0,0 +1,50 @@ +const defaultLocaleStringFormats: {[index: string]: string} = { + 'weekday': 'narrow', + 'era': 'narrow', + 'year': 'numeric', + 'month': 'numeric', + 'day': 'numeric', + 'hour': 'numeric', + 'minute': 'numeric', + 'second': 'numeric', + 'timeZoneName': 'short' +}; + +function formatLocaleString(date: Date, format: string): string { + return format.replace(/\{\{(\w+)(:(\w+))?\}\}/g, (match: string, kind: string, unused?, option?: string) => { + if (['weekday', 'era', 'year', 'month', 'day', 'hour', 'minute', 'second', 'timeZoneName'].includes(kind)) { + return date.toLocaleString(window.navigator.language, {[kind]: option ? option : defaultLocaleStringFormats[kind]}); + } else { + return match; + } + }); +} + +export function formatDateTimeString(date: Date, format: string): string { + return format + .replace(/yyyy/g, date.getFullYear().toString()) + .replace(/yy/g, date.getFullYear().toString().slice(-2)) + .replace(/MMMM/g, date.toLocaleString(window.navigator.language, { month: 'long'})) + .replace(/MMM/g, date.toLocaleString(window.navigator.language, { month: 'short'})) + .replace(/MM/g, (`0${date.getMonth() + 1}`).slice(-2)) + .replace(/M/g, (date.getMonth() + 1).toString()) + .replace(/dd/g, (`0${date.getDate()}`).slice(-2)) + .replace(/d/g, date.getDate().toString()) + .replace(/HH/g, (`0${date.getHours()}`).slice(-2)) + .replace(/H/g, date.getHours().toString()) + .replace(/hh/g, (`0${(date.getHours() % 12) || 12}`).slice(-2)) + .replace(/h/g, ((date.getHours() % 12) || 12).toString()) + .replace(/mm/g, (`0${date.getMinutes()}`).slice(-2)) + .replace(/m/g, date.getMinutes().toString()) + .replace(/ss/g, (`0${date.getSeconds()}`).slice(-2)) + .replace(/s/g, date.getSeconds().toString()) + .replace(/tt/g, date.getHours() >= 12 ? 'PM' : 'AM'); +} + +export function formatTimeString(date: Date, format: string): string { + return format.replace(/\[(([^\[]|\[\])*)\]|(([yMdHhmst])\4{0,3})/g, (match: string, localeformat?: string, unused?, datetimeformat?: string) => { + if (localeformat) return formatLocaleString(date, localeformat); + if (datetimeformat) return formatDateTimeString(date, datetimeformat); + return match; + }); +} diff --git a/packages/client/src/scripts/games/reversi/core.ts b/packages/client/src/scripts/games/reversi/core.ts new file mode 100644 index 0000000000..0cb8922e19 --- /dev/null +++ b/packages/client/src/scripts/games/reversi/core.ts @@ -0,0 +1,263 @@ +import { count, concat } from '@/scripts/array'; + +// MISSKEY REVERSI ENGINE + +/** + * true ... 黒 + * false ... 白 + */ +export type Color = boolean; +const BLACK = true; +const WHITE = false; + +export type MapPixel = 'null' | 'empty'; + +export type Options = { + isLlotheo: boolean; + canPutEverywhere: boolean; + loopedBoard: boolean; +}; + +export type Undo = { + /** + * 色 + */ + color: Color; + + /** + * どこに打ったか + */ + pos: number; + + /** + * 反転した石の位置の配列 + */ + effects: number[]; + + /** + * ターン + */ + turn: Color | null; +}; + +/** + * リバーシエンジン + */ +export default class Reversi { + public map: MapPixel[]; + public mapWidth: number; + public mapHeight: number; + public board: (Color | null | undefined)[]; + public turn: Color | null = BLACK; + public opts: Options; + + public prevPos = -1; + public prevColor: Color | null = null; + + private logs: Undo[] = []; + + /** + * ゲームを初期化します + */ + constructor(map: string[], opts: Options) { + //#region binds + this.put = this.put.bind(this); + //#endregion + + //#region Options + this.opts = opts; + if (this.opts.isLlotheo == null) this.opts.isLlotheo = false; + if (this.opts.canPutEverywhere == null) this.opts.canPutEverywhere = false; + if (this.opts.loopedBoard == null) this.opts.loopedBoard = false; + //#endregion + + //#region Parse map data + this.mapWidth = map[0].length; + this.mapHeight = map.length; + const mapData = map.join(''); + + this.board = mapData.split('').map(d => d === '-' ? null : d === 'b' ? BLACK : d === 'w' ? WHITE : undefined); + + this.map = mapData.split('').map(d => d === '-' || d === 'b' || d === 'w' ? 'empty' : 'null'); + //#endregion + + // ゲームが始まった時点で片方の色の石しかないか、始まった時点で勝敗が決定するようなマップの場合がある + if (!this.canPutSomewhere(BLACK)) + this.turn = this.canPutSomewhere(WHITE) ? WHITE : null; + } + + /** + * 黒石の数 + */ + public get blackCount() { + return count(BLACK, this.board); + } + + /** + * 白石の数 + */ + public get whiteCount() { + return count(WHITE, this.board); + } + + public transformPosToXy(pos: number): number[] { + const x = pos % this.mapWidth; + const y = Math.floor(pos / this.mapWidth); + return [x, y]; + } + + public transformXyToPos(x: number, y: number): number { + return x + (y * this.mapWidth); + } + + /** + * 指定のマスに石を打ちます + * @param color 石の色 + * @param pos 位置 + */ + public put(color: Color, pos: number) { + this.prevPos = pos; + this.prevColor = color; + + this.board[pos] = color; + + // 反転させられる石を取得 + const effects = this.effects(color, pos); + + // 反転させる + for (const pos of effects) { + this.board[pos] = color; + } + + const turn = this.turn; + + this.logs.push({ + color, + pos, + effects, + turn + }); + + this.calcTurn(); + } + + private calcTurn() { + // ターン計算 + this.turn = + this.canPutSomewhere(!this.prevColor) ? !this.prevColor : + this.canPutSomewhere(this.prevColor!) ? this.prevColor : + null; + } + + public undo() { + const undo = this.logs.pop()!; + this.prevColor = undo.color; + this.prevPos = undo.pos; + this.board[undo.pos] = null; + for (const pos of undo.effects) { + const color = this.board[pos]; + this.board[pos] = !color; + } + this.turn = undo.turn; + } + + /** + * 指定した位置のマップデータのマスを取得します + * @param pos 位置 + */ + public mapDataGet(pos: number): MapPixel { + const [x, y] = this.transformPosToXy(pos); + return x < 0 || y < 0 || x >= this.mapWidth || y >= this.mapHeight ? 'null' : this.map[pos]; + } + + /** + * 打つことができる場所を取得します + */ + public puttablePlaces(color: Color): number[] { + return Array.from(this.board.keys()).filter(i => this.canPut(color, i)); + } + + /** + * 打つことができる場所があるかどうかを取得します + */ + public canPutSomewhere(color: Color): boolean { + return this.puttablePlaces(color).length > 0; + } + + /** + * 指定のマスに石を打つことができるかどうかを取得します + * @param color 自分の色 + * @param pos 位置 + */ + public canPut(color: Color, pos: number): boolean { + return ( + this.board[pos] !== null ? false : // 既に石が置いてある場所には打てない + this.opts.canPutEverywhere ? this.mapDataGet(pos) == 'empty' : // 挟んでなくても置けるモード + this.effects(color, pos).length !== 0); // 相手の石を1つでも反転させられるか + } + + /** + * 指定のマスに石を置いた時の、反転させられる石を取得します + * @param color 自分の色 + * @param initPos 位置 + */ + public effects(color: Color, initPos: number): number[] { + const enemyColor = !color; + + const diffVectors: [number, number][] = [ + [ 0, -1], // 上 + [ +1, -1], // 右上 + [ +1, 0], // 右 + [ +1, +1], // 右下 + [ 0, +1], // 下 + [ -1, +1], // 左下 + [ -1, 0], // 左 + [ -1, -1] // 左上 + ]; + + const effectsInLine = ([dx, dy]: [number, number]): number[] => { + const nextPos = (x: number, y: number): [number, number] => [x + dx, y + dy]; + + const found: number[] = []; // 挟めるかもしれない相手の石を入れておく配列 + let [x, y] = this.transformPosToXy(initPos); + while (true) { + [x, y] = nextPos(x, y); + + // 座標が指し示す位置がボード外に出たとき + if (this.opts.loopedBoard && this.transformXyToPos( + (x = ((x % this.mapWidth) + this.mapWidth) % this.mapWidth), + (y = ((y % this.mapHeight) + this.mapHeight) % this.mapHeight)) === initPos) + // 盤面の境界でループし、自分が石を置く位置に戻ってきたとき、挟めるようにしている (ref: Test4のマップ) + return found; + else if (x === -1 || y === -1 || x === this.mapWidth || y === this.mapHeight) + return []; // 挟めないことが確定 (盤面外に到達) + + const pos = this.transformXyToPos(x, y); + if (this.mapDataGet(pos) === 'null') return []; // 挟めないことが確定 (配置不可能なマスに到達) + const stone = this.board[pos]; + if (stone === null) return []; // 挟めないことが確定 (石が置かれていないマスに到達) + if (stone === enemyColor) found.push(pos); // 挟めるかもしれない (相手の石を発見) + if (stone === color) return found; // 挟めることが確定 (対となる自分の石を発見) + } + }; + + return concat(diffVectors.map(effectsInLine)); + } + + /** + * ゲームが終了したか否か + */ + public get isEnded(): boolean { + return this.turn === null; + } + + /** + * ゲームの勝者 (null = 引き分け) + */ + public get winner(): Color | null { + return this.isEnded ? + this.blackCount == this.whiteCount ? null : + this.opts.isLlotheo === this.blackCount > this.whiteCount ? WHITE : BLACK : + undefined as never; + } +} diff --git a/packages/client/src/scripts/games/reversi/maps.ts b/packages/client/src/scripts/games/reversi/maps.ts new file mode 100644 index 0000000000..dc0d1bf9d0 --- /dev/null +++ b/packages/client/src/scripts/games/reversi/maps.ts @@ -0,0 +1,896 @@ +/** + * 組み込みマップ定義 + * + * データ値: + * (スペース) ... マス無し + * - ... マス + * b ... 初期配置される黒石 + * w ... 初期配置される白石 + */ + +export type Map = { + name?: string; + category?: string; + author?: string; + data: string[]; +}; + +export const fourfour: Map = { + name: '4x4', + category: '4x4', + data: [ + '----', + '-wb-', + '-bw-', + '----' + ] +}; + +export const sixsix: Map = { + name: '6x6', + category: '6x6', + data: [ + '------', + '------', + '--wb--', + '--bw--', + '------', + '------' + ] +}; + +export const roundedSixsix: Map = { + name: '6x6 rounded', + category: '6x6', + author: 'syuilo', + data: [ + ' ---- ', + '------', + '--wb--', + '--bw--', + '------', + ' ---- ' + ] +}; + +export const roundedSixsix2: Map = { + name: '6x6 rounded 2', + category: '6x6', + author: 'syuilo', + data: [ + ' -- ', + ' ---- ', + '--wb--', + '--bw--', + ' ---- ', + ' -- ' + ] +}; + +export const eighteight: Map = { + name: '8x8', + category: '8x8', + data: [ + '--------', + '--------', + '--------', + '---wb---', + '---bw---', + '--------', + '--------', + '--------' + ] +}; + +export const eighteightH1: Map = { + name: '8x8 handicap 1', + category: '8x8', + data: [ + 'b-------', + '--------', + '--------', + '---wb---', + '---bw---', + '--------', + '--------', + '--------' + ] +}; + +export const eighteightH2: Map = { + name: '8x8 handicap 2', + category: '8x8', + data: [ + 'b-------', + '--------', + '--------', + '---wb---', + '---bw---', + '--------', + '--------', + '-------b' + ] +}; + +export const eighteightH3: Map = { + name: '8x8 handicap 3', + category: '8x8', + data: [ + 'b------b', + '--------', + '--------', + '---wb---', + '---bw---', + '--------', + '--------', + '-------b' + ] +}; + +export const eighteightH4: Map = { + name: '8x8 handicap 4', + category: '8x8', + data: [ + 'b------b', + '--------', + '--------', + '---wb---', + '---bw---', + '--------', + '--------', + 'b------b' + ] +}; + +export const eighteightH28: Map = { + name: '8x8 handicap 28', + category: '8x8', + data: [ + 'bbbbbbbb', + 'b------b', + 'b------b', + 'b--wb--b', + 'b--bw--b', + 'b------b', + 'b------b', + 'bbbbbbbb' + ] +}; + +export const roundedEighteight: Map = { + name: '8x8 rounded', + category: '8x8', + author: 'syuilo', + data: [ + ' ------ ', + '--------', + '--------', + '---wb---', + '---bw---', + '--------', + '--------', + ' ------ ' + ] +}; + +export const roundedEighteight2: Map = { + name: '8x8 rounded 2', + category: '8x8', + author: 'syuilo', + data: [ + ' ---- ', + ' ------ ', + '--------', + '---wb---', + '---bw---', + '--------', + ' ------ ', + ' ---- ' + ] +}; + +export const roundedEighteight3: Map = { + name: '8x8 rounded 3', + category: '8x8', + author: 'syuilo', + data: [ + ' -- ', + ' ---- ', + ' ------ ', + '---wb---', + '---bw---', + ' ------ ', + ' ---- ', + ' -- ' + ] +}; + +export const eighteightWithNotch: Map = { + name: '8x8 with notch', + category: '8x8', + author: 'syuilo', + data: [ + '--- ---', + '--------', + '--------', + ' --wb-- ', + ' --bw-- ', + '--------', + '--------', + '--- ---' + ] +}; + +export const eighteightWithSomeHoles: Map = { + name: '8x8 with some holes', + category: '8x8', + author: 'syuilo', + data: [ + '--- ----', + '----- --', + '-- -----', + '---wb---', + '---bw- -', + ' -------', + '--- ----', + '--------' + ] +}; + +export const circle: Map = { + name: 'Circle', + category: '8x8', + author: 'syuilo', + data: [ + ' -- ', + ' ------ ', + ' ------ ', + '---wb---', + '---bw---', + ' ------ ', + ' ------ ', + ' -- ' + ] +}; + +export const smile: Map = { + name: 'Smile', + category: '8x8', + author: 'syuilo', + data: [ + ' ------ ', + '--------', + '-- -- --', + '---wb---', + '-- bw --', + '--- ---', + '--------', + ' ------ ' + ] +}; + +export const window: Map = { + name: 'Window', + category: '8x8', + author: 'syuilo', + data: [ + '--------', + '- -- -', + '- -- -', + '---wb---', + '---bw---', + '- -- -', + '- -- -', + '--------' + ] +}; + +export const reserved: Map = { + name: 'Reserved', + category: '8x8', + author: 'Aya', + data: [ + 'w------b', + '--------', + '--------', + '---wb---', + '---bw---', + '--------', + '--------', + 'b------w' + ] +}; + +export const x: Map = { + name: 'X', + category: '8x8', + author: 'Aya', + data: [ + 'w------b', + '-w----b-', + '--w--b--', + '---wb---', + '---bw---', + '--b--w--', + '-b----w-', + 'b------w' + ] +}; + +export const parallel: Map = { + name: 'Parallel', + category: '8x8', + author: 'Aya', + data: [ + '--------', + '--------', + '--------', + '---bb---', + '---ww---', + '--------', + '--------', + '--------' + ] +}; + +export const lackOfBlack: Map = { + name: 'Lack of Black', + category: '8x8', + data: [ + '--------', + '--------', + '--------', + '---w----', + '---bw---', + '--------', + '--------', + '--------' + ] +}; + +export const squareParty: Map = { + name: 'Square Party', + category: '8x8', + author: 'syuilo', + data: [ + '--------', + '-wwwbbb-', + '-w-wb-b-', + '-wwwbbb-', + '-bbbwww-', + '-b-bw-w-', + '-bbbwww-', + '--------' + ] +}; + +export const minesweeper: Map = { + name: 'Minesweeper', + category: '8x8', + author: 'syuilo', + data: [ + 'b-b--w-w', + '-w-wb-b-', + 'w-b--w-b', + '-b-wb-w-', + '-w-bw-b-', + 'b-w--b-w', + '-b-bw-w-', + 'w-w--b-b' + ] +}; + +export const tenthtenth: Map = { + name: '10x10', + category: '10x10', + data: [ + '----------', + '----------', + '----------', + '----------', + '----wb----', + '----bw----', + '----------', + '----------', + '----------', + '----------' + ] +}; + +export const hole: Map = { + name: 'The Hole', + category: '10x10', + author: 'syuilo', + data: [ + '----------', + '----------', + '--wb--wb--', + '--bw--bw--', + '---- ----', + '---- ----', + '--wb--wb--', + '--bw--bw--', + '----------', + '----------' + ] +}; + +export const grid: Map = { + name: 'Grid', + category: '10x10', + author: 'syuilo', + data: [ + '----------', + '- - -- - -', + '----------', + '- - -- - -', + '----wb----', + '----bw----', + '- - -- - -', + '----------', + '- - -- - -', + '----------' + ] +}; + +export const cross: Map = { + name: 'Cross', + category: '10x10', + author: 'Aya', + data: [ + ' ---- ', + ' ---- ', + ' ---- ', + '----------', + '----wb----', + '----bw----', + '----------', + ' ---- ', + ' ---- ', + ' ---- ' + ] +}; + +export const charX: Map = { + name: 'Char X', + category: '10x10', + author: 'syuilo', + data: [ + '--- ---', + '---- ----', + '----------', + ' -------- ', + ' --wb-- ', + ' --bw-- ', + ' -------- ', + '----------', + '---- ----', + '--- ---' + ] +}; + +export const charY: Map = { + name: 'Char Y', + category: '10x10', + author: 'syuilo', + data: [ + '--- ---', + '---- ----', + '----------', + ' -------- ', + ' --wb-- ', + ' --bw-- ', + ' ------ ', + ' ------ ', + ' ------ ', + ' ------ ' + ] +}; + +export const walls: Map = { + name: 'Walls', + category: '10x10', + author: 'Aya', + data: [ + ' bbbbbbbb ', + 'w--------w', + 'w--------w', + 'w--------w', + 'w---wb---w', + 'w---bw---w', + 'w--------w', + 'w--------w', + 'w--------w', + ' bbbbbbbb ' + ] +}; + +export const cpu: Map = { + name: 'CPU', + category: '10x10', + author: 'syuilo', + data: [ + ' b b b b ', + 'w--------w', + ' -------- ', + 'w--------w', + ' ---wb--- ', + ' ---bw--- ', + 'w--------w', + ' -------- ', + 'w--------w', + ' b b b b ' + ] +}; + +export const checker: Map = { + name: 'Checker', + category: '10x10', + author: 'Aya', + data: [ + '----------', + '----------', + '----------', + '---wbwb---', + '---bwbw---', + '---wbwb---', + '---bwbw---', + '----------', + '----------', + '----------' + ] +}; + +export const japaneseCurry: Map = { + name: 'Japanese curry', + category: '10x10', + author: 'syuilo', + data: [ + 'w-b-b-b-b-', + '-w-b-b-b-b', + 'w-w-b-b-b-', + '-w-w-b-b-b', + 'w-w-wwb-b-', + '-w-wbb-b-b', + 'w-w-w-b-b-', + '-w-w-w-b-b', + 'w-w-w-w-b-', + '-w-w-w-w-b' + ] +}; + +export const mosaic: Map = { + name: 'Mosaic', + category: '10x10', + author: 'syuilo', + data: [ + '- - - - - ', + ' - - - - -', + '- - - - - ', + ' - w w - -', + '- - b b - ', + ' - w w - -', + '- - b b - ', + ' - - - - -', + '- - - - - ', + ' - - - - -', + ] +}; + +export const arena: Map = { + name: 'Arena', + category: '10x10', + author: 'syuilo', + data: [ + '- - -- - -', + ' - - - - ', + '- ------ -', + ' -------- ', + '- --wb-- -', + '- --bw-- -', + ' -------- ', + '- ------ -', + ' - - - - ', + '- - -- - -' + ] +}; + +export const reactor: Map = { + name: 'Reactor', + category: '10x10', + author: 'syuilo', + data: [ + '-w------b-', + 'b- - - -w', + '- --wb-- -', + '---b w---', + '- b wb w -', + '- w bw b -', + '---w b---', + '- --bw-- -', + 'w- - - -b', + '-b------w-' + ] +}; + +export const sixeight: Map = { + name: '6x8', + category: 'Special', + data: [ + '------', + '------', + '------', + '--wb--', + '--bw--', + '------', + '------', + '------' + ] +}; + +export const spark: Map = { + name: 'Spark', + category: 'Special', + author: 'syuilo', + data: [ + ' - - ', + '----------', + ' -------- ', + ' -------- ', + ' ---wb--- ', + ' ---bw--- ', + ' -------- ', + ' -------- ', + '----------', + ' - - ' + ] +}; + +export const islands: Map = { + name: 'Islands', + category: 'Special', + author: 'syuilo', + data: [ + '-------- ', + '---wb--- ', + '---bw--- ', + '-------- ', + ' - - ', + ' - - ', + ' --------', + ' --------', + ' --------', + ' --------' + ] +}; + +export const galaxy: Map = { + name: 'Galaxy', + category: 'Special', + author: 'syuilo', + data: [ + ' ------ ', + ' --www--- ', + ' ------w--- ', + '---bbb--w---', + '--b---b-w-b-', + '-b--wwb-w-b-', + '-b-w-bww--b-', + '-b-w-b---b--', + '---w--bbb---', + ' ---w------ ', + ' ---www-- ', + ' ------ ' + ] +}; + +export const triangle: Map = { + name: 'Triangle', + category: 'Special', + author: 'syuilo', + data: [ + ' -- ', + ' -- ', + ' ---- ', + ' ---- ', + ' --wb-- ', + ' --bw-- ', + ' -------- ', + ' -------- ', + '----------', + '----------' + ] +}; + +export const iphonex: Map = { + name: 'iPhone X', + category: 'Special', + author: 'syuilo', + data: [ + ' -- -- ', + '--------', + '--------', + '--------', + '--------', + '---wb---', + '---bw---', + '--------', + '--------', + '--------', + '--------', + ' ------ ' + ] +}; + +export const dealWithIt: Map = { + name: 'Deal with it!', + category: 'Special', + author: 'syuilo', + data: [ + '------------', + '--w-b-------', + ' --b-w------', + ' --w-b---- ', + ' ------- ' + ] +}; + +export const experiment: Map = { + name: 'Let\'s experiment', + category: 'Special', + author: 'syuilo', + data: [ + ' ------------ ', + '------wb------', + '------bw------', + '--------------', + ' - - ', + '------ ------', + 'bbbbbb wwwwww', + 'bbbbbb wwwwww', + 'bbbbbb wwwwww', + 'bbbbbb wwwwww', + 'wwwwww bbbbbb' + ] +}; + +export const bigBoard: Map = { + name: 'Big board', + category: 'Special', + data: [ + '----------------', + '----------------', + '----------------', + '----------------', + '----------------', + '----------------', + '----------------', + '-------wb-------', + '-------bw-------', + '----------------', + '----------------', + '----------------', + '----------------', + '----------------', + '----------------', + '----------------' + ] +}; + +export const twoBoard: Map = { + name: 'Two board', + category: 'Special', + author: 'Aya', + data: [ + '-------- --------', + '-------- --------', + '-------- --------', + '---wb--- ---wb---', + '---bw--- ---bw---', + '-------- --------', + '-------- --------', + '-------- --------' + ] +}; + +export const test1: Map = { + name: 'Test1', + category: 'Test', + data: [ + '--------', + '---wb---', + '---bw---', + '--------' + ] +}; + +export const test2: Map = { + name: 'Test2', + category: 'Test', + data: [ + '------', + '------', + '-b--w-', + '-w--b-', + '-w--b-' + ] +}; + +export const test3: Map = { + name: 'Test3', + category: 'Test', + data: [ + '-w-', + '--w', + 'w--', + '-w-', + '--w', + 'w--', + '-w-', + '--w', + 'w--', + '-w-', + '---', + 'b--', + ] +}; + +export const test4: Map = { + name: 'Test4', + category: 'Test', + data: [ + '-w--b-', + '-w--b-', + '------', + '-w--b-', + '-w--b-' + ] +}; + +// 検証用: この盤面で藍(lv3)が黒で始めると何故か(?)A1に打ってしまう +export const test6: Map = { + name: 'Test6', + category: 'Test', + data: [ + '--wwwww-', + 'wwwwwwww', + 'wbbbwbwb', + 'wbbbbwbb', + 'wbwbbwbb', + 'wwbwbbbb', + '--wbbbbb', + '-wwwww--', + ] +}; + +// 検証用: この盤面で藍(lv3)が黒で始めると何故か(?)G7に打ってしまう +export const test7: Map = { + name: 'Test7', + category: 'Test', + data: [ + 'b--w----', + 'b-wwww--', + 'bwbwwwbb', + 'wbwwwwb-', + 'wwwwwww-', + '-wwbbwwb', + '--wwww--', + '--wwww--', + ] +}; + +// 検証用: この盤面で藍(lv5)が黒で始めると何故か(?)A1に打ってしまう +export const test8: Map = { + name: 'Test8', + category: 'Test', + data: [ + '--------', + '-----w--', + 'w--www--', + 'wwwwww--', + 'bbbbwww-', + 'wwwwww--', + '--www---', + '--ww----', + ] +}; diff --git a/packages/client/src/scripts/games/reversi/package.json b/packages/client/src/scripts/games/reversi/package.json new file mode 100644 index 0000000000..a4415ad141 --- /dev/null +++ b/packages/client/src/scripts/games/reversi/package.json @@ -0,0 +1,18 @@ +{ + "name": "misskey-reversi", + "version": "0.0.5", + "description": "Misskey reversi engine", + "keywords": [ + "misskey" + ], + "author": "syuilo ", + "license": "MIT", + "repository": "https://github.com/misskey-dev/misskey.git", + "bugs": "https://github.com/misskey-dev/misskey/issues", + "main": "./built/core.js", + "types": "./built/core.d.ts", + "scripts": { + "build": "tsc" + }, + "dependencies": {} +} diff --git a/packages/client/src/scripts/games/reversi/tsconfig.json b/packages/client/src/scripts/games/reversi/tsconfig.json new file mode 100644 index 0000000000..851fb6b7e4 --- /dev/null +++ b/packages/client/src/scripts/games/reversi/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "noEmitOnError": false, + "noImplicitAny": false, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "experimentalDecorators": true, + "declaration": true, + "sourceMap": false, + "target": "es2017", + "module": "commonjs", + "removeComments": false, + "noLib": false, + "outDir": "./built", + "rootDir": "./" + }, + "compileOnSave": false, + "include": [ + "./core.ts" + ] +} diff --git a/packages/client/src/scripts/gen-search-query.ts b/packages/client/src/scripts/gen-search-query.ts new file mode 100644 index 0000000000..57a06c280c --- /dev/null +++ b/packages/client/src/scripts/gen-search-query.ts @@ -0,0 +1,31 @@ +import * as Acct from 'misskey-js/built/acct'; +import { host as localHost } from '@/config'; + +export async function genSearchQuery(v: any, q: string) { + let host: string; + let userId: string; + if (q.split(' ').some(x => x.startsWith('@'))) { + for (const at of q.split(' ').filter(x => x.startsWith('@')).map(x => x.substr(1))) { + if (at.includes('.')) { + if (at === localHost || at === '.') { + host = null; + } else { + host = at; + } + } else { + const user = await v.os.api('users/show', Acct.parse(at)).catch(x => null); + if (user) { + userId = user.id; + } else { + // todo: show error + } + } + } + + } + return { + query: q.split(' ').filter(x => !x.startsWith('/') && !x.startsWith('@')).join(' '), + host: host, + userId: userId + }; +} diff --git a/packages/client/src/scripts/get-account-from-id.ts b/packages/client/src/scripts/get-account-from-id.ts new file mode 100644 index 0000000000..ba3adceecc --- /dev/null +++ b/packages/client/src/scripts/get-account-from-id.ts @@ -0,0 +1,7 @@ +import { get } from '@/scripts/idb-proxy'; + +export async function getAccountFromId(id: string) { + const accounts = await get('accounts') as { token: string; id: string; }[]; + if (!accounts) console.log('Accounts are not recorded'); + return accounts.find(e => e.id === id); +} diff --git a/packages/client/src/scripts/get-md5.ts b/packages/client/src/scripts/get-md5.ts new file mode 100644 index 0000000000..b002d762b1 --- /dev/null +++ b/packages/client/src/scripts/get-md5.ts @@ -0,0 +1,10 @@ +// スクリプトサイズがデカい +//import * as crypto from 'crypto'; + +export default (data: ArrayBuffer) => { + //const buf = new Buffer(data); + //const hash = crypto.createHash('md5'); + //hash.update(buf); + //return hash.digest('hex'); + return ''; +}; diff --git a/packages/client/src/scripts/get-note-summary.ts b/packages/client/src/scripts/get-note-summary.ts new file mode 100644 index 0000000000..bd394279cb --- /dev/null +++ b/packages/client/src/scripts/get-note-summary.ts @@ -0,0 +1,55 @@ +import * as misskey from 'misskey-js'; +import { i18n } from '@/i18n'; + +/** + * 投稿を表す文字列を取得します。 + * @param {*} note (packされた)投稿 + */ +export const getNoteSummary = (note: misskey.entities.Note): string => { + if (note.deletedAt) { + return `(${i18n.locale.deletedNote})`; + } + + if (note.isHidden) { + return `(${i18n.locale.invisibleNote})`; + } + + let summary = ''; + + // 本文 + if (note.cw != null) { + summary += note.cw; + } else { + summary += note.text ? note.text : ''; + } + + // ファイルが添付されているとき + if ((note.files || []).length != 0) { + summary += ` (${i18n.t('withNFiles', { n: note.files.length })})`; + } + + // 投票が添付されているとき + if (note.poll) { + summary += ` (${i18n.locale.poll})`; + } + + // 返信のとき + if (note.replyId) { + if (note.reply) { + summary += `\n\nRE: ${getNoteSummary(note.reply)}`; + } else { + summary += '\n\nRE: ...'; + } + } + + // Renoteのとき + if (note.renoteId) { + if (note.renote) { + summary += `\n\nRN: ${getNoteSummary(note.renote)}`; + } else { + summary += '\n\nRN: ...'; + } + } + + return summary.trim(); +}; diff --git a/packages/client/src/scripts/get-static-image-url.ts b/packages/client/src/scripts/get-static-image-url.ts new file mode 100644 index 0000000000..e9a3e87cc8 --- /dev/null +++ b/packages/client/src/scripts/get-static-image-url.ts @@ -0,0 +1,16 @@ +import { url as instanceUrl } from '@/config'; +import * as url from '@/scripts/url'; + +export function getStaticImageUrl(baseUrl: string): string { + const u = new URL(baseUrl); + if (u.href.startsWith(`${instanceUrl}/proxy/`)) { + // もう既にproxyっぽそうだったらsearchParams付けるだけ + u.searchParams.set('static', '1'); + return u.href; + } + const dummy = `${u.host}${u.pathname}`; // 拡張子がないとキャッシュしてくれないCDNがあるので + return `${instanceUrl}/proxy/${dummy}?${url.query({ + url: u.href, + static: '1' + })}`; +} diff --git a/packages/client/src/scripts/get-user-menu.ts b/packages/client/src/scripts/get-user-menu.ts new file mode 100644 index 0000000000..8d767afa25 --- /dev/null +++ b/packages/client/src/scripts/get-user-menu.ts @@ -0,0 +1,205 @@ +import { i18n } from '@/i18n'; +import copyToClipboard from '@/scripts/copy-to-clipboard'; +import { host } from '@/config'; +import * as Acct from 'misskey-js/built/acct'; +import * as os from '@/os'; +import { userActions } from '@/store'; +import { router } from '@/router'; +import { $i } from '@/account'; + +export function getUserMenu(user) { + const meId = $i ? $i.id : null; + + async function pushList() { + const t = i18n.locale.selectList; // なぜか後で参照すると null になるので最初にメモリに確保しておく + const lists = await os.api('users/lists/list'); + if (lists.length === 0) { + os.dialog({ + type: 'error', + text: i18n.locale.youHaveNoLists + }); + return; + } + const { canceled, result: listId } = await os.dialog({ + type: null, + title: t, + select: { + items: lists.map(list => ({ + value: list.id, text: list.name + })) + }, + showCancelButton: true + }); + if (canceled) return; + os.apiWithDialog('users/lists/push', { + listId: listId, + userId: user.id + }); + } + + async function inviteGroup() { + const groups = await os.api('users/groups/owned'); + if (groups.length === 0) { + os.dialog({ + type: 'error', + text: i18n.locale.youHaveNoGroups + }); + return; + } + const { canceled, result: groupId } = await os.dialog({ + type: null, + title: i18n.locale.group, + select: { + items: groups.map(group => ({ + value: group.id, text: group.name + })) + }, + showCancelButton: true + }); + if (canceled) return; + os.apiWithDialog('users/groups/invite', { + groupId: groupId, + userId: user.id + }); + } + + async function toggleMute() { + os.apiWithDialog(user.isMuted ? 'mute/delete' : 'mute/create', { + userId: user.id + }).then(() => { + user.isMuted = !user.isMuted; + }); + } + + async function toggleBlock() { + if (!await getConfirmed(user.isBlocking ? i18n.locale.unblockConfirm : i18n.locale.blockConfirm)) return; + + os.apiWithDialog(user.isBlocking ? 'blocking/delete' : 'blocking/create', { + userId: user.id + }).then(() => { + user.isBlocking = !user.isBlocking; + }); + } + + async function toggleSilence() { + if (!await getConfirmed(i18n.t(user.isSilenced ? 'unsilenceConfirm' : 'silenceConfirm'))) return; + + os.apiWithDialog(user.isSilenced ? 'admin/unsilence-user' : 'admin/silence-user', { + userId: user.id + }).then(() => { + user.isSilenced = !user.isSilenced; + }); + } + + async function toggleSuspend() { + if (!await getConfirmed(i18n.t(user.isSuspended ? 'unsuspendConfirm' : 'suspendConfirm'))) return; + + os.apiWithDialog(user.isSuspended ? 'admin/unsuspend-user' : 'admin/suspend-user', { + userId: user.id + }).then(() => { + user.isSuspended = !user.isSuspended; + }); + } + + function reportAbuse() { + os.popup(import('@/components/abuse-report-window.vue'), { + user: user, + }, {}, 'closed'); + } + + async function getConfirmed(text: string): Promise { + const confirm = await os.dialog({ + type: 'warning', + showCancelButton: true, + title: 'confirm', + text, + }); + + return !confirm.canceled; + } + + let menu = [{ + icon: 'fas fa-at', + text: i18n.locale.copyUsername, + action: () => { + copyToClipboard(`@${user.username}@${user.host || host}`); + } + }, { + icon: 'fas fa-info-circle', + text: i18n.locale.info, + action: () => { + os.pageWindow(`/user-info/${user.id}`); + } + }, { + icon: 'fas fa-envelope', + text: i18n.locale.sendMessage, + action: () => { + os.post({ specified: user }); + } + }, meId != user.id ? { + type: 'link', + icon: 'fas fa-comments', + text: i18n.locale.startMessaging, + to: '/my/messaging/' + Acct.toString(user), + } : undefined, null, { + icon: 'fas fa-list-ul', + text: i18n.locale.addToList, + action: pushList + }, meId != user.id ? { + icon: 'fas fa-users', + text: i18n.locale.inviteToGroup, + action: inviteGroup + } : undefined] as any; + + if ($i && meId != user.id) { + menu = menu.concat([null, { + icon: user.isMuted ? 'fas fa-eye' : 'fas fa-eye-slash', + text: user.isMuted ? i18n.locale.unmute : i18n.locale.mute, + action: toggleMute + }, { + icon: 'fas fa-ban', + text: user.isBlocking ? i18n.locale.unblock : i18n.locale.block, + action: toggleBlock + }]); + + menu = menu.concat([null, { + icon: 'fas fa-exclamation-circle', + text: i18n.locale.reportAbuse, + action: reportAbuse + }]); + + if ($i && ($i.isAdmin || $i.isModerator)) { + menu = menu.concat([null, { + icon: 'fas fa-microphone-slash', + text: user.isSilenced ? i18n.locale.unsilence : i18n.locale.silence, + action: toggleSilence + }, { + icon: 'fas fa-snowflake', + text: user.isSuspended ? i18n.locale.unsuspend : i18n.locale.suspend, + action: toggleSuspend + }]); + } + } + + if ($i && meId === user.id) { + menu = menu.concat([null, { + icon: 'fas fa-pencil-alt', + text: i18n.locale.editProfile, + action: () => { + router.push('/settings/profile'); + } + }]); + } + + if (userActions.length > 0) { + menu = menu.concat([null, ...userActions.map(action => ({ + icon: 'fas fa-plug', + text: action.title, + action: () => { + action.handler(user); + } + }))]); + } + + return menu; +} diff --git a/packages/client/src/scripts/hotkey.ts b/packages/client/src/scripts/hotkey.ts new file mode 100644 index 0000000000..2b3f491fd8 --- /dev/null +++ b/packages/client/src/scripts/hotkey.ts @@ -0,0 +1,88 @@ +import keyCode from './keycode'; + +type Keymap = Record; + +type Pattern = { + which: string[]; + ctrl?: boolean; + shift?: boolean; + alt?: boolean; +}; + +type Action = { + patterns: Pattern[]; + callback: Function; + allowRepeat: boolean; +}; + +const parseKeymap = (keymap: Keymap) => Object.entries(keymap).map(([patterns, callback]): Action => { + const result = { + patterns: [], + callback: callback, + allowRepeat: true + } as Action; + + if (patterns.match(/^\(.*\)$/) !== null) { + result.allowRepeat = false; + patterns = patterns.slice(1, -1); + } + + result.patterns = patterns.split('|').map(part => { + const pattern = { + which: [], + ctrl: false, + alt: false, + shift: false + } as Pattern; + + const keys = part.trim().split('+').map(x => x.trim().toLowerCase()); + for (const key of keys) { + switch (key) { + case 'ctrl': pattern.ctrl = true; break; + case 'alt': pattern.alt = true; break; + case 'shift': pattern.shift = true; break; + default: pattern.which = keyCode(key).map(k => k.toLowerCase()); + } + } + + return pattern; + }); + + return result; +}); + +const ignoreElemens = ['input', 'textarea']; + +function match(e: KeyboardEvent, patterns: Action['patterns']): boolean { + const key = e.code.toLowerCase(); + return patterns.some(pattern => pattern.which.includes(key) && + pattern.ctrl === e.ctrlKey && + pattern.shift === e.shiftKey && + pattern.alt === e.altKey && + !e.metaKey + ); +} + +export const makeHotkey = (keymap: Keymap) => { + const actions = parseKeymap(keymap); + + return (e: KeyboardEvent) => { + if (document.activeElement) { + if (ignoreElemens.some(el => document.activeElement!.matches(el))) return; + if (document.activeElement.attributes['contenteditable']) return; + } + + for (const action of actions) { + const matched = match(e, action.patterns); + + if (matched) { + if (!action.allowRepeat && e.repeat) return; + + e.preventDefault(); + e.stopPropagation(); + action.callback(e); + break; + } + } + }; +}; diff --git a/packages/client/src/scripts/hpml/block.ts b/packages/client/src/scripts/hpml/block.ts new file mode 100644 index 0000000000..804c5c1124 --- /dev/null +++ b/packages/client/src/scripts/hpml/block.ts @@ -0,0 +1,109 @@ +// blocks + +export type BlockBase = { + id: string; + type: string; +}; + +export type TextBlock = BlockBase & { + type: 'text'; + text: string; +}; + +export type SectionBlock = BlockBase & { + type: 'section'; + title: string; + children: (Block | VarBlock)[]; +}; + +export type ImageBlock = BlockBase & { + type: 'image'; + fileId: string | null; +}; + +export type ButtonBlock = BlockBase & { + type: 'button'; + text: any; + primary: boolean; + action: string; + content: string; + event: string; + message: string; + var: string; + fn: string; +}; + +export type IfBlock = BlockBase & { + type: 'if'; + var: string; + children: Block[]; +}; + +export type TextareaBlock = BlockBase & { + type: 'textarea'; + text: string; +}; + +export type PostBlock = BlockBase & { + type: 'post'; + text: string; + attachCanvasImage: boolean; + canvasId: string; +}; + +export type CanvasBlock = BlockBase & { + type: 'canvas'; + name: string; // canvas id + width: number; + height: number; +}; + +export type NoteBlock = BlockBase & { + type: 'note'; + detailed: boolean; + note: string | null; +}; + +export type Block = + TextBlock | SectionBlock | ImageBlock | ButtonBlock | IfBlock | TextareaBlock | PostBlock | CanvasBlock | NoteBlock | VarBlock; + +// variable blocks + +export type VarBlockBase = BlockBase & { + name: string; +}; + +export type NumberInputVarBlock = VarBlockBase & { + type: 'numberInput'; + text: string; +}; + +export type TextInputVarBlock = VarBlockBase & { + type: 'textInput'; + text: string; +}; + +export type SwitchVarBlock = VarBlockBase & { + type: 'switch'; + text: string; +}; + +export type RadioButtonVarBlock = VarBlockBase & { + type: 'radioButton'; + title: string; + values: string[]; +}; + +export type CounterVarBlock = VarBlockBase & { + type: 'counter'; + text: string; + inc: number; +}; + +export type VarBlock = + NumberInputVarBlock | TextInputVarBlock | SwitchVarBlock | RadioButtonVarBlock | CounterVarBlock; + +const varBlock = ['numberInput', 'textInput', 'switch', 'radioButton', 'counter']; +export function isVarBlock(block: Block): block is VarBlock { + return varBlock.includes(block.type); +} diff --git a/packages/client/src/scripts/hpml/evaluator.ts b/packages/client/src/scripts/hpml/evaluator.ts new file mode 100644 index 0000000000..20261d333d --- /dev/null +++ b/packages/client/src/scripts/hpml/evaluator.ts @@ -0,0 +1,234 @@ +import autobind from 'autobind-decorator'; +import { PageVar, envVarsDef, Fn, HpmlScope, HpmlError } from '.'; +import { version } from '@/config'; +import { AiScript, utils, values } from '@syuilo/aiscript'; +import { createAiScriptEnv } from '../aiscript/api'; +import { collectPageVars } from '../collect-page-vars'; +import { initHpmlLib, initAiLib } from './lib'; +import * as os from '@/os'; +import { markRaw, ref, Ref, unref } from 'vue'; +import { Expr, isLiteralValue, Variable } from './expr'; + +/** + * Hpml evaluator + */ +export class Hpml { + private variables: Variable[]; + private pageVars: PageVar[]; + private envVars: Record; + public aiscript?: AiScript; + public pageVarUpdatedCallback?: values.VFn; + public canvases: Record = {}; + public vars: Ref> = ref({}); + public page: Record; + + private opts: { + randomSeed: string; visitor?: any; url?: string; + enableAiScript: boolean; + }; + + constructor(page: Hpml['page'], opts: Hpml['opts']) { + this.page = page; + this.variables = this.page.variables; + this.pageVars = collectPageVars(this.page.content); + this.opts = opts; + + if (this.opts.enableAiScript) { + this.aiscript = markRaw(new AiScript({ ...createAiScriptEnv({ + storageKey: 'pages:' + this.page.id + }), ...initAiLib(this)}, { + in: (q) => { + return new Promise(ok => { + os.dialog({ + title: q, + input: {} + }).then(({ canceled, result: a }) => { + ok(a); + }); + }); + }, + out: (value) => { + console.log(value); + }, + log: (type, params) => { + }, + })); + + this.aiscript.scope.opts.onUpdated = (name, value) => { + this.eval(); + }; + } + + const date = new Date(); + + this.envVars = { + AI: 'kawaii', + VERSION: version, + URL: this.page ? `${opts.url}/@${this.page.user.username}/pages/${this.page.name}` : '', + LOGIN: opts.visitor != null, + NAME: opts.visitor ? opts.visitor.name || opts.visitor.username : '', + USERNAME: opts.visitor ? opts.visitor.username : '', + USERID: opts.visitor ? opts.visitor.id : '', + NOTES_COUNT: opts.visitor ? opts.visitor.notesCount : 0, + FOLLOWERS_COUNT: opts.visitor ? opts.visitor.followersCount : 0, + FOLLOWING_COUNT: opts.visitor ? opts.visitor.followingCount : 0, + IS_CAT: opts.visitor ? opts.visitor.isCat : false, + SEED: opts.randomSeed ? opts.randomSeed : '', + YMD: `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`, + AISCRIPT_DISABLED: !this.opts.enableAiScript, + NULL: null + }; + + this.eval(); + } + + @autobind + public eval() { + try { + this.vars.value = this.evaluateVars(); + } catch (e) { + //this.onError(e); + } + } + + @autobind + public interpolate(str: string) { + if (str == null) return null; + return str.replace(/{(.+?)}/g, match => { + const v = unref(this.vars)[match.slice(1, -1).trim()]; + return v == null ? 'NULL' : v.toString(); + }); + } + + @autobind + public callAiScript(fn: string) { + try { + if (this.aiscript) this.aiscript.execFn(this.aiscript.scope.get(fn), []); + } catch (e) {} + } + + @autobind + public registerCanvas(id: string, canvas: any) { + this.canvases[id] = canvas; + } + + @autobind + public updatePageVar(name: string, value: any) { + const pageVar = this.pageVars.find(v => v.name === name); + if (pageVar !== undefined) { + pageVar.value = value; + if (this.pageVarUpdatedCallback) { + if (this.aiscript) this.aiscript.execFn(this.pageVarUpdatedCallback, [values.STR(name), utils.jsToVal(value)]); + } + } else { + throw new HpmlError(`No such page var '${name}'`); + } + } + + @autobind + public updateRandomSeed(seed: string) { + this.opts.randomSeed = seed; + this.envVars.SEED = seed; + } + + @autobind + private _interpolateScope(str: string, scope: HpmlScope) { + return str.replace(/{(.+?)}/g, match => { + const v = scope.getState(match.slice(1, -1).trim()); + return v == null ? 'NULL' : v.toString(); + }); + } + + @autobind + public evaluateVars(): Record { + const values: Record = {}; + + for (const [k, v] of Object.entries(this.envVars)) { + values[k] = v; + } + + for (const v of this.pageVars) { + values[v.name] = v.value; + } + + for (const v of this.variables) { + values[v.name] = this.evaluate(v, new HpmlScope([values])); + } + + return values; + } + + @autobind + private evaluate(expr: Expr, scope: HpmlScope): any { + + if (isLiteralValue(expr)) { + if (expr.type === null) { + return null; + } + + if (expr.type === 'number') { + return parseInt((expr.value as any), 10); + } + + if (expr.type === 'text' || expr.type === 'multiLineText') { + return this._interpolateScope(expr.value || '', scope); + } + + if (expr.type === 'textList') { + return this._interpolateScope(expr.value || '', scope).trim().split('\n'); + } + + if (expr.type === 'ref') { + return scope.getState(expr.value); + } + + if (expr.type === 'aiScriptVar') { + if (this.aiscript) { + try { + return utils.valToJs(this.aiscript.scope.get(expr.value)); + } catch (e) { + return null; + } + } else { + return null; + } + } + + // Define user function + if (expr.type == 'fn') { + return { + slots: expr.value.slots.map(x => x.name), + exec: (slotArg: Record) => { + return this.evaluate(expr.value.expression, scope.createChildScope(slotArg, expr.id)); + } + } as Fn; + } + return; + } + + // Call user function + if (expr.type.startsWith('fn:')) { + const fnName = expr.type.split(':')[1]; + const fn = scope.getState(fnName); + const args = {} as Record; + for (let i = 0; i < fn.slots.length; i++) { + const name = fn.slots[i]; + args[name] = this.evaluate(expr.args[i], scope); + } + return fn.exec(args); + } + + if (expr.args === undefined) return null; + + const funcs = initHpmlLib(expr, scope, this.opts.randomSeed, this.opts.visitor); + + // Call function + const fnName = expr.type; + const fn = (funcs as any)[fnName]; + if (fn == null) { + throw new HpmlError(`No such function '${fnName}'`); + } else { + return fn(...expr.args.map(x => this.evaluate(x, scope))); + } + } +} diff --git a/packages/client/src/scripts/hpml/expr.ts b/packages/client/src/scripts/hpml/expr.ts new file mode 100644 index 0000000000..00e3ed118b --- /dev/null +++ b/packages/client/src/scripts/hpml/expr.ts @@ -0,0 +1,79 @@ +import { literalDefs, Type } from '.'; + +export type ExprBase = { + id: string; +}; + +// value + +export type EmptyValue = ExprBase & { + type: null; + value: null; +}; + +export type TextValue = ExprBase & { + type: 'text'; + value: string; +}; + +export type MultiLineTextValue = ExprBase & { + type: 'multiLineText'; + value: string; +}; + +export type TextListValue = ExprBase & { + type: 'textList'; + value: string; +}; + +export type NumberValue = ExprBase & { + type: 'number'; + value: number; +}; + +export type RefValue = ExprBase & { + type: 'ref'; + value: string; // value is variable name +}; + +export type AiScriptRefValue = ExprBase & { + type: 'aiScriptVar'; + value: string; // value is variable name +}; + +export type UserFnValue = ExprBase & { + type: 'fn'; + value: UserFnInnerValue; +}; +type UserFnInnerValue = { + slots: { + name: string; + type: Type; + }[]; + expression: Expr; +}; + +export type Value = + EmptyValue | TextValue | MultiLineTextValue | TextListValue | NumberValue | RefValue | AiScriptRefValue | UserFnValue; + +export function isLiteralValue(expr: Expr): expr is Value { + if (expr.type == null) return true; + if (literalDefs[expr.type]) return true; + return false; +} + +// call function + +export type CallFn = ExprBase & { // "fn:hoge" or string + type: string; + args: Expr[]; + value: null; +}; + +// variable +export type Variable = (Value | CallFn) & { + name: string; +}; + +// expression +export type Expr = Variable | Value | CallFn; diff --git a/packages/client/src/scripts/hpml/index.ts b/packages/client/src/scripts/hpml/index.ts new file mode 100644 index 0000000000..ac81eac2d9 --- /dev/null +++ b/packages/client/src/scripts/hpml/index.ts @@ -0,0 +1,103 @@ +/** + * Hpml + */ + +import autobind from 'autobind-decorator'; +import { Hpml } from './evaluator'; +import { funcDefs } from './lib'; + +export type Fn = { + slots: string[]; + exec: (args: Record) => ReturnType; +}; + +export type Type = 'string' | 'number' | 'boolean' | 'stringArray' | null; + +export const literalDefs: Record = { + text: { out: 'string', category: 'value', icon: 'fas fa-quote-right', }, + multiLineText: { out: 'string', category: 'value', icon: 'fas fa-align-left', }, + textList: { out: 'stringArray', category: 'value', icon: 'fas fa-list', }, + number: { out: 'number', category: 'value', icon: 'fas fa-sort-numeric-up', }, + ref: { out: null, category: 'value', icon: 'fas fa-magic', }, + aiScriptVar: { out: null, category: 'value', icon: 'fas fa-magic', }, + fn: { out: 'function', category: 'value', icon: 'fas fa-square-root-alt', }, +}; + +export const blockDefs = [ + ...Object.entries(literalDefs).map(([k, v]) => ({ + type: k, out: v.out, category: v.category, icon: v.icon + })), + ...Object.entries(funcDefs).map(([k, v]) => ({ + type: k, out: v.out, category: v.category, icon: v.icon + })) +]; + +export type PageVar = { name: string; value: any; type: Type; }; + +export const envVarsDef: Record = { + AI: 'string', + URL: 'string', + VERSION: 'string', + LOGIN: 'boolean', + NAME: 'string', + USERNAME: 'string', + USERID: 'string', + NOTES_COUNT: 'number', + FOLLOWERS_COUNT: 'number', + FOLLOWING_COUNT: 'number', + IS_CAT: 'boolean', + SEED: null, + YMD: 'string', + AISCRIPT_DISABLED: 'boolean', + NULL: null, +}; + +export class HpmlScope { + private layerdStates: Record[]; + public name: string; + + constructor(layerdStates: HpmlScope['layerdStates'], name?: HpmlScope['name']) { + this.layerdStates = layerdStates; + this.name = name || 'anonymous'; + } + + @autobind + public createChildScope(states: Record, name?: HpmlScope['name']): HpmlScope { + const layer = [states, ...this.layerdStates]; + return new HpmlScope(layer, name); + } + + /** + * 指定した名前の変数の値を取得します + * @param name 変数名 + */ + @autobind + public getState(name: string): any { + for (const later of this.layerdStates) { + const state = later[name]; + if (state !== undefined) { + return state; + } + } + + throw new HpmlError( + `No such variable '${name}' in scope '${this.name}'`, { + scope: this.layerdStates + }); + } +} + +export class HpmlError extends Error { + public info?: any; + + constructor(message: string, info?: any) { + super(message); + + this.info = info; + + // Maintains proper stack trace for where our error was thrown (only available on V8) + if (Error.captureStackTrace) { + Error.captureStackTrace(this, HpmlError); + } + } +} diff --git a/packages/client/src/scripts/hpml/lib.ts b/packages/client/src/scripts/hpml/lib.ts new file mode 100644 index 0000000000..2a1ac73a40 --- /dev/null +++ b/packages/client/src/scripts/hpml/lib.ts @@ -0,0 +1,246 @@ +import * as tinycolor from 'tinycolor2'; +import { Hpml } from './evaluator'; +import { values, utils } from '@syuilo/aiscript'; +import { Fn, HpmlScope } from '.'; +import { Expr } from './expr'; +import * as seedrandom from 'seedrandom'; + +/* TODO: https://www.chartjs.org/docs/latest/configuration/canvas-background.html#color +// https://stackoverflow.com/questions/38493564/chart-area-background-color-chartjs +Chart.pluginService.register({ + beforeDraw: (chart, easing) => { + if (chart.config.options.chartArea && chart.config.options.chartArea.backgroundColor) { + const ctx = chart.chart.ctx; + ctx.save(); + ctx.fillStyle = chart.config.options.chartArea.backgroundColor; + ctx.fillRect(0, 0, chart.chart.width, chart.chart.height); + ctx.restore(); + } + } +}); +*/ + +export function initAiLib(hpml: Hpml) { + return { + 'MkPages:updated': values.FN_NATIVE(([callback]) => { + hpml.pageVarUpdatedCallback = (callback as values.VFn); + }), + 'MkPages:get_canvas': values.FN_NATIVE(([id]) => { + utils.assertString(id); + const canvas = hpml.canvases[id.value]; + const ctx = canvas.getContext('2d'); + return values.OBJ(new Map([ + ['clear_rect', values.FN_NATIVE(([x, y, width, height]) => { ctx.clearRect(x.value, y.value, width.value, height.value); })], + ['fill_rect', values.FN_NATIVE(([x, y, width, height]) => { ctx.fillRect(x.value, y.value, width.value, height.value); })], + ['stroke_rect', values.FN_NATIVE(([x, y, width, height]) => { ctx.strokeRect(x.value, y.value, width.value, height.value); })], + ['fill_text', values.FN_NATIVE(([text, x, y, width]) => { ctx.fillText(text.value, x.value, y.value, width ? width.value : undefined); })], + ['stroke_text', values.FN_NATIVE(([text, x, y, width]) => { ctx.strokeText(text.value, x.value, y.value, width ? width.value : undefined); })], + ['set_line_width', values.FN_NATIVE(([width]) => { ctx.lineWidth = width.value; })], + ['set_font', values.FN_NATIVE(([font]) => { ctx.font = font.value; })], + ['set_fill_style', values.FN_NATIVE(([style]) => { ctx.fillStyle = style.value; })], + ['set_stroke_style', values.FN_NATIVE(([style]) => { ctx.strokeStyle = style.value; })], + ['begin_path', values.FN_NATIVE(() => { ctx.beginPath(); })], + ['close_path', values.FN_NATIVE(() => { ctx.closePath(); })], + ['move_to', values.FN_NATIVE(([x, y]) => { ctx.moveTo(x.value, y.value); })], + ['line_to', values.FN_NATIVE(([x, y]) => { ctx.lineTo(x.value, y.value); })], + ['arc', values.FN_NATIVE(([x, y, radius, startAngle, endAngle]) => { ctx.arc(x.value, y.value, radius.value, startAngle.value, endAngle.value); })], + ['rect', values.FN_NATIVE(([x, y, width, height]) => { ctx.rect(x.value, y.value, width.value, height.value); })], + ['fill', values.FN_NATIVE(() => { ctx.fill(); })], + ['stroke', values.FN_NATIVE(() => { ctx.stroke(); })], + ])); + }), + 'MkPages:chart': values.FN_NATIVE(([id, opts]) => { + /* TODO + utils.assertString(id); + utils.assertObject(opts); + const canvas = hpml.canvases[id.value]; + const color = getComputedStyle(document.documentElement).getPropertyValue('--accent'); + Chart.defaults.color = '#555'; + const chart = new Chart(canvas, { + type: opts.value.get('type').value, + data: { + labels: opts.value.get('labels').value.map(x => x.value), + datasets: opts.value.get('datasets').value.map(x => ({ + label: x.value.has('label') ? x.value.get('label').value : '', + data: x.value.get('data').value.map(x => x.value), + pointRadius: 0, + lineTension: 0, + borderWidth: 2, + borderColor: x.value.has('color') ? x.value.get('color') : color, + backgroundColor: tinycolor(x.value.has('color') ? x.value.get('color') : color).setAlpha(0.1).toRgbString(), + })) + }, + options: { + responsive: false, + devicePixelRatio: 1.5, + title: { + display: opts.value.has('title'), + text: opts.value.has('title') ? opts.value.get('title').value : '', + fontSize: 14, + }, + layout: { + padding: { + left: 32, + right: 32, + top: opts.value.has('title') ? 16 : 32, + bottom: 16 + } + }, + legend: { + display: opts.value.get('datasets').value.filter(x => x.value.has('label') && x.value.get('label').value).length === 0 ? false : true, + position: 'bottom', + labels: { + boxWidth: 16, + } + }, + tooltips: { + enabled: false, + }, + chartArea: { + backgroundColor: '#fff' + }, + ...(opts.value.get('type').value === 'radar' ? { + scale: { + ticks: { + display: opts.value.has('show_tick_label') ? opts.value.get('show_tick_label').value : false, + min: opts.value.has('min') ? opts.value.get('min').value : undefined, + max: opts.value.has('max') ? opts.value.get('max').value : undefined, + maxTicksLimit: 8, + }, + pointLabels: { + fontSize: 12 + } + } + } : { + scales: { + yAxes: [{ + ticks: { + display: opts.value.has('show_tick_label') ? opts.value.get('show_tick_label').value : true, + min: opts.value.has('min') ? opts.value.get('min').value : undefined, + max: opts.value.has('max') ? opts.value.get('max').value : undefined, + } + }] + } + }) + } + }); + */ + }) + }; +} + +export const funcDefs: Record = { + if: { in: ['boolean', 0, 0], out: 0, category: 'flow', icon: 'fas fa-share-alt', }, + for: { in: ['number', 'function'], out: null, category: 'flow', icon: 'fas fa-recycle', }, + not: { in: ['boolean'], out: 'boolean', category: 'logical', icon: 'fas fa-flag', }, + or: { in: ['boolean', 'boolean'], out: 'boolean', category: 'logical', icon: 'fas fa-flag', }, + and: { in: ['boolean', 'boolean'], out: 'boolean', category: 'logical', icon: 'fas fa-flag', }, + add: { in: ['number', 'number'], out: 'number', category: 'operation', icon: 'fas fa-plus', }, + subtract: { in: ['number', 'number'], out: 'number', category: 'operation', icon: 'fas fa-minus', }, + multiply: { in: ['number', 'number'], out: 'number', category: 'operation', icon: 'fas fa-times', }, + divide: { in: ['number', 'number'], out: 'number', category: 'operation', icon: 'fas fa-divide', }, + mod: { in: ['number', 'number'], out: 'number', category: 'operation', icon: 'fas fa-divide', }, + round: { in: ['number'], out: 'number', category: 'operation', icon: 'fas fa-calculator', }, + eq: { in: [0, 0], out: 'boolean', category: 'comparison', icon: 'fas fa-equals', }, + notEq: { in: [0, 0], out: 'boolean', category: 'comparison', icon: 'fas fa-not-equal', }, + gt: { in: ['number', 'number'], out: 'boolean', category: 'comparison', icon: 'fas fa-greater-than', }, + lt: { in: ['number', 'number'], out: 'boolean', category: 'comparison', icon: 'fas fa-less-than', }, + gtEq: { in: ['number', 'number'], out: 'boolean', category: 'comparison', icon: 'fas fa-greater-than-equal', }, + ltEq: { in: ['number', 'number'], out: 'boolean', category: 'comparison', icon: 'fas fa-less-than-equal', }, + strLen: { in: ['string'], out: 'number', category: 'text', icon: 'fas fa-quote-right', }, + strPick: { in: ['string', 'number'], out: 'string', category: 'text', icon: 'fas fa-quote-right', }, + strReplace: { in: ['string', 'string', 'string'], out: 'string', category: 'text', icon: 'fas fa-quote-right', }, + strReverse: { in: ['string'], out: 'string', category: 'text', icon: 'fas fa-quote-right', }, + join: { in: ['stringArray', 'string'], out: 'string', category: 'text', icon: 'fas fa-quote-right', }, + stringToNumber: { in: ['string'], out: 'number', category: 'convert', icon: 'fas fa-exchange-alt', }, + numberToString: { in: ['number'], out: 'string', category: 'convert', icon: 'fas fa-exchange-alt', }, + splitStrByLine: { in: ['string'], out: 'stringArray', category: 'convert', icon: 'fas fa-exchange-alt', }, + pick: { in: [null, 'number'], out: null, category: 'list', icon: 'fas fa-indent', }, + listLen: { in: [null], out: 'number', category: 'list', icon: 'fas fa-indent', }, + rannum: { in: ['number', 'number'], out: 'number', category: 'random', icon: 'fas fa-dice', }, + dailyRannum: { in: ['number', 'number'], out: 'number', category: 'random', icon: 'fas fa-dice', }, + seedRannum: { in: [null, 'number', 'number'], out: 'number', category: 'random', icon: 'fas fa-dice', }, + random: { in: ['number'], out: 'boolean', category: 'random', icon: 'fas fa-dice', }, + dailyRandom: { in: ['number'], out: 'boolean', category: 'random', icon: 'fas fa-dice', }, + seedRandom: { in: [null, 'number'], out: 'boolean', category: 'random', icon: 'fas fa-dice', }, + randomPick: { in: [0], out: 0, category: 'random', icon: 'fas fa-dice', }, + dailyRandomPick: { in: [0], out: 0, category: 'random', icon: 'fas fa-dice', }, + seedRandomPick: { in: [null, 0], out: 0, category: 'random', icon: 'fas fa-dice', }, + DRPWPM: { in: ['stringArray'], out: 'string', category: 'random', icon: 'fas fa-dice', }, // dailyRandomPickWithProbabilityMapping +}; + +export function initHpmlLib(expr: Expr, scope: HpmlScope, randomSeed: string, visitor?: any) { + + const date = new Date(); + const day = `${visitor ? visitor.id : ''} ${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`; + + const funcs: Record = { + not: (a: boolean) => !a, + or: (a: boolean, b: boolean) => a || b, + and: (a: boolean, b: boolean) => a && b, + eq: (a: any, b: any) => a === b, + notEq: (a: any, b: any) => a !== b, + gt: (a: number, b: number) => a > b, + lt: (a: number, b: number) => a < b, + gtEq: (a: number, b: number) => a >= b, + ltEq: (a: number, b: number) => a <= b, + if: (bool: boolean, a: any, b: any) => bool ? a : b, + for: (times: number, fn: Fn) => { + const result: any[] = []; + for (let i = 0; i < times; i++) { + result.push(fn.exec({ + [fn.slots[0]]: i + 1 + })); + } + return result; + }, + add: (a: number, b: number) => a + b, + subtract: (a: number, b: number) => a - b, + multiply: (a: number, b: number) => a * b, + divide: (a: number, b: number) => a / b, + mod: (a: number, b: number) => a % b, + round: (a: number) => Math.round(a), + strLen: (a: string) => a.length, + strPick: (a: string, b: number) => a[b - 1], + strReplace: (a: string, b: string, c: string) => a.split(b).join(c), + strReverse: (a: string) => a.split('').reverse().join(''), + join: (texts: string[], separator: string) => texts.join(separator || ''), + stringToNumber: (a: string) => parseInt(a), + numberToString: (a: number) => a.toString(), + splitStrByLine: (a: string) => a.split('\n'), + pick: (list: any[], i: number) => list[i - 1], + listLen: (list: any[]) => list.length, + random: (probability: number) => Math.floor(seedrandom(`${randomSeed}:${expr.id}`)() * 100) < probability, + rannum: (min: number, max: number) => min + Math.floor(seedrandom(`${randomSeed}:${expr.id}`)() * (max - min + 1)), + randomPick: (list: any[]) => list[Math.floor(seedrandom(`${randomSeed}:${expr.id}`)() * list.length)], + dailyRandom: (probability: number) => Math.floor(seedrandom(`${day}:${expr.id}`)() * 100) < probability, + dailyRannum: (min: number, max: number) => min + Math.floor(seedrandom(`${day}:${expr.id}`)() * (max - min + 1)), + dailyRandomPick: (list: any[]) => list[Math.floor(seedrandom(`${day}:${expr.id}`)() * list.length)], + seedRandom: (seed: any, probability: number) => Math.floor(seedrandom(seed)() * 100) < probability, + seedRannum: (seed: any, min: number, max: number) => min + Math.floor(seedrandom(seed)() * (max - min + 1)), + seedRandomPick: (seed: any, list: any[]) => list[Math.floor(seedrandom(seed)() * list.length)], + DRPWPM: (list: string[]) => { + const xs: any[] = []; + let totalFactor = 0; + for (const x of list) { + const parts = x.split(' '); + const factor = parseInt(parts.pop()!, 10); + const text = parts.join(' '); + totalFactor += factor; + xs.push({ factor, text }); + } + const r = seedrandom(`${day}:${expr.id}`)() * totalFactor; + let stackedFactor = 0; + for (const x of xs) { + if (r >= stackedFactor && r <= stackedFactor + x.factor) { + return x.text; + } else { + stackedFactor += x.factor; + } + } + return xs[0].text; + }, + }; + + return funcs; +} diff --git a/packages/client/src/scripts/hpml/type-checker.ts b/packages/client/src/scripts/hpml/type-checker.ts new file mode 100644 index 0000000000..9633b3cd01 --- /dev/null +++ b/packages/client/src/scripts/hpml/type-checker.ts @@ -0,0 +1,189 @@ +import autobind from 'autobind-decorator'; +import { Type, envVarsDef, PageVar } from '.'; +import { Expr, isLiteralValue, Variable } from './expr'; +import { funcDefs } from './lib'; + +type TypeError = { + arg: number; + expect: Type; + actual: Type; +}; + +/** + * Hpml type checker + */ +export class HpmlTypeChecker { + public variables: Variable[]; + public pageVars: PageVar[]; + + constructor(variables: HpmlTypeChecker['variables'] = [], pageVars: HpmlTypeChecker['pageVars'] = []) { + this.variables = variables; + this.pageVars = pageVars; + } + + @autobind + public typeCheck(v: Expr): TypeError | null { + if (isLiteralValue(v)) return null; + + const def = funcDefs[v.type || '']; + if (def == null) { + throw new Error('Unknown type: ' + v.type); + } + + const generic: Type[] = []; + + for (let i = 0; i < def.in.length; i++) { + const arg = def.in[i]; + const type = this.infer(v.args[i]); + if (type === null) continue; + + if (typeof arg === 'number') { + if (generic[arg] === undefined) { + generic[arg] = type; + } else if (type !== generic[arg]) { + return { + arg: i, + expect: generic[arg], + actual: type + }; + } + } else if (type !== arg) { + return { + arg: i, + expect: arg, + actual: type + }; + } + } + + return null; + } + + @autobind + public getExpectedType(v: Expr, slot: number): Type { + const def = funcDefs[v.type || '']; + if (def == null) { + throw new Error('Unknown type: ' + v.type); + } + + const generic: Type[] = []; + + for (let i = 0; i < def.in.length; i++) { + const arg = def.in[i]; + const type = this.infer(v.args[i]); + if (type === null) continue; + + if (typeof arg === 'number') { + if (generic[arg] === undefined) { + generic[arg] = type; + } + } + } + + if (typeof def.in[slot] === 'number') { + return generic[def.in[slot]] || null; + } else { + return def.in[slot]; + } + } + + @autobind + public infer(v: Expr): Type { + if (v.type === null) return null; + if (v.type === 'text') return 'string'; + if (v.type === 'multiLineText') return 'string'; + if (v.type === 'textList') return 'stringArray'; + if (v.type === 'number') return 'number'; + if (v.type === 'ref') { + const variable = this.variables.find(va => va.name === v.value); + if (variable) { + return this.infer(variable); + } + + const pageVar = this.pageVars.find(va => va.name === v.value); + if (pageVar) { + return pageVar.type; + } + + const envVar = envVarsDef[v.value || '']; + if (envVar !== undefined) { + return envVar; + } + + return null; + } + if (v.type === 'aiScriptVar') return null; + if (v.type === 'fn') return null; // todo + if (v.type.startsWith('fn:')) return null; // todo + + const generic: Type[] = []; + + const def = funcDefs[v.type]; + + for (let i = 0; i < def.in.length; i++) { + const arg = def.in[i]; + if (typeof arg === 'number') { + const type = this.infer(v.args[i]); + + if (generic[arg] === undefined) { + generic[arg] = type; + } else { + if (type !== generic[arg]) { + generic[arg] = null; + } + } + } + } + + if (typeof def.out === 'number') { + return generic[def.out]; + } else { + return def.out; + } + } + + @autobind + public getVarByName(name: string): Variable { + const v = this.variables.find(x => x.name === name); + if (v !== undefined) { + return v; + } else { + throw new Error(`No such variable '${name}'`); + } + } + + @autobind + public getVarsByType(type: Type): Variable[] { + if (type == null) return this.variables; + return this.variables.filter(x => (this.infer(x) === null) || (this.infer(x) === type)); + } + + @autobind + public getEnvVarsByType(type: Type): string[] { + if (type == null) return Object.keys(envVarsDef); + return Object.entries(envVarsDef).filter(([k, v]) => v === null || type === v).map(([k, v]) => k); + } + + @autobind + public getPageVarsByType(type: Type): string[] { + if (type == null) return this.pageVars.map(v => v.name); + return this.pageVars.filter(v => type === v.type).map(v => v.name); + } + + @autobind + public isUsedName(name: string) { + if (this.variables.some(v => v.name === name)) { + return true; + } + + if (this.pageVars.some(v => v.name === name)) { + return true; + } + + if (envVarsDef[name]) { + return true; + } + + return false; + } +} diff --git a/packages/client/src/scripts/i18n.ts b/packages/client/src/scripts/i18n.ts new file mode 100644 index 0000000000..4fa398763a --- /dev/null +++ b/packages/client/src/scripts/i18n.ts @@ -0,0 +1,29 @@ +export class I18n> { + public locale: T; + + constructor(locale: T) { + this.locale = locale; + + //#region BIND + this.t = this.t.bind(this); + //#endregion + } + + // string にしているのは、ドット区切りでのパス指定を許可するため + // なるべくこのメソッド使うよりもlocale直接参照の方がvueのキャッシュ効いてパフォーマンスが良いかも + public t(key: string, args?: Record): string { + try { + let str = key.split('.').reduce((o, i) => o[i], this.locale) as string; + + if (args) { + for (const [k, v] of Object.entries(args)) { + str = str.replace(`{${k}}`, v); + } + } + return str; + } catch (e) { + console.warn(`missing localization '${key}'`); + return key; + } + } +} diff --git a/packages/client/src/scripts/idb-proxy.ts b/packages/client/src/scripts/idb-proxy.ts new file mode 100644 index 0000000000..5f76ae30bb --- /dev/null +++ b/packages/client/src/scripts/idb-proxy.ts @@ -0,0 +1,37 @@ +// FirefoxのプライベートモードなどではindexedDBが使用不可能なので、 +// indexedDBが使えない環境ではlocalStorageを使う +import { + get as iget, + set as iset, + del as idel, +} from 'idb-keyval'; + +const fallbackName = (key: string) => `idbfallback::${key}`; + +let idbAvailable = typeof window !== 'undefined' ? !!window.indexedDB : true; + +if (idbAvailable) { + try { + await iset('idb-test', 'test'); + } catch (e) { + console.error('idb error', e); + idbAvailable = false; + } +} + +if (!idbAvailable) console.error('indexedDB is unavailable. It will use localStorage.'); + +export async function get(key: string) { + if (idbAvailable) return iget(key); + return JSON.parse(localStorage.getItem(fallbackName(key))); +} + +export async function set(key: string, val: any) { + if (idbAvailable) return iset(key, val); + return localStorage.setItem(fallbackName(key), JSON.stringify(val)); +} + +export async function del(key: string) { + if (idbAvailable) return idel(key); + return localStorage.removeItem(fallbackName(key)); +} diff --git a/packages/client/src/scripts/initialize-sw.ts b/packages/client/src/scripts/initialize-sw.ts new file mode 100644 index 0000000000..d6dbd5dbd4 --- /dev/null +++ b/packages/client/src/scripts/initialize-sw.ts @@ -0,0 +1,68 @@ +import { instance } from '@/instance'; +import { $i } from '@/account'; +import { api } from '@/os'; +import { lang } from '@/config'; + +export async function initializeSw() { + if (instance.swPublickey && + ('serviceWorker' in navigator) && + ('PushManager' in window) && + $i && $i.token) { + navigator.serviceWorker.register(`/sw.js`); + + navigator.serviceWorker.ready.then(registration => { + registration.active?.postMessage({ + msg: 'initialize', + lang, + }); + // SEE: https://developer.mozilla.org/en-US/docs/Web/API/PushManager/subscribe#Parameters + registration.pushManager.subscribe({ + userVisibleOnly: true, + applicationServerKey: urlBase64ToUint8Array(instance.swPublickey) + }).then(subscription => { + function encode(buffer: ArrayBuffer | null) { + return btoa(String.fromCharCode.apply(null, new Uint8Array(buffer))); + } + + // Register + api('sw/register', { + endpoint: subscription.endpoint, + auth: encode(subscription.getKey('auth')), + publickey: encode(subscription.getKey('p256dh')) + }); + }) + // When subscribe failed + .catch(async (err: Error) => { + // 通知が許可されていなかったとき + if (err.name === 'NotAllowedError') { + return; + } + + // 違うapplicationServerKey (または gcm_sender_id)のサブスクリプションが + // 既に存在していることが原因でエラーになった可能性があるので、 + // そのサブスクリプションを解除しておく + const subscription = await registration.pushManager.getSubscription(); + if (subscription) subscription.unsubscribe(); + }); + }); + } +} + +/** + * Convert the URL safe base64 string to a Uint8Array + * @param base64String base64 string + */ +function urlBase64ToUint8Array(base64String: string): Uint8Array { + const padding = '='.repeat((4 - base64String.length % 4) % 4); + const base64 = (base64String + padding) + .replace(/-/g, '+') + .replace(/_/g, '/'); + + const rawData = window.atob(base64); + const outputArray = new Uint8Array(rawData.length); + + for (let i = 0; i < rawData.length; ++i) { + outputArray[i] = rawData.charCodeAt(i); + } + return outputArray; +} diff --git a/packages/client/src/scripts/is-device-darkmode.ts b/packages/client/src/scripts/is-device-darkmode.ts new file mode 100644 index 0000000000..854f38e517 --- /dev/null +++ b/packages/client/src/scripts/is-device-darkmode.ts @@ -0,0 +1,3 @@ +export function isDeviceDarkmode() { + return window.matchMedia('(prefers-color-scheme: dark)').matches; +} diff --git a/packages/client/src/scripts/is-device-touch.ts b/packages/client/src/scripts/is-device-touch.ts new file mode 100644 index 0000000000..3f0bfefed2 --- /dev/null +++ b/packages/client/src/scripts/is-device-touch.ts @@ -0,0 +1 @@ +export const isDeviceTouch = 'maxTouchPoints' in navigator && navigator.maxTouchPoints > 0; diff --git a/packages/client/src/scripts/is-mobile.ts b/packages/client/src/scripts/is-mobile.ts new file mode 100644 index 0000000000..60cb59f91e --- /dev/null +++ b/packages/client/src/scripts/is-mobile.ts @@ -0,0 +1,2 @@ +const ua = navigator.userAgent.toLowerCase(); +export const isMobile = /mobile|iphone|ipad|android/.test(ua); diff --git a/packages/client/src/scripts/keycode.ts b/packages/client/src/scripts/keycode.ts new file mode 100644 index 0000000000..c127d54bb2 --- /dev/null +++ b/packages/client/src/scripts/keycode.ts @@ -0,0 +1,33 @@ +export default (input: string): string[] => { + if (Object.keys(aliases).some(a => a.toLowerCase() === input.toLowerCase())) { + const codes = aliases[input]; + return Array.isArray(codes) ? codes : [codes]; + } else { + return [input]; + } +}; + +export const aliases = { + 'esc': 'Escape', + 'enter': ['Enter', 'NumpadEnter'], + 'up': 'ArrowUp', + 'down': 'ArrowDown', + 'left': 'ArrowLeft', + 'right': 'ArrowRight', + 'plus': ['NumpadAdd', 'Semicolon'], +}; + +/*! +* Programatically add the following +*/ + +// lower case chars +for (let i = 97; i < 123; i++) { + const char = String.fromCharCode(i); + aliases[char] = `Key${char.toUpperCase()}`; +} + +// numbers +for (let i = 0; i < 10; i++) { + aliases[i] = [`Numpad${i}`, `Digit${i}`]; +} diff --git a/packages/client/src/scripts/loading.ts b/packages/client/src/scripts/loading.ts new file mode 100644 index 0000000000..4b0a560e34 --- /dev/null +++ b/packages/client/src/scripts/loading.ts @@ -0,0 +1,11 @@ +export default { + start: () => { + // TODO + }, + done: () => { + // TODO + }, + set: val => { + // TODO + } +}; diff --git a/packages/client/src/scripts/login-id.ts b/packages/client/src/scripts/login-id.ts new file mode 100644 index 0000000000..0f9c6be4a9 --- /dev/null +++ b/packages/client/src/scripts/login-id.ts @@ -0,0 +1,11 @@ +export function getUrlWithLoginId(url: string, loginId: string) { + const u = new URL(url, origin); + u.searchParams.append('loginId', loginId); + return u.toString(); +} + +export function getUrlWithoutLoginId(url: string) { + const u = new URL(url); + u.searchParams.delete('loginId'); + return u.toString(); +} diff --git a/packages/client/src/scripts/lookup-user.ts b/packages/client/src/scripts/lookup-user.ts new file mode 100644 index 0000000000..174fa9f879 --- /dev/null +++ b/packages/client/src/scripts/lookup-user.ts @@ -0,0 +1,37 @@ +import * as Acct from 'misskey-js/built/acct'; +import { i18n } from '@/i18n'; +import * as os from '@/os'; + +export async function lookupUser() { + const { canceled, result } = await os.dialog({ + title: i18n.locale.usernameOrUserId, + input: true + }); + if (canceled) return; + + const show = (user) => { + os.pageWindow(`/user-info/${user.id}`); + }; + + const usernamePromise = os.api('users/show', Acct.parse(result)); + const idPromise = os.api('users/show', { userId: result }); + let _notFound = false; + const notFound = () => { + if (_notFound) { + os.dialog({ + type: 'error', + text: i18n.locale.noSuchUser + }); + } else { + _notFound = true; + } + }; + usernamePromise.then(show).catch(e => { + if (e.code === 'NO_SUCH_USER') { + notFound(); + } + }); + idPromise.then(show).catch(e => { + notFound(); + }); +} diff --git a/packages/client/src/scripts/mfm-tags.ts b/packages/client/src/scripts/mfm-tags.ts new file mode 100644 index 0000000000..1b18210aa9 --- /dev/null +++ b/packages/client/src/scripts/mfm-tags.ts @@ -0,0 +1 @@ +export const MFM_TAGS = ['tada', 'jelly', 'twitch', 'shake', 'spin', 'jump', 'bounce', 'flip', 'x2', 'x3', 'x4', 'font', 'blur', 'rainbow', 'sparkle']; diff --git a/packages/client/src/scripts/paging.ts b/packages/client/src/scripts/paging.ts new file mode 100644 index 0000000000..ef63ecc450 --- /dev/null +++ b/packages/client/src/scripts/paging.ts @@ -0,0 +1,246 @@ +import { markRaw } from 'vue'; +import * as os from '@/os'; +import { onScrollTop, isTopVisible, getScrollPosition, getScrollContainer } from './scroll'; + +const SECOND_FETCH_LIMIT = 30; + +// reversed: items 配列の中身を逆順にする(新しい方が最後) + +export default (opts) => ({ + emits: ['queue'], + + data() { + return { + items: [], + queue: [], + offset: 0, + fetching: true, + moreFetching: false, + inited: false, + more: false, + backed: false, // 遡り中か否か + isBackTop: false, + }; + }, + + computed: { + empty(): boolean { + return this.items.length === 0 && !this.fetching && this.inited; + }, + + error(): boolean { + return !this.fetching && !this.inited; + }, + }, + + watch: { + pagination: { + handler() { + this.init(); + }, + deep: true + }, + + queue: { + handler(a, b) { + if (a.length === 0 && b.length === 0) return; + this.$emit('queue', this.queue.length); + }, + deep: true + } + }, + + created() { + opts.displayLimit = opts.displayLimit || 30; + this.init(); + }, + + activated() { + this.isBackTop = false; + }, + + deactivated() { + this.isBackTop = window.scrollY === 0; + }, + + methods: { + reload() { + this.items = []; + this.init(); + }, + + replaceItem(finder, data) { + const i = this.items.findIndex(finder); + this.items[i] = data; + }, + + removeItem(finder) { + const i = this.items.findIndex(finder); + this.items.splice(i, 1); + }, + + async init() { + this.queue = []; + this.fetching = true; + if (opts.before) opts.before(this); + let params = typeof this.pagination.params === 'function' ? this.pagination.params(true) : this.pagination.params; + if (params && params.then) params = await params; + if (params === null) return; + const endpoint = typeof this.pagination.endpoint === 'function' ? this.pagination.endpoint() : this.pagination.endpoint; + await os.api(endpoint, { + ...params, + limit: this.pagination.noPaging ? (this.pagination.limit || 10) : (this.pagination.limit || 10) + 1, + }).then(items => { + for (let i = 0; i < items.length; i++) { + const item = items[i]; + markRaw(item); + if (this.pagination.reversed) { + if (i === items.length - 2) item._shouldInsertAd_ = true; + } else { + if (i === 3) item._shouldInsertAd_ = true; + } + } + if (!this.pagination.noPaging && (items.length > (this.pagination.limit || 10))) { + items.pop(); + this.items = this.pagination.reversed ? [...items].reverse() : items; + this.more = true; + } else { + this.items = this.pagination.reversed ? [...items].reverse() : items; + this.more = false; + } + this.offset = items.length; + this.inited = true; + this.fetching = false; + if (opts.after) opts.after(this, null); + }, e => { + this.fetching = false; + if (opts.after) opts.after(this, e); + }); + }, + + async fetchMore() { + if (!this.more || this.fetching || this.moreFetching || this.items.length === 0) return; + this.moreFetching = true; + this.backed = true; + let params = typeof this.pagination.params === 'function' ? this.pagination.params(false) : this.pagination.params; + if (params && params.then) params = await params; + const endpoint = typeof this.pagination.endpoint === 'function' ? this.pagination.endpoint() : this.pagination.endpoint; + await os.api(endpoint, { + ...params, + limit: SECOND_FETCH_LIMIT + 1, + ...(this.pagination.offsetMode ? { + offset: this.offset, + } : { + untilId: this.pagination.reversed ? this.items[0].id : this.items[this.items.length - 1].id, + }), + }).then(items => { + for (let i = 0; i < items.length; i++) { + const item = items[i]; + markRaw(item); + if (this.pagination.reversed) { + if (i === items.length - 9) item._shouldInsertAd_ = true; + } else { + if (i === 10) item._shouldInsertAd_ = true; + } + } + if (items.length > SECOND_FETCH_LIMIT) { + items.pop(); + this.items = this.pagination.reversed ? [...items].reverse().concat(this.items) : this.items.concat(items); + this.more = true; + } else { + this.items = this.pagination.reversed ? [...items].reverse().concat(this.items) : this.items.concat(items); + this.more = false; + } + this.offset += items.length; + this.moreFetching = false; + }, e => { + this.moreFetching = false; + }); + }, + + async fetchMoreFeature() { + if (!this.more || this.fetching || this.moreFetching || this.items.length === 0) return; + this.moreFetching = true; + let params = typeof this.pagination.params === 'function' ? this.pagination.params(false) : this.pagination.params; + if (params && params.then) params = await params; + const endpoint = typeof this.pagination.endpoint === 'function' ? this.pagination.endpoint() : this.pagination.endpoint; + await os.api(endpoint, { + ...params, + limit: SECOND_FETCH_LIMIT + 1, + ...(this.pagination.offsetMode ? { + offset: this.offset, + } : { + sinceId: this.pagination.reversed ? this.items[0].id : this.items[this.items.length - 1].id, + }), + }).then(items => { + for (const item of items) { + markRaw(item); + } + if (items.length > SECOND_FETCH_LIMIT) { + items.pop(); + this.items = this.pagination.reversed ? [...items].reverse().concat(this.items) : this.items.concat(items); + this.more = true; + } else { + this.items = this.pagination.reversed ? [...items].reverse().concat(this.items) : this.items.concat(items); + this.more = false; + } + this.offset += items.length; + this.moreFetching = false; + }, e => { + this.moreFetching = false; + }); + }, + + prepend(item) { + if (this.pagination.reversed) { + const container = getScrollContainer(this.$el); + const pos = getScrollPosition(this.$el); + const viewHeight = container.clientHeight; + const height = container.scrollHeight; + const isBottom = (pos + viewHeight > height - 32); + if (isBottom) { + // オーバーフローしたら古いアイテムは捨てる + if (this.items.length >= opts.displayLimit) { + // このやり方だとVue 3.2以降アニメーションが動かなくなる + //this.items = this.items.slice(-opts.displayLimit); + while (this.items.length >= opts.displayLimit) { + this.items.shift(); + } + this.more = true; + } + } + this.items.push(item); + // TODO + } else { + const isTop = this.isBackTop || (document.body.contains(this.$el) && isTopVisible(this.$el)); + + if (isTop) { + // Prepend the item + this.items.unshift(item); + + // オーバーフローしたら古いアイテムは捨てる + if (this.items.length >= opts.displayLimit) { + // このやり方だとVue 3.2以降アニメーションが動かなくなる + //this.items = this.items.slice(0, opts.displayLimit); + while (this.items.length >= opts.displayLimit) { + this.items.pop(); + } + this.more = true; + } + } else { + this.queue.push(item); + onScrollTop(this.$el, () => { + for (const item of this.queue) { + this.prepend(item); + } + this.queue = []; + }); + } + } + }, + + append(item) { + this.items.push(item); + }, + } +}); diff --git a/packages/client/src/scripts/physics.ts b/packages/client/src/scripts/physics.ts new file mode 100644 index 0000000000..445b6296eb --- /dev/null +++ b/packages/client/src/scripts/physics.ts @@ -0,0 +1,152 @@ +import * as Matter from 'matter-js'; + +export function physics(container: HTMLElement) { + const containerWidth = container.offsetWidth; + const containerHeight = container.offsetHeight; + const containerCenterX = containerWidth / 2; + + // サイズ固定化(要らないかも?) + container.style.position = 'relative'; + container.style.boxSizing = 'border-box'; + container.style.width = `${containerWidth}px`; + container.style.height = `${containerHeight}px`; + + // create engine + const engine = Matter.Engine.create({ + constraintIterations: 4, + positionIterations: 8, + velocityIterations: 8, + }); + + const world = engine.world; + + // create renderer + const render = Matter.Render.create({ + engine: engine, + //element: document.getElementById('debug'), + options: { + width: containerWidth, + height: containerHeight, + background: 'transparent', // transparent to hide + wireframeBackground: 'transparent', // transparent to hide + } + }); + + // Disable to hide debug + Matter.Render.run(render); + + // create runner + const runner = Matter.Runner.create(); + Matter.Runner.run(runner, engine); + + const groundThickness = 1024; + const ground = Matter.Bodies.rectangle(containerCenterX, containerHeight + (groundThickness / 2), containerWidth, groundThickness, { + isStatic: true, + restitution: 0.1, + friction: 2 + }); + + //const wallRight = Matter.Bodies.rectangle(window.innerWidth+50, window.innerHeight/2, 100, window.innerHeight, wallopts); + //const wallLeft = Matter.Bodies.rectangle(-50, window.innerHeight/2, 100, window.innerHeight, wallopts); + + Matter.World.add(world, [ + ground, + //wallRight, + //wallLeft, + ]); + + const objEls = Array.from(container.children); + const objs = []; + for (const objEl of objEls) { + const left = objEl.dataset.physicsX ? parseInt(objEl.dataset.physicsX) : objEl.offsetLeft; + const top = objEl.dataset.physicsY ? parseInt(objEl.dataset.physicsY) : objEl.offsetTop; + + let obj; + if (objEl.classList.contains('_physics_circle_')) { + obj = Matter.Bodies.circle( + left + (objEl.offsetWidth / 2), + top + (objEl.offsetHeight / 2), + Math.max(objEl.offsetWidth, objEl.offsetHeight) / 2, + { + restitution: 0.5 + } + ); + } else { + const style = window.getComputedStyle(objEl); + obj = Matter.Bodies.rectangle( + left + (objEl.offsetWidth / 2), + top + (objEl.offsetHeight / 2), + objEl.offsetWidth, + objEl.offsetHeight, + { + chamfer: { radius: parseInt(style.borderRadius || '0', 10) }, + restitution: 0.5 + } + ); + } + objEl.id = obj.id; + objs.push(obj); + } + + Matter.World.add(engine.world, objs); + + // Add mouse control + + const mouse = Matter.Mouse.create(container); + const mouseConstraint = Matter.MouseConstraint.create(engine, { + mouse: mouse, + constraint: { + stiffness: 0.1, + render: { + visible: false + } + } + }); + + Matter.World.add(engine.world, mouseConstraint); + + // keep the mouse in sync with rendering + render.mouse = mouse; + + for (const objEl of objEls) { + objEl.style.position = `absolute`; + objEl.style.top = 0; + objEl.style.left = 0; + objEl.style.margin = 0; + } + + window.requestAnimationFrame(update); + + let stop = false; + + function update() { + for (const objEl of objEls) { + const obj = objs.find(obj => obj.id.toString() === objEl.id.toString()); + if (obj == null) continue; + + const x = (obj.position.x - objEl.offsetWidth / 2); + const y = (obj.position.y - objEl.offsetHeight / 2); + const angle = obj.angle; + objEl.style.transform = `translate(${x}px, ${y}px) rotate(${angle}rad)`; + } + + if (!stop) { + window.requestAnimationFrame(update); + } + } + + // 奈落に落ちたオブジェクトは消す + const intervalId = setInterval(() => { + for (const obj of objs) { + if (obj.position.y > (containerHeight + 1024)) Matter.World.remove(world, obj); + } + }, 1000 * 10); + + return { + stop: () => { + stop = true; + Matter.Runner.stop(runner); + clearInterval(intervalId); + } + }; +} diff --git a/packages/client/src/scripts/please-login.ts b/packages/client/src/scripts/please-login.ts new file mode 100644 index 0000000000..928f6ec0f4 --- /dev/null +++ b/packages/client/src/scripts/please-login.ts @@ -0,0 +1,14 @@ +import { $i } from '@/account'; +import { i18n } from '@/i18n'; +import { dialog } from '@/os'; + +export function pleaseLogin() { + if ($i) return; + + dialog({ + title: i18n.locale.signinRequired, + text: null + }); + + throw new Error('signin required'); +} diff --git a/packages/client/src/scripts/popout.ts b/packages/client/src/scripts/popout.ts new file mode 100644 index 0000000000..51b8d72868 --- /dev/null +++ b/packages/client/src/scripts/popout.ts @@ -0,0 +1,22 @@ +import * as config from '@/config'; + +export function popout(path: string, w?: HTMLElement) { + let url = path.startsWith('http://') || path.startsWith('https://') ? path : config.url + path; + url += '?zen'; // TODO: ちゃんとURLパースしてクエリ付ける + if (w) { + const position = w.getBoundingClientRect(); + const width = parseInt(getComputedStyle(w, '').width, 10); + const height = parseInt(getComputedStyle(w, '').height, 10); + const x = window.screenX + position.left; + const y = window.screenY + position.top; + window.open(url, url, + `width=${width}, height=${height}, top=${y}, left=${x}`); + } else { + const width = 400; + const height = 500; + const x = window.top.outerHeight / 2 + window.top.screenY - (height / 2); + const y = window.top.outerWidth / 2 + window.top.screenX - (width / 2); + window.open(url, url, + `width=${width}, height=${height}, top=${x}, left=${y}`); + } +} diff --git a/packages/client/src/scripts/reaction-picker.ts b/packages/client/src/scripts/reaction-picker.ts new file mode 100644 index 0000000000..e923326ece --- /dev/null +++ b/packages/client/src/scripts/reaction-picker.ts @@ -0,0 +1,41 @@ +import { Ref, ref } from 'vue'; +import { popup } from '@/os'; + +class ReactionPicker { + private src: Ref = ref(null); + private manualShowing = ref(false); + private onChosen?: Function; + private onClosed?: Function; + + constructor() { + // nop + } + + public async init() { + await popup(import('@/components/emoji-picker-dialog.vue'), { + src: this.src, + asReactionPicker: true, + manualShowing: this.manualShowing + }, { + done: reaction => { + this.onChosen!(reaction); + }, + close: () => { + this.manualShowing.value = false; + }, + closed: () => { + this.src.value = null; + this.onClosed!(); + } + }); + } + + public show(src: HTMLElement, onChosen: Function, onClosed: Function) { + this.src.value = src; + this.manualShowing.value = true; + this.onChosen = onChosen; + this.onClosed = onClosed; + } +} + +export const reactionPicker = new ReactionPicker(); diff --git a/packages/client/src/scripts/room/furniture.ts b/packages/client/src/scripts/room/furniture.ts new file mode 100644 index 0000000000..7734e32668 --- /dev/null +++ b/packages/client/src/scripts/room/furniture.ts @@ -0,0 +1,21 @@ +export type RoomInfo = { + roomType: string; + carpetColor: string; + furnitures: Furniture[]; +}; + +export type Furniture = { + id: string; // 同じ家具が複数ある場合にそれぞれを識別するためのIDであり、家具IDではない + type: string; // こっちが家具ID(chairとか) + position: { + x: number; + y: number; + z: number; + }; + rotation: { + x: number; + y: number; + z: number; + }; + props?: Record; +}; diff --git a/packages/client/src/scripts/room/furnitures.json5 b/packages/client/src/scripts/room/furnitures.json5 new file mode 100644 index 0000000000..4a40994107 --- /dev/null +++ b/packages/client/src/scripts/room/furnitures.json5 @@ -0,0 +1,407 @@ +// 家具メタデータ + +// 家具IDはglbファイル及びそのディレクトリ名と一致する必要があります + +// 家具にはユーザーが設定できるプロパティを設定可能です: +// +// props: { +// : +// } +// +// proptype一覧: +// * image ... 画像選択ダイアログを出し、その画像のURLが格納されます +// * color ... 色選択コントロールを出し、選択された色が格納されます + +// 家具にカスタムテクスチャを適用できるようにするには、textureプロパティに以下の追加の情報を含めます: +// 便宜上そのUVのどの部分にカスタムテクスチャを貼り合わせるかのエリアをテクスチャエリアと呼びます。 +// UVは1024*1024だと仮定します。 +// +// : { +// prop: <プロパティ名>, +// uv: { +// x: <テクスチャエリアX座標>, +// y: <テクスチャエリアY座標>, +// width: <テクスチャエリアの幅>, +// height: <テクスチャエリアの高さ>, +// }, +// } +// +// には、カスタムテクスチャを適用したいメッシュ名を指定します +// <プロパティ名>には、カスタムテクスチャとして使用する画像を格納するプロパティ(前述)名を指定します + +// 家具にカスタムカラーを適用できるようにするには、colorプロパティに以下の追加の情報を含めます: +// +// : <プロパティ名> +// +// には、カスタムカラーを適用したいマテリアル名を指定します +// <プロパティ名>には、カスタムカラーとして使用する色を格納するプロパティ(前述)名を指定します + +[ + { + id: "milk", + place: "floor" + }, + { + id: "bed", + place: "floor" + }, + { + id: "low-table", + place: "floor", + props: { + color: 'color' + }, + color: { + Table: 'color' + } + }, + { + id: "desk", + place: "floor", + props: { + color: 'color' + }, + color: { + Board: 'color' + } + }, + { + id: "chair", + place: "floor", + props: { + color: 'color' + }, + color: { + Chair: 'color' + } + }, + { + id: "chair2", + place: "floor", + props: { + color1: 'color', + color2: 'color' + }, + color: { + Cushion: 'color1', + Leg: 'color2' + } + }, + { + id: "fan", + place: "wall" + }, + { + id: "pc", + place: "floor" + }, + { + id: "plant", + place: "floor" + }, + { + id: "plant2", + place: "floor" + }, + { + id: "eraser", + place: "floor" + }, + { + id: "pencil", + place: "floor" + }, + { + id: "pudding", + place: "floor" + }, + { + id: "cardboard-box", + place: "floor" + }, + { + id: "cardboard-box2", + place: "floor" + }, + { + id: "cardboard-box3", + place: "floor" + }, + { + id: "book", + place: "floor", + props: { + color: 'color' + }, + color: { + Cover: 'color' + } + }, + { + id: "book2", + place: "floor" + }, + { + id: "piano", + place: "floor" + }, + { + id: "facial-tissue", + place: "floor" + }, + { + id: "server", + place: "floor" + }, + { + id: "moon", + place: "floor" + }, + { + id: "corkboard", + place: "wall" + }, + { + id: "mousepad", + place: "floor", + props: { + color: 'color' + }, + color: { + Pad: 'color' + } + }, + { + id: "monitor", + place: "floor", + props: { + screen: 'image' + }, + texture: { + Screen: { + prop: 'screen', + uv: { + x: 0, + y: 434, + width: 1024, + height: 588, + }, + }, + }, + }, + { + id: "tv", + place: "floor", + props: { + screen: 'image' + }, + texture: { + Screen: { + prop: 'screen', + uv: { + x: 0, + y: 434, + width: 1024, + height: 588, + }, + }, + }, + }, + { + id: "keyboard", + place: "floor" + }, + { + id: "carpet-stripe", + place: "floor", + props: { + color1: 'color', + color2: 'color' + }, + color: { + CarpetAreaA: 'color1', + CarpetAreaB: 'color2' + }, + }, + { + id: "mat", + place: "floor", + props: { + color: 'color' + }, + color: { + Mat: 'color' + } + }, + { + id: "color-box", + place: "floor", + props: { + color: 'color' + }, + color: { + main: 'color' + } + }, + { + id: "wall-clock", + place: "wall" + }, + { + id: "cube", + place: "floor", + props: { + color: 'color' + }, + color: { + Cube: 'color' + } + }, + { + id: "photoframe", + place: "wall", + props: { + photo: 'image', + color: 'color' + }, + texture: { + Photo: { + prop: 'photo', + uv: { + x: 0, + y: 342, + width: 1024, + height: 683, + }, + }, + }, + color: { + Frame: 'color' + } + }, + { + id: "pinguin", + place: "floor", + props: { + body: 'color', + belly: 'color' + }, + color: { + Body: 'body', + Belly: 'belly', + } + }, + { + id: "rubik-cube", + place: "floor", + }, + { + id: "poster-h", + place: "wall", + props: { + picture: 'image' + }, + texture: { + Poster: { + prop: 'picture', + uv: { + x: 0, + y: 277, + width: 1024, + height: 745, + }, + }, + }, + }, + { + id: "poster-v", + place: "wall", + props: { + picture: 'image' + }, + texture: { + Poster: { + prop: 'picture', + uv: { + x: 0, + y: 0, + width: 745, + height: 1024, + }, + }, + }, + }, + { + id: "sofa", + place: "floor", + props: { + color: 'color' + }, + color: { + Sofa: 'color' + } + }, + { + id: "spiral", + place: "floor", + props: { + color: 'color' + }, + color: { + Step: 'color' + } + }, + { + id: "bin", + place: "floor", + props: { + color: 'color' + }, + color: { + Bin: 'color' + } + }, + { + id: "cup-noodle", + place: "floor" + }, + { + id: "holo-display", + place: "floor", + props: { + image: 'image' + }, + texture: { + Image_Front: { + prop: 'image', + uv: { + x: 0, + y: 0, + width: 1024, + height: 1024, + }, + }, + Image_Back: { + prop: 'image', + uv: { + x: 0, + y: 0, + width: 1024, + height: 1024, + }, + }, + }, + }, + { + id: 'energy-drink', + place: "floor", + }, + { + id: 'doll-ai', + place: "floor", + }, + { + id: 'banknote', + place: "floor", + }, +] diff --git a/packages/client/src/scripts/room/room.ts b/packages/client/src/scripts/room/room.ts new file mode 100644 index 0000000000..7e04bec646 --- /dev/null +++ b/packages/client/src/scripts/room/room.ts @@ -0,0 +1,775 @@ +import autobind from 'autobind-decorator'; +import { v4 as uuid } from 'uuid'; +import * as THREE from 'three'; +import { GLTFLoader, GLTF } from 'three/examples/jsm/loaders/GLTFLoader'; +import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js'; +import { EffectComposer } from 'three/examples/jsm/postprocessing/EffectComposer.js'; +import { RenderPass } from 'three/examples/jsm/postprocessing/RenderPass.js'; +import { ShaderPass } from 'three/examples/jsm/postprocessing/ShaderPass.js'; +import { BloomPass } from 'three/examples/jsm/postprocessing/BloomPass.js'; +import { FXAAShader } from 'three/examples/jsm/shaders/FXAAShader.js'; +import { TransformControls } from 'three/examples/jsm/controls/TransformControls.js'; +import { Furniture, RoomInfo } from './furniture'; +import { query as urlQuery } from '@/scripts/url'; +const furnitureDefs = require('./furnitures.json5'); + +THREE.ImageUtils.crossOrigin = ''; + +type Options = { + graphicsQuality: Room['graphicsQuality']; + onChangeSelect: Room['onChangeSelect']; + useOrthographicCamera: boolean; +}; + +/** + * MisskeyRoom Core Engine + */ +export class Room { + private clock: THREE.Clock; + private scene: THREE.Scene; + private renderer: THREE.WebGLRenderer; + private camera: THREE.PerspectiveCamera | THREE.OrthographicCamera; + private controls: OrbitControls; + private composer: EffectComposer; + private mixers: THREE.AnimationMixer[] = []; + private furnitureControl: TransformControls; + private roomInfo: RoomInfo; + private graphicsQuality: 'cheep' | 'low' | 'medium' | 'high' | 'ultra'; + private roomObj: THREE.Object3D; + private objects: THREE.Object3D[] = []; + private selectedObject: THREE.Object3D = null; + private onChangeSelect: Function; + private isTransformMode = false; + private renderFrameRequestId: number; + + private get canvas(): HTMLCanvasElement { + return this.renderer.domElement; + } + + private get furnitures(): Furniture[] { + return this.roomInfo.furnitures; + } + + private set furnitures(furnitures: Furniture[]) { + this.roomInfo.furnitures = furnitures; + } + + private get enableShadow() { + return this.graphicsQuality != 'cheep'; + } + + private get usePostFXs() { + return this.graphicsQuality !== 'cheep' && this.graphicsQuality !== 'low'; + } + + private get shadowQuality() { + return ( + this.graphicsQuality === 'ultra' ? 16384 : + this.graphicsQuality === 'high' ? 8192 : + this.graphicsQuality === 'medium' ? 4096 : + this.graphicsQuality === 'low' ? 1024 : + 0); // cheep + } + + constructor(user, isMyRoom, roomInfo: RoomInfo, container: Element, options: Options) { + this.roomInfo = roomInfo; + this.graphicsQuality = options.graphicsQuality; + this.onChangeSelect = options.onChangeSelect; + + this.clock = new THREE.Clock(true); + + //#region Init a scene + this.scene = new THREE.Scene(); + + const width = container.clientWidth; + const height = container.clientHeight; + + //#region Init a renderer + this.renderer = new THREE.WebGLRenderer({ + antialias: false, + stencil: false, + alpha: false, + powerPreference: + this.graphicsQuality === 'ultra' ? 'high-performance' : + this.graphicsQuality === 'high' ? 'high-performance' : + this.graphicsQuality === 'medium' ? 'default' : + this.graphicsQuality === 'low' ? 'low-power' : + 'low-power' // cheep + }); + + this.renderer.setPixelRatio(window.devicePixelRatio); + this.renderer.setSize(width, height); + this.renderer.autoClear = false; + this.renderer.setClearColor(new THREE.Color(0x051f2d)); + this.renderer.shadowMap.enabled = this.enableShadow; + this.renderer.shadowMap.type = + this.graphicsQuality === 'ultra' ? THREE.PCFSoftShadowMap : + this.graphicsQuality === 'high' ? THREE.PCFSoftShadowMap : + this.graphicsQuality === 'medium' ? THREE.PCFShadowMap : + this.graphicsQuality === 'low' ? THREE.BasicShadowMap : + THREE.BasicShadowMap; // cheep + + container.insertBefore(this.canvas, container.firstChild); + //#endregion + + //#region Init a camera + this.camera = options.useOrthographicCamera + ? new THREE.OrthographicCamera( + width / - 2, width / 2, height / 2, height / - 2, -10, 10) + : new THREE.PerspectiveCamera(45, width / height); + + if (options.useOrthographicCamera) { + this.camera.position.x = 2; + this.camera.position.y = 2; + this.camera.position.z = 2; + this.camera.zoom = 100; + this.camera.updateProjectionMatrix(); + } else { + this.camera.position.x = 5; + this.camera.position.y = 2; + this.camera.position.z = 5; + } + + this.scene.add(this.camera); + //#endregion + + //#region AmbientLight + const ambientLight = new THREE.AmbientLight(0xffffff, 1); + this.scene.add(ambientLight); + //#endregion + + if (this.graphicsQuality !== 'cheep') { + //#region Room light + const roomLight = new THREE.SpotLight(0xffffff, 0.1); + + roomLight.position.set(0, 8, 0); + roomLight.castShadow = this.enableShadow; + roomLight.shadow.bias = -0.0001; + roomLight.shadow.mapSize.width = this.shadowQuality; + roomLight.shadow.mapSize.height = this.shadowQuality; + roomLight.shadow.camera.near = 0.1; + roomLight.shadow.camera.far = 9; + roomLight.shadow.camera.fov = 45; + + this.scene.add(roomLight); + //#endregion + } + + //#region Out light + const outLight1 = new THREE.SpotLight(0xffffff, 0.4); + outLight1.position.set(9, 3, -2); + outLight1.castShadow = this.enableShadow; + outLight1.shadow.bias = -0.001; // アクネ、アーチファクト対策 その代わりピーターパンが発生する可能性がある + outLight1.shadow.mapSize.width = this.shadowQuality; + outLight1.shadow.mapSize.height = this.shadowQuality; + outLight1.shadow.camera.near = 6; + outLight1.shadow.camera.far = 15; + outLight1.shadow.camera.fov = 45; + this.scene.add(outLight1); + + const outLight2 = new THREE.SpotLight(0xffffff, 0.2); + outLight2.position.set(-2, 3, 9); + outLight2.castShadow = false; + outLight2.shadow.bias = -0.001; // アクネ、アーチファクト対策 その代わりピーターパンが発生する可能性がある + outLight2.shadow.camera.near = 6; + outLight2.shadow.camera.far = 15; + outLight2.shadow.camera.fov = 45; + this.scene.add(outLight2); + //#endregion + + //#region Init a controller + this.controls = new OrbitControls(this.camera, this.canvas); + + this.controls.target.set(0, 1, 0); + this.controls.enableZoom = true; + this.controls.enablePan = isMyRoom; + this.controls.minPolarAngle = 0; + this.controls.maxPolarAngle = Math.PI / 2; + this.controls.minAzimuthAngle = 0; + this.controls.maxAzimuthAngle = Math.PI / 2; + this.controls.enableDamping = true; + this.controls.dampingFactor = 0.2; + //#endregion + + //#region POST FXs + if (!this.usePostFXs) { + this.composer = null; + } else { + const renderTarget = new THREE.WebGLRenderTarget(width, height, { + minFilter: THREE.LinearFilter, + magFilter: THREE.LinearFilter, + format: THREE.RGBFormat, + stencilBuffer: false, + }); + + const fxaa = new ShaderPass(FXAAShader); + fxaa.uniforms['resolution'].value = new THREE.Vector2(1 / width, 1 / height); + fxaa.renderToScreen = true; + + this.composer = new EffectComposer(this.renderer, renderTarget); + this.composer.addPass(new RenderPass(this.scene, this.camera)); + if (this.graphicsQuality === 'ultra') { + this.composer.addPass(new BloomPass(0.25, 30, 128.0, 512)); + } + this.composer.addPass(fxaa); + } + //#endregion + //#endregion + + //#region Label + //#region Avatar + const avatarUrl = `/proxy/?${urlQuery({ url: user.avatarUrl })}`; + + const textureLoader = new THREE.TextureLoader(); + textureLoader.crossOrigin = 'anonymous'; + + const iconTexture = textureLoader.load(avatarUrl); + iconTexture.wrapS = THREE.RepeatWrapping; + iconTexture.wrapT = THREE.RepeatWrapping; + iconTexture.anisotropy = 16; + + const avatarMaterial = new THREE.MeshBasicMaterial({ + map: iconTexture, + side: THREE.DoubleSide, + alphaTest: 0.5 + }); + + const iconGeometry = new THREE.PlaneGeometry(1, 1); + + const avatarObject = new THREE.Mesh(iconGeometry, avatarMaterial); + avatarObject.position.set(-3, 2.5, 2); + avatarObject.rotation.y = Math.PI / 2; + avatarObject.castShadow = false; + + this.scene.add(avatarObject); + //#endregion + + //#region Username + const name = user.username; + + new THREE.FontLoader().load('/assets/fonts/helvetiker_regular.typeface.json', font => { + const nameGeometry = new THREE.TextGeometry(name, { + size: 0.5, + height: 0, + curveSegments: 8, + font: font, + bevelThickness: 0, + bevelSize: 0, + bevelEnabled: false + }); + + const nameMaterial = new THREE.MeshLambertMaterial({ + color: 0xffffff + }); + + const nameObject = new THREE.Mesh(nameGeometry, nameMaterial); + nameObject.position.set(-3, 2.25, 1.25); + nameObject.rotation.y = Math.PI / 2; + nameObject.castShadow = false; + + this.scene.add(nameObject); + }); + //#endregion + //#endregion + + //#region Interaction + if (isMyRoom) { + this.furnitureControl = new TransformControls(this.camera, this.canvas); + this.scene.add(this.furnitureControl); + + // Hover highlight + this.canvas.onmousemove = this.onmousemove; + + // Click + this.canvas.onmousedown = this.onmousedown; + } + //#endregion + + //#region Init room + this.loadRoom(); + //#endregion + + //#region Load furnitures + for (const furniture of this.furnitures) { + this.loadFurniture(furniture).then(obj => { + this.scene.add(obj.scene); + this.objects.push(obj.scene); + }); + } + //#endregion + + // Start render + if (this.usePostFXs) { + this.renderWithPostFXs(); + } else { + this.renderWithoutPostFXs(); + } + } + + @autobind + private renderWithoutPostFXs() { + this.renderFrameRequestId = + window.requestAnimationFrame(this.renderWithoutPostFXs); + + // Update animations + const clock = this.clock.getDelta(); + for (const mixer of this.mixers) { + mixer.update(clock); + } + + this.controls.update(); + this.renderer.render(this.scene, this.camera); + } + + @autobind + private renderWithPostFXs() { + this.renderFrameRequestId = + window.requestAnimationFrame(this.renderWithPostFXs); + + // Update animations + const clock = this.clock.getDelta(); + for (const mixer of this.mixers) { + mixer.update(clock); + } + + this.controls.update(); + this.renderer.clear(); + this.composer.render(); + } + + @autobind + private loadRoom() { + const type = this.roomInfo.roomType; + new GLTFLoader().load(`/client-assets/room/rooms/${type}/${type}.glb`, gltf => { + gltf.scene.traverse(child => { + if (!(child instanceof THREE.Mesh)) return; + + child.receiveShadow = this.enableShadow; + + child.material = new THREE.MeshLambertMaterial({ + color: (child.material as THREE.MeshStandardMaterial).color, + map: (child.material as THREE.MeshStandardMaterial).map, + name: (child.material as THREE.MeshStandardMaterial).name, + }); + + // 異方性フィルタリング + if ((child.material as THREE.MeshLambertMaterial).map && this.graphicsQuality !== 'cheep') { + (child.material as THREE.MeshLambertMaterial).map.minFilter = THREE.LinearMipMapLinearFilter; + (child.material as THREE.MeshLambertMaterial).map.magFilter = THREE.LinearMipMapLinearFilter; + (child.material as THREE.MeshLambertMaterial).map.anisotropy = 8; + } + }); + + gltf.scene.position.set(0, 0, 0); + + this.scene.add(gltf.scene); + this.roomObj = gltf.scene; + if (this.roomInfo.roomType === 'default') { + this.applyCarpetColor(); + } + }); + } + + @autobind + private loadFurniture(furniture: Furniture) { + const def = furnitureDefs.find(d => d.id === furniture.type); + return new Promise((res, rej) => { + const loader = new GLTFLoader(); + loader.load(`/client-assets/room/furnitures/${furniture.type}/${furniture.type}.glb`, gltf => { + const model = gltf.scene; + + // Load animation + if (gltf.animations.length > 0) { + const mixer = new THREE.AnimationMixer(model); + this.mixers.push(mixer); + for (const clip of gltf.animations) { + mixer.clipAction(clip).play(); + } + } + + model.name = furniture.id; + model.position.x = furniture.position.x; + model.position.y = furniture.position.y; + model.position.z = furniture.position.z; + model.rotation.x = furniture.rotation.x; + model.rotation.y = furniture.rotation.y; + model.rotation.z = furniture.rotation.z; + + model.traverse(child => { + if (!(child instanceof THREE.Mesh)) return; + child.castShadow = this.enableShadow; + child.receiveShadow = this.enableShadow; + (child.material as THREE.MeshStandardMaterial).metalness = 0; + + // 異方性フィルタリング + if ((child.material as THREE.MeshStandardMaterial).map && this.graphicsQuality !== 'cheep') { + (child.material as THREE.MeshStandardMaterial).map.minFilter = THREE.LinearMipMapLinearFilter; + (child.material as THREE.MeshStandardMaterial).map.magFilter = THREE.LinearMipMapLinearFilter; + (child.material as THREE.MeshStandardMaterial).map.anisotropy = 8; + } + }); + + if (def.color) { // カスタムカラー + this.applyCustomColor(model); + } + + if (def.texture) { // カスタムテクスチャ + this.applyCustomTexture(model); + } + + res(gltf); + }, null, rej); + }); + } + + @autobind + private applyCarpetColor() { + this.roomObj.traverse(child => { + if (!(child instanceof THREE.Mesh)) return; + if (child.material && + (child.material as THREE.MeshStandardMaterial).name && + (child.material as THREE.MeshStandardMaterial).name === 'Carpet' + ) { + const colorHex = parseInt(this.roomInfo.carpetColor.substr(1), 16); + (child.material as THREE.MeshStandardMaterial).color.setHex(colorHex); + } + }); + } + + @autobind + private applyCustomColor(model: THREE.Object3D) { + const furniture = this.furnitures.find(furniture => furniture.id === model.name); + const def = furnitureDefs.find(d => d.id === furniture.type); + if (def.color == null) return; + model.traverse(child => { + if (!(child instanceof THREE.Mesh)) return; + for (const t of Object.keys(def.color)) { + if (!child.material || + !(child.material as THREE.MeshStandardMaterial).name || + (child.material as THREE.MeshStandardMaterial).name !== t + ) continue; + + const prop = def.color[t]; + const val = furniture.props ? furniture.props[prop] : undefined; + + if (val == null) continue; + + const colorHex = parseInt(val.substr(1), 16); + (child.material as THREE.MeshStandardMaterial).color.setHex(colorHex); + } + }); + } + + @autobind + private applyCustomTexture(model: THREE.Object3D) { + const furniture = this.furnitures.find(furniture => furniture.id === model.name); + const def = furnitureDefs.find(d => d.id === furniture.type); + if (def.texture == null) return; + + model.traverse(child => { + if (!(child instanceof THREE.Mesh)) return; + for (const t of Object.keys(def.texture)) { + if (child.name !== t) continue; + + const prop = def.texture[t].prop; + const val = furniture.props ? furniture.props[prop] : undefined; + + if (val == null) continue; + + const canvas = document.createElement('canvas'); + canvas.height = 1024; + canvas.width = 1024; + + child.material = new THREE.MeshLambertMaterial({ + emissive: 0x111111, + side: THREE.DoubleSide, + alphaTest: 0.5, + }); + + const img = new Image(); + img.crossOrigin = 'anonymous'; + img.onload = () => { + const uvInfo = def.texture[t].uv; + + const ctx = canvas.getContext('2d'); + ctx.drawImage(img, + 0, 0, img.width, img.height, + uvInfo.x, uvInfo.y, uvInfo.width, uvInfo.height); + + const texture = new THREE.Texture(canvas); + texture.wrapS = THREE.RepeatWrapping; + texture.wrapT = THREE.RepeatWrapping; + texture.anisotropy = 16; + texture.flipY = false; + + (child.material as THREE.MeshLambertMaterial).map = texture; + (child.material as THREE.MeshLambertMaterial).needsUpdate = true; + (child.material as THREE.MeshLambertMaterial).map.needsUpdate = true; + }; + img.src = val; + } + }); + } + + @autobind + private onmousemove(ev: MouseEvent) { + if (this.isTransformMode) return; + + const rect = (ev.target as HTMLElement).getBoundingClientRect(); + const x = ((ev.clientX - rect.left) / rect.width) * 2 - 1; + const y = -((ev.clientY - rect.top) / rect.height) * 2 + 1; + const pos = new THREE.Vector2(x, y); + + this.camera.updateMatrixWorld(); + + const raycaster = new THREE.Raycaster(); + raycaster.setFromCamera(pos, this.camera); + + const intersects = raycaster.intersectObjects(this.objects, true); + + for (const object of this.objects) { + if (this.isSelectedObject(object)) continue; + object.traverse(child => { + if (child instanceof THREE.Mesh) { + (child.material as THREE.MeshStandardMaterial).emissive.setHex(0x000000); + } + }); + } + + if (intersects.length > 0) { + const intersected = this.getRoot(intersects[0].object); + if (this.isSelectedObject(intersected)) return; + intersected.traverse(child => { + if (child instanceof THREE.Mesh) { + (child.material as THREE.MeshStandardMaterial).emissive.setHex(0x191919); + } + }); + } + } + + @autobind + private onmousedown(ev: MouseEvent) { + if (this.isTransformMode) return; + if (ev.target !== this.canvas || ev.button !== 0) return; + + const rect = (ev.target as HTMLElement).getBoundingClientRect(); + const x = ((ev.clientX - rect.left) / rect.width) * 2 - 1; + const y = -((ev.clientY - rect.top) / rect.height) * 2 + 1; + const pos = new THREE.Vector2(x, y); + + this.camera.updateMatrixWorld(); + + const raycaster = new THREE.Raycaster(); + raycaster.setFromCamera(pos, this.camera); + + const intersects = raycaster.intersectObjects(this.objects, true); + + for (const object of this.objects) { + object.traverse(child => { + if (child instanceof THREE.Mesh) { + (child.material as THREE.MeshStandardMaterial).emissive.setHex(0x000000); + } + }); + } + + if (intersects.length > 0) { + const selectedObj = this.getRoot(intersects[0].object); + this.selectFurniture(selectedObj); + } else { + this.selectedObject = null; + this.onChangeSelect(null); + } + } + + @autobind + private getRoot(obj: THREE.Object3D): THREE.Object3D { + let found = false; + let x = obj.parent; + while (!found) { + if (x.parent.parent == null) { + found = true; + } else { + x = x.parent; + } + } + return x; + } + + @autobind + private isSelectedObject(obj: THREE.Object3D): boolean { + if (this.selectedObject == null) { + return false; + } else { + return obj.name === this.selectedObject.name; + } + } + + @autobind + private selectFurniture(obj: THREE.Object3D) { + this.selectedObject = obj; + this.onChangeSelect(obj); + obj.traverse(child => { + if (child instanceof THREE.Mesh) { + (child.material as THREE.MeshStandardMaterial).emissive.setHex(0xff0000); + } + }); + } + + /** + * 家具の移動/回転モードにします + * @param type 移動か回転か + */ + @autobind + public enterTransformMode(type: 'translate' | 'rotate') { + this.isTransformMode = true; + this.furnitureControl.setMode(type); + this.furnitureControl.attach(this.selectedObject); + this.controls.enableRotate = false; + } + + /** + * 家具の移動/回転モードを終了します + */ + @autobind + public exitTransformMode() { + this.isTransformMode = false; + this.furnitureControl.detach(); + this.controls.enableRotate = true; + } + + /** + * 家具プロパティを更新します + * @param key プロパティ名 + * @param value 値 + */ + @autobind + public updateProp(key: string, value: any) { + const furniture = this.furnitures.find(furniture => furniture.id === this.selectedObject.name); + if (furniture.props == null) furniture.props = {}; + furniture.props[key] = value; + this.applyCustomColor(this.selectedObject); + this.applyCustomTexture(this.selectedObject); + } + + /** + * 部屋に家具を追加します + * @param type 家具の種類 + */ + @autobind + public addFurniture(type: string) { + const furniture = { + id: uuid(), + type: type, + position: { + x: 0, + y: 0, + z: 0, + }, + rotation: { + x: 0, + y: 0, + z: 0, + }, + }; + + this.furnitures.push(furniture); + + this.loadFurniture(furniture).then(obj => { + this.scene.add(obj.scene); + this.objects.push(obj.scene); + }); + } + + /** + * 現在選択されている家具を部屋から削除します + */ + @autobind + public removeFurniture() { + this.exitTransformMode(); + const obj = this.selectedObject; + this.scene.remove(obj); + this.objects = this.objects.filter(object => object.name !== obj.name); + this.furnitures = this.furnitures.filter(furniture => furniture.id !== obj.name); + this.selectedObject = null; + this.onChangeSelect(null); + } + + /** + * 全ての家具を部屋から削除します + */ + @autobind + public removeAllFurnitures() { + this.exitTransformMode(); + for (const obj of this.objects) { + this.scene.remove(obj); + } + this.objects = []; + this.furnitures = []; + this.selectedObject = null; + this.onChangeSelect(null); + } + + /** + * 部屋の床の色を変更します + * @param color 色 + */ + @autobind + public updateCarpetColor(color: string) { + this.roomInfo.carpetColor = color; + this.applyCarpetColor(); + } + + /** + * 部屋の種類を変更します + * @param type 種類 + */ + @autobind + public changeRoomType(type: string) { + this.roomInfo.roomType = type; + this.scene.remove(this.roomObj); + this.loadRoom(); + } + + /** + * 部屋データを取得します + */ + @autobind + public getRoomInfo() { + for (const obj of this.objects) { + const furniture = this.furnitures.find(f => f.id === obj.name); + furniture.position.x = obj.position.x; + furniture.position.y = obj.position.y; + furniture.position.z = obj.position.z; + furniture.rotation.x = obj.rotation.x; + furniture.rotation.y = obj.rotation.y; + furniture.rotation.z = obj.rotation.z; + } + + return this.roomInfo; + } + + /** + * 選択されている家具を取得します + */ + @autobind + public getSelectedObject() { + return this.selectedObject; + } + + @autobind + public findFurnitureById(id: string) { + return this.furnitures.find(furniture => furniture.id === id); + } + + /** + * レンダリングを終了します + */ + @autobind + public destroy() { + // Stop render loop + window.cancelAnimationFrame(this.renderFrameRequestId); + + this.controls.dispose(); + this.scene.dispose(); + } +} diff --git a/packages/client/src/scripts/scroll.ts b/packages/client/src/scripts/scroll.ts new file mode 100644 index 0000000000..621fe88105 --- /dev/null +++ b/packages/client/src/scripts/scroll.ts @@ -0,0 +1,80 @@ +type ScrollBehavior = 'auto' | 'smooth' | 'instant'; + +export function getScrollContainer(el: Element | null): Element | null { + if (el == null || el.tagName === 'BODY') return null; + const overflow = window.getComputedStyle(el).getPropertyValue('overflow'); + if (overflow.endsWith('auto')) { // xとyを個別に指定している場合、hidden auto みたいな値になる + return el; + } else { + return getScrollContainer(el.parentElement); + } +} + +export function getScrollPosition(el: Element | null): number { + const container = getScrollContainer(el); + return container == null ? window.scrollY : container.scrollTop; +} + +export function isTopVisible(el: Element | null): boolean { + const scrollTop = getScrollPosition(el); + const topPosition = el.offsetTop; // TODO: container内でのelの相対位置を取得できればより正確になる + + return scrollTop <= topPosition; +} + +export function onScrollTop(el: Element, cb) { + const container = getScrollContainer(el) || window; + const onScroll = ev => { + if (!document.body.contains(el)) return; + if (isTopVisible(el)) { + cb(); + container.removeEventListener('scroll', onScroll); + } + }; + container.addEventListener('scroll', onScroll, { passive: true }); +} + +export function onScrollBottom(el: Element, cb) { + const container = getScrollContainer(el) || window; + const onScroll = ev => { + if (!document.body.contains(el)) return; + const pos = getScrollPosition(el); + if (pos + el.clientHeight > el.scrollHeight - 1) { + cb(); + container.removeEventListener('scroll', onScroll); + } + }; + container.addEventListener('scroll', onScroll, { passive: true }); +} + +export function scroll(el: Element, options: { + top?: number; + left?: number; + behavior?: ScrollBehavior; +}) { + const container = getScrollContainer(el); + if (container == null) { + window.scroll(options); + } else { + container.scroll(options); + } +} + +export function scrollToTop(el: Element, options: { behavior?: ScrollBehavior; } = {}) { + scroll(el, { top: 0, ...options }); +} + +export function scrollToBottom(el: Element, options: { behavior?: ScrollBehavior; } = {}) { + scroll(el, { top: 99999, ...options }); // TODO: ちゃんと計算する +} + +export function isBottom(el: Element, asobi = 0) { + const container = getScrollContainer(el); + const current = container + ? el.scrollTop + el.offsetHeight + : window.scrollY + window.innerHeight; + const max = container + ? el.scrollHeight + : document.body.offsetHeight; + return current >= (max - asobi); +} diff --git a/packages/client/src/scripts/search.ts b/packages/client/src/scripts/search.ts new file mode 100644 index 0000000000..b28cccfab7 --- /dev/null +++ b/packages/client/src/scripts/search.ts @@ -0,0 +1,64 @@ +import * as os from '@/os'; +import { i18n } from '@/i18n'; +import { router } from '@/router'; + +export async function search() { + const { canceled, result: query } = await os.dialog({ + title: i18n.locale.search, + input: true + }); + if (canceled || query == null || query === '') return; + + const q = query.trim(); + + if (q.startsWith('@') && !q.includes(' ')) { + router.push(`/${q}`); + return; + } + + if (q.startsWith('#')) { + router.push(`/tags/${encodeURIComponent(q.substr(1))}`); + return; + } + + // like 2018/03/12 + if (/^[0-9]{4}\/[0-9]{2}\/[0-9]{2}/.test(q.replace(/-/g, '/'))) { + const date = new Date(q.replace(/-/g, '/')); + + // 日付しか指定されてない場合、例えば 2018/03/12 ならユーザーは + // 2018/03/12 のコンテンツを「含む」結果になることを期待するはずなので + // 23時間59分進める(そのままだと 2018/03/12 00:00:00 「まで」の + // 結果になってしまい、2018/03/12 のコンテンツは含まれない) + if (q.replace(/-/g, '/').match(/^[0-9]{4}\/[0-9]{2}\/[0-9]{2}$/)) { + date.setHours(23, 59, 59, 999); + } + + // TODO + //v.$root.$emit('warp', date); + os.dialog({ + icon: 'fas fa-history', + iconOnly: true, autoClose: true + }); + return; + } + + if (q.startsWith('https://')) { + const promise = os.api('ap/show', { + uri: q + }); + + os.promiseDialog(promise, null, null, i18n.locale.fetchingAsApObject); + + const res = await promise; + + if (res.type === 'User') { + router.push(`/@${res.object.username}@${res.object.host}`); + } else if (res.type === 'Note') { + router.push(`/notes/${res.object.id}`); + } + + return; + } + + router.push(`/search?q=${encodeURIComponent(q)}`); +} diff --git a/packages/client/src/scripts/select-file.ts b/packages/client/src/scripts/select-file.ts new file mode 100644 index 0000000000..5fbc545b26 --- /dev/null +++ b/packages/client/src/scripts/select-file.ts @@ -0,0 +1,89 @@ +import * as os from '@/os'; +import { i18n } from '@/i18n'; +import { defaultStore } from '@/store'; + +export function selectFile(src: any, label: string | null, multiple = false) { + return new Promise((res, rej) => { + const chooseFileFromPc = () => { + const input = document.createElement('input'); + input.type = 'file'; + input.multiple = multiple; + input.onchange = () => { + const promises = Array.from(input.files).map(file => os.upload(file, defaultStore.state.uploadFolder)); + + Promise.all(promises).then(driveFiles => { + res(multiple ? driveFiles : driveFiles[0]); + }).catch(e => { + os.dialog({ + type: 'error', + text: e + }); + }); + + // 一応廃棄 + (window as any).__misskey_input_ref__ = null; + }; + + // https://qiita.com/fukasawah/items/b9dc732d95d99551013d + // iOS Safari で正常に動かす為のおまじない + (window as any).__misskey_input_ref__ = input; + + input.click(); + }; + + const chooseFileFromDrive = () => { + os.selectDriveFile(multiple).then(files => { + res(files); + }); + }; + + const chooseFileFromUrl = () => { + os.dialog({ + title: i18n.locale.uploadFromUrl, + input: { + placeholder: i18n.locale.uploadFromUrlDescription + } + }).then(({ canceled, result: url }) => { + if (canceled) return; + + const marker = Math.random().toString(); // TODO: UUIDとか使う + + const connection = os.stream.useChannel('main'); + connection.on('urlUploadFinished', data => { + if (data.marker === marker) { + res(multiple ? [data.file] : data.file); + connection.dispose(); + } + }); + + os.api('drive/files/upload-from-url', { + url: url, + folderId: defaultStore.state.uploadFolder, + marker + }); + + os.dialog({ + title: i18n.locale.uploadFromUrlRequested, + text: i18n.locale.uploadFromUrlMayTakeTime + }); + }); + }; + + os.popupMenu([label ? { + text: label, + type: 'label' + } : undefined, { + text: i18n.locale.upload, + icon: 'fas fa-upload', + action: chooseFileFromPc + }, { + text: i18n.locale.fromDrive, + icon: 'fas fa-cloud', + action: chooseFileFromDrive + }, { + text: i18n.locale.fromUrl, + icon: 'fas fa-link', + action: chooseFileFromUrl + }], src); + }); +} diff --git a/packages/client/src/scripts/show-suspended-dialog.ts b/packages/client/src/scripts/show-suspended-dialog.ts new file mode 100644 index 0000000000..3bc4800030 --- /dev/null +++ b/packages/client/src/scripts/show-suspended-dialog.ts @@ -0,0 +1,10 @@ +import * as os from '@/os'; +import { i18n } from '@/i18n'; + +export function showSuspendedDialog() { + return os.dialog({ + type: 'error', + title: i18n.locale.yourAccountSuspendedTitle, + text: i18n.locale.yourAccountSuspendedDescription + }); +} diff --git a/packages/client/src/scripts/sound.ts b/packages/client/src/scripts/sound.ts new file mode 100644 index 0000000000..2b8279b3df --- /dev/null +++ b/packages/client/src/scripts/sound.ts @@ -0,0 +1,34 @@ +import { ColdDeviceStorage } from '@/store'; + +const cache = new Map(); + +export function getAudio(file: string, useCache = true): HTMLAudioElement { + let audio: HTMLAudioElement; + if (useCache && cache.has(file)) { + audio = cache.get(file); + } else { + audio = new Audio(`/client-assets/sounds/${file}.mp3`); + if (useCache) cache.set(file, audio); + } + return audio; +} + +export function setVolume(audio: HTMLAudioElement, volume: number): HTMLAudioElement { + const masterVolume = ColdDeviceStorage.get('sound_masterVolume'); + audio.volume = masterVolume - ((1 - volume) * masterVolume); + return audio; +} + +export function play(type: string) { + const sound = ColdDeviceStorage.get('sound_' + type as any); + if (sound.type == null) return; + playFile(sound.type, sound.volume); +} + +export function playFile(file: string, volume: number) { + const masterVolume = ColdDeviceStorage.get('sound_masterVolume'); + if (masterVolume === 0) return; + + const audio = setVolume(getAudio(file), volume); + audio.play(); +} diff --git a/packages/client/src/scripts/sticky-sidebar.ts b/packages/client/src/scripts/sticky-sidebar.ts new file mode 100644 index 0000000000..c67b8f37ac --- /dev/null +++ b/packages/client/src/scripts/sticky-sidebar.ts @@ -0,0 +1,50 @@ +export class StickySidebar { + private lastScrollTop = 0; + private container: HTMLElement; + private el: HTMLElement; + private spacer: HTMLElement; + private marginTop: number; + private isTop = false; + private isBottom = false; + private offsetTop: number; + private globalHeaderHeight: number = 59; + + constructor(container: StickySidebar['container'], marginTop = 0, globalHeaderHeight = 0) { + this.container = container; + this.el = this.container.children[0] as HTMLElement; + this.el.style.position = 'sticky'; + this.spacer = document.createElement('div'); + this.container.prepend(this.spacer); + this.marginTop = marginTop; + this.offsetTop = this.container.getBoundingClientRect().top; + this.globalHeaderHeight = globalHeaderHeight; + } + + public calc(scrollTop: number) { + if (scrollTop > this.lastScrollTop) { // downscroll + const overflow = Math.max(0, this.globalHeaderHeight + (this.el.clientHeight + this.marginTop) - window.innerHeight); + this.el.style.bottom = null; + this.el.style.top = `${-overflow + this.marginTop + this.globalHeaderHeight}px`; + + this.isBottom = (scrollTop + window.innerHeight) >= (this.el.offsetTop + this.el.clientHeight); + + if (this.isTop) { + this.isTop = false; + this.spacer.style.marginTop = `${Math.max(0, this.globalHeaderHeight + this.lastScrollTop + this.marginTop - this.offsetTop)}px`; + } + } else { // upscroll + const overflow = this.globalHeaderHeight + (this.el.clientHeight + this.marginTop) - window.innerHeight; + this.el.style.top = null; + this.el.style.bottom = `${-overflow}px`; + + this.isTop = scrollTop + this.marginTop + this.globalHeaderHeight <= this.el.offsetTop; + + if (this.isBottom) { + this.isBottom = false; + this.spacer.style.marginTop = `${this.globalHeaderHeight + this.lastScrollTop + this.marginTop - this.offsetTop - overflow}px`; + } + } + + this.lastScrollTop = scrollTop <= 0 ? 0 : scrollTop; + } +} diff --git a/packages/client/src/scripts/theme-editor.ts b/packages/client/src/scripts/theme-editor.ts new file mode 100644 index 0000000000..3d69d2836a --- /dev/null +++ b/packages/client/src/scripts/theme-editor.ts @@ -0,0 +1,81 @@ +import { v4 as uuid} from 'uuid'; + +import { themeProps, Theme } from './theme'; + +export type Default = null; +export type Color = string; +export type FuncName = 'alpha' | 'darken' | 'lighten'; +export type Func = { type: 'func'; name: FuncName; arg: number; value: string; }; +export type RefProp = { type: 'refProp'; key: string; }; +export type RefConst = { type: 'refConst'; key: string; }; +export type Css = { type: 'css'; value: string; }; + +export type ThemeValue = Color | Func | RefProp | RefConst | Css | Default; + +export type ThemeViewModel = [ string, ThemeValue ][]; + +export const fromThemeString = (str?: string) : ThemeValue => { + if (!str) return null; + if (str.startsWith(':')) { + const parts = str.slice(1).split('<'); + const name = parts[0] as FuncName; + const arg = parseFloat(parts[1]); + const value = parts[2].startsWith('@') ? parts[2].slice(1) : ''; + return { type: 'func', name, arg, value }; + } else if (str.startsWith('@')) { + return { + type: 'refProp', + key: str.slice(1), + }; + } else if (str.startsWith('$')) { + return { + type: 'refConst', + key: str.slice(1), + }; + } else if (str.startsWith('"')) { + return { + type: 'css', + value: str.substr(1).trim(), + }; + } else { + return str; + } +}; + +export const toThemeString = (value: Color | Func | RefProp | RefConst | Css) => { + if (typeof value === 'string') return value; + switch (value.type) { + case 'func': return `:${value.name}<${value.arg}<@${value.value}`; + case 'refProp': return `@${value.key}`; + case 'refConst': return `$${value.key}`; + case 'css': return `" ${value.value}`; + } +}; + +export const convertToMisskeyTheme = (vm: ThemeViewModel, name: string, desc: string, author: string, base: 'dark' | 'light'): Theme => { + const props = { } as { [key: string]: string }; + for (const [ key, value ] of vm) { + if (value === null) continue; + props[key] = toThemeString(value); + } + + return { + id: uuid(), + name, desc, author, props, base + }; +}; + +export const convertToViewModel = (theme: Theme): ThemeViewModel => { + const vm: ThemeViewModel = []; + // プロパティの登録 + vm.push(...themeProps.map(key => [ key, fromThemeString(theme.props[key])] as [ string, ThemeValue ])); + + // 定数の登録 + const consts = Object + .keys(theme.props) + .filter(k => k.startsWith('$')) + .map(k => [ k, fromThemeString(theme.props[k]) ] as [ string, ThemeValue ]); + + vm.push(...consts); + return vm; +}; diff --git a/packages/client/src/scripts/theme.ts b/packages/client/src/scripts/theme.ts new file mode 100644 index 0000000000..3b7f003d0f --- /dev/null +++ b/packages/client/src/scripts/theme.ts @@ -0,0 +1,127 @@ +import { globalEvents } from '@/events'; +import * as tinycolor from 'tinycolor2'; + +export type Theme = { + id: string; + name: string; + author: string; + desc?: string; + base?: 'dark' | 'light'; + props: Record; +}; + +export const lightTheme: Theme = require('@/themes/_light.json5'); +export const darkTheme: Theme = require('@/themes/_dark.json5'); + +export const themeProps = Object.keys(lightTheme.props).filter(key => !key.startsWith('X')); + +export const builtinThemes = [ + require('@/themes/l-light.json5'), + require('@/themes/l-apricot.json5'), + require('@/themes/l-rainy.json5'), + require('@/themes/l-vivid.json5'), + require('@/themes/l-sushi.json5'), + + require('@/themes/d-dark.json5'), + require('@/themes/d-persimmon.json5'), + require('@/themes/d-astro.json5'), + require('@/themes/d-future.json5'), + require('@/themes/d-botanical.json5'), + require('@/themes/d-pumpkin.json5'), + require('@/themes/d-black.json5'), +] as Theme[]; + +let timeout = null; + +export function applyTheme(theme: Theme, persist = true) { + if (timeout) clearTimeout(timeout); + + document.documentElement.classList.add('_themeChanging_'); + + timeout = setTimeout(() => { + document.documentElement.classList.remove('_themeChanging_'); + }, 1000); + + // Deep copy + const _theme = JSON.parse(JSON.stringify(theme)); + + if (_theme.base) { + const base = [lightTheme, darkTheme].find(x => x.id === _theme.base); + _theme.props = Object.assign({}, base.props, _theme.props); + } + + const props = compile(_theme); + + for (const tag of document.head.children) { + if (tag.tagName === 'META' && tag.getAttribute('name') === 'theme-color') { + tag.setAttribute('content', props['html']); + break; + } + } + + for (const [k, v] of Object.entries(props)) { + document.documentElement.style.setProperty(`--${k}`, v.toString()); + } + + if (persist) { + localStorage.setItem('theme', JSON.stringify(props)); + } + + // 色計算など再度行えるようにクライアント全体に通知 + globalEvents.emit('themeChanged'); +} + +function compile(theme: Theme): Record { + function getColor(val: string): tinycolor.Instance { + // ref (prop) + if (val[0] === '@') { + return getColor(theme.props[val.substr(1)]); + } + + // ref (const) + else if (val[0] === '$') { + return getColor(theme.props[val]); + } + + // func + else if (val[0] === ':') { + const parts = val.split('<'); + const func = parts.shift().substr(1); + const arg = parseFloat(parts.shift()); + const color = getColor(parts.join('<')); + + switch (func) { + case 'darken': return color.darken(arg); + case 'lighten': return color.lighten(arg); + case 'alpha': return color.setAlpha(arg); + case 'hue': return color.spin(arg); + case 'saturate': return color.saturate(arg); + } + } + + // other case + return tinycolor(val); + } + + const props = {}; + + for (const [k, v] of Object.entries(theme.props)) { + if (k.startsWith('$')) continue; // ignore const + + props[k] = v.startsWith('"') ? v.replace(/^"\s*/, '') : genValue(getColor(v)); + } + + return props; +} + +function genValue(c: tinycolor.Instance): string { + return c.toRgbString(); +} + +export function validateTheme(theme: Record): boolean { + if (theme.id == null || typeof theme.id !== 'string') return false; + if (theme.name == null || typeof theme.name !== 'string') return false; + if (theme.base == null || !['light', 'dark'].includes(theme.base)) return false; + if (theme.props == null || typeof theme.props !== 'object') return false; + return true; +} diff --git a/packages/client/src/scripts/time.ts b/packages/client/src/scripts/time.ts new file mode 100644 index 0000000000..34e8b6b17c --- /dev/null +++ b/packages/client/src/scripts/time.ts @@ -0,0 +1,39 @@ +const dateTimeIntervals = { + 'day': 86400000, + 'hour': 3600000, + 'ms': 1, +}; + +export function dateUTC(time: number[]): Date { + const d = time.length === 2 ? Date.UTC(time[0], time[1]) + : time.length === 3 ? Date.UTC(time[0], time[1], time[2]) + : time.length === 4 ? Date.UTC(time[0], time[1], time[2], time[3]) + : time.length === 5 ? Date.UTC(time[0], time[1], time[2], time[3], time[4]) + : time.length === 6 ? Date.UTC(time[0], time[1], time[2], time[3], time[4], time[5]) + : time.length === 7 ? Date.UTC(time[0], time[1], time[2], time[3], time[4], time[5], time[6]) + : null; + + if (!d) throw 'wrong number of arguments'; + + return new Date(d); +} + +export function isTimeSame(a: Date, b: Date): boolean { + return a.getTime() === b.getTime(); +} + +export function isTimeBefore(a: Date, b: Date): boolean { + return (a.getTime() - b.getTime()) < 0; +} + +export function isTimeAfter(a: Date, b: Date): boolean { + return (a.getTime() - b.getTime()) > 0; +} + +export function addTime(x: Date, value: number, span: keyof typeof dateTimeIntervals = 'ms'): Date { + return new Date(x.getTime() + (value * dateTimeIntervals[span])); +} + +export function subtractTime(x: Date, value: number, span: keyof typeof dateTimeIntervals = 'ms'): Date { + return new Date(x.getTime() - (value * dateTimeIntervals[span])); +} diff --git a/packages/client/src/scripts/twemoji-base.ts b/packages/client/src/scripts/twemoji-base.ts new file mode 100644 index 0000000000..cd50311b15 --- /dev/null +++ b/packages/client/src/scripts/twemoji-base.ts @@ -0,0 +1 @@ +export const twemojiSvgBase = '/twemoji'; diff --git a/packages/client/src/scripts/unison-reload.ts b/packages/client/src/scripts/unison-reload.ts new file mode 100644 index 0000000000..59af584c1b --- /dev/null +++ b/packages/client/src/scripts/unison-reload.ts @@ -0,0 +1,15 @@ +// SafariがBroadcastChannel未実装なのでライブラリを使う +import { BroadcastChannel } from 'broadcast-channel'; + +export const reloadChannel = new BroadcastChannel('reload'); + +// BroadcastChannelを用いて、クライアントが一斉にreloadするようにします。 +export function unisonReload(path?: string) { + if (path !== undefined) { + reloadChannel.postMessage(path); + location.href = path; + } else { + reloadChannel.postMessage(null); + location.reload(); + } +} diff --git a/packages/client/src/scripts/url.ts b/packages/client/src/scripts/url.ts new file mode 100644 index 0000000000..c7f2b7c1e7 --- /dev/null +++ b/packages/client/src/scripts/url.ts @@ -0,0 +1,13 @@ +export function query(obj: {}): string { + const params = Object.entries(obj) + .filter(([, v]) => Array.isArray(v) ? v.length : v !== undefined) + .reduce((a, [k, v]) => (a[k] = v, a), {} as Record); + + return Object.entries(params) + .map((e) => `${e[0]}=${encodeURIComponent(e[1])}`) + .join('&'); +} + +export function appendQuery(url: string, query: string): string { + return `${url}${/\?/.test(url) ? url.endsWith('?') ? '' : '&' : '?'}${query}`; +} diff --git a/packages/client/src/store.ts b/packages/client/src/store.ts new file mode 100644 index 0000000000..955d94a074 --- /dev/null +++ b/packages/client/src/store.ts @@ -0,0 +1,318 @@ +import { markRaw, ref } from 'vue'; +import { Storage } from './pizzax'; +import { Theme } from './scripts/theme'; + +export const postFormActions = []; +export const userActions = []; +export const noteActions = []; +export const noteViewInterruptors = []; +export const notePostInterruptors = []; + +// TODO: それぞれいちいちwhereとかdefaultというキーを付けなきゃいけないの冗長なのでなんとかする(ただ型定義が面倒になりそう) +// あと、現行の定義の仕方なら「whereが何であるかに関わらずキー名の重複不可」という制約を付けられるメリットもあるからそのメリットを引き継ぐ方法も考えないといけない +export const defaultStore = markRaw(new Storage('base', { + tutorial: { + where: 'account', + default: 0 + }, + keepCw: { + where: 'account', + default: false + }, + showFullAcct: { + where: 'account', + default: false + }, + rememberNoteVisibility: { + where: 'account', + default: false + }, + defaultNoteVisibility: { + where: 'account', + default: 'public' + }, + defaultNoteLocalOnly: { + where: 'account', + default: false + }, + uploadFolder: { + where: 'account', + default: null as string | null + }, + pastedFileName: { + where: 'account', + default: 'yyyy-MM-dd HH-mm-ss [{{number}}]' + }, + memo: { + where: 'account', + default: null + }, + reactions: { + where: 'account', + default: ['👍', '❤️', '😆', '🤔', '😮', '🎉', '💢', '😥', '😇', '🍮'] + }, + mutedWords: { + where: 'account', + default: [] + }, + mutedAds: { + where: 'account', + default: [] as string[] + }, + + menu: { + where: 'deviceAccount', + default: [ + 'notifications', + 'messaging', + 'drive', + 'followRequests', + '-', + 'gallery', + 'featured', + 'explore', + 'announcements', + 'search', + '-', + 'ui', + ] + }, + visibility: { + where: 'deviceAccount', + default: 'public' as 'public' | 'home' | 'followers' | 'specified' + }, + localOnly: { + where: 'deviceAccount', + default: false + }, + widgets: { + where: 'deviceAccount', + default: [] as { + name: string; + id: string; + place: string | null; + data: Record; + }[] + }, + tl: { + where: 'deviceAccount', + default: { + src: 'home', + arg: null + } + }, + + serverDisconnectedBehavior: { + where: 'device', + default: 'quiet' as 'quiet' | 'reload' | 'dialog' + }, + nsfw: { + where: 'device', + default: 'respect' as 'respect' | 'force' | 'ignore' + }, + animation: { + where: 'device', + default: true + }, + animatedMfm: { + where: 'device', + default: true + }, + loadRawImages: { + where: 'device', + default: false + }, + imageNewTab: { + where: 'device', + default: false + }, + disableShowingAnimatedImages: { + where: 'device', + default: false + }, + disablePagesScript: { + where: 'device', + default: false + }, + useOsNativeEmojis: { + where: 'device', + default: false + }, + useBlurEffectForModal: { + where: 'device', + default: true + }, + useBlurEffect: { + where: 'device', + default: true + }, + showFixedPostForm: { + where: 'device', + default: false + }, + enableInfiniteScroll: { + where: 'device', + default: true + }, + useReactionPickerForContextMenu: { + where: 'device', + default: true + }, + showGapBetweenNotesInTimeline: { + where: 'device', + default: false + }, + darkMode: { + where: 'device', + default: false + }, + instanceTicker: { + where: 'device', + default: 'remote' as 'none' | 'remote' | 'always' + }, + reactionPickerWidth: { + where: 'device', + default: 1 + }, + reactionPickerHeight: { + where: 'device', + default: 1 + }, + recentlyUsedEmojis: { + where: 'device', + default: [] as string[] + }, + recentlyUsedUsers: { + where: 'device', + default: [] as string[] + }, + defaultSideView: { + where: 'device', + default: false + }, + menuDisplay: { + where: 'device', + default: 'sideFull' as 'sideFull' | 'sideIcon' | 'top' + }, + reportError: { + where: 'device', + default: false + }, + squareAvatars: { + where: 'device', + default: false + }, + postFormWithHashtags: { + where: 'device', + default: false + }, + postFormHashtags: { + where: 'device', + default: '' + }, + aiChanMode: { + where: 'device', + default: false + }, +})); + +// TODO: 他のタブと永続化されたstateを同期 + +const PREFIX = 'miux:'; + +type Plugin = { + id: string; + name: string; + active: boolean; + configData: Record; + token: string; + ast: any[]; +}; + +/** + * 常にメモリにロードしておく必要がないような設定情報を保管するストレージ(非リアクティブ) + */ +export class ColdDeviceStorage { + public static default = { + lightTheme: require('@/themes/l-light.json5') as Theme, + darkTheme: require('@/themes/d-dark.json5') as Theme, + syncDeviceDarkMode: true, + chatOpenBehavior: 'page' as 'page' | 'window' | 'popout', + plugins: [] as Plugin[], + mediaVolume: 0.5, + sound_masterVolume: 0.3, + sound_note: { type: 'syuilo/down', volume: 1 }, + sound_noteMy: { type: 'syuilo/up', volume: 1 }, + sound_notification: { type: 'syuilo/pope2', volume: 1 }, + sound_chat: { type: 'syuilo/pope1', volume: 1 }, + sound_chatBg: { type: 'syuilo/waon', volume: 1 }, + sound_antenna: { type: 'syuilo/triple', volume: 1 }, + sound_channel: { type: 'syuilo/square-pico', volume: 1 }, + sound_reversiPutBlack: { type: 'syuilo/kick', volume: 0.3 }, + sound_reversiPutWhite: { type: 'syuilo/snare', volume: 0.3 }, + roomGraphicsQuality: 'medium' as 'cheep' | 'low' | 'medium' | 'high' | 'ultra', + roomUseOrthographicCamera: true, + }; + + public static watchers = []; + + public static get(key: T): typeof ColdDeviceStorage.default[T] { + // TODO: indexedDBにする + // ただしその際はnullチェックではなくキー存在チェックにしないとダメ + // (indexedDBはnullを保存できるため、ユーザーが意図してnullを格納した可能性がある) + const value = localStorage.getItem(PREFIX + key); + if (value == null) { + return ColdDeviceStorage.default[key]; + } else { + return JSON.parse(value); + } + } + + public static set(key: T, value: typeof ColdDeviceStorage.default[T]): void { + localStorage.setItem(PREFIX + key, JSON.stringify(value)); + + for (const watcher of this.watchers) { + if (watcher.key === key) watcher.callback(value); + } + } + + public static watch(key, callback) { + this.watchers.push({ key, callback }); + } + + // TODO: VueのcustomRef使うと良い感じになるかも + public static ref(key: T) { + const v = ColdDeviceStorage.get(key); + const r = ref(v); + // TODO: このままではwatcherがリークするので開放する方法を考える + this.watch(key, v => { + r.value = v; + }); + return r; + } + + /** + * 特定のキーの、簡易的なgetter/setterを作ります + * 主にvue場で設定コントロールのmodelとして使う用 + */ + public static makeGetterSetter(key: K) { + // TODO: VueのcustomRef使うと良い感じになるかも + const valueRef = ColdDeviceStorage.ref(key); + return { + get: () => { + return valueRef.value; + }, + set: (value: unknown) => { + const val = value; + ColdDeviceStorage.set(key, val); + } + }; + } +} + +// このファイルに書きたくないけどここに書かないと何故かVeturが認識しない +declare module '@vue/runtime-core' { + interface ComponentCustomProperties { + $store: typeof defaultStore; + } +} diff --git a/packages/client/src/style.scss b/packages/client/src/style.scss new file mode 100644 index 0000000000..951d5a14f3 --- /dev/null +++ b/packages/client/src/style.scss @@ -0,0 +1,562 @@ +@charset "utf-8"; + +:root { + --radius: 12px; + --marginFull: 16px; + --marginHalf: 10px; + + --margin: var(--marginFull); + + @media (max-width: 500px) { + --margin: var(--marginHalf); + } + + //--ad: rgb(255 169 0 / 10%); +} + +::selection { + color: #fff; + background-color: var(--accent); +} + +html { + touch-action: manipulation; + background-color: var(--bg); + background-attachment: fixed; + background-size: cover; + background-position: center; + color: var(--fg); + overflow: auto; + overflow-wrap: break-word; + font-family: "BIZ UDGothic", Roboto, HelveticaNeue, Arial, sans-serif; + line-height: 1.35; + text-size-adjust: 100%; + tab-size: 2; + + &, * { + scrollbar-color: var(--scrollbarHandle) inherit; + scrollbar-width: thin; + + &:hover { + scrollbar-color: var(--scrollbarHandleHover) inherit; + } + + &:active { + scrollbar-color: var(--accent) inherit; + } + + &::-webkit-scrollbar { + width: 6px; + height: 6px; + } + + &::-webkit-scrollbar-track { + background: inherit; + } + + &::-webkit-scrollbar-thumb { + background: var(--scrollbarHandle); + + &:hover { + background: var(--scrollbarHandleHover); + } + + &:active { + background: var(--accent); + } + } + } + + &.f-small { + font-size: 0.9em; + } + + &.f-large { + font-size: 1.1em; + } + + &.f-veryLarge { + font-size: 1.2em; + } + + &.useSystemFont { + font-family: sans-serif; + } +} + +html._themeChanging_ { + &, * { + transition: background 1s ease, border 1s ease !important; + } +} + +html, body { + margin: 0; + padding: 0; + scroll-behavior: smooth; +} + +a { + text-decoration: none; + cursor: pointer; + color: inherit; + tap-highlight-color: transparent; + -webkit-tap-highlight-color: transparent; + + &:hover { + text-decoration: underline; + } +} + +textarea, input { + tap-highlight-color: transparent; + -webkit-tap-highlight-color: transparent; +} + +optgroup, option { + background: var(--panel); + color: var(--fg); +} + +hr { + margin: var(--margin) 0 var(--margin) 0; + border: none; + height: 1px; + background: var(--divider); +} + +._noSelect { + user-select: none; + -webkit-user-select: none; + -webkit-touch-callout: none; +} + +._ghost { + &, * { + @extend ._noSelect; + pointer-events: none; + } +} + +._modalBg { + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + background: var(--modalBg); + -webkit-backdrop-filter: var(--modalBgFilter); + backdrop-filter: var(--modalBgFilter); +} + +._shadow { + box-shadow: 0px 4px 32px var(--shadow) !important; +} + +._button { + appearance: none; + display: inline-block; + padding: 0; + margin: 0; // for Safari + background: none; + border: none; + cursor: pointer; + color: inherit; + touch-action: manipulation; + tap-highlight-color: transparent; + -webkit-tap-highlight-color: transparent; + font-size: 1em; + font-family: inherit; + line-height: inherit; + + &, * { + @extend ._noSelect; + } + + * { + pointer-events: none; + } + + &:focus-visible { + outline: none; + } + + &:disabled { + opacity: 0.5; + cursor: default; + } +} + +._buttonPrimary { + @extend ._button; + color: var(--fgOnAccent); + background: var(--accent); + + &:not(:disabled):hover { + background: var(--X8); + } + + &:not(:disabled):active { + background: var(--X9); + } +} + +._buttonGradate { + @extend ._buttonPrimary; + color: var(--fgOnAccent); + background: linear-gradient(90deg, var(--buttonGradateA), var(--buttonGradateB)); + + &:not(:disabled):hover { + background: linear-gradient(90deg, var(--X8), var(--X8)); + } + + &:not(:disabled):active { + background: linear-gradient(90deg, var(--X8), var(--X8)); + } +} + +._help { + color: var(--accent); + cursor: help +} + +._textButton { + @extend ._button; + color: var(--accent); + + &:not(:disabled):hover { + text-decoration: underline; + } +} + +._inputs { + display: flex; + margin: 32px 0; + + &:first-child { + margin-top: 8px; + } + + &:last-child { + margin-bottom: 8px; + } + + > * { + flex: 1; + margin: 0 !important; + + &:not(:first-child) { + margin-left: 8px !important; + } + + &:not(:last-child) { + margin-right: 8px !important; + } + } +} + +._panel { + background: var(--panel); + border-radius: var(--radius); + overflow: clip; +} + +._block { + @extend ._panel; + + & + ._block { + margin-top: var(--margin); + } +} + +._gap { + margin: var(--margin) 0; +} + +// TODO: 廃止 +._card { + @extend ._panel; + + // TODO: _cardTitle に + > ._title { + margin: 0; + padding: 22px 32px; + font-size: 1em; + border-bottom: solid 1px var(--panelHeaderDivider); + font-weight: bold; + background: var(--panelHeaderBg); + color: var(--panelHeaderFg); + + @media (max-width: 500px) { + padding: 16px; + font-size: 1em; + } + } + + // TODO: _cardContent に + > ._content { + padding: 32px; + + @media (max-width: 500px) { + padding: 16px; + } + + &._noPad { + padding: 0 !important; + } + + & + ._content { + border-top: solid 0.5px var(--divider); + } + } + + // TODO: _cardFooter に + > ._footer { + border-top: solid 0.5px var(--divider); + padding: 24px 32px; + + @media (max-width: 500px) { + padding: 16px; + } + } +} + +._borderButton { + @extend ._button; + display: block; + width: 100%; + padding: 10px; + box-sizing: border-box; + text-align: center; + border: solid 0.5px var(--divider); + border-radius: var(--radius); + + &:active { + border-color: var(--accent); + } +} + +._window { + background: var(--panel); + border-radius: var(--radius); + contain: content; +} + +._popup { + background: var(--popup); + border-radius: var(--radius); + contain: layout; // ふき出しがボックスから飛び出て表示されるようなデザインをする場合もあるので paint は contain することができない +} + +// TODO: 廃止 +._monolithic_ { + ._section:not(:empty) { + box-sizing: border-box; + padding: var(--root-margin, 32px); + + @media (max-width: 500px) { + --root-margin: 10px; + } + + & + ._section:not(:empty) { + border-top: solid 0.5px var(--divider); + } + } +} + +._narrow_ ._card { + > ._title { + padding: 16px; + font-size: 1em; + } + + > ._content { + padding: 16px; + } + + > ._footer { + padding: 16px; + } +} + +._acrylic { + background: var(--acrylicPanel); + -webkit-backdrop-filter: var(--blur, blur(15px)); + backdrop-filter: var(--blur, blur(15px)); +} + +._inputSplit { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); + grid-gap: 8px; + margin: 1em 0; + + > * { + margin: 0 !important; + } +} + +._formBlock { + margin: 20px 0; +} + +._formRoot { + > ._formBlock:first-child { + margin-top: 0; + } + + > ._formBlock:last-child { + margin-bottom: 0; + } +} + +._table { + > ._row { + display: flex; + + &:not(:last-child) { + margin-bottom: 16px; + + @media (max-width: 500px) { + margin-bottom: 8px; + } + } + + > ._cell { + flex: 1; + + > ._label { + font-size: 80%; + opacity: 0.7; + + > ._icon { + margin-right: 4px; + display: none; + } + } + } + } +} + +._fullinfo { + padding: 64px 32px; + text-align: center; + + > img { + vertical-align: bottom; + height: 128px; + margin-bottom: 16px; + border-radius: 16px; + } +} + +._keyValue { + display: flex; + + > * { + flex: 1; + } +} + +._link { + color: var(--link); +} + +._caption { + font-size: 0.8em; + opacity: 0.7; +} + +._monospace { + font-family: Fira code, Fira Mono, Consolas, Menlo, Courier, monospace !important; +} + +._code { + @extend ._monospace; + background: #2d2d2d; + color: #ccc; + font-size: 14px; + line-height: 1.5; + padding: 5px; +} + +.prism-editor__textarea:focus { + outline: none; +} + +._zoom { + transition-duration: 0.5s, 0.5s; + transition-property: opacity, transform; + transition-timing-function: cubic-bezier(0,.5,.5,1); +} + +.zoom-enter-active, .zoom-leave-active { + transition: opacity 0.5s, transform 0.5s !important; +} +.zoom-enter-from, .zoom-leave-to { + opacity: 0; + transform: scale(0.9); +} + +@keyframes blink { + 0% { opacity: 1; transform: scale(1); } + 30% { opacity: 1; transform: scale(1); } + 90% { opacity: 0; transform: scale(0.5); } +} + +@keyframes tada { + from { + transform: scale3d(1, 1, 1); + } + + 10%, + 20% { + transform: scale3d(0.9, 0.9, 0.9) rotate3d(0, 0, 1, -3deg); + } + + 30%, + 50%, + 70%, + 90% { + transform: scale3d(1.1, 1.1, 1.1) rotate3d(0, 0, 1, 3deg); + } + + 40%, + 60%, + 80% { + transform: scale3d(1.1, 1.1, 1.1) rotate3d(0, 0, 1, -3deg); + } + + to { + transform: scale3d(1, 1, 1); + } +} + +._anime_bounce { + will-change: transform; + animation: bounce ease 0.7s; + animation-iteration-count: 1; + transform-origin: 50% 50%; +} +._anime_bounce_ready { + will-change: transform; + transform: scaleX(0.90) scaleY(0.90) ; +} +._anime_bounce_standBy { + transition: transform 0.1s ease; +} + +@keyframes bounce{ + 0% { + transform: scaleX(0.90) scaleY(0.90) ; + } + 19% { + transform: scaleX(1.10) scaleY(1.10) ; + } + 48% { + transform: scaleX(0.95) scaleY(0.95) ; + } + 100% { + transform: scaleX(1.00) scaleY(1.00) ; + } +} diff --git a/packages/client/src/sw/compose-notification.ts b/packages/client/src/sw/compose-notification.ts new file mode 100644 index 0000000000..0aed9610ea --- /dev/null +++ b/packages/client/src/sw/compose-notification.ts @@ -0,0 +1,103 @@ +/** + * Notification composer of Service Worker + */ +declare var self: ServiceWorkerGlobalScope; + +import { getNoteSummary } from '@/scripts/get-note-summary'; +import * as misskey from 'misskey-js'; + +function getUserName(user: misskey.entities.User): string { + return user.name || user.username; +} + +export default async function(type, data, i18n): Promise<[string, NotificationOptions] | null | undefined> { + if (!i18n) { + console.log('no i18n'); + return; + } + + switch (type) { + case 'driveFileCreated': // TODO (Server Side) + return [i18n.t('_notification.fileUploaded'), { + body: data.name, + icon: data.url + }]; + case 'notification': + switch (data.type) { + case 'mention': + return [i18n.t('_notification.youGotMention', { name: getUserName(data.user) }), { + body: getNoteSummary(data.note, i18n.locale), + icon: data.user.avatarUrl + }]; + + case 'reply': + return [i18n.t('_notification.youGotReply', { name: getUserName(data.user) }), { + body: getNoteSummary(data.note, i18n.locale), + icon: data.user.avatarUrl + }]; + + case 'renote': + return [i18n.t('_notification.youRenoted', { name: getUserName(data.user) }), { + body: getNoteSummary(data.note, i18n.locale), + icon: data.user.avatarUrl + }]; + + case 'quote': + return [i18n.t('_notification.youGotQuote', { name: getUserName(data.user) }), { + body: getNoteSummary(data.note, i18n.locale), + icon: data.user.avatarUrl + }]; + + case 'reaction': + return [`${data.reaction} ${getUserName(data.user)}`, { + body: getNoteSummary(data.note, i18n.locale), + icon: data.user.avatarUrl + }]; + + case 'pollVote': + return [i18n.t('_notification.youGotPoll', { name: getUserName(data.user) }), { + body: getNoteSummary(data.note, i18n.locale), + icon: data.user.avatarUrl + }]; + + case 'follow': + return [i18n.t('_notification.youWereFollowed'), { + body: getUserName(data.user), + icon: data.user.avatarUrl + }]; + + case 'receiveFollowRequest': + return [i18n.t('_notification.youReceivedFollowRequest'), { + body: getUserName(data.user), + icon: data.user.avatarUrl + }]; + + case 'followRequestAccepted': + return [i18n.t('_notification.yourFollowRequestAccepted'), { + body: getUserName(data.user), + icon: data.user.avatarUrl + }]; + + case 'groupInvited': + return [i18n.t('_notification.youWereInvitedToGroup'), { + body: data.group.name + }]; + + default: + return null; + } + case 'unreadMessagingMessage': + if (data.groupId === null) { + return [i18n.t('_notification.youGotMessagingMessageFromUser', { name: getUserName(data.user) }), { + icon: data.user.avatarUrl, + tag: `messaging:user:${data.user.id}` + }]; + } + return [i18n.t('_notification.youGotMessagingMessageFromGroup', { name: data.group.name }), { + icon: data.user.avatarUrl, + tag: `messaging:group:${data.group.id}` + }]; + default: + return null; + } +} diff --git a/packages/client/src/sw/sw.ts b/packages/client/src/sw/sw.ts new file mode 100644 index 0000000000..68c650c771 --- /dev/null +++ b/packages/client/src/sw/sw.ts @@ -0,0 +1,123 @@ +/** + * Service Worker + */ +declare var self: ServiceWorkerGlobalScope; + +import { get, set } from 'idb-keyval'; +import composeNotification from '@/sw/compose-notification'; +import { I18n } from '@/scripts/i18n'; + +//#region Variables +const version = _VERSION_; +const cacheName = `mk-cache-${version}`; + +let lang: string; +let i18n: I18n; +let pushesPool: any[] = []; +//#endregion + +//#region Startup +get('lang').then(async prelang => { + if (!prelang) return; + lang = prelang; + return fetchLocale(); +}); +//#endregion + +//#region Lifecycle: Install +self.addEventListener('install', ev => { + self.skipWaiting(); +}); +//#endregion + +//#region Lifecycle: Activate +self.addEventListener('activate', ev => { + ev.waitUntil( + caches.keys() + .then(cacheNames => Promise.all( + cacheNames + .filter((v) => v !== cacheName) + .map(name => caches.delete(name)) + )) + .then(() => self.clients.claim()) + ); +}); +//#endregion + +//#region When: Fetching +self.addEventListener('fetch', ev => { + // Nothing to do +}); +//#endregion + +//#region When: Caught Notification +self.addEventListener('push', ev => { + // クライアント取得 + ev.waitUntil(self.clients.matchAll({ + includeUncontrolled: true + }).then(async clients => { + // クライアントがあったらストリームに接続しているということなので通知しない + if (clients.length != 0) return; + + const { type, body } = ev.data?.json(); + + // localeを読み込めておらずi18nがundefinedだった場合はpushesPoolにためておく + if (!i18n) return pushesPool.push({ type, body }); + + const n = await composeNotification(type, body, i18n); + if (n) return self.registration.showNotification(...n); + })); +}); +//#endregion + +//#region When: Caught a message from the client +self.addEventListener('message', ev => { + switch(ev.data) { + case 'clear': + return; // TODO + default: + break; + } + + if (typeof ev.data === 'object') { + // E.g. '[object Array]' → 'array' + const otype = Object.prototype.toString.call(ev.data).slice(8, -1).toLowerCase(); + + if (otype === 'object') { + if (ev.data.msg === 'initialize') { + lang = ev.data.lang; + set('lang', lang); + fetchLocale(); + } + } + } +}); +//#endregion + +//#region Function: (Re)Load i18n instance +async function fetchLocale() { + //#region localeファイルの読み込み + // Service Workerは何度も起動しそのたびにlocaleを読み込むので、CacheStorageを使う + const localeUrl = `/assets/locales/${lang}.${version}.json`; + let localeRes = await caches.match(localeUrl); + + if (!localeRes) { + localeRes = await fetch(localeUrl); + const clone = localeRes?.clone(); + if (!clone?.clone().ok) return; + + caches.open(cacheName).then(cache => cache.put(localeUrl, clone)); + } + + i18n = new I18n(await localeRes.json()); + //#endregion + + //#region i18nをきちんと読み込んだ後にやりたい処理 + for (const { type, body } of pushesPool) { + const n = await composeNotification(type, body, i18n); + if (n) self.registration.showNotification(...n); + } + pushesPool = []; + //#endregion +} +//#endregion diff --git a/packages/client/src/symbols.ts b/packages/client/src/symbols.ts new file mode 100644 index 0000000000..6913f29c28 --- /dev/null +++ b/packages/client/src/symbols.ts @@ -0,0 +1 @@ +export const PAGE_INFO = Symbol('Page info'); diff --git a/packages/client/src/theme-store.ts b/packages/client/src/theme-store.ts new file mode 100644 index 0000000000..e7962e7e8e --- /dev/null +++ b/packages/client/src/theme-store.ts @@ -0,0 +1,34 @@ +import { api } from '@/os'; +import { $i } from '@/account'; +import { Theme } from './scripts/theme'; + +const lsCacheKey = $i ? `themes:${$i.id}` : ''; + +export function getThemes(): Theme[] { + return JSON.parse(localStorage.getItem(lsCacheKey) || '[]'); +} + +export async function fetchThemes(): Promise { + if ($i == null) return; + + try { + const themes = await api('i/registry/get', { scope: ['client'], key: 'themes' }); + localStorage.setItem(lsCacheKey, JSON.stringify(themes)); + } catch (e) { + if (e.code === 'NO_SUCH_KEY') return; + throw e; + } +} + +export async function addTheme(theme: Theme): Promise { + await fetchThemes(); + const themes = getThemes().concat(theme); + await api('i/registry/set', { scope: ['client'], key: 'themes', value: themes }); + localStorage.setItem(lsCacheKey, JSON.stringify(themes)); +} + +export async function removeTheme(theme: Theme): Promise { + const themes = getThemes().filter(t => t.id != theme.id); + await api('i/registry/set', { scope: ['client'], key: 'themes', value: themes }); + localStorage.setItem(lsCacheKey, JSON.stringify(themes)); +} diff --git a/packages/client/src/themes/_dark.json5 b/packages/client/src/themes/_dark.json5 new file mode 100644 index 0000000000..d8be16f60a --- /dev/null +++ b/packages/client/src/themes/_dark.json5 @@ -0,0 +1,90 @@ +// ダークテーマのベーステーマ +// このテーマが直接使われることは無い +{ + id: 'dark', + + name: 'Dark', + author: 'syuilo', + desc: 'Default dark theme', + kind: 'dark', + + props: { + accent: '#86b300', + accentDarken: ':darken<10<@accent', + accentLighten: ':lighten<10<@accent', + accentedBg: ':alpha<0.15<@accent', + focus: ':alpha<0.3<@accent', + bg: '#000', + acrylicBg: ':alpha<0.5<@bg', + fg: '#dadada', + fgTransparentWeak: ':alpha<0.75<@fg', + fgTransparent: ':alpha<0.5<@fg', + fgHighlighted: ':lighten<3<@fg', + fgOnAccent: '#fff', + divider: 'rgba(255, 255, 255, 0.1)', + indicator: '@accent', + panel: ':lighten<3<@bg', + panelHighlight: ':lighten<3<@panel', + panelHeaderBg: ':lighten<3<@panel', + panelHeaderFg: '@fg', + panelHeaderDivider: 'rgba(0, 0, 0, 0)', + panelBorder: '" solid 1px var(--divider)', + acrylicPanel: ':alpha<0.5<@panel', + popup: ':lighten<3<@panel', + shadow: 'rgba(0, 0, 0, 0.3)', + header: ':alpha<0.7<@panel', + navBg: '@panel', + navFg: '@fg', + navHoverFg: ':lighten<17<@fg', + navActive: '@accent', + navIndicator: '@indicator', + link: '#44a4c1', + hashtag: '#ff9156', + mention: '@accent', + mentionMe: '@mention', + renote: '#229e82', + modalBg: 'rgba(0, 0, 0, 0.5)', + scrollbarHandle: 'rgba(255, 255, 255, 0.2)', + scrollbarHandleHover: 'rgba(255, 255, 255, 0.4)', + dateLabelFg: '@fg', + infoBg: '#253142', + infoFg: '#fff', + infoWarnBg: '#42321c', + infoWarnFg: '#ffbd3e', + switchBg: 'rgba(255, 255, 255, 0.15)', + cwBg: '#687390', + cwFg: '#393f4f', + cwHoverBg: '#707b97', + buttonBg: 'rgba(255, 255, 255, 0.05)', + buttonHoverBg: 'rgba(255, 255, 255, 0.1)', + buttonGradateA: '@accent', + buttonGradateB: ':hue<20<@accent', + inputBorder: 'rgba(255, 255, 255, 0.1)', + inputBorderHover: 'rgba(255, 255, 255, 0.2)', + listItemHoverBg: 'rgba(255, 255, 255, 0.03)', + driveFolderBg: ':alpha<0.3<@accent', + wallpaperOverlay: 'rgba(0, 0, 0, 0.5)', + badge: '#31b1ce', + messageBg: '@bg', + success: '#86b300', + error: '#ec4137', + warn: '#ecb637', + htmlThemeColor: '@bg', + X2: ':darken<2<@panel', + X3: 'rgba(255, 255, 255, 0.05)', + X4: 'rgba(255, 255, 255, 0.1)', + X5: 'rgba(255, 255, 255, 0.05)', + X6: 'rgba(255, 255, 255, 0.15)', + X7: 'rgba(255, 255, 255, 0.05)', + X8: ':lighten<5<@accent', + X9: ':darken<5<@accent', + X10: ':alpha<0.4<@accent', + X11: 'rgba(0, 0, 0, 0.3)', + X12: 'rgba(255, 255, 255, 0.1)', + X13: 'rgba(255, 255, 255, 0.15)', + X14: ':alpha<0.5<@navBg', + X15: ':alpha<0<@panel', + X16: ':alpha<0.7<@panel', + X17: ':alpha<0.8<@bg', + }, +} diff --git a/packages/client/src/themes/_light.json5 b/packages/client/src/themes/_light.json5 new file mode 100644 index 0000000000..251aa36c7a --- /dev/null +++ b/packages/client/src/themes/_light.json5 @@ -0,0 +1,90 @@ +// ライトテーマのベーステーマ +// このテーマが直接使われることは無い +{ + id: 'light', + + name: 'Light', + author: 'syuilo', + desc: 'Default light theme', + kind: 'light', + + props: { + accent: '#86b300', + accentDarken: ':darken<10<@accent', + accentLighten: ':lighten<10<@accent', + accentedBg: ':alpha<0.15<@accent', + focus: ':alpha<0.3<@accent', + bg: '#fff', + acrylicBg: ':alpha<0.5<@bg', + fg: '#5f5f5f', + fgTransparentWeak: ':alpha<0.75<@fg', + fgTransparent: ':alpha<0.5<@fg', + fgHighlighted: ':darken<3<@fg', + fgOnAccent: '#fff', + divider: 'rgba(0, 0, 0, 0.1)', + indicator: '@accent', + panel: ':lighten<3<@bg', + panelHighlight: ':darken<3<@panel', + panelHeaderBg: ':lighten<3<@panel', + panelHeaderFg: '@fg', + panelHeaderDivider: 'rgba(0, 0, 0, 0)', + panelBorder: '" solid 1px var(--divider)', + acrylicPanel: ':alpha<0.5<@panel', + popup: ':lighten<3<@panel', + shadow: 'rgba(0, 0, 0, 0.1)', + header: ':alpha<0.7<@panel', + navBg: '@panel', + navFg: '@fg', + navHoverFg: ':darken<17<@fg', + navActive: '@accent', + navIndicator: '@indicator', + link: '#44a4c1', + hashtag: '#ff9156', + mention: '@accent', + mentionMe: '@mention', + renote: '#229e82', + modalBg: 'rgba(0, 0, 0, 0.3)', + scrollbarHandle: 'rgba(0, 0, 0, 0.2)', + scrollbarHandleHover: 'rgba(0, 0, 0, 0.4)', + dateLabelFg: '@fg', + infoBg: '#e5f5ff', + infoFg: '#72818a', + infoWarnBg: '#fff0db', + infoWarnFg: '#8f6e31', + switchBg: 'rgba(0, 0, 0, 0.15)', + cwBg: '#b1b9c1', + cwFg: '#fff', + cwHoverBg: '#bbc4ce', + buttonBg: 'rgba(0, 0, 0, 0.05)', + buttonHoverBg: 'rgba(0, 0, 0, 0.1)', + buttonGradateA: '@accent', + buttonGradateB: ':hue<20<@accent', + inputBorder: 'rgba(0, 0, 0, 0.1)', + inputBorderHover: 'rgba(0, 0, 0, 0.2)', + listItemHoverBg: 'rgba(0, 0, 0, 0.03)', + driveFolderBg: ':alpha<0.3<@accent', + wallpaperOverlay: 'rgba(255, 255, 255, 0.5)', + badge: '#31b1ce', + messageBg: '@bg', + success: '#86b300', + error: '#ec4137', + warn: '#ecb637', + htmlThemeColor: '@bg', + X2: ':darken<2<@panel', + X3: 'rgba(0, 0, 0, 0.05)', + X4: 'rgba(0, 0, 0, 0.1)', + X5: 'rgba(0, 0, 0, 0.05)', + X6: 'rgba(0, 0, 0, 0.25)', + X7: 'rgba(0, 0, 0, 0.05)', + X8: ':lighten<5<@accent', + X9: ':darken<5<@accent', + X10: ':alpha<0.4<@accent', + X11: 'rgba(0, 0, 0, 0.1)', + X12: 'rgba(0, 0, 0, 0.1)', + X13: 'rgba(0, 0, 0, 0.15)', + X14: ':alpha<0.5<@navBg', + X15: ':alpha<0<@panel', + X16: ':alpha<0.7<@panel', + X17: ':alpha<0.8<@bg', + }, +} diff --git a/packages/client/src/themes/d-astro.json5 b/packages/client/src/themes/d-astro.json5 new file mode 100644 index 0000000000..c6a927ec3a --- /dev/null +++ b/packages/client/src/themes/d-astro.json5 @@ -0,0 +1,78 @@ +{ + id: '080a01c5-377d-4fbb-88cc-6bb5d04977ea', + base: 'dark', + name: 'Mi Astro Dark', + author: 'syuilo', + props: { + bg: '#232125', + fg: '#efdab9', + cwBg: '#687390', + cwFg: '#393f4f', + link: '#78b0a0', + warn: '#ecb637', + badge: '#31b1ce', + error: '#ec4137', + focus: ':alpha<0.3<@accent', + navBg: '@panel', + navFg: '@fg', + panel: '#2a272b', + accent: '#81c08b', + header: ':alpha<0.7<@bg', + infoBg: '#253142', + infoFg: '#fff', + renote: '#659CC8', + shadow: 'rgba(0, 0, 0, 0.3)', + divider: 'rgba(255, 255, 255, 0.1)', + hashtag: '#ff9156', + mention: '#ffd152', + modalBg: 'rgba(0, 0, 0, 0.5)', + success: '#86b300', + buttonBg: 'rgba(255, 255, 255, 0.05)', + acrylicBg: ':alpha<0.5<@bg', + cwHoverBg: '#707b97', + indicator: '@accent', + mentionMe: '#fb5d38', + messageBg: '@bg', + navActive: '@accent', + infoWarnBg: '#42321c', + infoWarnFg: '#ffbd3e', + navHoverFg: ':lighten<17<@fg', + dateLabelFg: '@fg', + inputBorder: 'rgba(255, 255, 255, 0.1)', + inputBorderHover: 'rgba(255, 255, 255, 0.2)', + panelBorder: '" solid 1px var(--divider)', + accentDarken: ':darken<10<@accent', + acrylicPanel: ':alpha<0.5<@panel', + navIndicator: '@accent', + accentLighten: ':lighten<10<@accent', + buttonHoverBg: 'rgba(255, 255, 255, 0.1)', + buttonGradateA: '@accent', + buttonGradateB: ':hue<-20<@accent', + driveFolderBg: ':alpha<0.3<@accent', + fgHighlighted: ':lighten<3<@fg', + panelHeaderBg: ':lighten<3<@panel', + panelHeaderFg: '@fg', + htmlThemeColor: '@bg', + panelHighlight: ':lighten<3<@panel', + listItemHoverBg: 'rgba(255, 255, 255, 0.03)', + scrollbarHandle: 'rgba(255, 255, 255, 0.2)', + wallpaperOverlay: 'rgba(0, 0, 0, 0.5)', + panelHeaderDivider: 'rgba(0, 0, 0, 0)', + scrollbarHandleHover: 'rgba(255, 255, 255, 0.4)', + X2: ':darken<2<@panel', + X3: 'rgba(255, 255, 255, 0.05)', + X4: 'rgba(255, 255, 255, 0.1)', + X5: 'rgba(255, 255, 255, 0.05)', + X6: 'rgba(255, 255, 255, 0.15)', + X7: 'rgba(255, 255, 255, 0.05)', + X8: ':lighten<5<@accent', + X9: ':darken<5<@accent', + X10: ':alpha<0.4<@accent', + X11: 'rgba(0, 0, 0, 0.3)', + X12: 'rgba(255, 255, 255, 0.1)', + X13: 'rgba(255, 255, 255, 0.15)', + X14: ':alpha<0.5<@navBg', + X15: ':alpha<0<@panel', + X16: ':alpha<0.7<@panel', + }, +} diff --git a/packages/client/src/themes/d-black.json5 b/packages/client/src/themes/d-black.json5 new file mode 100644 index 0000000000..3c18ebdaf1 --- /dev/null +++ b/packages/client/src/themes/d-black.json5 @@ -0,0 +1,17 @@ +{ + id: '8c539dc1-0fab-4d47-9194-39c508e9bfe1', + + name: 'Mi Black', + author: 'syuilo', + + base: 'dark', + + props: { + divider: '#2d2d2d', + panel: '#131313', + panelHeaderBg: '@panel', + panelHeaderDivider: '@divider', + shadow: 'rgba(255, 255, 255, 0.05)', + modalBg: 'rgba(255, 255, 255, 0.1)', + }, +} diff --git a/packages/client/src/themes/d-botanical.json5 b/packages/client/src/themes/d-botanical.json5 new file mode 100644 index 0000000000..c03b95e2d7 --- /dev/null +++ b/packages/client/src/themes/d-botanical.json5 @@ -0,0 +1,26 @@ +{ + id: '504debaf-4912-6a4c-5059-1db08a76b737', + + name: 'Mi Botanical Dark', + author: 'syuilo', + + base: 'dark', + + props: { + accent: 'rgb(148, 179, 0)', + bg: 'rgb(37, 38, 36)', + fg: 'rgb(216, 212, 199)', + fgHighlighted: '#fff', + divider: 'rgba(255, 255, 255, 0.14)', + panel: 'rgb(47, 47, 44)', + panelHeaderBg: '@panel', + panelHeaderDivider: '@divider', + header: ':alpha<0.7<@panel', + navBg: '#363636', + renote: '@accent', + mention: 'rgb(212, 153, 76)', + mentionMe: 'rgb(212, 210, 76)', + hashtag: '#5bcbb0', + link: '@accent', + }, +} diff --git a/packages/client/src/themes/d-dark.json5 b/packages/client/src/themes/d-dark.json5 new file mode 100644 index 0000000000..d24ce4df69 --- /dev/null +++ b/packages/client/src/themes/d-dark.json5 @@ -0,0 +1,26 @@ +{ + id: '8050783a-7f63-445a-b270-36d0f6ba1677', + + name: 'Mi Dark', + author: 'syuilo', + desc: 'Default light theme', + + base: 'dark', + + props: { + bg: '#232323', + fg: 'rgb(199, 209, 216)', + fgHighlighted: '#fff', + divider: 'rgba(255, 255, 255, 0.14)', + panel: '#2d2d2d', + panelHeaderBg: '@panel', + panelHeaderDivider: '@divider', + header: ':alpha<0.7<@panel', + navBg: '#363636', + renote: '@accent', + mention: '#da6d35', + mentionMe: '#d44c4c', + hashtag: '#4cb8d4', + link: '@accent', + }, +} diff --git a/packages/client/src/themes/d-future.json5 b/packages/client/src/themes/d-future.json5 new file mode 100644 index 0000000000..b6fa1ab0c1 --- /dev/null +++ b/packages/client/src/themes/d-future.json5 @@ -0,0 +1,27 @@ +{ + id: '32a637ef-b47a-4775-bb7b-bacbb823f865', + + name: 'Mi Future Dark', + author: 'syuilo', + + base: 'dark', + + props: { + accent: '#63e2b7', + bg: '#101014', + fg: '#D5D5D6', + fgHighlighted: '#fff', + fgOnAccent: '#000', + divider: 'rgba(255, 255, 255, 0.1)', + panel: '#18181c', + panelHeaderBg: '@panel', + panelHeaderDivider: '@divider', + renote: '@accent', + mention: '#f2c97d', + mentionMe: '@accent', + hashtag: '#70c0e8', + link: '#e88080', + buttonGradateA: '@accent', + buttonGradateB: ':saturate<30<:hue<30<@accent', + }, +} diff --git a/packages/client/src/themes/d-persimmon.json5 b/packages/client/src/themes/d-persimmon.json5 new file mode 100644 index 0000000000..e36265ff10 --- /dev/null +++ b/packages/client/src/themes/d-persimmon.json5 @@ -0,0 +1,25 @@ +{ + id: 'c503d768-7c70-4db2-a4e6-08264304bc8d', + + name: 'Mi Persimmon Dark', + author: 'syuilo', + + base: 'dark', + + props: { + accent: 'rgb(206, 102, 65)', + bg: 'rgb(31, 33, 31)', + fg: '#cdd8c7', + fgHighlighted: '#fff', + divider: 'rgba(255, 255, 255, 0.14)', + panel: 'rgb(41, 43, 41)', + infoFg: '@fg', + infoBg: '#333c3b', + navBg: '#141714', + renote: '@accent', + mention: '@accent', + mentionMe: '#de6161', + hashtag: '#68bad0', + link: '#a1c758', + }, +} diff --git a/packages/client/src/themes/d-pumpkin.json5 b/packages/client/src/themes/d-pumpkin.json5 new file mode 100644 index 0000000000..064ca4577b --- /dev/null +++ b/packages/client/src/themes/d-pumpkin.json5 @@ -0,0 +1,88 @@ +{ + id: '0b64fef3-02c7-20b5-dd87-b3f77e2b4301', + + name: 'Mi Pumpkin Dark', + author: 'syuilo', + + base: 'dark', + + props: { + X2: ':darken<2<@panel', + X3: 'rgba(255, 255, 255, 0.05)', + X4: 'rgba(255, 255, 255, 0.1)', + X5: 'rgba(255, 255, 255, 0.05)', + X6: 'rgba(255, 255, 255, 0.15)', + X7: 'rgba(255, 255, 255, 0.05)', + X8: ':lighten<5<@accent', + X9: ':darken<5<@accent', + bg: 'rgb(37, 32, 47)', + fg: '#e0d5c0', + X10: ':alpha<0.4<@accent', + X11: 'rgba(0, 0, 0, 0.3)', + X12: 'rgba(255, 255, 255, 0.1)', + X13: 'rgba(255, 255, 255, 0.15)', + X14: ':alpha<0.5<@navBg', + X15: ':alpha<0<@panel', + X16: ':alpha<0.7<@panel', + X17: ':alpha<0.8<@bg', + cwBg: '#687390', + cwFg: '#393f4f', + link: 'rgb(172, 193, 68)', + warn: '#ecb637', + badge: '#31b1ce', + error: '#ec4137', + focus: ':alpha<0.3<@accent', + navBg: '@panel', + navFg: '@fg', + panel: ':lighten<3<@bg', + popup: ':lighten<3<@panel', + accent: 'rgb(242, 133, 36)', + header: ':alpha<0.7<@panel', + infoBg: '#253142', + infoFg: '#fff', + renote: 'rgb(110, 179, 72)', + shadow: 'rgba(0, 0, 0, 0.3)', + divider: 'rgba(255, 255, 255, 0.1)', + hashtag: 'rgb(188, 90, 255)', + mention: 'rgb(72, 179, 139)', + modalBg: 'rgba(0, 0, 0, 0.5)', + success: '#86b300', + buttonBg: 'rgba(255, 255, 255, 0.05)', + switchBg: 'rgba(255, 255, 255, 0.15)', + acrylicBg: ':alpha<0.5<@bg', + cwHoverBg: '#707b97', + indicator: '@accent', + mentionMe: '@accent', + messageBg: '@bg', + navActive: '@accent', + accentedBg: ':alpha<0.15<@accent', + fgOnAccent: '#000', + infoWarnBg: '#42321c', + infoWarnFg: '#ffbd3e', + navHoverFg: ':lighten<17<@fg', + dateLabelFg: '@fg', + inputBorder: 'rgba(255, 255, 255, 0.1)', + panelBorder: '" solid 1px var(--divider)', + accentDarken: ':darken<10<@accent', + acrylicPanel: ':alpha<0.5<@panel', + navIndicator: '@indicator', + accentLighten: ':lighten<10<@accent', + buttonHoverBg: 'rgba(255, 255, 255, 0.1)', + driveFolderBg: ':alpha<0.3<@accent', + fgHighlighted: ':lighten<3<@fg', + fgTransparent: ':alpha<0.5<@fg', + panelHeaderBg: ':lighten<3<@panel', + panelHeaderFg: '@fg', + buttonGradateA: '@accent', + buttonGradateB: ':hue<20<@accent', + htmlThemeColor: '@bg', + panelHighlight: ':lighten<3<@panel', + listItemHoverBg: 'rgba(255, 255, 255, 0.03)', + scrollbarHandle: 'rgba(255, 255, 255, 0.2)', + inputBorderHover: 'rgba(255, 255, 255, 0.2)', + wallpaperOverlay: 'rgba(0, 0, 0, 0.5)', + fgTransparentWeak: ':alpha<0.75<@fg', + panelHeaderDivider: 'rgba(0, 0, 0, 0)', + scrollbarHandleHover: 'rgba(255, 255, 255, 0.4)', + }, +} diff --git a/packages/client/src/themes/l-apricot.json5 b/packages/client/src/themes/l-apricot.json5 new file mode 100644 index 0000000000..1ed5525575 --- /dev/null +++ b/packages/client/src/themes/l-apricot.json5 @@ -0,0 +1,22 @@ +{ + id: '0ff48d43-aab3-46e7-ab12-8492110d2e2b', + + name: 'Mi Apricot Light', + author: 'syuilo', + + base: 'light', + + props: { + accent: 'rgb(234, 154, 82)', + bg: '#e6e5e2', + fg: 'rgb(149, 143, 139)', + panel: '#EEECE8', + renote: '@accent', + link: '@accent', + mention: '@accent', + hashtag: '@accent', + inputBorder: 'rgba(0, 0, 0, 0.1)', + inputBorderHover: 'rgba(0, 0, 0, 0.2)', + infoBg: 'rgb(226, 235, 241)', + }, +} diff --git a/packages/client/src/themes/l-light.json5 b/packages/client/src/themes/l-light.json5 new file mode 100644 index 0000000000..248355c945 --- /dev/null +++ b/packages/client/src/themes/l-light.json5 @@ -0,0 +1,20 @@ +{ + id: '4eea646f-7afa-4645-83e9-83af0333cd37', + + name: 'Mi Light', + author: 'syuilo', + desc: 'Default light theme', + + base: 'light', + + props: { + bg: '#f9f9f9', + fg: '#676767', + divider: '#e8e8e8', + header: ':alpha<0.7<@panel', + navBg: '#fff', + panel: '#fff', + panelHeaderDivider: '@divider', + mentionMe: 'rgb(0, 179, 70)', + }, +} diff --git a/packages/client/src/themes/l-rainy.json5 b/packages/client/src/themes/l-rainy.json5 new file mode 100644 index 0000000000..283dd74c6c --- /dev/null +++ b/packages/client/src/themes/l-rainy.json5 @@ -0,0 +1,21 @@ +{ + id: 'a58a0abb-ff8c-476a-8dec-0ad7837e7e96', + + name: 'Mi Rainy Light', + author: 'syuilo', + + base: 'light', + + props: { + accent: '#5db0da', + bg: 'rgb(246 248 249)', + fg: '#636b71', + panel: '#fff', + divider: 'rgb(230 233 234)', + panelHeaderDivider: '@divider', + renote: '@accent', + link: '@accent', + mention: '@accent', + hashtag: '@accent', + }, +} diff --git a/packages/client/src/themes/l-sushi.json5 b/packages/client/src/themes/l-sushi.json5 new file mode 100644 index 0000000000..5846927d65 --- /dev/null +++ b/packages/client/src/themes/l-sushi.json5 @@ -0,0 +1,18 @@ +{ + id: '213273e5-7d20-d5f0-6e36-1b6a4f67115c', + + name: 'Mi Sushi Light', + author: 'syuilo', + + base: 'light', + + props: { + accent: '#e36749', + bg: '#f0eee9', + fg: '#5f5f5f', + renote: '@accent', + link: '@accent', + mention: '@accent', + hashtag: '#229e82', + }, +} diff --git a/packages/client/src/themes/l-vivid.json5 b/packages/client/src/themes/l-vivid.json5 new file mode 100644 index 0000000000..b3c08f38ae --- /dev/null +++ b/packages/client/src/themes/l-vivid.json5 @@ -0,0 +1,82 @@ +{ + id: '6128c2a9-5c54-43fe-a47d-17942356470b', + + name: 'Mi Vivid Light', + author: 'syuilo', + + base: 'light', + + props: { + bg: '#fafafa', + fg: '#444', + cwBg: '#b1b9c1', + cwFg: '#fff', + link: '#ff9400', + warn: '#ecb637', + badge: '#31b1ce', + error: '#ec4137', + focus: ':alpha<0.3<@accent', + navBg: '@panel', + navFg: '@fg', + panel: '#fff', + accent: '#008cff', + header: ':alpha<0.7<@panel', + infoBg: '#e5f5ff', + infoFg: '#72818a', + renote: '@accent', + shadow: 'rgba(0, 0, 0, 0.1)', + divider: 'rgba(0, 0, 0, 0.08)', + hashtag: '#92d400', + mention: '@accent', + modalBg: 'rgba(0, 0, 0, 0.3)', + success: '#86b300', + buttonBg: 'rgba(0, 0, 0, 0.05)', + acrylicBg: ':alpha<0.5<@bg', + cwHoverBg: '#bbc4ce', + indicator: '@accent', + mentionMe: '@mention', + messageBg: '@bg', + navActive: '@accent', + infoWarnBg: '#fff0db', + infoWarnFg: '#8f6e31', + navHoverFg: ':darken<17<@fg', + dateLabelFg: '@fg', + inputBorder: 'rgba(0, 0, 0, 0.1)', + inputBorderHover: 'rgba(0, 0, 0, 0.2)', + panelBorder: '" solid 1px var(--divider)', + accentDarken: ':darken<10<@accent', + acrylicPanel: ':alpha<0.5<@panel', + navIndicator: '@accent', + accentLighten: ':lighten<10<@accent', + buttonHoverBg: 'rgba(0, 0, 0, 0.1)', + driveFolderBg: ':alpha<0.3<@accent', + fgHighlighted: ':darken<3<@fg', + fgTransparent: ':alpha<0.5<@fg', + panelHeaderBg: ':lighten<3<@panel', + panelHeaderFg: '@fg', + htmlThemeColor: '@bg', + panelHighlight: ':darken<3<@panel', + listItemHoverBg: 'rgba(0, 0, 0, 0.03)', + scrollbarHandle: 'rgba(0, 0, 0, 0.2)', + wallpaperOverlay: 'rgba(255, 255, 255, 0.5)', + fgTransparentWeak: ':alpha<0.75<@fg', + panelHeaderDivider: '@divider', + scrollbarHandleHover: 'rgba(0, 0, 0, 0.4)', + X2: ':darken<2<@panel', + X3: 'rgba(0, 0, 0, 0.05)', + X4: 'rgba(0, 0, 0, 0.1)', + X5: 'rgba(0, 0, 0, 0.05)', + X6: 'rgba(0, 0, 0, 0.25)', + X7: 'rgba(0, 0, 0, 0.05)', + X8: ':lighten<5<@accent', + X9: ':darken<5<@accent', + X10: ':alpha<0.4<@accent', + X11: 'rgba(0, 0, 0, 0.1)', + X12: 'rgba(0, 0, 0, 0.1)', + X13: 'rgba(0, 0, 0, 0.15)', + X14: ':alpha<0.5<@navBg', + X15: ':alpha<0<@panel', + X16: ':alpha<0.7<@panel', + X17: ':alpha<0.8<@bg', + }, +} diff --git a/packages/client/src/ui/_common_/common.vue b/packages/client/src/ui/_common_/common.vue new file mode 100644 index 0000000000..59e26c837e --- /dev/null +++ b/packages/client/src/ui/_common_/common.vue @@ -0,0 +1,89 @@ + + + + + diff --git a/packages/client/src/ui/_common_/sidebar.vue b/packages/client/src/ui/_common_/sidebar.vue new file mode 100644 index 0000000000..9bbf1b3e3d --- /dev/null +++ b/packages/client/src/ui/_common_/sidebar.vue @@ -0,0 +1,388 @@ + + + + + diff --git a/packages/client/src/ui/_common_/stream-indicator.vue b/packages/client/src/ui/_common_/stream-indicator.vue new file mode 100644 index 0000000000..8b1b4b567c --- /dev/null +++ b/packages/client/src/ui/_common_/stream-indicator.vue @@ -0,0 +1,70 @@ + + + + + diff --git a/packages/client/src/ui/_common_/upload.vue b/packages/client/src/ui/_common_/upload.vue new file mode 100644 index 0000000000..0ca353e4e1 --- /dev/null +++ b/packages/client/src/ui/_common_/upload.vue @@ -0,0 +1,134 @@ + + + + + diff --git a/packages/client/src/ui/chat/date-separated-list.vue b/packages/client/src/ui/chat/date-separated-list.vue new file mode 100644 index 0000000000..b21e425aba --- /dev/null +++ b/packages/client/src/ui/chat/date-separated-list.vue @@ -0,0 +1,163 @@ + + + + + diff --git a/packages/client/src/ui/chat/header-clock.vue b/packages/client/src/ui/chat/header-clock.vue new file mode 100644 index 0000000000..3488289c21 --- /dev/null +++ b/packages/client/src/ui/chat/header-clock.vue @@ -0,0 +1,62 @@ + + + + + diff --git a/packages/client/src/ui/chat/index.vue b/packages/client/src/ui/chat/index.vue new file mode 100644 index 0000000000..e8d15b2cfc --- /dev/null +++ b/packages/client/src/ui/chat/index.vue @@ -0,0 +1,467 @@ + + + + + diff --git a/packages/client/src/ui/chat/note-header.vue b/packages/client/src/ui/chat/note-header.vue new file mode 100644 index 0000000000..8ab03501b2 --- /dev/null +++ b/packages/client/src/ui/chat/note-header.vue @@ -0,0 +1,112 @@ + + + + + diff --git a/packages/client/src/ui/chat/note-preview.vue b/packages/client/src/ui/chat/note-preview.vue new file mode 100644 index 0000000000..2a08a3d7f5 --- /dev/null +++ b/packages/client/src/ui/chat/note-preview.vue @@ -0,0 +1,112 @@ + + + + + diff --git a/packages/client/src/ui/chat/note.sub.vue b/packages/client/src/ui/chat/note.sub.vue new file mode 100644 index 0000000000..75d9d98088 --- /dev/null +++ b/packages/client/src/ui/chat/note.sub.vue @@ -0,0 +1,137 @@ + + + + + diff --git a/packages/client/src/ui/chat/note.vue b/packages/client/src/ui/chat/note.vue new file mode 100644 index 0000000000..c0b5cebd94 --- /dev/null +++ b/packages/client/src/ui/chat/note.vue @@ -0,0 +1,1144 @@ + + + + + diff --git a/packages/client/src/ui/chat/notes.vue b/packages/client/src/ui/chat/notes.vue new file mode 100644 index 0000000000..9103f717e6 --- /dev/null +++ b/packages/client/src/ui/chat/notes.vue @@ -0,0 +1,94 @@ + + + diff --git a/packages/client/src/ui/chat/pages/channel.vue b/packages/client/src/ui/chat/pages/channel.vue new file mode 100644 index 0000000000..5152af20f9 --- /dev/null +++ b/packages/client/src/ui/chat/pages/channel.vue @@ -0,0 +1,259 @@ + + + + + diff --git a/packages/client/src/ui/chat/pages/timeline.vue b/packages/client/src/ui/chat/pages/timeline.vue new file mode 100644 index 0000000000..f4dfdf891e --- /dev/null +++ b/packages/client/src/ui/chat/pages/timeline.vue @@ -0,0 +1,221 @@ + + + + + diff --git a/packages/client/src/ui/chat/post-form.vue b/packages/client/src/ui/chat/post-form.vue new file mode 100644 index 0000000000..44461c4a58 --- /dev/null +++ b/packages/client/src/ui/chat/post-form.vue @@ -0,0 +1,772 @@ + + + + + diff --git a/packages/client/src/widgets/button.vue b/packages/client/src/widgets/button.vue new file mode 100644 index 0000000000..3417181d0c --- /dev/null +++ b/packages/client/src/widgets/button.vue @@ -0,0 +1,95 @@ + + + + + diff --git a/packages/client/src/widgets/calendar.vue b/packages/client/src/widgets/calendar.vue new file mode 100644 index 0000000000..545072e87b --- /dev/null +++ b/packages/client/src/widgets/calendar.vue @@ -0,0 +1,204 @@ + + + + + diff --git a/packages/client/src/widgets/clock.vue b/packages/client/src/widgets/clock.vue new file mode 100644 index 0000000000..da0cd65c96 --- /dev/null +++ b/packages/client/src/widgets/clock.vue @@ -0,0 +1,55 @@ + + + + + diff --git a/packages/client/src/widgets/define.ts b/packages/client/src/widgets/define.ts new file mode 100644 index 0000000000..08a346d97c --- /dev/null +++ b/packages/client/src/widgets/define.ts @@ -0,0 +1,75 @@ +import { defineComponent } from 'vue'; +import { throttle } from 'throttle-debounce'; +import { Form } from '@/scripts/form'; +import * as os from '@/os'; + +export default function (data: { + name: string; + props?: () => T; +}) { + return defineComponent({ + props: { + widget: { + type: Object, + required: false + }, + settingCallback: { + required: false + } + }, + + emits: ['updateProps'], + + data() { + return { + props: this.widget ? JSON.parse(JSON.stringify(this.widget.data)) : {}, + save: throttle(3000, () => { + this.$emit('updateProps', this.props); + }), + }; + }, + + computed: { + id(): string { + return this.widget ? this.widget.id : null; + }, + }, + + created() { + this.mergeProps(); + + this.$watch('props', () => { + this.mergeProps(); + }, { deep: true }); + + if (this.settingCallback) this.settingCallback(this.setting); + }, + + methods: { + mergeProps() { + if (data.props) { + const defaultProps = data.props(); + for (const prop of Object.keys(defaultProps)) { + if (this.props.hasOwnProperty(prop)) continue; + this.props[prop] = defaultProps[prop].default; + } + } + }, + + async setting() { + const form = data.props(); + for (const item of Object.keys(form)) { + form[item].default = this.props[item]; + } + const { canceled, result } = await os.form(data.name, form); + if (canceled) return; + + for (const key of Object.keys(result)) { + this.props[key] = result[key]; + } + + this.save(); + }, + } + }); +} diff --git a/packages/client/src/widgets/digital-clock.vue b/packages/client/src/widgets/digital-clock.vue new file mode 100644 index 0000000000..9d32e8b9fe --- /dev/null +++ b/packages/client/src/widgets/digital-clock.vue @@ -0,0 +1,79 @@ + + + + + diff --git a/packages/client/src/widgets/federation.vue b/packages/client/src/widgets/federation.vue new file mode 100644 index 0000000000..85cfb8b845 --- /dev/null +++ b/packages/client/src/widgets/federation.vue @@ -0,0 +1,145 @@ + + + + + diff --git a/packages/client/src/widgets/index.ts b/packages/client/src/widgets/index.ts new file mode 100644 index 0000000000..51a82af080 --- /dev/null +++ b/packages/client/src/widgets/index.ts @@ -0,0 +1,45 @@ +import { App, defineAsyncComponent } from 'vue'; + +export default function(app: App) { + app.component('MkwMemo', defineAsyncComponent(() => import('./memo.vue'))); + app.component('MkwNotifications', defineAsyncComponent(() => import('./notifications.vue'))); + app.component('MkwTimeline', defineAsyncComponent(() => import('./timeline.vue'))); + app.component('MkwCalendar', defineAsyncComponent(() => import('./calendar.vue'))); + app.component('MkwRss', defineAsyncComponent(() => import('./rss.vue'))); + app.component('MkwTrends', defineAsyncComponent(() => import('./trends.vue'))); + app.component('MkwClock', defineAsyncComponent(() => import('./clock.vue'))); + app.component('MkwActivity', defineAsyncComponent(() => import('./activity.vue'))); + app.component('MkwPhotos', defineAsyncComponent(() => import('./photos.vue'))); + app.component('MkwDigitalClock', defineAsyncComponent(() => import('./digital-clock.vue'))); + app.component('MkwFederation', defineAsyncComponent(() => import('./federation.vue'))); + app.component('MkwPostForm', defineAsyncComponent(() => import('./post-form.vue'))); + app.component('MkwSlideshow', defineAsyncComponent(() => import('./slideshow.vue'))); + app.component('MkwServerMetric', defineAsyncComponent(() => import('./server-metric/index.vue'))); + app.component('MkwOnlineUsers', defineAsyncComponent(() => import('./online-users.vue'))); + app.component('MkwJobQueue', defineAsyncComponent(() => import('./job-queue.vue'))); + app.component('MkwButton', defineAsyncComponent(() => import('./button.vue'))); + app.component('MkwAiscript', defineAsyncComponent(() => import('./aiscript.vue'))); + app.component('MkwAichan', defineAsyncComponent(() => import('./aichan.vue'))); +} + +export const widgets = [ + 'memo', + 'notifications', + 'timeline', + 'calendar', + 'rss', + 'trends', + 'clock', + 'activity', + 'photos', + 'digitalClock', + 'federation', + 'postForm', + 'slideshow', + 'serverMetric', + 'onlineUsers', + 'jobQueue', + 'button', + 'aiscript', + 'aichan', +]; diff --git a/packages/client/src/widgets/job-queue.vue b/packages/client/src/widgets/job-queue.vue new file mode 100644 index 0000000000..ef440881e5 --- /dev/null +++ b/packages/client/src/widgets/job-queue.vue @@ -0,0 +1,183 @@ + + + + + diff --git a/packages/client/src/widgets/memo.vue b/packages/client/src/widgets/memo.vue new file mode 100644 index 0000000000..100f1b2934 --- /dev/null +++ b/packages/client/src/widgets/memo.vue @@ -0,0 +1,106 @@ + + + + + diff --git a/packages/client/src/widgets/notifications.vue b/packages/client/src/widgets/notifications.vue new file mode 100644 index 0000000000..462f39a339 --- /dev/null +++ b/packages/client/src/widgets/notifications.vue @@ -0,0 +1,65 @@ + + + diff --git a/packages/client/src/widgets/online-users.vue b/packages/client/src/widgets/online-users.vue new file mode 100644 index 0000000000..5b889f4816 --- /dev/null +++ b/packages/client/src/widgets/online-users.vue @@ -0,0 +1,67 @@ + + + + + diff --git a/packages/client/src/widgets/photos.vue b/packages/client/src/widgets/photos.vue new file mode 100644 index 0000000000..0c919526b0 --- /dev/null +++ b/packages/client/src/widgets/photos.vue @@ -0,0 +1,113 @@ + + + + + diff --git a/packages/client/src/widgets/post-form.vue b/packages/client/src/widgets/post-form.vue new file mode 100644 index 0000000000..5ecaa67b5a --- /dev/null +++ b/packages/client/src/widgets/post-form.vue @@ -0,0 +1,23 @@ + + + diff --git a/packages/client/src/widgets/rss.vue b/packages/client/src/widgets/rss.vue new file mode 100644 index 0000000000..235fce574a --- /dev/null +++ b/packages/client/src/widgets/rss.vue @@ -0,0 +1,89 @@ + + + + + diff --git a/packages/client/src/widgets/server-metric/cpu-mem.vue b/packages/client/src/widgets/server-metric/cpu-mem.vue new file mode 100644 index 0000000000..ad9e6a8b0f --- /dev/null +++ b/packages/client/src/widgets/server-metric/cpu-mem.vue @@ -0,0 +1,174 @@ + + + + + diff --git a/packages/client/src/widgets/server-metric/cpu.vue b/packages/client/src/widgets/server-metric/cpu.vue new file mode 100644 index 0000000000..4478ee3065 --- /dev/null +++ b/packages/client/src/widgets/server-metric/cpu.vue @@ -0,0 +1,76 @@ + + + + + diff --git a/packages/client/src/widgets/server-metric/disk.vue b/packages/client/src/widgets/server-metric/disk.vue new file mode 100644 index 0000000000..650101b0ee --- /dev/null +++ b/packages/client/src/widgets/server-metric/disk.vue @@ -0,0 +1,70 @@ + + + + + diff --git a/packages/client/src/widgets/server-metric/index.vue b/packages/client/src/widgets/server-metric/index.vue new file mode 100644 index 0000000000..cfe3c15df7 --- /dev/null +++ b/packages/client/src/widgets/server-metric/index.vue @@ -0,0 +1,82 @@ + + + diff --git a/packages/client/src/widgets/server-metric/mem.vue b/packages/client/src/widgets/server-metric/mem.vue new file mode 100644 index 0000000000..a6ca7b1175 --- /dev/null +++ b/packages/client/src/widgets/server-metric/mem.vue @@ -0,0 +1,85 @@ + + + + + diff --git a/packages/client/src/widgets/server-metric/net.vue b/packages/client/src/widgets/server-metric/net.vue new file mode 100644 index 0000000000..23c148eeb6 --- /dev/null +++ b/packages/client/src/widgets/server-metric/net.vue @@ -0,0 +1,148 @@ + + + + + diff --git a/packages/client/src/widgets/server-metric/pie.vue b/packages/client/src/widgets/server-metric/pie.vue new file mode 100644 index 0000000000..38dcf6fcd9 --- /dev/null +++ b/packages/client/src/widgets/server-metric/pie.vue @@ -0,0 +1,65 @@ + + + + + diff --git a/packages/client/src/widgets/slideshow.vue b/packages/client/src/widgets/slideshow.vue new file mode 100644 index 0000000000..0909bda67c --- /dev/null +++ b/packages/client/src/widgets/slideshow.vue @@ -0,0 +1,167 @@ + + + + + diff --git a/packages/client/src/widgets/timeline.vue b/packages/client/src/widgets/timeline.vue new file mode 100644 index 0000000000..0d0629abe2 --- /dev/null +++ b/packages/client/src/widgets/timeline.vue @@ -0,0 +1,116 @@ + + + diff --git a/packages/client/src/widgets/trends.vue b/packages/client/src/widgets/trends.vue new file mode 100644 index 0000000000..dba3392618 --- /dev/null +++ b/packages/client/src/widgets/trends.vue @@ -0,0 +1,111 @@ + + + + + -- cgit v1.2.3-freya