From 31b9fb2b98fd2c95e00cb0533f61bcebe3bb11d7 Mon Sep 17 00:00:00 2001 From: Simon Woolf Date: Wed, 8 Jan 2025 23:53:34 +0000 Subject: [PATCH] Fix accidental non-tree-shakability of PresenceMessage --- src/common/lib/types/presencemessage.ts | 5 +++++ src/platform/web/modular/presencemessage.ts | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/common/lib/types/presencemessage.ts b/src/common/lib/types/presencemessage.ts index f736d21e4..e7a46bc60 100644 --- a/src/common/lib/types/presencemessage.ts +++ b/src/common/lib/types/presencemessage.ts @@ -56,6 +56,11 @@ export async function _fromEncodedArray( ); } +// for tree-shakability +export function fromValues(values: Properties) { + return PresenceMessage.fromValues(values); +} + class PresenceMessage extends BaseMessage { action?: string; diff --git a/src/platform/web/modular/presencemessage.ts b/src/platform/web/modular/presencemessage.ts index 1c1cdaeb5..273517b45 100644 --- a/src/platform/web/modular/presencemessage.ts +++ b/src/platform/web/modular/presencemessage.ts @@ -1,5 +1,5 @@ import * as API from '../../../../ably'; -import PresenceMessage, { fromEncoded, fromEncodedArray } from '../../../common/lib/types/presencemessage'; +import { fromValues, fromEncoded, fromEncodedArray } from '../../../common/lib/types/presencemessage'; import { Crypto } from './crypto'; import Logger from '../../../common/lib/util/logger'; @@ -21,4 +21,4 @@ export const decodeEncryptedPresenceMessages = ((obj, options) => { return fromEncodedArray(Logger.defaultLogger, Crypto, obj, options); }) as API.PresenceMessageStatic['fromEncodedArray']; -export const constructPresenceMessage = PresenceMessage.fromValues as API.PresenceMessageStatic['fromValues']; +export const constructPresenceMessage = fromValues as API.PresenceMessageStatic['fromValues'];