Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,11 @@ Currently, `react-native-live-markdown` supports only [ExpensiMark](https://gith

### `react-native-worklets` compatibility

| | 0.6.x | 0.7.x | 0.8.x | 0.9.x |
|:-----------------:|:-----:|:-----:|:-----:|:-----:|
| 0.1.321+ | ❌ | ✅ | ✅ | ✅ |
| 0.1.308 – 0.1.320 | ✅ | ❌ | ❌ | ❌ |
| | 0.6.x | 0.7.x | 0.8.x | 0.9.x | 0.10.x |
|:-----------------:|:-----:|:-----:|:-----:|:-----:|:------:|
| 0.1.333+ | ❌ | ✅ | ✅ | ✅ | ✅ |
| 0.1.321 – 0.1.332 | ❌ | ✅ | ✅ | ✅ | ❌ |
| 0.1.308 – 0.1.320 | ✅ | ❌ | ❌ | ❌ | ❌ |
Comment on lines +216 to +218


## License
Expand Down
12 changes: 6 additions & 6 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1810,7 +1810,7 @@ PODS:
- ReactNativeDependencies
- RNWorklets
- Yoga
- RNWorklets (0.9.1):
- RNWorklets (0.10.1):
- hermes-engine
- RCTRequired
- RCTTypeSafety
Expand All @@ -1832,10 +1832,10 @@ PODS:
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- ReactNativeDependencies
- RNWorklets/apple (= 0.9.1)
- RNWorklets/common (= 0.9.1)
- RNWorklets/apple (= 0.10.1)
- RNWorklets/common (= 0.10.1)
- Yoga
- RNWorklets/apple (0.9.1):
- RNWorklets/apple (0.10.1):
- hermes-engine
- RCTRequired
- RCTTypeSafety
Expand All @@ -1858,7 +1858,7 @@ PODS:
- ReactCommon/turbomodule/core
- ReactNativeDependencies
- Yoga
- RNWorklets/common (0.9.1):
- RNWorklets/common (0.10.1):
- hermes-engine
- RCTRequired
- RCTTypeSafety
Expand Down Expand Up @@ -2192,7 +2192,7 @@ SPEC CHECKSUMS:
ReactCommon: 7dfc3250793bf36cf221096ff59e1179e13eef7f
ReactNativeDependencies: d31ce49efcbdece34c3541b1307e2d9074626c92
RNLiveMarkdown: 325f2f9421d5e9f9214ae5980b50ebe4b2fb6d02
RNWorklets: c9d31be8d2b0f73d73c573489c885a8534a9f53e
RNWorklets: bb6f040dd3a46ef34d7e9ca51d4c7d1b804c190c
Yoga: 77dfa8673de2874e1855002ae59c68b8be9b007b

PODFILE CHECKSUM: 3f53660915b3f926239de7f89ab29581306a2614
Expand Down
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"expensify-common": "2.0.148",
"react": "19.2.3",
"react-native": "0.85.3",
"react-native-worklets": "0.9.1"
"react-native-worklets": "0.10.1"
},
"devDependencies": {
"@babel/core": "^7.25.2",
Expand Down
11 changes: 6 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
"react-native": "0.85.3",
"react-native-builder-bob": "^0.30.2",
"react-native-web": "^0.20.0",
"react-native-worklets": "0.9.1",
"react-native-worklets": "0.10.1",
"release-it": "^15.0.0",
"turbo": "^1.10.7",
"typescript": "^5.8.3"
Expand Down
31 changes: 30 additions & 1 deletion src/MarkdownTextInput.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {StyleSheet, TextInput, processColor} from 'react-native';
import React from 'react';
import type {TextInputProps} from 'react-native';
import {createSerializable, createWorkletRuntime} from 'react-native-worklets';
import {createSerializable, createWorkletRuntime, registerCustomSerializable} from 'react-native-worklets';
import type {SerializableRef, WorkletFunction, WorkletRuntime} from 'react-native-worklets';
import MarkdownTextInputDecoratorViewNativeComponent from './MarkdownTextInputDecoratorViewNativeComponent';
import type {MarkdownStyle} from './MarkdownTextInputDecoratorViewNativeComponent';
Expand All @@ -22,6 +22,34 @@ declare global {
let initialized = false;
let workletRuntime: WorkletRuntime | undefined;

// The worklet closure of the built-in `parseExpensiMark` parser captures the `Log` singleton from
// `expensify-common`, and serializing the parser worklet fails because `react-native-worklets` 0.10
// can't copy `Logger` class instances. The logger is unused on the worklet runtime, so serialize it as a no-op.
// `registerCustomSerializable` has been available since react-native-worklets 0.7.0, so this stays
// compatible with every supported version (on 0.9.x and older it's a harmless no-op — they don't throw).
function registerLoggerSerializableOnceIfNeeded() {
type NoopLogger = Record<string, (...args: unknown[]) => void>;
registerCustomSerializable<NoopLogger, Record<string, never>>({
name: 'react-native-live-markdown/Logger',
Comment on lines 22 to +33
determine: (value): value is NoopLogger => {
'worklet';

return value !== null && typeof value === 'object' && (value as {constructor?: {name?: string}}).constructor?.name === 'Logger';
},
pack: () => {
'worklet';

return {};
},
unpack: () => {
'worklet';

const noop = () => undefined;
return {logToServer: noop, add: noop, info: noop, alert: noop, warn: noop, hmmm: noop, client: noop};
},
});
}

function getWorkletRuntime(): WorkletRuntime {
if (workletRuntime === undefined) {
throw new Error(
Expand All @@ -41,6 +69,7 @@ function initializeLiveMarkdownIfNeeded() {
if (!global.jsi_setMarkdownRuntime) {
throw new Error('[react-native-live-markdown] global.jsi_setMarkdownRuntime is not available');
}
registerLoggerSerializableOnceIfNeeded();
workletRuntime = createWorkletRuntime({name: 'LiveMarkdownRuntime'});
global.jsi_setMarkdownRuntime(workletRuntime);
initialized = true;
Expand Down
Loading