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:
Ada
2026-02-04 15:24:14 -08:00
parent c1ce804d14
commit 96d95a50fc
3 changed files with 16 additions and 0 deletions

View File

@@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 B

15
src/polyfills.ts Normal file
View 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;
}