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:
1
App.tsx
1
App.tsx
@@ -4,6 +4,7 @@
|
|||||||
* Main application component with authentication routing.
|
* Main application component with authentication routing.
|
||||||
* Shows loading screen while restoring auth state.
|
* Shows loading screen while restoring auth state.
|
||||||
*/
|
*/
|
||||||
|
import './src/polyfills';
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Buffer } from 'buffer';
|
import { Buffer } from 'buffer';
|
||||||
|
|||||||
BIN
assets/images/icon.png
Normal file
BIN
assets/images/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 70 B |
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