diff --git a/src/app/components/create-room/utils.ts b/src/app/components/create-room/utils.ts index 063d91947..520bc508a 100644 --- a/src/app/components/create-room/utils.ts +++ b/src/app/components/create-room/utils.ts @@ -11,6 +11,7 @@ import type { StateEvents } from '$types/matrix-sdk'; import { getViaServers } from '$plugins/via-servers'; import { getMxIdServer } from '$utils/mxIdHelper'; import { CreateRoomAccess } from './types'; +import * as prefix from '$unstable/prefixes'; export const createRoomCreationContent = ( type: RoomType | undefined, @@ -87,7 +88,7 @@ export const createRoomEncryptionState = () => ({ }); export const createRoomCallState = () => ({ - type: 'org.matrix.msc3401.call', + type: prefix.MATRIX_UNSTABLE_ROOM_TYPE_CALL_PROPERTY_NAME, state_key: '', content: {}, }); diff --git a/src/app/components/message/MsgTypeRenderers.tsx b/src/app/components/message/MsgTypeRenderers.tsx index 303c90313..8fb7f8c78 100644 --- a/src/app/components/message/MsgTypeRenderers.tsx +++ b/src/app/components/message/MsgTypeRenderers.tsx @@ -16,10 +16,7 @@ import type { IVideoContent, IVideoInfo, } from '$types/matrix/common'; -import { - MATRIX_SPOILER_PROPERTY_NAME, - MATRIX_SPOILER_REASON_PROPERTY_NAME, -} from '$types/matrix/common'; +import * as prefix from '$unstable/prefixes'; import { FALLBACK_MIMETYPE, getBlobSafeMimeType } from '$utils/mimeTypes'; import { parseGeoUri, scaleYDimension } from '$utils/common'; import { useSetting } from '$state/hooks/settings'; @@ -133,7 +130,9 @@ const getUrlsFromContent = ( urls = urls.filter((url) => safeUrlsSet.has(url) && !url.startsWith(MATRIX_TO_BASE)); } - let bundleContent = content['com.beeper.linkpreviews'] as BundleContent[]; + let bundleContent = content[ + prefix.MATRIX_UNSTABLE_EMBEDDED_LINK_PREVIEW_PROPERTY_NAME + ] as BundleContent[]; try { bundleContent = bundleContent?.filter((bundle) => !!urls?.includes(bundle.matched_url)); if (renderUrlsPreview && bundleContent) @@ -170,7 +169,7 @@ export function MText({ ); const isForwarded = useMemo(() => { - const forwardMeta = content['moe.sable.message.forward']; + const forwardMeta = content[prefix.MATRIX_SABLE_UNSTABLE_MESSAGE_FORWARD_META_PROPERTY_NAME]; return typeof forwardMeta === 'object'; }, [content]); @@ -205,7 +204,13 @@ export function MText({ const { urls, bundleContent } = getUrlsFromContent(content, renderUrlsPreview); - if ((content['com.beeper.per_message_profile'] as PerMessageProfileBeeperFormat)?.has_fallback) { + if ( + ( + content[ + prefix.MATRIX_UNSTABLE_PER_MESSAGE_PROFILE_PROPERTY_NAME + ] as PerMessageProfileBeeperFormat + )?.has_fallback + ) { // unwrap per-message profile fallback if present return ( <> @@ -428,8 +433,8 @@ export function MImage({ content, renderImageContent, outlined }: MImageProps) { mimeType: imgInfo?.mimetype, url: mxcUrl, encInfo: content.file, - markedAsSpoiler: content[MATRIX_SPOILER_PROPERTY_NAME], - spoilerReason: content[MATRIX_SPOILER_REASON_PROPERTY_NAME], + markedAsSpoiler: content[prefix.MATRIX_UNSTABLE_SPOILER_PROPERTY_NAME], + spoilerReason: content[prefix.MATRIX_UNSTABLE_SPOILER_REASON_PROPERTY_NAME], })} @@ -500,8 +505,8 @@ export function MVideo({ content, renderAsFile, renderVideoContent, outlined }: mimeType: safeMimeType, url: mxcUrl, encInfo: content.file, - markedAsSpoiler: content[MATRIX_SPOILER_PROPERTY_NAME], - spoilerReason: content[MATRIX_SPOILER_REASON_PROPERTY_NAME], + markedAsSpoiler: content[prefix.MATRIX_UNSTABLE_SPOILER_PROPERTY_NAME], + spoilerReason: content[prefix.MATRIX_UNSTABLE_SPOILER_REASON_PROPERTY_NAME], })} diff --git a/src/app/components/message/content/ImageContent.tsx b/src/app/components/message/content/ImageContent.tsx index d5d9ccc41..183cb35f5 100644 --- a/src/app/components/message/content/ImageContent.tsx +++ b/src/app/components/message/content/ImageContent.tsx @@ -25,7 +25,6 @@ import { BlurhashCanvas } from 'react-blurhash'; import FocusTrap from 'focus-trap-react'; import type { EncryptedAttachmentInfo } from 'browser-encrypt-attachment'; import type { IImageInfo } from '$types/matrix/common'; -import { MATRIX_BLUR_HASH_PROPERTY_NAME } from '$types/matrix/common'; import { AsyncStatus, useAsyncCallback } from '$hooks/useAsyncCallback'; import { useMatrixClient } from '$hooks/useMatrixClient'; import { bytesToSize } from '$utils/common'; @@ -36,6 +35,7 @@ import { useMediaAuthentication } from '$hooks/useMediaAuthentication'; import { ModalWide } from '$styles/Modal.css'; import { validBlurHash } from '$utils/blurHash'; import * as css from './style.css'; +import { MATRIX_UNSTABLE_BLUR_HASH_PROPERTY_NAME } from '../../../../unstable/prefixes'; type RenderViewerProps = { src: string; @@ -84,7 +84,7 @@ export const ImageContent = as<'div', ImageContentProps>( ) => { const mx = useMatrixClient(); const useAuthentication = useMediaAuthentication(); - const blurHash = validBlurHash(info?.[MATRIX_BLUR_HASH_PROPERTY_NAME]); + const blurHash = validBlurHash(info?.[MATRIX_UNSTABLE_BLUR_HASH_PROPERTY_NAME]); const [load, setLoad] = useState(false); const [error, setError] = useState(false); diff --git a/src/app/components/message/content/VideoContent.tsx b/src/app/components/message/content/VideoContent.tsx index 51658ebf5..2b1166084 100644 --- a/src/app/components/message/content/VideoContent.tsx +++ b/src/app/components/message/content/VideoContent.tsx @@ -20,7 +20,6 @@ import classNames from 'classnames'; import { BlurhashCanvas } from 'react-blurhash'; import type { EncryptedAttachmentInfo } from 'browser-encrypt-attachment'; import type { IThumbnailContent, IVideoInfo } from '$types/matrix/common'; -import { MATRIX_BLUR_HASH_PROPERTY_NAME } from '$types/matrix/common'; import { useMatrixClient } from '$hooks/useMatrixClient'; import { AsyncStatus, useAsyncCallback } from '$hooks/useAsyncCallback'; import { bytesToSize, millisecondsToMinutesAndSeconds } from '$utils/common'; @@ -28,6 +27,7 @@ import { decryptFile, downloadEncryptedMedia, downloadMedia, mxcUrlToHttp } from import { useMediaAuthentication } from '$hooks/useMediaAuthentication'; import { validBlurHash } from '$utils/blurHash'; import * as css from './style.css'; +import { MATRIX_UNSTABLE_BLUR_HASH_PROPERTY_NAME } from '../../../../unstable/prefixes'; type RenderVideoProps = { title: string; @@ -69,7 +69,7 @@ export const VideoContent = as<'div', VideoContentProps>( ) => { const mx = useMatrixClient(); const useAuthentication = useMediaAuthentication(); - const blurHash = validBlurHash(info.thumbnail_info?.[MATRIX_BLUR_HASH_PROPERTY_NAME]); + const blurHash = validBlurHash(info.thumbnail_info?.[MATRIX_UNSTABLE_BLUR_HASH_PROPERTY_NAME]); const [load, setLoad] = useState(false); const [error, setError] = useState(false); diff --git a/src/app/components/message/modals/MessageForward.tsx b/src/app/components/message/modals/MessageForward.tsx index ebd8566c0..f9389bb66 100644 --- a/src/app/components/message/modals/MessageForward.tsx +++ b/src/app/components/message/modals/MessageForward.tsx @@ -27,6 +27,7 @@ import { sanitizeCustomHtml, sanitizeText } from '$utils/sanitize'; import { createDebugLogger } from '$utils/debugLogger'; import * as Sentry from '@sentry/react'; import { isRoomPrivate } from '$utils/roomVisibility'; +import * as prefix from '$unstable/prefixes'; const debugLog = createDebugLogger('MessageForward'); @@ -203,7 +204,7 @@ export function MessageForwardInternal({ const baseContent = { ...mEvent.getContent() }; delete baseContent['m.relates_to']; // remove relations from the forwarded message delete baseContent['m.mentions']; // remove mentions from forwarded message - delete baseContent['com.beeper.per_message_profile']; // remove per-message profile as that could confuse clients in the target room + delete baseContent[prefix.MATRIX_UNSTABLE_PER_MESSAGE_PROFILE_PROPERTY_NAME]; // remove per-message profile as that could confuse clients in the target room let content; // handle privacy stuff if (isRoomPrivate(mx, room)) { @@ -212,13 +213,13 @@ export function MessageForwardInternal({ content = { ...baseContent, ...forwardedTextContent, - 'moe.sable.message.forward': { + [prefix.MATRIX_SABLE_UNSTABLE_MESSAGE_FORWARD_META_PROPERTY_NAME]: { v: 1, is_forwarded: true, original_timestamp: mEvent.getTs(), original_event_private: true, } satisfies ForwardMeta, - 'com.famedly.app.forwarded': { + [prefix.MATRIX_UNSTABLE_MESSAGE_FORWARD_META_PROPERTY_NAME]: { origin_server_ts: mEvent.getTs(), } satisfies MSC2723ForwardMeta, }; @@ -226,7 +227,7 @@ export function MessageForwardInternal({ content = { ...baseContent, ...forwardedTextContent, - 'moe.sable.message.forward': { + [prefix.MATRIX_SABLE_UNSTABLE_MESSAGE_FORWARD_META_PROPERTY_NAME]: { v: 1, is_forwarded: true, original_timestamp: mEvent.getTs(), @@ -234,7 +235,7 @@ export function MessageForwardInternal({ original_event_id: eventId, original_event_private: false, } satisfies ForwardMeta, - 'com.famedly.app.forwarded': { + [prefix.MATRIX_UNSTABLE_MESSAGE_FORWARD_META_PROPERTY_NAME]: { event_id: eventId, room_id: room.roomId, origin_server_ts: mEvent.getTs(), diff --git a/src/app/components/url-preview/ClientPreview.tsx b/src/app/components/url-preview/ClientPreview.tsx index cea5b3c6f..61809f187 100644 --- a/src/app/components/url-preview/ClientPreview.tsx +++ b/src/app/components/url-preview/ClientPreview.tsx @@ -5,11 +5,11 @@ import { AsyncStatus, useAsyncCallback } from '$hooks/useAsyncCallback'; import { useSetting } from '$state/hooks/settings'; import { settingsAtom } from '$state/settings'; import { encodeBlurHash } from '$utils/blurHash'; -import { MATRIX_BLUR_HASH_PROPERTY_NAME } from '$types/matrix/common'; import { Attachment, AttachmentBox, AttachmentHeader } from '../message/attachment'; import { Image } from '../media'; import { UrlPreview } from './UrlPreview'; import { VideoContent } from '../message'; +import { MATRIX_UNSTABLE_BLUR_HASH_PROPERTY_NAME } from '../../../unstable/prefixes'; interface OEmbed { type: 'photo' | 'video' | 'link' | 'rich'; @@ -114,7 +114,7 @@ export const YoutubeElement = as<'div', YoutubeElementProps>(({ videoInfo, embed mimeType="fake" url={videoUrl} info={{ - thumbnail_info: { [MATRIX_BLUR_HASH_PROPERTY_NAME]: blurHash }, + thumbnail_info: { [MATRIX_UNSTABLE_BLUR_HASH_PROPERTY_NAME]: blurHash }, }} renderThumbnail={() => ( { let rawBio = - profile.extended?.['moe.sable.app.bio'] || - profile.extended?.['chat.commet.profile_bio'] || + profile.extended?.[prefix.MATRIX_SABLE_UNSTABLE_PROFILE_BIOGRAPHY_PROPERTY_NAME] || + profile.extended?.[prefix.MATRIX_COMMET_UNSTABLE_PROFILE_BIO_PROPERTY_NAME] || profile.bio; if (!rawBio) return null; diff --git a/src/app/features/room/RoomInput.tsx b/src/app/features/room/RoomInput.tsx index d0223f6bc..448dee7a3 100644 --- a/src/app/features/room/RoomInput.tsx +++ b/src/app/features/room/RoomInput.tsx @@ -128,7 +128,6 @@ import { getSupportedAudioExtension } from '$plugins/voice-recorder-kit/supporte import { sanitizeText } from '$utils/sanitize'; import { PKitCommandMessageHandler } from '$plugins/pluralkit-handler/PKitCommandMessageHandler'; import { PKitProxyMessageHandler } from '$plugins/pluralkit-handler/PKitProxyMessageHandler'; -import { MATRIX_IMAGE_SOURCE_PACK_PROPERTY_NAME } from '$types/matrix/common'; import type { IGenericMSC4459, MSC4459ImagePackReference } from '$types/matrix/common'; import { getImagePackReferencesForMxc, @@ -152,6 +151,7 @@ import type { AudioRecordingCompletePayload, } from './AudioMessageRecorder'; import { AudioMessageRecorder } from './AudioMessageRecorder'; +import * as prefix from '$unstable/prefixes'; // Returns the event ID of the most recent non-reaction/non-edit event in a thread, // falling back to the thread root if no replies exist yet. @@ -546,10 +546,8 @@ export const RoomInput = forwardRef( // We intentionally mutate the objects here to avoid unnecessary copying // mutating should be unproblematic here, since contents isn't a react component, // or used for rendering - c['com.beeper.per_message_profile'] = convertPerMessageProfileToBeeperFormat( - perMessageProfile, - false - ); + c[prefix.MATRIX_UNSTABLE_PER_MESSAGE_PROFILE_PROPERTY_NAME] = + convertPerMessageProfileToBeeperFormat(perMessageProfile, false); }); } @@ -827,11 +825,16 @@ export const RoomInput = forwardRef( } content['m.mentions'] = getMentionContent(Array.from(mentionData.users), mentionData.room); - content[MATRIX_IMAGE_SOURCE_PACK_PROPERTY_NAME] = imagePacksUsedRef.current.toJSON(); + content[prefix.MATRIX_UNSTABLE_IMAGE_SOURCE_PACK_PROPERTY_NAME] = + imagePacksUsedRef.current.toJSON(); const links = getLinks(serializedChildren); - content['com.beeper.linkpreviews'] = []; - links?.forEach((link) => content['com.beeper.linkpreviews'].push({ matched_url: link })); + content[prefix.MATRIX_UNSTABLE_EMBEDDED_LINK_PREVIEW_PROPERTY_NAME] = []; + links?.forEach((link) => + content[prefix.MATRIX_UNSTABLE_EMBEDDED_LINK_PREVIEW_PROPERTY_NAME].push({ + matched_url: link, + }) + ); if (replyDraft || !customHtmlEqualsPlainText(formattedBody, body)) { content.format = 'org.matrix.custom.html'; @@ -851,18 +854,19 @@ export const RoomInput = forwardRef( if (pmpProxyingEnable && pluralkitProxyMessageHandler.isAProxiedMessage(plainText)) plainText = pluralkitProxyMessageHandler.stripProxyFromMessage(plainText) ?? plainText; if (perMessageProfile) { - content['com.beeper.per_message_profile'] = convertPerMessageProfileToBeeperFormat( - perMessageProfile, - perMessageProfile.name.trim() !== '' - ); + content[prefix.MATRIX_UNSTABLE_PER_MESSAGE_PROFILE_PROPERTY_NAME] = + convertPerMessageProfileToBeeperFormat( + perMessageProfile, + perMessageProfile.name.trim() !== '' + ); if (perMessageProfile.name.trim() !== '') { // if a per-message profile is used, it must per spec include a fallback - const prefix = `${perMessageProfile.name}: `; + const pmpPrefix = `${perMessageProfile.name}: `; - if (!content.body.startsWith(prefix)) { + if (!content.body.startsWith(pmpPrefix)) { // to prevent double-prefixing when the fallback is already present - content.body = prefix + content.body; + content.body = pmpPrefix + content.body; } /** @@ -1171,12 +1175,8 @@ export const RoomInput = forwardRef( }; // add the image pack reference - content[MATRIX_IMAGE_SOURCE_PACK_PROPERTY_NAME] = getImagePackReferencesForMxcWrappedInMap( - mxc, - mx, - ImageUsage.Sticker, - room - ); + content[prefix.MATRIX_UNSTABLE_IMAGE_SOURCE_PACK_PROPERTY_NAME] = + getImagePackReferencesForMxcWrappedInMap(mxc, mx, ImageUsage.Sticker, room); /** * the currently with the room associated per-message profile, if any, so that it can be included in the message content when sending. @@ -1186,17 +1186,11 @@ export const RoomInput = forwardRef( const perMessageProfile = await getCurrentlyUsedPerMessageProfileForRoom(mx, roomId); if (perMessageProfile) { - content['com.beeper.per_message_profile'] = convertPerMessageProfileToBeeperFormat( - perMessageProfile, - false - ); + content[prefix.MATRIX_UNSTABLE_PER_MESSAGE_PROFILE_PROPERTY_NAME] = + convertPerMessageProfileToBeeperFormat(perMessageProfile, false); } - content[MATRIX_IMAGE_SOURCE_PACK_PROPERTY_NAME] = getImagePackReferencesForMxcWrappedInMap( - mxc, - mx, - ImageUsage.Sticker, - room - ); + content[prefix.MATRIX_UNSTABLE_IMAGE_SOURCE_PACK_PROPERTY_NAME] = + getImagePackReferencesForMxcWrappedInMap(mxc, mx, ImageUsage.Sticker, room); if (replyDraft) { content['m.relates_to'] = getReplyContent(replyDraft, room); diff --git a/src/app/features/room/msgContent.ts b/src/app/features/room/msgContent.ts index 85e7200b8..8d51eb213 100644 --- a/src/app/features/room/msgContent.ts +++ b/src/app/features/room/msgContent.ts @@ -2,7 +2,6 @@ import type { IContent, MatrixClient } from '$types/matrix-sdk'; import { MsgType } from '$types/matrix-sdk'; import to from 'await-to-js'; import type { IThumbnailContent } from '$types/matrix/common'; -import { MATRIX_BLUR_HASH_PROPERTY_NAME, MATRIX_SPOILER_PROPERTY_NAME } from '$types/matrix/common'; import { getImageFileUrl, getThumbnail, @@ -16,6 +15,10 @@ import type { TUploadItem } from '$state/room/roomInputDrafts'; import { encodeBlurHash } from '$utils/blurHash'; import { scaleYDimension } from '$utils/common'; import { createLogger } from '$utils/debug'; +import { + MATRIX_UNSTABLE_BLUR_HASH_PROPERTY_NAME, + MATRIX_UNSTABLE_SPOILER_PROPERTY_NAME, +} from '../../../unstable/prefixes'; const log = createLogger('msgContent'); @@ -57,14 +60,14 @@ export const getImageMsgContent = async ( msgtype: MsgType.Image, filename: file.name, body: file.name, - [MATRIX_SPOILER_PROPERTY_NAME]: metadata.markedAsSpoiler, + [MATRIX_UNSTABLE_SPOILER_PROPERTY_NAME]: metadata.markedAsSpoiler, }; if (imgEl) { const blurHash = encodeBlurHash(imgEl, 512, scaleYDimension(imgEl.width, 512, imgEl.height)); content.info = { ...getImageInfo(imgEl, file), - [MATRIX_BLUR_HASH_PROPERTY_NAME]: blurHash, + [MATRIX_UNSTABLE_BLUR_HASH_PROPERTY_NAME]: blurHash, }; } if (encInfo) { @@ -97,7 +100,7 @@ export const getVideoMsgContent = async ( msgtype: MsgType.Video, filename: file.name, body: file.name, - [MATRIX_SPOILER_PROPERTY_NAME]: metadata.markedAsSpoiler, + [MATRIX_UNSTABLE_SPOILER_PROPERTY_NAME]: metadata.markedAsSpoiler, }; if (videoEl) { const [thumbError, thumbContent] = await to( @@ -109,7 +112,7 @@ export const getVideoMsgContent = async ( ) ); if (thumbContent && thumbContent.thumbnail_info) { - thumbContent.thumbnail_info[MATRIX_BLUR_HASH_PROPERTY_NAME] = encodeBlurHash( + thumbContent.thumbnail_info[MATRIX_UNSTABLE_BLUR_HASH_PROPERTY_NAME] = encodeBlurHash( videoEl, 512, scaleYDimension(videoEl.videoWidth, 512, videoEl.videoHeight) diff --git a/src/app/features/settings/account/AnimalCosmetics.tsx b/src/app/features/settings/account/AnimalCosmetics.tsx index e31be585c..a214a036e 100644 --- a/src/app/features/settings/account/AnimalCosmetics.tsx +++ b/src/app/features/settings/account/AnimalCosmetics.tsx @@ -9,6 +9,7 @@ import { Box, Switch, Text } from 'folds'; import { useSetAtom } from 'jotai'; import { useCallback } from 'react'; import { SequenceCardStyle } from '../styles.css'; +import * as prefix from '$unstable/prefixes'; type AnimalCosmeticsProps = { profile: UserProfile; @@ -54,7 +55,12 @@ export function AnimalCosmetics({ profile, userId }: Readonly handleSaveField('kitty.meow.is_cat', !isCat)} + onChange={() => + handleSaveField( + prefix.MATRIX_SABLE_UNSTABLE_ANIMAL_IDENTITY_IS_CAT_PROPERTY_NAME, + !isCat + ) + } /> } /> @@ -68,7 +74,12 @@ export function AnimalCosmetics({ profile, userId }: Readonly handleSaveField('kitty.meow.has_cats', !hasCats)} + onChange={() => + handleSaveField( + prefix.MATRIX_SABLE_UNSTABLE_ANIMAL_IDENTITY_HAS_CAT_PROPERTY_NAME, + !hasCats + ) + } /> } /> diff --git a/src/app/features/settings/account/Profile.tsx b/src/app/features/settings/account/Profile.tsx index 0fefcbaf6..4715d660b 100644 --- a/src/app/features/settings/account/Profile.tsx +++ b/src/app/features/settings/account/Profile.tsx @@ -50,6 +50,7 @@ import { BioEditor } from './BioEditor'; import { NameColorEditor } from './NameColorEditor'; import { StatusEditor } from './StatusEditor'; import { AnimalCosmetics } from './AnimalCosmetics'; +import * as prefix from '$unstable/prefixes'; type PronounSet = { summary: string; @@ -258,7 +259,7 @@ function ProfileBanner({ profile }: Readonly>) { if (imageFileURL) setStagedUrl(imageFileURL); - mx.setExtendedProfileProperty?.('chat.commet.profile_banner', mxc); + mx.setExtendedProfileProperty?.(prefix.MATRIX_UNSTABLE_PROFILE_BANNER_PROPERTY_NAME, mxc); setImageFile(undefined); }, [mx, imageFileURL] @@ -269,7 +270,10 @@ function ProfileBanner({ profile }: Readonly>) { setStagedUrl(undefined); setImageFile(undefined); - await mx.setExtendedProfileProperty?.('chat.commet.profile_banner', null); + await mx.setExtendedProfileProperty?.( + prefix.MATRIX_UNSTABLE_PROFILE_BANNER_PROPERTY_NAME, + null + ); setAlertRemove(false); }; @@ -539,9 +543,13 @@ function ProfileExtended({ profile, userId }: Readonly) { focusId="name-color" current={ profile.nameColor || - (profile.extended?.['moe.sable.app.name_color'] as string | undefined) + (profile.extended?.[prefix.MATRIX_SABLE_UNSTABLE_NAME_COLOR_PROPERTY_NAME] as + | string + | undefined) + } + onSave={(color) => + handleSaveField(prefix.MATRIX_SABLE_UNSTABLE_NAME_COLOR_PROPERTY_NAME, color) } - onSave={(color) => handleSaveField('moe.sable.app.name_color', color)} /> ) { focusId="name-color-dark-theme" current={ profile.nameColorDark || - (profile.extended?.['moe.sable.app.name_color_dark_theme'] as string | undefined) + (profile.extended?.[prefix.MATRIX_SABLE_UNSTABLE_NAME_COLOR_DARK_PROPERTY_NAME] as + | string + | undefined) + } + onSave={(color) => + handleSaveField(prefix.MATRIX_SABLE_UNSTABLE_NAME_COLOR_DARK_PROPERTY_NAME, color) } - onSave={(color) => handleSaveField('moe.sable.app.name_color_dark_theme', color)} /> ) { focusId="name-color-light-theme" current={ profile.nameColorLight || - (profile.extended?.['moe.sable.app.name_color_light_theme'] as string | undefined) + (profile.extended?.[prefix.MATRIX_SABLE_UNSTABLE_NAME_COLOR_LIGHT_PROPERTY_NAME] as + | string + | undefined) + } + onSave={(color) => + handleSaveField(prefix.MATRIX_SABLE_UNSTABLE_NAME_COLOR_LIGHT_PROPERTY_NAME, color) } - onSave={(color) => handleSaveField('moe.sable.app.name_color_light_theme', color)} /> ) { handleSaveField('io.fsky.nyx.pronouns', p)} + onSave={(p) => handleSaveField(prefix.MATRIX_UNSTABLE_PROFILE_PRONOUNS_PROPERTY_NAME, p)} /> ) { { - handleSaveField('us.cloke.msc4175.tz', tz); - handleSaveField('m.tz', tz); + handleSaveField(prefix.MATRIX_UNSTABLE_PROFILE_TIMEZONE_PROPERTY_NAME, tz); + handleSaveField(prefix.MATRIX_STABLE_PROFILE_TIMEZONE_PROPERTY_NAME, tz); }} /> @@ -598,17 +614,24 @@ function ProfileExtended({ profile, userId }: Readonly) { > { - handleSaveField('moe.sable.app.bio', htmlBio); + handleSaveField(prefix.MATRIX_SABLE_UNSTABLE_PROFILE_BIOGRAPHY_PROPERTY_NAME, htmlBio); // MSC4440 - handleSaveField('gay.fomx.biography', { + handleSaveField(prefix.MATRIX_UNSTABLE_PROFILE_BIOGRAPHY_PROPERTY_NAME, { 'm.text': [ { body: htmlBio, @@ -621,7 +644,7 @@ function ProfileExtended({ profile, userId }: Readonly) { } satisfies MSC4440Bio); const cleanedHtml = htmlBio.replaceAll('
', ''); - handleSaveField('chat.commet.profile_bio', { + handleSaveField(prefix.MATRIX_COMMET_UNSTABLE_PROFILE_BIO_PROPERTY_NAME, { format: 'org.matrix.custom.html', formatted_body: cleanedHtml, }); @@ -640,7 +663,7 @@ function ProfileExtended({ profile, userId }: Readonly) { focusId="user-hero-color" current={profile?.heroColorScheme?.color} onSave={(color) => - handleSaveField('chat.commet.profile_color_scheme', { + handleSaveField(prefix.MATRIX_COMMET_UNSTABLE_PROFILE_COLOR_SCHEME_PROPERTY_NAME, { color, brightness: color ? profile?.heroColorScheme?.brightness : null, }) @@ -649,7 +672,7 @@ function ProfileExtended({ profile, userId }: Readonly) { - handleSaveField('chat.commet.profile_color_scheme', { + handleSaveField(prefix.MATRIX_COMMET_UNSTABLE_PROFILE_COLOR_SCHEME_PROPERTY_NAME, { color: profile?.heroColorScheme?.color, brightness: profile?.heroColorScheme?.brightness === 'dark' ? 'light' : 'dark', }) diff --git a/src/app/hooks/timeline/useTimelineActions.ts b/src/app/hooks/timeline/useTimelineActions.ts index 9b66447d5..c82719411 100644 --- a/src/app/hooks/timeline/useTimelineActions.ts +++ b/src/app/hooks/timeline/useTimelineActions.ts @@ -9,6 +9,7 @@ import { ReactEditor } from 'slate-react'; import { getMxIdLocalPart, toggleReaction } from '$utils/matrix'; import { getMemberDisplayName, getEditedEvent } from '$utils/room'; import { createMentionElement, moveCursor } from '$components/editor'; +import * as prefix from '$unstable/prefixes'; export interface UseTimelineActionsOptions { room: Room; @@ -68,18 +69,20 @@ export function useTimelineActions({ const cleanExtended = cachedData?.extended ? { ...cachedData.extended } : undefined; if (cleanExtended) { - delete cleanExtended['io.fsky.nyx.pronouns']; - delete cleanExtended['moe.sable.app.bio']; - delete cleanExtended['chat.commet.profile_bio']; - delete cleanExtended['chat.commet.profile_status']; - delete cleanExtended['us.cloke.msc4175.tz']; - delete cleanExtended['m.tz']; - delete cleanExtended['chat.commet.profile_banner']; - delete cleanExtended['moe.sable.app.name_color']; + delete cleanExtended[prefix.MATRIX_UNSTABLE_PROFILE_PRONOUNS_PROPERTY_NAME]; + delete cleanExtended[prefix.MATRIX_SABLE_UNSTABLE_PROFILE_BIOGRAPHY_PROPERTY_NAME]; + delete cleanExtended[prefix.MATRIX_COMMET_UNSTABLE_PROFILE_BIO_PROPERTY_NAME]; + delete cleanExtended[prefix.MATRIX_COMMET_UNSTABLE_PROFILE_STATUS_PROPERTY_NAME]; + delete cleanExtended[prefix.MATRIX_UNSTABLE_PROFILE_TIMEZONE_PROPERTY_NAME]; + delete cleanExtended[prefix.MATRIX_STABLE_PROFILE_TIMEZONE_PROPERTY_NAME]; + delete cleanExtended[prefix.MATRIX_UNSTABLE_PROFILE_BANNER_PROPERTY_NAME]; + delete cleanExtended[prefix.MATRIX_SABLE_UNSTABLE_NAME_COLOR_PROPERTY_NAME]; + delete cleanExtended[prefix.MATRIX_SABLE_UNSTABLE_NAME_COLOR_DARK_PROPERTY_NAME]; + delete cleanExtended[prefix.MATRIX_SABLE_UNSTABLE_NAME_COLOR_LIGHT_PROPERTY_NAME]; delete cleanExtended.avatar_url; delete cleanExtended.displayname; - delete cleanExtended['kitty.meow.has_cats']; - delete cleanExtended['kitty.meow.is_cat']; + delete cleanExtended[prefix.MATRIX_SABLE_UNSTABLE_ANIMAL_IDENTITY_HAS_CAT_PROPERTY_NAME]; + delete cleanExtended[prefix.MATRIX_SABLE_UNSTABLE_ANIMAL_IDENTITY_IS_CAT_PROPERTY_NAME]; } openUserRoomProfile( diff --git a/src/app/hooks/usePerMessageProfile.ts b/src/app/hooks/usePerMessageProfile.ts index af525addd..0f9c7c284 100644 --- a/src/app/hooks/usePerMessageProfile.ts +++ b/src/app/hooks/usePerMessageProfile.ts @@ -3,6 +3,7 @@ import type { AccountDataCompatVersion } from '$types/matrix/accountData'; import type { PronounSet } from '$utils/pronouns'; import type { MatrixClient } from '$types/matrix-sdk'; import { CustomAccountDataEvent } from '$types/matrix/accountData'; +import { MATRIX_UNSTABLE_PROFILE_PRONOUNS_PROPERTY_NAME } from '$unstable/prefixes'; const ACCOUNT_DATA_PREFIX = CustomAccountDataEvent.SablePerProfileMessageProfiles; @@ -53,7 +54,7 @@ export type PerMessageProfileBeeperFormat = { /** * using the unstable prefix for pronouns, under which it is also stored in profiles */ - 'io.fsky.nyx.pronouns'?: PronounSet[]; + [MATRIX_UNSTABLE_PROFILE_PRONOUNS_PROPERTY_NAME]?: PronounSet[]; has_fallback?: boolean; }; @@ -72,14 +73,15 @@ export function convertPerMessageProfileToBeeperFormat( id: profile.id, displayname: profile.name, avatar_url: profile.avatarUrl, - 'io.fsky.nyx.pronouns': profile.pronouns, + [MATRIX_UNSTABLE_PROFILE_PRONOUNS_PROPERTY_NAME]: profile.pronouns, has_fallback, }; // delete empty fields // to-do maybe find a better way of doing it if (!profile.name || profile?.name.trim().length === 0) delete beeperPMP.displayname; if (!profile.avatarUrl) delete beeperPMP.avatar_url; - if (!profile.pronouns || profile.pronouns?.length === 0) delete beeperPMP['io.fsky.nyx.pronouns']; + if (!profile.pronouns || profile.pronouns?.length === 0) + delete beeperPMP[MATRIX_UNSTABLE_PROFILE_PRONOUNS_PROPERTY_NAME]; if (!has_fallback) delete beeperPMP.has_fallback; return beeperPMP; } @@ -99,7 +101,7 @@ export function convertBeeperFormatToOurPerMessageProfile( id: beeperProfile.id, name: beeperProfile.displayname ?? '', avatarUrl: beeperProfile.avatar_url, - pronouns: beeperProfile['io.fsky.nyx.pronouns'], + pronouns: beeperProfile[MATRIX_UNSTABLE_PROFILE_PRONOUNS_PROPERTY_NAME], }; } diff --git a/src/app/hooks/useUserProfile.ts b/src/app/hooks/useUserProfile.ts index e7494b640..153f3444c 100644 --- a/src/app/hooks/useUserProfile.ts +++ b/src/app/hooks/useUserProfile.ts @@ -14,6 +14,7 @@ import type { PronounSet } from '$utils/pronouns'; import { useMatrixClient } from './useMatrixClient'; import { ThemeKind, useActiveTheme } from './useTheme'; import { CustomStateEvent } from '$types/matrix/room'; +import * as prefix from '$unstable/prefixes'; const inFlightProfiles = new Map>>(); @@ -40,24 +41,26 @@ export type UserProfile = { }; const normalizeInfo = (info: Record): UserProfile => { - const msc4440Bio = info['gay.fomx.biography'] as MSC4440Bio | undefined; + const msc4440Bio = info[prefix.MATRIX_UNSTABLE_PROFILE_BIOGRAPHY_PROPERTY_NAME] as + | MSC4440Bio + | undefined; const knownKeys = new Set([ 'avatar_url', 'displayname', - 'io.fsky.nyx.pronouns', - 'us.cloke.msc4175.tz', - 'm.tz', - 'moe.sable.app.bio', - 'chat.commet.profile_bio', - 'gay.fomx.biography', - 'chat.commet.profile_banner', - 'chat.commet.profile_status', - 'moe.sable.app.name_color', - 'moe.sable.app.name_color_dark_theme', - 'moe.sable.app.name_color_light_theme', - 'chat.commet.profile_color_scheme', - 'kitty.meow.has_cats', - 'kitty.meow.is_cat', + prefix.MATRIX_UNSTABLE_PROFILE_PRONOUNS_PROPERTY_NAME, + prefix.MATRIX_STABLE_PROFILE_TIMEZONE_PROPERTY_NAME, + prefix.MATRIX_UNSTABLE_PROFILE_TIMEZONE_PROPERTY_NAME, + prefix.MATRIX_SABLE_UNSTABLE_PROFILE_BIOGRAPHY_PROPERTY_NAME, + prefix.MATRIX_COMMET_UNSTABLE_PROFILE_BIO_PROPERTY_NAME, + prefix.MATRIX_UNSTABLE_PROFILE_BIOGRAPHY_PROPERTY_NAME, + prefix.MATRIX_UNSTABLE_PROFILE_BANNER_PROPERTY_NAME, + prefix.MATRIX_COMMET_UNSTABLE_PROFILE_STATUS_PROPERTY_NAME, + prefix.MATRIX_SABLE_UNSTABLE_NAME_COLOR_PROPERTY_NAME, + prefix.MATRIX_SABLE_UNSTABLE_NAME_COLOR_LIGHT_PROPERTY_NAME, + prefix.MATRIX_SABLE_UNSTABLE_NAME_COLOR_DARK_PROPERTY_NAME, + prefix.MATRIX_COMMET_UNSTABLE_PROFILE_COLOR_SCHEME_PROPERTY_NAME, + prefix.MATRIX_SABLE_UNSTABLE_ANIMAL_IDENTITY_HAS_CAT_PROPERTY_NAME, + prefix.MATRIX_SABLE_UNSTABLE_ANIMAL_IDENTITY_IS_CAT_PROPERTY_NAME, ]); const extended: Record = {}; @@ -70,20 +73,29 @@ const normalizeInfo = (info: Record): UserProfile => { return { avatarUrl: info.avatar_url as string | undefined, displayName: info.displayname as string | undefined, - pronouns: info['io.fsky.nyx.pronouns'] as PronounSet[] | undefined, - timezone: (info['us.cloke.msc4175.tz'] || info['m.tz']) as string | undefined, + pronouns: info[prefix.MATRIX_UNSTABLE_PROFILE_PRONOUNS_PROPERTY_NAME] as + | PronounSet[] + | undefined, + timezone: (info[prefix.MATRIX_UNSTABLE_PROFILE_TIMEZONE_PROPERTY_NAME] || + info[prefix.MATRIX_STABLE_PROFILE_TIMEZONE_PROPERTY_NAME]) as string | undefined, bio: msc4440Bio?.['m.text']?.[0]?.body || - (info['moe.sable.app.bio'] as string | undefined) || - (info['chat.commet.profile_bio'] as string | undefined), - status: info['chat.commet.profile_status'] as string | undefined, - bannerUrl: info['chat.commet.profile_banner'] as string | undefined, - nameColor: info['moe.sable.app.name_color'] as string | undefined, - nameColorDark: info['moe.sable.app.name_color_dark_theme'] as string | undefined, - nameColorLight: info['moe.sable.app.name_color_light_theme'] as string | undefined, - heroColorScheme: info['chat.commet.profile_color_scheme'] as Record | undefined, - isCat: info['kitty.meow.is_cat'] === true, - hasCats: info['kitty.meow.has_cats'] === true, + (info[prefix.MATRIX_SABLE_UNSTABLE_PROFILE_BIOGRAPHY_PROPERTY_NAME] as string | undefined) || + (info[prefix.MATRIX_COMMET_UNSTABLE_PROFILE_BIO_PROPERTY_NAME] as string | undefined), + status: info[prefix.MATRIX_COMMET_UNSTABLE_PROFILE_STATUS_PROPERTY_NAME] as string | undefined, + bannerUrl: info[prefix.MATRIX_UNSTABLE_PROFILE_BANNER_PROPERTY_NAME] as string | undefined, + nameColor: info[prefix.MATRIX_SABLE_UNSTABLE_NAME_COLOR_PROPERTY_NAME] as string | undefined, + nameColorDark: info[prefix.MATRIX_SABLE_UNSTABLE_NAME_COLOR_DARK_PROPERTY_NAME] as + | string + | undefined, + nameColorLight: info[prefix.MATRIX_SABLE_UNSTABLE_NAME_COLOR_LIGHT_PROPERTY_NAME] as + | string + | undefined, + heroColorScheme: info[prefix.MATRIX_COMMET_UNSTABLE_PROFILE_COLOR_SCHEME_PROPERTY_NAME] as + | Record + | undefined, + isCat: info[prefix.MATRIX_SABLE_UNSTABLE_ANIMAL_IDENTITY_IS_CAT_PROPERTY_NAME] === true, + hasCats: info[prefix.MATRIX_SABLE_UNSTABLE_ANIMAL_IDENTITY_HAS_CAT_PROPERTY_NAME] === true, extended, _fetched: true, }; diff --git a/src/app/utils/messageReaction.ts b/src/app/utils/messageReaction.ts index cf42ea607..ae74030ad 100644 --- a/src/app/utils/messageReaction.ts +++ b/src/app/utils/messageReaction.ts @@ -1,8 +1,8 @@ -import { MATRIX_IMAGE_SOURCE_PACK_PROPERTY_NAME } from '$types/matrix/common'; import type { MatrixReactionEvent } from '$types/matrix/common'; import type { MatrixClient, Room } from 'matrix-js-sdk'; import { ImageUsage } from '$plugins/custom-emoji'; import { getImagePackReferencesForMxcWrappedInMap } from './msc4459helper'; +import { MATRIX_UNSTABLE_IMAGE_SOURCE_PACK_PROPERTY_NAME } from '$unstable/prefixes'; export const getReactionContent = ( eventId: string, @@ -18,7 +18,7 @@ export const getReactionContent = ( }, shortcode, 'com.beeper.reaction.shortcode': shortcode, - [MATRIX_IMAGE_SOURCE_PACK_PROPERTY_NAME]: getImagePackReferencesForMxcWrappedInMap( + [MATRIX_UNSTABLE_IMAGE_SOURCE_PACK_PROPERTY_NAME]: getImagePackReferencesForMxcWrappedInMap( key, matrixClient, ImageUsage.Emoticon, diff --git a/src/types/matrix-sdk-events.d.ts b/src/types/matrix-sdk-events.d.ts index 1f6ad2f83..17ca0888c 100644 --- a/src/types/matrix-sdk-events.d.ts +++ b/src/types/matrix-sdk-events.d.ts @@ -4,6 +4,7 @@ import type { InCinnySpacesContent } from '$hooks/useSidebarItems'; import type { MemberPowerTag } from '$types/matrix/room'; import type { RoomAbbreviationsContent } from '$utils/abbreviations'; import type { PronounSet } from '$utils/pronouns'; +import type * as prefix from '$unstable/prefixes'; type PowerLevelTagsEventContent = Record; @@ -33,21 +34,21 @@ type RoomCosmeticsPronounsEventContent = { declare module 'matrix-js-sdk/lib/@types/event' { interface StateEvents { - 'im.ponies.room_emotes': PackContent; - 'in.cinny.room.power_level_tags': PowerLevelTagsEventContent; - 'im.vector.modular.widgets': RoomWidgetEventContent; - 'moe.sable.room.cosmetics.color': RoomCosmeticsColorEventContent; - 'moe.sable.room.cosmetics.font': RoomCosmeticsFontEventContent; - 'moe.sable.room.cosmetics.pronouns': RoomCosmeticsPronounsEventContent; - 'moe.sable.room.abbreviations': RoomAbbreviationsContent; + [prefix.MATRIX_UNSTABLE_STATE_ROOM_EMOTES_PROPERTY_NAME]: PackContent; + [prefix.MATRIX_CINNY_UNSTABLE_STATE_ROOM_POWER_LEVELS_LABEL_PROPERTY_NAME]: PowerLevelTagsEventContent; + [prefix.MATRIX_ELEMENT_UNSTABLE_STATE_ROOM_WIDGET_PROPERTY_NAME]: RoomWidgetEventContent; + [prefix.MATRIX_SABLE_UNSTABLE_STATE_COSMETICS_MEMBER_COLOR_PROPERTY_NAME]: RoomCosmeticsColorEventContent; + [prefix.MATRIX_SABLE_UNSTABLE_STATE_COSMETICS_MEMBER_FONT_PROPERTY_NAME]: RoomCosmeticsFontEventContent; + [prefix.MATRIX_SABLE_UNSTABLE_STATE_COSMETICS_MEMBER_PRONOUNS_PROPERTY_NAME]: RoomCosmeticsPronounsEventContent; + [prefix.MATRIX_SABLE_UNSTABLE_STATE_ROOM_ABBREVIATIONS_PROPERTY_NAME]: RoomAbbreviationsContent; } interface AccountDataEvents { - 'in.cinny.spaces': InCinnySpacesContent; - 'io.element.recent_emoji': IRecentEmojiContent; - 'im.ponies.user_emotes': PackContent; - 'im.ponies.emote_rooms': EmoteRoomsContent; - 'moe.sable.app.nicknames': Record; - 'moe.sable.app.settings': Record; + [prefix.MATRIX_CINNY_UNSTABLE_ACCOUNT_SPACES_PROPERTY_NAME]: InCinnySpacesContent; + [prefix.MATRIX_ELEMENT_UNSTABLE_ACCOUNT_RECENT_EMOJIS_PROPERTY_NAME]: IRecentEmojiContent; + [prefix.MATRIX_UNSTABLE_ACCOUNT_USER_EMOTES_PROPERTY_NAME]: PackContent; + [prefix.MATRIX_UNSTABLE_ACCOUNT_EMOTE_ROOMS_PROPERTY_NAME]: EmoteRoomsContent; + [prefix.MATRIX_SABLE_UNSTABLE_ACCOUNT_NICKNAMES_PROPERTY_NAME]: Record; + [prefix.MATRIX_SABLE_UNSTABLE_ACCOUNT_SETTINGS_PROPERTY_NAME]: Record; } } diff --git a/src/types/matrix/accountData.ts b/src/types/matrix/accountData.ts index 283859cd3..670effb19 100644 --- a/src/types/matrix/accountData.ts +++ b/src/types/matrix/accountData.ts @@ -1,13 +1,15 @@ +import * as prefix from '$unstable/prefixes'; + export const CustomAccountDataEvent = { - CinnySpaces: 'in.cinny.spaces', - ElementRecentEmoji: 'io.element.recent_emoji', - PoniesUserEmotes: 'im.ponies.user_emotes', - PoniesEmoteRooms: 'im.ponies.emote_rooms', - SableNicknames: 'moe.sable.app.nicknames', - SablePinStatus: 'moe.sable.app.pins_read_marker', - // because of a mistake hasn't been renamed in time - SablePerProfileMessageProfiles: 'fyi.cisnt.permessageprofile', - SableSettings: 'moe.sable.app.settings', + CinnySpaces: prefix.MATRIX_CINNY_UNSTABLE_ACCOUNT_SPACES_PROPERTY_NAME, + ElementRecentEmoji: prefix.MATRIX_ELEMENT_UNSTABLE_ACCOUNT_RECENT_EMOJIS_PROPERTY_NAME, + PoniesUserEmotes: prefix.MATRIX_UNSTABLE_ACCOUNT_USER_EMOTES_PROPERTY_NAME, + PoniesEmoteRooms: prefix.MATRIX_UNSTABLE_ACCOUNT_EMOTE_ROOMS_PROPERTY_NAME, + SableNicknames: prefix.MATRIX_SABLE_UNSTABLE_ACCOUNT_NICKNAMES_PROPERTY_NAME, + SablePinStatus: prefix.MATRIX_SABLE_UNSTABLE_ACCOUNT_PIN_STATUS_PROPERTY_NAME, + SablePerProfileMessageProfiles: + prefix.MATRIX_SABLE_UNSTABLE_ACCOUNT_PER_MESSAGE_PROFILES_PROPERTY_NAME, + SableSettings: prefix.MATRIX_SABLE_UNSTABLE_ACCOUNT_SETTINGS_PROPERTY_NAME, } as const; export type CustomAccountDataEvent = (typeof CustomAccountDataEvent)[keyof typeof CustomAccountDataEvent]; diff --git a/src/types/matrix/common.ts b/src/types/matrix/common.ts index 2f7c8abe2..8f4301201 100644 --- a/src/types/matrix/common.ts +++ b/src/types/matrix/common.ts @@ -2,19 +2,14 @@ import type { SerializableMap } from '$types/wrapper/SerializableMap'; import type { SerializableSet } from '$types/wrapper/SerializableSet'; import type { EncryptedAttachmentInfo } from 'browser-encrypt-attachment'; import type { MsgType } from '$types/matrix-sdk'; - -export const MATRIX_BLUR_HASH_PROPERTY_NAME = 'xyz.amorgan.blurhash'; -export const MATRIX_SPOILER_PROPERTY_NAME = 'page.codeberg.everypizza.msc4193.spoiler'; -export const MATRIX_SPOILER_REASON_PROPERTY_NAME = - 'page.codeberg.everypizza.msc4193.spoiler.reason'; -export const MATRIX_IMAGE_SOURCE_PACK_PROPERTY_NAME = 'com.beeper.msc4459.image_source_packs'; +import type * as prefix from '$unstable/prefixes'; export type IImageInfo = { w?: number; h?: number; mimetype?: string; size?: number; - [MATRIX_BLUR_HASH_PROPERTY_NAME]?: string; + [prefix.MATRIX_UNSTABLE_BLUR_HASH_PROPERTY_NAME]?: string; }; export type MatrixRelatesTo = { @@ -59,11 +54,17 @@ export type MatrixReactionEvent = { /** * a map of image pack references */ - [MATRIX_IMAGE_SOURCE_PACK_PROPERTY_NAME]?: SerializableMap; + [prefix.MATRIX_UNSTABLE_IMAGE_SOURCE_PACK_PROPERTY_NAME]?: SerializableMap< + string, + MSC4459ImagePackReference + >; }; export interface IGenericMSC4459 { - [MATRIX_IMAGE_SOURCE_PACK_PROPERTY_NAME]?: SerializableMap; + [prefix.MATRIX_UNSTABLE_IMAGE_SOURCE_PACK_PROPERTY_NAME]?: SerializableMap< + string, + MSC4459ImagePackReference + >; } export type IVideoInfo = { @@ -102,8 +103,8 @@ export type IImageContent = { url?: string; info?: IImageInfo & IThumbnailContent; file?: IEncryptedFile; - [MATRIX_SPOILER_PROPERTY_NAME]?: boolean; - [MATRIX_SPOILER_REASON_PROPERTY_NAME]?: string; + [prefix.MATRIX_UNSTABLE_SPOILER_PROPERTY_NAME]?: boolean; + [prefix.MATRIX_UNSTABLE_SPOILER_REASON_PROPERTY_NAME]?: string; }; export type IVideoContent = { @@ -113,8 +114,8 @@ export type IVideoContent = { url?: string; info?: IVideoInfo & IThumbnailContent; file?: IEncryptedFile; - [MATRIX_SPOILER_PROPERTY_NAME]?: boolean; - [MATRIX_SPOILER_REASON_PROPERTY_NAME]?: string; + [prefix.MATRIX_UNSTABLE_SPOILER_PROPERTY_NAME]?: boolean; + [prefix.MATRIX_UNSTABLE_SPOILER_REASON_PROPERTY_NAME]?: string; }; export type IAudioContent = { diff --git a/src/unstable/prefixes.ts b/src/unstable/prefixes.ts new file mode 100644 index 000000000..2fb1b8075 --- /dev/null +++ b/src/unstable/prefixes.ts @@ -0,0 +1,6 @@ +// a list of constants for unstable prefixes used +// central list to be used throughout the codebase + +export * from './prefixes/msc/index'; +export * from './prefixes/sable/index'; +export * from './prefixes/misc'; diff --git a/src/unstable/prefixes/misc.ts b/src/unstable/prefixes/misc.ts new file mode 100644 index 000000000..c35fea44a --- /dev/null +++ b/src/unstable/prefixes/misc.ts @@ -0,0 +1,17 @@ +/** + * unstable prefix for profile banners + */ +export const MATRIX_UNSTABLE_PROFILE_BANNER_PROPERTY_NAME = 'chat.commet.profile_banner'; +export const MATRIX_COMMET_UNSTABLE_PROFILE_COLOR_SCHEME_PROPERTY_NAME = + 'chat.commet.profile_color_scheme'; +/** + * @deprecated + */ +export const MATRIX_COMMET_UNSTABLE_PROFILE_BIO_PROPERTY_NAME = 'chat.commet.profile_bio'; +export const MATRIX_COMMET_UNSTABLE_PROFILE_STATUS_PROPERTY_NAME = 'chat.commet.profile_status'; +export const MATRIX_CINNY_UNSTABLE_ACCOUNT_SPACES_PROPERTY_NAME = 'in.cinny.spaces'; +export const MATRIX_CINNY_UNSTABLE_STATE_ROOM_POWER_LEVELS_LABEL_PROPERTY_NAME = + 'in.cinny.room.power_level_tags'; +export const MATRIX_ELEMENT_UNSTABLE_ACCOUNT_RECENT_EMOJIS_PROPERTY_NAME = + 'io.element.recent_emoji'; +export const MATRIX_ELEMENT_UNSTABLE_STATE_ROOM_WIDGET_PROPERTY_NAME = 'im.vector.modular.widgets'; diff --git a/src/unstable/prefixes/msc/accountdata.ts b/src/unstable/prefixes/msc/accountdata.ts new file mode 100644 index 000000000..35624d44f --- /dev/null +++ b/src/unstable/prefixes/msc/accountdata.ts @@ -0,0 +1,10 @@ +// account data related unstable prefixes +// don't import this file directly, import '$unstable/prefixes' +// partly migrated from src/types/matrix/accountData.ts + +/** + * @deprecated no longer part of MSC + */ +export const MATRIX_UNSTABLE_ACCOUNT_USER_EMOTES_PROPERTY_NAME = 'im.ponies.user_emotes'; + +export const MATRIX_UNSTABLE_ACCOUNT_EMOTE_ROOMS_PROPERTY_NAME = 'im.ponies.emote_rooms'; diff --git a/src/unstable/prefixes/msc/event_misc.ts b/src/unstable/prefixes/msc/event_misc.ts new file mode 100644 index 000000000..bbe4108be --- /dev/null +++ b/src/unstable/prefixes/msc/event_misc.ts @@ -0,0 +1,39 @@ +// event related unstable prefixes +// don't import this file directly, import '$unstable/prefixes' + +/** + * unstable prefix for blur hashes + */ +export const MATRIX_UNSTABLE_BLUR_HASH_PROPERTY_NAME = 'xyz.amorgan.blurhash'; +/** + * unstable prefix for media spoilers + * defined in MSC4193 https://github.com/matrix-org/matrix-spec-proposals/pull/4193 + */ +export const MATRIX_UNSTABLE_SPOILER_PROPERTY_NAME = 'page.codeberg.everypizza.msc4193.spoiler'; +/** + * unstable prefix for media spoilers reasons + * defined in MSC4193 https://github.com/matrix-org/matrix-spec-proposals/pull/4193 + */ +export const MATRIX_UNSTABLE_SPOILER_REASON_PROPERTY_NAME = + 'page.codeberg.everypizza.msc4193.spoiler.reason'; +/** + * unstable prefix for image pack references + * defined in MSC4459 https://github.com/matrix-org/matrix-spec-proposals/pull/4259 + */ +export const MATRIX_UNSTABLE_IMAGE_SOURCE_PACK_PROPERTY_NAME = + 'com.beeper.msc4459.image_source_packs'; +/** + * unstable prefix for per-message profiles + * defined in MSC4144 https://github.com/matrix-org/matrix-spec-proposals/pull/4144 + */ +export const MATRIX_UNSTABLE_PER_MESSAGE_PROFILE_PROPERTY_NAME = 'com.beeper.per_message_profile'; +/** + * unstable prefix for embedded link previews + */ +export const MATRIX_UNSTABLE_EMBEDDED_LINK_PREVIEW_PROPERTY_NAME = 'com.beeper.linkpreviews'; + +/** + * unstable prefix for message forwards meta + * defined in MSC2723 https://github.com/matrix-org/matrix-spec-proposals/pull/2723 + */ +export const MATRIX_UNSTABLE_MESSAGE_FORWARD_META_PROPERTY_NAME = 'com.famedly.app.forwarded'; diff --git a/src/unstable/prefixes/msc/index.ts b/src/unstable/prefixes/msc/index.ts new file mode 100644 index 000000000..aa61f337f --- /dev/null +++ b/src/unstable/prefixes/msc/index.ts @@ -0,0 +1,7 @@ +// unstable prefixes defined in MSCs +// don't import this file directly, import '$unstable/prefixes' + +export * from './event_misc'; +export * from './profile'; +export * from './accountdata'; +export * from './state_events'; diff --git a/src/unstable/prefixes/msc/profile.ts b/src/unstable/prefixes/msc/profile.ts new file mode 100644 index 000000000..885f4f79f --- /dev/null +++ b/src/unstable/prefixes/msc/profile.ts @@ -0,0 +1,16 @@ +// profile related unstable prefixes +// don't import this file directly, import '$unstable/prefixes' + +/** + * unstable prefix for profile pronouns + */ +export const MATRIX_UNSTABLE_PROFILE_PRONOUNS_PROPERTY_NAME = 'io.fsky.nyx.pronouns'; + +/** + * unstable prefix for profile biography + * defined in MSC4440 https://github.com/matrix-org/matrix-spec-proposals/pull/4440 + */ +export const MATRIX_UNSTABLE_PROFILE_BIOGRAPHY_PROPERTY_NAME = 'gay.fomx.biography'; + +export const MATRIX_UNSTABLE_PROFILE_TIMEZONE_PROPERTY_NAME = 'us.cloke.msc4175.tz'; +export const MATRIX_STABLE_PROFILE_TIMEZONE_PROPERTY_NAME = 'm.tz'; diff --git a/src/unstable/prefixes/msc/state_events.ts b/src/unstable/prefixes/msc/state_events.ts new file mode 100644 index 000000000..bf9f05334 --- /dev/null +++ b/src/unstable/prefixes/msc/state_events.ts @@ -0,0 +1,9 @@ +// state event related unstable prefixes +// don't import this file directly, import '$unstable/prefixes' + +export const MATRIX_UNSTABLE_STATE_ROOM_EMOTES_PROPERTY_NAME = 'im.ponies.room_emotes'; +/** + * unstable prefix for call rooms + * defined in MSC3401 https://github.com/matrix-org/matrix-spec-proposals/pull/3401 + */ +export const MATRIX_UNSTABLE_ROOM_TYPE_CALL_PROPERTY_NAME = 'org.matrix.msc3401.call'; diff --git a/src/unstable/prefixes/sable/accountdata.ts b/src/unstable/prefixes/sable/accountdata.ts new file mode 100644 index 000000000..9179d491a --- /dev/null +++ b/src/unstable/prefixes/sable/accountdata.ts @@ -0,0 +1,13 @@ +// account data related unstable prefixes +// don't import this file directly, import '$unstable/prefixes' +// partly migrated from src/types/matrix/accountData.ts + +export const MATRIX_SABLE_UNSTABLE_ACCOUNT_NICKNAMES_PROPERTY_NAME = 'moe.sable.app.nicknames'; +export const MATRIX_SABLE_UNSTABLE_ACCOUNT_PIN_STATUS_PROPERTY_NAME = + 'moe.sable.app.pins_read_marker'; +export const MATRIX_SABLE_UNSTABLE_ACCOUNT_SETTINGS_PROPERTY_NAME = 'moe.sable.app.settings'; +/** + * the prefix which is used to save used per message profiles to the account data + */ +export const MATRIX_SABLE_UNSTABLE_ACCOUNT_PER_MESSAGE_PROFILES_PROPERTY_NAME = + 'fyi.cisnt.permessageprofile'; diff --git a/src/unstable/prefixes/sable/event_misc.ts b/src/unstable/prefixes/sable/event_misc.ts new file mode 100644 index 000000000..3e05a0ccb --- /dev/null +++ b/src/unstable/prefixes/sable/event_misc.ts @@ -0,0 +1,4 @@ +// event related unstable prefixes +// don't import this file directly, import '$unstable/prefixes' + +export const MATRIX_SABLE_UNSTABLE_MESSAGE_FORWARD_META_PROPERTY_NAME = 'moe.sable.message.forward'; diff --git a/src/unstable/prefixes/sable/index.ts b/src/unstable/prefixes/sable/index.ts new file mode 100644 index 000000000..947118fa5 --- /dev/null +++ b/src/unstable/prefixes/sable/index.ts @@ -0,0 +1,7 @@ +// unstable prefixes NOT defined in MSCs but used for sable +// don't import this file directly, import '$unstable/prefixes' + +export * from './profile'; +export * from './event_misc'; +export * from './accountdata'; +export * from './state_events'; diff --git a/src/unstable/prefixes/sable/profile.ts b/src/unstable/prefixes/sable/profile.ts new file mode 100644 index 000000000..9d5632834 --- /dev/null +++ b/src/unstable/prefixes/sable/profile.ts @@ -0,0 +1,14 @@ +// unstable prefixes NOT defined in MSCs but used for sable +// don't import this file directly, import '$unstable/prefixes' + +/** + * @deprecated in favor of MSC4440 + */ +export const MATRIX_SABLE_UNSTABLE_PROFILE_BIOGRAPHY_PROPERTY_NAME = 'moe.sable.app.bio'; +export const MATRIX_SABLE_UNSTABLE_NAME_COLOR_PROPERTY_NAME = 'moe.sable.app.name_color'; +export const MATRIX_SABLE_UNSTABLE_NAME_COLOR_DARK_PROPERTY_NAME = + 'moe.sable.app.name_color_dark_theme'; +export const MATRIX_SABLE_UNSTABLE_NAME_COLOR_LIGHT_PROPERTY_NAME = + 'moe.sable.app.name_color_light_theme'; +export const MATRIX_SABLE_UNSTABLE_ANIMAL_IDENTITY_IS_CAT_PROPERTY_NAME = 'kitty.meow.is_cat'; +export const MATRIX_SABLE_UNSTABLE_ANIMAL_IDENTITY_HAS_CAT_PROPERTY_NAME = 'kitty.meow.has_cat'; diff --git a/src/unstable/prefixes/sable/state_events.ts b/src/unstable/prefixes/sable/state_events.ts new file mode 100644 index 000000000..2baecd627 --- /dev/null +++ b/src/unstable/prefixes/sable/state_events.ts @@ -0,0 +1,11 @@ +// state event related unstable prefixes +// don't import this file directly, import '$unstable/prefixes' + +export const MATRIX_SABLE_UNSTABLE_STATE_COSMETICS_MEMBER_COLOR_PROPERTY_NAME = + 'moe.sable.room.cosmetics.color'; +export const MATRIX_SABLE_UNSTABLE_STATE_COSMETICS_MEMBER_FONT_PROPERTY_NAME = + 'moe.sable.room.cosmetics.font'; +export const MATRIX_SABLE_UNSTABLE_STATE_COSMETICS_MEMBER_PRONOUNS_PROPERTY_NAME = + 'moe.sable.room.cosmetics.pronouns'; +export const MATRIX_SABLE_UNSTABLE_STATE_ROOM_ABBREVIATIONS_PROPERTY_NAME = + 'moe.sable.room.abbreviations'; diff --git a/tsconfig.json b/tsconfig.json index bcb8c6217..77dac6f3d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -23,7 +23,8 @@ "$pages/*": ["./src/app/pages/*"], "$types/*": ["./src/types/*"], "$public/*": ["./public/*"], - "$client/*": ["./src/client/*"] + "$client/*": ["./src/client/*"], + "$unstable/*": ["./src/unstable/*"] }, "moduleResolution": "bundler", "allowImportingTsExtensions": true, diff --git a/vite.config.ts b/vite.config.ts index 7b482ef78..bfa79f67c 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -145,6 +145,7 @@ export default defineConfig(({ command }) => ({ $types: path.resolve(__dirname, 'src/types'), $public: path.resolve(__dirname, 'public'), $client: path.resolve(__dirname, 'src/client'), + $unstable: path.resolve(__dirname, 'src/unstable'), }, }, server: { diff --git a/vitest.config.ts b/vitest.config.ts index fedea1151..609b42c2b 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -20,6 +20,7 @@ export default defineConfig({ $types: path.resolve(__dirname, 'src/types'), $public: path.resolve(__dirname, 'public'), $client: path.resolve(__dirname, 'src/client'), + $unstable: path.resolve(__dirname, 'src/unstable'), }, }, define: {