diff --git a/.yarn/patches/react-native-npm-0.82.0-228ad0ffa7.patch b/.yarn/patches/react-native-npm-0.82.0-228ad0ffa7.patch index 5786993e420f..d65d72970d00 100644 --- a/.yarn/patches/react-native-npm-0.82.0-228ad0ffa7.patch +++ b/.yarn/patches/react-native-npm-0.82.0-228ad0ffa7.patch @@ -749,9 +749,18 @@ index d6552a8a978..ca4e72ac488 100644 void callFunctionOnModule( diff --git a/ReactCommon/react/nativemodule/core/ReactCommon/TurboModule.h b/ReactCommon/react/nativemodule/core/ReactCommon/TurboModule.h -index 9ef16f4cc5c..5c0622ad990 100644 +index 9ef16f4..94afa4e 100644 --- a/ReactCommon/react/nativemodule/core/ReactCommon/TurboModule.h +++ b/ReactCommon/react/nativemodule/core/ReactCommon/TurboModule.h +@@ -61,7 +61,7 @@ class JSI_EXPORT TurboModule : public jsi::HostObject { + // If we have a JS wrapper, cache the result of this lookup + // We don't cache misses, to allow for methodMap_ to dynamically be + // extended +- if (jsRepresentation_ && !prop.isUndefined()) { ++ if (jsRepresentation_ && !prop.isUndefined() && &runtime == representationRuntime_) { + jsRepresentation_->lock(runtime).asObject(runtime).setProperty( + runtime, propName, prop); + } @@ -150,6 +150,7 @@ class JSI_EXPORT TurboModule : public jsi::HostObject { private: friend class TurboModuleBinding; diff --git a/apps/common-app/package.json b/apps/common-app/package.json index 8b2eba4dfcdc..e066096c5265 100644 --- a/apps/common-app/package.json +++ b/apps/common-app/package.json @@ -28,6 +28,7 @@ "@react-navigation/native-stack": "7.3.27", "@react-navigation/stack": "7.4.9", "@shopify/flash-list": "2.1.0", + "axios": "1.10.0", "d3-shape": "3.2.0", "fuse.js": "patch:fuse.js@npm%3A7.1.0#~/.yarn/patches/fuse.js-npm-7.1.0-5dcae892a6.patch", "react": "19.1.1", diff --git a/apps/common-app/src/apps/reanimated/examples/EmptyExample.tsx b/apps/common-app/src/apps/reanimated/examples/EmptyExample.tsx index 7f3a1ac26ce1..abc8c43a5e9a 100644 --- a/apps/common-app/src/apps/reanimated/examples/EmptyExample.tsx +++ b/apps/common-app/src/apps/reanimated/examples/EmptyExample.tsx @@ -1,10 +1,163 @@ import React from 'react'; -import { StyleSheet, Text, View } from 'react-native'; +import { StyleSheet, View, Button } from 'react-native'; +import { + createWorkletRuntime, + scheduleOnRuntime, + type WorkletRuntime, +} from 'react-native-worklets'; +import axios from 'axios'; -export default function EmptyExample() { +const mydloRuntime = createWorkletRuntime({ + name: 'mydlo', +}); + +const widloRuntime = createWorkletRuntime({ + name: 'widlo', +}); + +const powidloRuntime = createWorkletRuntime({ + name: 'powidlo', +}); + +function testXHR( + readystateHandler: boolean, + progressHandler: boolean, + arraybuffer: boolean, + chunked: boolean +) { + 'worklet'; + const xhr = new globalThis.XMLHttpRequest(); + + const state = { + readystateHandler, + progressHandler, + arraybuffer, + chunked, + downloading: false, + contentLength: 1, + responseLength: 0, + progressTotal: 1, + progressLoaded: 0, + cancelled: false, + }; + + const onreadystatechange = () => { + if (xhr.readyState === xhr.HEADERS_RECEIVED) { + const contentLength = parseInt( + xhr.getResponseHeader('Content-Length')!, + 10 + ); + state.contentLength = contentLength; + state.responseLength = 0; + } else if (xhr.readyState === xhr.LOADING && xhr.response) { + state.responseLength = xhr.response.length; + } + }; + const onprogress = (event: ProgressEvent) => { + state.progressTotal = event.total; + state.progressLoaded = event.loaded; + }; + const onerror = (event: ProgressEvent) => { + state.downloading = false; + throw new Error( + `XHR error: ${event.type} - ${xhr.status} - ${xhr.responseText} - ${event.toString()}` + ); + }; + + if (state.readystateHandler) { + xhr.onreadystatechange = onreadystatechange; + } + if (state.progressHandler) { + xhr.onprogress = onprogress; + } + if (state.arraybuffer) { + xhr.responseType = 'arraybuffer'; + } + xhr.onerror = onerror; + xhr.onload = () => { + // this.setState({ downloading: false }); + state.downloading = false; + if (state.cancelled) { + state.cancelled = false; + return; + } + if (xhr.status === 200) { + let responseType = `Response is a string, ${xhr.response.length} characters long.`; + if (xhr.response instanceof ArrayBuffer) { + responseType = `Response is an ArrayBuffer, ${xhr.response.byteLength} bytes long.`; + } + console.log('Download complete!', responseType); + } else if (xhr.status !== 0) { + console.error( + `Server returned HTTP status of ${xhr.status}: ${xhr.responseText}` + ); + } else { + console.error(xhr.responseText); + } + }; + if (state.chunked) { + xhr.open( + 'GET', + 'https://filesamples.com/samples/ebook/azw3/Around%20the%20World%20in%2028%20Languages.azw3' + ); + } else { + xhr.open('GET', 'https://filesamples.com/samples/document/txt/sample3.txt'); + // Avoid gzip so we can actually show progress + xhr.setRequestHeader('Accept-Encoding', ''); + } + xhr.send(); + + state.downloading = true; +} + +function callback(runtime: WorkletRuntime, count: number) { + 'worklet'; + axios({ + method: 'get', + url: 'https://tomekzaw.pl', + }) + .then((response) => { + console.log(`Received ${count} response on ${runtime.name}`); + console.log(response.data); + }) + .catch((error) => { + console.error('Axios error:', error); + }); + if (count > 32) { + return; + } + + const nextRuntime = + runtime.name === mydloRuntime.name + ? widloRuntime + : runtime.name === widloRuntime.name + ? powidloRuntime + : mydloRuntime; + + setTimeout(() => { + scheduleOnRuntime(nextRuntime, callback, nextRuntime, count + 1); + }, 100); +} + +export default function App() { return ( - Hello world! +