Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tjzel committed Feb 3, 2025
1 parent 3082624 commit e422706
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions packages/react-native-worklets/src/worklets/initializers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,25 @@ function overrideLogFunctionImplementation() {
});
}

// Register logger config and replace the log function implementation in
// the React runtime global scope
registerLoggerConfig(DEFAULT_LOGGER_CONFIG);
overrideLogFunctionImplementation();

// this is for web implementation
if (SHOULD_BE_USE_WEB) {
global._WORKLET = false;
global._log = console.log;
global._getAnimationTimestamp = () => performance.now();
} else {
// Register WorkletsError and logger config in the UI runtime global scope.
// (we are using `executeOnUIRuntimeSync` here to make sure that the changes
// are applied before any async operations are executed on the UI runtime)
executeOnUIRuntimeSync(registerWorkletsError);
executeOnUIRuntimeSync(registerLoggerConfig)(DEFAULT_LOGGER_CONFIG);
executeOnUIRuntimeSync(overrideLogFunctionImplementation)();
}

// callGuard is only used with debug builds
export function callGuardDEV<Args extends unknown[], ReturnValue>(
fn: (...args: Args) => ReturnValue,
Expand Down Expand Up @@ -62,25 +81,6 @@ export function setupCallGuard() {
};
}

// Register logger config and replace the log function implementation in
// the React runtime global scope
registerLoggerConfig(DEFAULT_LOGGER_CONFIG);
overrideLogFunctionImplementation();

// this is for web implementation
if (SHOULD_BE_USE_WEB) {
global._WORKLET = false;
global._log = console.log;
global._getAnimationTimestamp = () => performance.now();
} else {
// Register WorkletsError and logger config in the UI runtime global scope.
// (we are using `executeOnUIRuntimeSync` here to make sure that the changes
// are applied before any async operations are executed on the UI runtime)
executeOnUIRuntimeSync(registerWorkletsError);
executeOnUIRuntimeSync(registerLoggerConfig)(DEFAULT_LOGGER_CONFIG);
executeOnUIRuntimeSync(overrideLogFunctionImplementation)();
}

/**
* Currently there seems to be a bug in the JSI layer which causes a crash when
* we try to copy some of the console methods, i.e. `clear` or `dirxml`.
Expand Down

0 comments on commit e422706

Please sign in to comment.