From 1be5373dfc839be589668dea84009eb33fa0213b Mon Sep 17 00:00:00 2001 From: naskya Date: Fri, 19 Apr 2024 21:59:12 +0900 Subject: [PATCH 01/13] chore (backend-rs): make exported enum compatible w/ TypeScript's string enum --- packages/backend-rs/Makefile | 2 +- packages/backend-rs/index.d.ts | 132 +++++++++--------- packages/backend-rs/package.json | 4 +- .../src/model/entity/sea_orm_active_enums.rs | 20 +-- 4 files changed, 79 insertions(+), 79 deletions(-) diff --git a/packages/backend-rs/Makefile b/packages/backend-rs/Makefile index eb4b30c6df..11b614c82a 100644 --- a/packages/backend-rs/Makefile +++ b/packages/backend-rs/Makefile @@ -17,7 +17,7 @@ regenerate-entities: attribute=$$(printf 'cfg_attr(feature = "napi", napi_derive::napi(object, js_name = "%s", use_nullable = true))' "$${jsname}"); \ sed -i "s/NAPI_EXTRA_ATTR_PLACEHOLDER/$${attribute}/" "$${file}"; \ done - sed -i 's/#\[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)\]/#[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]\n#[cfg_attr(not(feature = "napi"), derive(Clone))]\n#[cfg_attr(feature = "napi", napi_derive::napi)]/' \ + sed -i 's/#\[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)\]/#[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]\n#[cfg_attr(not(feature = "napi"), derive(Clone))]\n#[cfg_attr(feature = "napi", napi_derive::napi(string_enum = "camelCase"))]/' \ src/model/entity/sea_orm_active_enums.rs cargo fmt --all -- diff --git a/packages/backend-rs/index.d.ts b/packages/backend-rs/index.d.ts index 5ee69969c6..1cf961bd30 100644 --- a/packages/backend-rs/index.d.ts +++ b/packages/backend-rs/index.d.ts @@ -772,81 +772,81 @@ export interface ReplyMuting { muteeId: string muterId: string } -export const enum AntennaSrcEnum { - All = 0, - Group = 1, - Home = 2, - Instances = 3, - List = 4, - Users = 5 +export enum AntennaSrcEnum { + All = 'all', + Group = 'group', + Home = 'home', + Instances = 'instances', + List = 'list', + Users = 'users' } -export const enum MutedNoteReasonEnum { - Manual = 0, - Other = 1, - Spam = 2, - Word = 3 +export enum MutedNoteReasonEnum { + Manual = 'manual', + Other = 'other', + Spam = 'spam', + Word = 'word' } -export const enum NoteVisibilityEnum { - Followers = 0, - Hidden = 1, - Home = 2, - Public = 3, - Specified = 4 +export enum NoteVisibilityEnum { + Followers = 'followers', + Hidden = 'hidden', + Home = 'home', + Public = 'public', + Specified = 'specified' } -export const enum NotificationTypeEnum { - App = 0, - Follow = 1, - FollowRequestAccepted = 2, - GroupInvited = 3, - Mention = 4, - PollEnded = 5, - PollVote = 6, - Quote = 7, - Reaction = 8, - ReceiveFollowRequest = 9, - Renote = 10, - Reply = 11 +export enum NotificationTypeEnum { + App = 'app', + Follow = 'follow', + FollowRequestAccepted = 'followRequestAccepted', + GroupInvited = 'groupInvited', + Mention = 'mention', + PollEnded = 'pollEnded', + PollVote = 'pollVote', + Quote = 'quote', + Reaction = 'reaction', + ReceiveFollowRequest = 'receiveFollowRequest', + Renote = 'renote', + Reply = 'reply' } -export const enum PageVisibilityEnum { - Followers = 0, - Public = 1, - Specified = 2 +export enum PageVisibilityEnum { + Followers = 'followers', + Public = 'public', + Specified = 'specified' } -export const enum PollNotevisibilityEnum { - Followers = 0, - Home = 1, - Public = 2, - Specified = 3 +export enum PollNotevisibilityEnum { + Followers = 'followers', + Home = 'home', + Public = 'public', + Specified = 'specified' } -export const enum RelayStatusEnum { - Accepted = 0, - Rejected = 1, - Requesting = 2 +export enum RelayStatusEnum { + Accepted = 'accepted', + Rejected = 'rejected', + Requesting = 'requesting' } -export const enum UserEmojimodpermEnum { - Add = 0, - Full = 1, - Mod = 2, - Unauthorized = 3 +export enum UserEmojimodpermEnum { + Add = 'add', + Full = 'full', + Mod = 'mod', + Unauthorized = 'unauthorized' } -export const enum UserProfileFfvisibilityEnum { - Followers = 0, - Private = 1, - Public = 2 +export enum UserProfileFfvisibilityEnum { + Followers = 'followers', + Private = 'private', + Public = 'public' } -export const enum UserProfileMutingnotificationtypesEnum { - App = 0, - Follow = 1, - FollowRequestAccepted = 2, - GroupInvited = 3, - Mention = 4, - PollEnded = 5, - PollVote = 6, - Quote = 7, - Reaction = 8, - ReceiveFollowRequest = 9, - Renote = 10, - Reply = 11 +export enum UserProfileMutingnotificationtypesEnum { + App = 'app', + Follow = 'follow', + FollowRequestAccepted = 'followRequestAccepted', + GroupInvited = 'groupInvited', + Mention = 'mention', + PollEnded = 'pollEnded', + PollVote = 'pollVote', + Quote = 'quote', + Reaction = 'reaction', + ReceiveFollowRequest = 'receiveFollowRequest', + Renote = 'renote', + Reply = 'reply' } export interface Signin { id: string diff --git a/packages/backend-rs/package.json b/packages/backend-rs/package.json index 69ae09fa49..1f3f49e9fb 100644 --- a/packages/backend-rs/package.json +++ b/packages/backend-rs/package.json @@ -33,8 +33,8 @@ }, "scripts": { "artifacts": "napi artifacts", - "build": "napi build --features napi --platform --release ./built/", - "build:debug": "napi build --features napi --platform ./built/", + "build": "napi build --features napi --no-const-enum --platform --release ./built/", + "build:debug": "napi build --features napi --no-const-enum --platform ./built/", "prepublishOnly": "napi prepublish -t npm", "test": "pnpm run cargo:test && pnpm run build:debug && ava", "universal": "napi universal", diff --git a/packages/backend-rs/src/model/entity/sea_orm_active_enums.rs b/packages/backend-rs/src/model/entity/sea_orm_active_enums.rs index 861b3a18d0..38820e1bd8 100644 --- a/packages/backend-rs/src/model/entity/sea_orm_active_enums.rs +++ b/packages/backend-rs/src/model/entity/sea_orm_active_enums.rs @@ -4,7 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)] #[cfg_attr(not(feature = "napi"), derive(Clone))] -#[cfg_attr(feature = "napi", napi_derive::napi)] +#[cfg_attr(feature = "napi", napi_derive::napi(string_enum = "camelCase"))] #[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "antenna_src_enum")] pub enum AntennaSrcEnum { #[sea_orm(string_value = "all")] @@ -22,7 +22,7 @@ pub enum AntennaSrcEnum { } #[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)] #[cfg_attr(not(feature = "napi"), derive(Clone))] -#[cfg_attr(feature = "napi", napi_derive::napi)] +#[cfg_attr(feature = "napi", napi_derive::napi(string_enum = "camelCase"))] #[sea_orm( rs_type = "String", db_type = "Enum", @@ -40,7 +40,7 @@ pub enum MutedNoteReasonEnum { } #[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)] #[cfg_attr(not(feature = "napi"), derive(Clone))] -#[cfg_attr(feature = "napi", napi_derive::napi)] +#[cfg_attr(feature = "napi", napi_derive::napi(string_enum = "camelCase"))] #[sea_orm( rs_type = "String", db_type = "Enum", @@ -60,7 +60,7 @@ pub enum NoteVisibilityEnum { } #[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)] #[cfg_attr(not(feature = "napi"), derive(Clone))] -#[cfg_attr(feature = "napi", napi_derive::napi)] +#[cfg_attr(feature = "napi", napi_derive::napi(string_enum = "camelCase"))] #[sea_orm( rs_type = "String", db_type = "Enum", @@ -94,7 +94,7 @@ pub enum NotificationTypeEnum { } #[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)] #[cfg_attr(not(feature = "napi"), derive(Clone))] -#[cfg_attr(feature = "napi", napi_derive::napi)] +#[cfg_attr(feature = "napi", napi_derive::napi(string_enum = "camelCase"))] #[sea_orm( rs_type = "String", db_type = "Enum", @@ -110,7 +110,7 @@ pub enum PageVisibilityEnum { } #[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)] #[cfg_attr(not(feature = "napi"), derive(Clone))] -#[cfg_attr(feature = "napi", napi_derive::napi)] +#[cfg_attr(feature = "napi", napi_derive::napi(string_enum = "camelCase"))] #[sea_orm( rs_type = "String", db_type = "Enum", @@ -128,7 +128,7 @@ pub enum PollNotevisibilityEnum { } #[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)] #[cfg_attr(not(feature = "napi"), derive(Clone))] -#[cfg_attr(feature = "napi", napi_derive::napi)] +#[cfg_attr(feature = "napi", napi_derive::napi(string_enum = "camelCase"))] #[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "relay_status_enum")] pub enum RelayStatusEnum { #[sea_orm(string_value = "accepted")] @@ -140,7 +140,7 @@ pub enum RelayStatusEnum { } #[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)] #[cfg_attr(not(feature = "napi"), derive(Clone))] -#[cfg_attr(feature = "napi", napi_derive::napi)] +#[cfg_attr(feature = "napi", napi_derive::napi(string_enum = "camelCase"))] #[sea_orm( rs_type = "String", db_type = "Enum", @@ -158,7 +158,7 @@ pub enum UserEmojimodpermEnum { } #[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)] #[cfg_attr(not(feature = "napi"), derive(Clone))] -#[cfg_attr(feature = "napi", napi_derive::napi)] +#[cfg_attr(feature = "napi", napi_derive::napi(string_enum = "camelCase"))] #[sea_orm( rs_type = "String", db_type = "Enum", @@ -174,7 +174,7 @@ pub enum UserProfileFfvisibilityEnum { } #[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)] #[cfg_attr(not(feature = "napi"), derive(Clone))] -#[cfg_attr(feature = "napi", napi_derive::napi)] +#[cfg_attr(feature = "napi", napi_derive::napi(string_enum = "camelCase"))] #[sea_orm( rs_type = "String", db_type = "Enum", From ab221c98a74ee665784b773bb6ef02061a61946e Mon Sep 17 00:00:00 2001 From: Lhcfl Date: Sat, 20 Apr 2024 00:05:37 +0800 Subject: [PATCH 02/13] revert unnecessary MaybeRef in components --- packages/client/src/components/MkChartTooltip.vue | 3 +-- .../client/src/components/MkReactionTooltip.vue | 3 +-- .../src/components/MkReactionsViewer.details.vue | 3 +-- packages/client/src/components/MkTooltip.vue | 13 +++---------- packages/client/src/components/MkUsersTooltip.vue | 3 +-- packages/client/src/components/MkWaitingDialog.vue | 9 ++++----- packages/client/src/os.ts | 9 +++++++-- 7 files changed, 18 insertions(+), 25 deletions(-) diff --git a/packages/client/src/components/MkChartTooltip.vue b/packages/client/src/components/MkChartTooltip.vue index 678a3ccdaa..cafc40413b 100644 --- a/packages/client/src/components/MkChartTooltip.vue +++ b/packages/client/src/components/MkChartTooltip.vue @@ -28,11 +28,10 @@