mirror of
https://github.com/CopilotKit/CopilotKit.git
synced 2026-09-14 16:26:20 +08:00
94c9c1d4c3
Headless React Native wrapper for CopilotKit. Provides a lightweight CopilotKitProvider and re-exports platform-agnostic hooks from react-core without pulling web dependencies (no DOM, CSS, Radix, Lit, A2UI). Includes XHR-based streaming fetch polyfill for Hermes and granular polyfills for streams, encoding, crypto, DOM, and location APIs.
28 lines
666 B
TypeScript
28 lines
666 B
TypeScript
/**
|
|
* Polyfill: ReadableStream, WritableStream, TransformStream
|
|
*
|
|
* Required for SSE streaming in CopilotKit.
|
|
* Skipped individually if the global already has each class defined.
|
|
*
|
|
* Usage:
|
|
* import "@copilotkit/react-native/polyfills/streams";
|
|
*/
|
|
|
|
import {
|
|
ReadableStream,
|
|
WritableStream,
|
|
TransformStream,
|
|
} from "web-streams-polyfill";
|
|
|
|
const g = globalThis as Record<string, unknown>;
|
|
|
|
if (typeof g.ReadableStream === "undefined") {
|
|
g.ReadableStream = ReadableStream;
|
|
}
|
|
if (typeof g.WritableStream === "undefined") {
|
|
g.WritableStream = WritableStream;
|
|
}
|
|
if (typeof g.TransformStream === "undefined") {
|
|
g.TransformStream = TransformStream;
|
|
}
|