Skip to content

Commit

Permalink
fix: #242 exported worklet functions are undefined (#247)
Browse files Browse the repository at this point in the history
  • Loading branch information
hannojg authored Jul 23, 2024
1 parent 3cf76c6 commit ee2b4ef
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package/src/ErrorUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ const throwErrorOnJS = Worklets.createRunOnJS((message: string, stack: string |
reportError(error, fatal)
})

export function reportWorkletError(error: unknown, fatal = true): void {
export const reportWorkletError = (error: unknown, fatal = true): void => {
'worklet'
const safeError = error as Error | undefined
const message = safeError != null && 'message' in safeError ? safeError.message : 'Filament threw an error.'
throwErrorOnJS(message, safeError?.stack, fatal)
}

export function wrapWithErrorHandler<T extends (...args: any[]) => any>(callback: T): (...args: Parameters<T>) => ReturnType<T> {
export const wrapWithErrorHandler = <T extends (...args: any[]) => any>(callback: T): ((...args: Parameters<T>) => ReturnType<T>) => {
return (...args: Parameters<T>): ReturnType<T> => {
'worklet'
try {
Expand Down
4 changes: 2 additions & 2 deletions package/src/utilities/helper.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { ISharedValue } from 'react-native-worklets-core'
import { Float3 } from '../types'

export function areFloat3Equal(a: Float3, b?: Float3): boolean {
export const areFloat3Equal = (a: Float3, b?: Float3): boolean => {
return a[0] === b?.[0] && a[1] === b?.[1] && a[2] === b?.[2]
}

export function isWorkletSharedValue(value: any): value is ISharedValue<any> {
export const isWorkletSharedValue = (value: any): value is ISharedValue<any> => {
'worklet'
return typeof value === 'object' && value != null && 'addListener' in value && typeof value.addListener === 'function'
}

0 comments on commit ee2b4ef

Please sign in to comment.