From 484f5780a658d29e5a8be5914ad78e6045d48a96 Mon Sep 17 00:00:00 2001 From: Tomek Zawadzki Date: Tue, 10 Dec 2024 09:26:01 +0100 Subject: [PATCH] Throw error when `html-entities` is not workletized --- example/ios/Podfile.lock | 8 ++++---- src/parseExpensiMark.ts | 9 +++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index f3bb3529..aba22425 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1497,7 +1497,7 @@ PODS: - React-logger (= 0.75.3) - React-perflogger (= 0.75.3) - React-utils (= 0.75.3) - - RNLiveMarkdown (0.1.199): + - RNLiveMarkdown (0.1.203): - DoubleConversion - glog - hermes-engine @@ -1517,10 +1517,10 @@ PODS: - ReactCodegen - ReactCommon/turbomodule/bridging - ReactCommon/turbomodule/core - - RNLiveMarkdown/newarch (= 0.1.199) + - RNLiveMarkdown/newarch (= 0.1.203) - RNReanimated/worklets - Yoga - - RNLiveMarkdown/newarch (0.1.199): + - RNLiveMarkdown/newarch (0.1.203): - DoubleConversion - glog - hermes-engine @@ -1897,7 +1897,7 @@ SPEC CHECKSUMS: React-utils: f2afa6acd905ca2ce7bb8ffb4a22f7f8a12534e8 ReactCodegen: e35c23cdd36922f6d2990c6c1f1b022ade7ad74d ReactCommon: 289214026502e6a93484f4a46bcc0efa4f3f2864 - RNLiveMarkdown: 18dd4ceada29d66a6b7c29b1b0df589e2fc82183 + RNLiveMarkdown: ed779eaf35a346f5254079b825a13f0a032ba64a RNReanimated: ab6c33a61e90c4cbe5dbcbe65bd6c7cb3be167e6 SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d Yoga: 1354c027ab07c7736f99a3bef16172d6f1b12b47 diff --git a/src/parseExpensiMark.ts b/src/parseExpensiMark.ts index 4162eb6c..d90078c8 100644 --- a/src/parseExpensiMark.ts +++ b/src/parseExpensiMark.ts @@ -2,8 +2,17 @@ import {ExpensiMark} from 'expensify-common'; import {unescapeText} from 'expensify-common/dist/utils'; +import {decode} from 'html-entities'; +import type {WorkletFunction} from 'react-native-reanimated/lib/typescript/commonTypes'; import type {MarkdownType, MarkdownRange} from './commonTypes'; +// eslint-disable-next-line no-underscore-dangle +if (__DEV__ && (decode as WorkletFunction).__workletHash === undefined) { + throw new Error( + "[react-native-live-markdown] `parseExpensiMark` requires `html-entities` package to be workletized. Please add `'worklet';` directive at the top of `node_modules/html-entities/lib/index.js` using patch-package.", + ); +} + const MAX_PARSABLE_LENGTH = 4000; type Token = ['TEXT' | 'HTML', string];