fix: resolve ReadableStream in simulator so LangGraph runs on RN
- Add src/polyfills.ts as the first executed module; inject ReadableStream/WritableStream/TransformStream via web-streams-polyfill and ponyfill fallback - Import polyfills at the top of App.tsx so globals are set before any LangChain/LangGraph code loads - Add assets/images/icon.png to fix Metro “Asset not found” for icon
This commit is contained in:
15
src/polyfills.ts
Normal file
15
src/polyfills.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Polyfills that must run before any other app code (including LangChain/LangGraph).
|
||||
* This file is imported as the very first line in App.tsx so that ReadableStream
|
||||
* exists before @langchain/core or @langchain/langgraph are loaded.
|
||||
*/
|
||||
import 'web-streams-polyfill';
|
||||
|
||||
// Ensure globalThis has ReadableStream (main polyfill may not patch in RN/Metro)
|
||||
const g = typeof globalThis !== 'undefined' ? globalThis : (typeof global !== 'undefined' ? global : (typeof self !== 'undefined' ? self : {}));
|
||||
if (typeof (g as any).ReadableStream === 'undefined') {
|
||||
const ponyfill = require('web-streams-polyfill/dist/ponyfill.js');
|
||||
(g as any).ReadableStream = ponyfill.ReadableStream;
|
||||
(g as any).WritableStream = ponyfill.WritableStream;
|
||||
(g as any).TransformStream = ponyfill.TransformStream;
|
||||
}
|
||||
Reference in New Issue
Block a user