@copilotkit/react-native 1.57.0-canary.1778116520
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +54 -0
- package/dist/index.cjs +203 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +51 -0
- package/dist/index.d.mts +51 -0
- package/dist/index.mjs +101 -0
- package/dist/index.mjs.map +1 -0
- package/dist/polyfills/crypto.cjs +15 -0
- package/dist/polyfills/crypto.cjs.map +1 -0
- package/dist/polyfills/crypto.d.cts +1 -0
- package/dist/polyfills/crypto.d.mts +1 -0
- package/dist/polyfills/crypto.mjs +15 -0
- package/dist/polyfills/crypto.mjs.map +1 -0
- package/dist/polyfills/dom.cjs +59 -0
- package/dist/polyfills/dom.cjs.map +1 -0
- package/dist/polyfills/dom.d.cts +1 -0
- package/dist/polyfills/dom.d.mts +1 -0
- package/dist/polyfills/dom.mjs +59 -0
- package/dist/polyfills/dom.mjs.map +1 -0
- package/dist/polyfills/encoding.cjs +19 -0
- package/dist/polyfills/encoding.cjs.map +1 -0
- package/dist/polyfills/encoding.d.cts +1 -0
- package/dist/polyfills/encoding.d.mts +1 -0
- package/dist/polyfills/encoding.mjs +19 -0
- package/dist/polyfills/encoding.mjs.map +1 -0
- package/dist/polyfills/location.cjs +18 -0
- package/dist/polyfills/location.cjs.map +1 -0
- package/dist/polyfills/location.d.cts +1 -0
- package/dist/polyfills/location.d.mts +1 -0
- package/dist/polyfills/location.mjs +18 -0
- package/dist/polyfills/location.mjs.map +1 -0
- package/dist/polyfills/streams.cjs +20 -0
- package/dist/polyfills/streams.cjs.map +1 -0
- package/dist/polyfills/streams.d.cts +1 -0
- package/dist/polyfills/streams.d.mts +1 -0
- package/dist/polyfills/streams.mjs +20 -0
- package/dist/polyfills/streams.mjs.map +1 -0
- package/dist/polyfills.cjs +196 -0
- package/dist/polyfills.cjs.map +1 -0
- package/dist/polyfills.d.cts +1 -0
- package/dist/polyfills.d.mts +1 -0
- package/dist/polyfills.mjs +196 -0
- package/dist/polyfills.mjs.map +1 -0
- package/package.json +92 -0
- package/project.json +18 -0
- package/src/CopilotKitProvider.tsx +188 -0
- package/src/__tests__/copilotkit-provider.test.tsx +424 -0
- package/src/__tests__/headless-integration.test.tsx +378 -0
- package/src/__tests__/polyfills.test.ts +242 -0
- package/src/__tests__/setup.ts +9 -0
- package/src/__tests__/streaming-fetch.test.ts +486 -0
- package/src/index.ts +44 -0
- package/src/polyfills/crypto.ts +34 -0
- package/src/polyfills/dom.ts +85 -0
- package/src/polyfills/encoding.ts +20 -0
- package/src/polyfills/location.ts +30 -0
- package/src/polyfills/streams.ts +27 -0
- package/src/polyfills.ts +22 -0
- package/src/streaming-fetch.ts +336 -0
- package/src/types.d.ts +23 -0
- package/tsconfig.json +16 -0
- package/tsdown.config.ts +25 -0
- package/vitest.config.mjs +17 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Polyfill: ReadableStream, WritableStream, TransformStream
|
|
3
|
+
*
|
|
4
|
+
* Required for SSE streaming in CopilotKit.
|
|
5
|
+
* Skipped individually if the global already has each class defined.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* import "@copilotkit/react-native/polyfills/streams";
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
ReadableStream,
|
|
13
|
+
WritableStream,
|
|
14
|
+
TransformStream,
|
|
15
|
+
} from "web-streams-polyfill";
|
|
16
|
+
|
|
17
|
+
const g = globalThis as Record<string, unknown>;
|
|
18
|
+
|
|
19
|
+
if (typeof g.ReadableStream === "undefined") {
|
|
20
|
+
g.ReadableStream = ReadableStream;
|
|
21
|
+
}
|
|
22
|
+
if (typeof g.WritableStream === "undefined") {
|
|
23
|
+
g.WritableStream = WritableStream;
|
|
24
|
+
}
|
|
25
|
+
if (typeof g.TransformStream === "undefined") {
|
|
26
|
+
g.TransformStream = TransformStream;
|
|
27
|
+
}
|
package/src/polyfills.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* All polyfills required for CopilotKit to work in React Native.
|
|
3
|
+
*
|
|
4
|
+
* Import this BEFORE any CopilotKit code in your app entry point:
|
|
5
|
+
* import "@copilotkit/react-native/polyfills";
|
|
6
|
+
*
|
|
7
|
+
* For granular control, import individual polyfills instead:
|
|
8
|
+
* import "@copilotkit/react-native/polyfills/streams";
|
|
9
|
+
* import "@copilotkit/react-native/polyfills/encoding";
|
|
10
|
+
* import "@copilotkit/react-native/polyfills/crypto";
|
|
11
|
+
* import "@copilotkit/react-native/polyfills/dom";
|
|
12
|
+
* import "@copilotkit/react-native/polyfills/location";
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import "./polyfills/streams";
|
|
16
|
+
import "./polyfills/encoding";
|
|
17
|
+
import "./polyfills/crypto";
|
|
18
|
+
import "./polyfills/dom";
|
|
19
|
+
import "./polyfills/location";
|
|
20
|
+
|
|
21
|
+
import { installStreamingFetch } from "./streaming-fetch";
|
|
22
|
+
installStreamingFetch();
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Streaming fetch implementation for React Native.
|
|
3
|
+
*
|
|
4
|
+
* React Native's built-in fetch doesn't support response.body.getReader()
|
|
5
|
+
* (ReadableStream). This replaces global.fetch with an XHR-based
|
|
6
|
+
* implementation that streams chunks via ReadableStream, enabling
|
|
7
|
+
* CopilotKit's SSE-based agent communication.
|
|
8
|
+
*
|
|
9
|
+
* If native fetch already supports ReadableStream bodies (newer RN / Hermes),
|
|
10
|
+
* the replacement is skipped entirely.
|
|
11
|
+
*
|
|
12
|
+
* Call `installStreamingFetch()` once at app startup after polyfills.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
declare const global: typeof globalThis;
|
|
16
|
+
|
|
17
|
+
/** Subset of the Response interface implemented by the streaming fetch polyfill. */
|
|
18
|
+
interface StreamingFetchResponse {
|
|
19
|
+
readonly ok: boolean;
|
|
20
|
+
readonly status: number;
|
|
21
|
+
readonly statusText: string;
|
|
22
|
+
readonly url: string;
|
|
23
|
+
readonly type: string;
|
|
24
|
+
readonly redirected: boolean;
|
|
25
|
+
readonly bodyUsed: boolean;
|
|
26
|
+
readonly headers: Headers;
|
|
27
|
+
readonly body: ReadableStream<Uint8Array>;
|
|
28
|
+
json(): Promise<unknown>;
|
|
29
|
+
text(): Promise<string>;
|
|
30
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
|
31
|
+
blob(): Promise<Blob>;
|
|
32
|
+
clone(): never;
|
|
33
|
+
formData(): Promise<never>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function createAbortError(): DOMException {
|
|
37
|
+
return new (global as any).DOMException(
|
|
38
|
+
"The operation was aborted.",
|
|
39
|
+
"AbortError",
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function installStreamingFetch(): void {
|
|
44
|
+
// Skip if native fetch already supports ReadableStream body.
|
|
45
|
+
// Newer React Native versions (Hermes) may support this natively.
|
|
46
|
+
try {
|
|
47
|
+
const testResponse = new Response("");
|
|
48
|
+
if (
|
|
49
|
+
testResponse.body != null &&
|
|
50
|
+
typeof testResponse.body.getReader === "function"
|
|
51
|
+
) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
} catch (e) {
|
|
55
|
+
// Response constructor unavailable — expected in older RN environments.
|
|
56
|
+
if (
|
|
57
|
+
__DEV__ &&
|
|
58
|
+
e instanceof Error &&
|
|
59
|
+
!(e instanceof ReferenceError) &&
|
|
60
|
+
!(e instanceof TypeError)
|
|
61
|
+
) {
|
|
62
|
+
console.warn(
|
|
63
|
+
"[CopilotKit] Unexpected error during streaming fetch feature detection, " +
|
|
64
|
+
"installing XHR-based polyfill:",
|
|
65
|
+
e,
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const originalFetch = global.fetch;
|
|
71
|
+
const TextEncoder = global.TextEncoder;
|
|
72
|
+
|
|
73
|
+
const streamingFetch = function streamingFetch(
|
|
74
|
+
input: RequestInfo | URL,
|
|
75
|
+
init?: RequestInit,
|
|
76
|
+
): Promise<Response> {
|
|
77
|
+
// Extract defaults from Request object when input is a Request
|
|
78
|
+
const request =
|
|
79
|
+
typeof input !== "string" && !(input instanceof URL) ? input : null;
|
|
80
|
+
let url: string;
|
|
81
|
+
if (typeof input === "string") {
|
|
82
|
+
url = input;
|
|
83
|
+
} else if (input instanceof URL) {
|
|
84
|
+
url = input.href;
|
|
85
|
+
} else {
|
|
86
|
+
url = (input as Request).url;
|
|
87
|
+
}
|
|
88
|
+
const method = init?.method || request?.method || "GET";
|
|
89
|
+
const headers = init?.headers || (request ? request.headers : {});
|
|
90
|
+
const body = (init?.body ?? request?.body) as string | null | undefined;
|
|
91
|
+
const signal = init?.signal || request?.signal;
|
|
92
|
+
|
|
93
|
+
return new Promise((resolve, reject) => {
|
|
94
|
+
// Reject immediately if signal is already aborted (per fetch spec)
|
|
95
|
+
if (signal?.aborted) {
|
|
96
|
+
reject(createAbortError());
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const xhr = new XMLHttpRequest();
|
|
101
|
+
xhr.open(method, url);
|
|
102
|
+
|
|
103
|
+
// Default 60s timeout to prevent hanging on stalled mobile connections
|
|
104
|
+
// (WiFi→cellular transitions, tunnels, serverless cold starts).
|
|
105
|
+
// Callers can still use AbortSignal.timeout() for finer control.
|
|
106
|
+
xhr.timeout = 60_000;
|
|
107
|
+
|
|
108
|
+
let headerEntries: [string, string][];
|
|
109
|
+
if (headers instanceof Headers) {
|
|
110
|
+
headerEntries = Array.from(headers.entries());
|
|
111
|
+
} else if (Array.isArray(headers)) {
|
|
112
|
+
headerEntries = headers as [string, string][];
|
|
113
|
+
} else {
|
|
114
|
+
headerEntries = Object.entries(headers as Record<string, string>);
|
|
115
|
+
}
|
|
116
|
+
for (const [key, value] of headerEntries) {
|
|
117
|
+
xhr.setRequestHeader(key, value as string);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
xhr.responseType = "text";
|
|
121
|
+
|
|
122
|
+
let streamController: ReadableStreamDefaultController<Uint8Array> | null =
|
|
123
|
+
null;
|
|
124
|
+
let lastIndex = 0;
|
|
125
|
+
let streamClosed = false;
|
|
126
|
+
let settled = false;
|
|
127
|
+
const encoder = new TextEncoder();
|
|
128
|
+
|
|
129
|
+
// Promise that resolves/rejects when XHR completes or fails
|
|
130
|
+
let resolveFullText: (text: string) => void;
|
|
131
|
+
let rejectFullText: (error: Error) => void;
|
|
132
|
+
const fullTextPromise = new Promise<string>((res, rej) => {
|
|
133
|
+
resolveFullText = res;
|
|
134
|
+
rejectFullText = rej;
|
|
135
|
+
});
|
|
136
|
+
// Prevent unhandled rejection when error occurs but .text()/.json() is never called
|
|
137
|
+
fullTextPromise.catch(() => {});
|
|
138
|
+
|
|
139
|
+
function closeStream() {
|
|
140
|
+
if (streamController && !streamClosed) {
|
|
141
|
+
streamClosed = true;
|
|
142
|
+
streamController.close();
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function errorStream(err: Error) {
|
|
147
|
+
if (streamController && !streamClosed) {
|
|
148
|
+
streamClosed = true;
|
|
149
|
+
streamController.error(err);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function flushChunks() {
|
|
154
|
+
if (
|
|
155
|
+
streamController &&
|
|
156
|
+
!streamClosed &&
|
|
157
|
+
xhr.responseText.length > lastIndex
|
|
158
|
+
) {
|
|
159
|
+
const newData = xhr.responseText.slice(lastIndex);
|
|
160
|
+
lastIndex = xhr.responseText.length;
|
|
161
|
+
streamController.enqueue(encoder.encode(newData));
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** Centralized error handler — errors the stream, rejects fullTextPromise,
|
|
166
|
+
* and rejects the outer fetch promise if not yet settled. */
|
|
167
|
+
function fail(err: Error) {
|
|
168
|
+
cleanupAbortListener();
|
|
169
|
+
errorStream(err);
|
|
170
|
+
rejectFullText(err);
|
|
171
|
+
if (!settled) {
|
|
172
|
+
settled = true;
|
|
173
|
+
reject(err);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const onAbort = () => {
|
|
178
|
+
fail(createAbortError());
|
|
179
|
+
xhr.abort();
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
if (signal) {
|
|
183
|
+
signal.addEventListener("abort", onAbort);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function cleanupAbortListener() {
|
|
187
|
+
if (signal) {
|
|
188
|
+
signal.removeEventListener("abort", onAbort);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const stream = new ReadableStream<Uint8Array>({
|
|
193
|
+
start(controller) {
|
|
194
|
+
streamController = controller;
|
|
195
|
+
},
|
|
196
|
+
cancel() {
|
|
197
|
+
xhr.abort();
|
|
198
|
+
rejectFullText(createAbortError());
|
|
199
|
+
},
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
xhr.onprogress = function () {
|
|
203
|
+
try {
|
|
204
|
+
flushChunks();
|
|
205
|
+
} catch (err) {
|
|
206
|
+
fail(err instanceof Error ? err : new Error(String(err)));
|
|
207
|
+
xhr.abort();
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
xhr.onload = function () {
|
|
212
|
+
cleanupAbortListener();
|
|
213
|
+
try {
|
|
214
|
+
flushChunks();
|
|
215
|
+
} catch (err) {
|
|
216
|
+
fail(err instanceof Error ? err : new Error(String(err)));
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
closeStream();
|
|
220
|
+
resolveFullText(xhr.responseText);
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
xhr.onerror = function () {
|
|
224
|
+
fail(new TypeError("Network request failed"));
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
xhr.ontimeout = function () {
|
|
228
|
+
fail(new TypeError("Network request timed out"));
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
// Resolve with Response once headers arrive.
|
|
232
|
+
// Guard against status === 0 which XHR produces for CORS failures,
|
|
233
|
+
// DNS errors, and mixed-content blocks — let onerror handle those.
|
|
234
|
+
let resp: StreamingFetchResponse | null = null;
|
|
235
|
+
xhr.onreadystatechange = function () {
|
|
236
|
+
// Safety net: if XHR completed but we never resolved/rejected, fail explicitly.
|
|
237
|
+
// This can happen when status === 0 and onerror doesn't fire (some RN networking impls).
|
|
238
|
+
if (xhr.readyState === 4 && !settled && !resp) {
|
|
239
|
+
fail(
|
|
240
|
+
new TypeError(
|
|
241
|
+
`Network request to ${url} completed with status ${xhr.status} but no response was produced. ` +
|
|
242
|
+
`This may indicate a CORS failure, DNS error, or React Native networking issue.`,
|
|
243
|
+
),
|
|
244
|
+
);
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
if (xhr.readyState >= 2 && !resp && xhr.status !== 0) {
|
|
249
|
+
const respHeaders: Record<string, string> = {};
|
|
250
|
+
const rawHeaders = xhr.getAllResponseHeaders() || "";
|
|
251
|
+
for (const line of rawHeaders.trim().split("\r\n")) {
|
|
252
|
+
const idx = line.indexOf(": ");
|
|
253
|
+
if (idx > 0) {
|
|
254
|
+
respHeaders[line.slice(0, idx).toLowerCase()] = line.slice(
|
|
255
|
+
idx + 2,
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
const responseHeaders = new Headers(respHeaders);
|
|
261
|
+
|
|
262
|
+
let bodyUsed = false;
|
|
263
|
+
|
|
264
|
+
resp = {
|
|
265
|
+
// Duck-typed Response object (not a native Response instance)
|
|
266
|
+
ok: xhr.status >= 200 && xhr.status < 300,
|
|
267
|
+
status: xhr.status,
|
|
268
|
+
statusText: xhr.statusText,
|
|
269
|
+
url: url,
|
|
270
|
+
type: "basic",
|
|
271
|
+
redirected: false,
|
|
272
|
+
get bodyUsed() {
|
|
273
|
+
return bodyUsed;
|
|
274
|
+
},
|
|
275
|
+
headers: responseHeaders,
|
|
276
|
+
body: stream,
|
|
277
|
+
json: async () => {
|
|
278
|
+
bodyUsed = true;
|
|
279
|
+
const text = await fullTextPromise;
|
|
280
|
+
try {
|
|
281
|
+
return JSON.parse(text);
|
|
282
|
+
} catch (e) {
|
|
283
|
+
throw new TypeError(
|
|
284
|
+
`Failed to parse JSON from ${method} ${url} (status ${xhr.status}): ${
|
|
285
|
+
text.length > 200 ? text.slice(0, 200) + "..." : text
|
|
286
|
+
}`,
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
text: async () => {
|
|
291
|
+
bodyUsed = true;
|
|
292
|
+
return fullTextPromise;
|
|
293
|
+
},
|
|
294
|
+
arrayBuffer: async () => {
|
|
295
|
+
bodyUsed = true;
|
|
296
|
+
return encoder.encode(await fullTextPromise).buffer;
|
|
297
|
+
},
|
|
298
|
+
blob: async () => {
|
|
299
|
+
bodyUsed = true;
|
|
300
|
+
const buf = encoder.encode(await fullTextPromise);
|
|
301
|
+
if (typeof Blob !== "undefined") {
|
|
302
|
+
return new Blob([buf], {
|
|
303
|
+
type: responseHeaders.get("content-type") || "",
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
throw new Error(
|
|
307
|
+
"Blob is not available in this React Native environment.",
|
|
308
|
+
);
|
|
309
|
+
},
|
|
310
|
+
clone: () => {
|
|
311
|
+
throw new Error(
|
|
312
|
+
"Response.clone() is not supported by the React Native streaming fetch polyfill.",
|
|
313
|
+
);
|
|
314
|
+
},
|
|
315
|
+
formData: async () => {
|
|
316
|
+
throw new Error(
|
|
317
|
+
"Response.formData() is not supported by the React Native streaming fetch polyfill.",
|
|
318
|
+
);
|
|
319
|
+
},
|
|
320
|
+
};
|
|
321
|
+
settled = true;
|
|
322
|
+
// NOTE: abort listener is NOT removed here — the signal must remain
|
|
323
|
+
// wired to xhr.abort() for mid-stream cancellation. Cleanup happens
|
|
324
|
+
// in terminal handlers (onload, onerror, ontimeout) or onAbort itself.
|
|
325
|
+
resolve(resp as unknown as Response);
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
xhr.send(body ?? null);
|
|
330
|
+
});
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
// Expose original fetch for opt-out (e.g., third-party libs that need native behavior)
|
|
334
|
+
(streamingFetch as any).__originalFetch = originalFetch;
|
|
335
|
+
global.fetch = streamingFetch;
|
|
336
|
+
}
|
package/src/types.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// React Native global provided by Metro bundler
|
|
2
|
+
declare const __DEV__: boolean;
|
|
3
|
+
|
|
4
|
+
// Polyfill files use `const g = globalThis as Record<string, unknown>` to assign
|
|
5
|
+
// web APIs (ReadableStream, TextEncoder, Headers, etc.) that may not exist in the
|
|
6
|
+
// React Native runtime. TypeScript's `globalThis` type doesn't include optional
|
|
7
|
+
// web APIs, so there's no way to assign them without a cast. We use a local alias
|
|
8
|
+
// (`g`) instead of repeating `(globalThis as any)` on every line — same pattern as
|
|
9
|
+
// packages/angular/src/test-setup.ts. Files without imports add `export {}` so
|
|
10
|
+
// TypeScript treats them as modules with isolated scope.
|
|
11
|
+
|
|
12
|
+
declare module "text-encoding" {
|
|
13
|
+
export class TextEncoder {
|
|
14
|
+
encode(input?: string): Uint8Array;
|
|
15
|
+
}
|
|
16
|
+
export class TextDecoder {
|
|
17
|
+
constructor(label?: string, options?: { fatal?: boolean });
|
|
18
|
+
decode(
|
|
19
|
+
input?: ArrayBufferView | ArrayBuffer,
|
|
20
|
+
options?: { stream?: boolean },
|
|
21
|
+
): string;
|
|
22
|
+
}
|
|
23
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"jsx": "react-jsx",
|
|
7
|
+
"strict": true,
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"declaration": true,
|
|
11
|
+
"outDir": "dist",
|
|
12
|
+
"rootDir": "src"
|
|
13
|
+
},
|
|
14
|
+
"include": ["src"],
|
|
15
|
+
"exclude": ["node_modules", "dist"]
|
|
16
|
+
}
|
package/tsdown.config.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { defineConfig } from "tsdown";
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
entry: [
|
|
5
|
+
"src/index.ts",
|
|
6
|
+
"src/polyfills.ts",
|
|
7
|
+
"src/polyfills/streams.ts",
|
|
8
|
+
"src/polyfills/encoding.ts",
|
|
9
|
+
"src/polyfills/crypto.ts",
|
|
10
|
+
"src/polyfills/dom.ts",
|
|
11
|
+
"src/polyfills/location.ts",
|
|
12
|
+
],
|
|
13
|
+
format: ["esm", "cjs"],
|
|
14
|
+
dts: true,
|
|
15
|
+
sourcemap: true,
|
|
16
|
+
target: "es2022",
|
|
17
|
+
outDir: "dist",
|
|
18
|
+
external: [
|
|
19
|
+
"react",
|
|
20
|
+
"react-native",
|
|
21
|
+
"@copilotkit/react-core",
|
|
22
|
+
"@copilotkit/core",
|
|
23
|
+
"@copilotkit/shared",
|
|
24
|
+
],
|
|
25
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { defineConfig } from "vitest/config";
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
test: {
|
|
5
|
+
environment: "jsdom",
|
|
6
|
+
globals: true,
|
|
7
|
+
include: ["src/**/__tests__/**/*.{test,spec}.{ts,tsx}"],
|
|
8
|
+
setupFiles: ["./src/__tests__/setup.ts"],
|
|
9
|
+
reporters: [["default", { summary: false }]],
|
|
10
|
+
silent: true,
|
|
11
|
+
server: {
|
|
12
|
+
deps: {
|
|
13
|
+
inline: [/@copilotkit/],
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
});
|