Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Hermes instead of JSC on iOS #83

Closed
wants to merge 7 commits into from
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Merge branch 'main' into @tomekzaw/hermes-ios
  • Loading branch information
tomekzaw committed Jan 8, 2024
commit c90ea1f8ba0394854174f27cf47abdc920d6874d
23 changes: 4 additions & 19 deletions ios/RCTMarkdownUtils.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,11 @@
#import <react/debug/react_native_assert.h>
#import <React/RCTAssert.h>
#import <JavaScriptCore/JavaScriptCore.h>

#include <jsi/jsi.h>
#include <hermes/hermes.h>

using namespace facebook;

static UIColor *syntaxColor = [UIColor grayColor];
static UIColor *linkColor = [UIColor blueColor];
static UIColor *codeForegroundColor = [[UIColor alloc] initWithRed:6/255.0 green:25/255.0 blue:109/255.0 alpha:1.0];
static UIColor *codeBackgroundColor = [[UIColor alloc] initWithRed:0.95 green:0.95 blue:0.95 alpha:1.0];
static UIColor *mentionHereColor = [[UIColor alloc] initWithRed:252/255.0 green:232/255.0 blue:142/255.0 alpha:1.0];
static UIColor *mentionUserColor = [[UIColor alloc] initWithRed:176/255.0 green:217/255.0 blue:255/255.0 alpha:1.0];
static CGFloat headingFontSize = 25;

@implementation RCTMarkdownUtils {
NSString *_prevInputString;
NSAttributedString *_prevAttributedString;
Expand Down Expand Up @@ -56,22 +47,16 @@ - (NSAttributedString *)parseMarkdown:(nullable NSAttributedString *)input
}

jsi::Runtime &rt = *runtime;
auto func = rt.global().getPropertyAsFunction(rt, "parseMarkdownToTextAndRanges");
auto func = rt.global().getPropertyAsFunction(rt, "parseExpensiMarkToRanges");
auto output = func.call(rt, [inputString UTF8String]);
auto json = rt.global().getPropertyAsObject(rt, "JSON").getPropertyAsFunction(rt, "stringify").call(rt, output).asString(rt).utf8(rt);

NSError *error = nil;

NSData *data = [NSData dataWithBytes:json.data() length:json.length()];
NSArray *result = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
NSError *error = nil;
NSArray *ranges = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
if (error != nil) {
return input;
}
NSString *outputString = result[0];
NSArray *ranges = result[1];

if (![outputString isEqualToString:inputString]) {
return input;
}

NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:inputString attributes:_backedTextInputView.defaultTextAttributes];
[attributedString beginEditing];
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.