Skip to content

Commit

Permalink
Throw error when html-entities is not workletized (#576)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomekzaw authored Dec 10, 2024
1 parent 440b75c commit 0a5d4f0
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/parseExpensiMark.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
'worklet';

import {Platform} from 'react-native';
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';

function isWeb() {
return Platform.OS === 'web';
}

function isJest() {
return !!global.process.env.JEST_WORKER_ID;
}

// eslint-disable-next-line no-underscore-dangle
if (__DEV__ && !isWeb() && !isJest() && (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];
Expand Down

0 comments on commit 0a5d4f0

Please sign in to comment.