@copilotkit/react-native 2.0.0-rc.37 → 2.0.0-rc.39

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.
Files changed (82) hide show
  1. package/README.md +334 -2
  2. package/USAGE.md +382 -21
  3. package/dist/{CopilotKitProvider-F7Pn5kp4.d.cts → CopilotKitProvider-Cbfrm_7u.d.mts} +2 -2
  4. package/dist/{CopilotKitProvider-DDPbJkHS.cjs → CopilotKitProvider-CvJYytjn.cjs} +4 -3
  5. package/dist/{CopilotKitProvider-DDPbJkHS.cjs.map → CopilotKitProvider-CvJYytjn.cjs.map} +1 -1
  6. package/dist/{CopilotKitProvider-Khgz5dQo.d.mts → CopilotKitProvider-Dv3ISMKf.d.cts} +2 -2
  7. package/dist/{CopilotKitProvider-BXpkAl1Y.mjs → CopilotKitProvider-oTdmylSY.mjs} +2 -2
  8. package/dist/{CopilotKitProvider-BXpkAl1Y.mjs.map → CopilotKitProvider-oTdmylSY.mjs.map} +1 -1
  9. package/dist/{Markdown-CaYHlD4j.cjs → Markdown-DLopAh5W.cjs} +3 -3
  10. package/dist/{Markdown-CaYHlD4j.cjs.map → Markdown-DLopAh5W.cjs.map} +1 -1
  11. package/dist/{Markdown-a-rdG22_.d.mts → Markdown-Du-b_Qpr.d.mts} +1 -1
  12. package/dist/{Markdown-DzjnSuu5.d.cts → Markdown-UXZdDjzs.d.cts} +1 -1
  13. package/dist/{Markdown-SE9MfY2U.mjs → Markdown-VxtPJ_yh.mjs} +1 -1
  14. package/dist/{Markdown-SE9MfY2U.mjs.map → Markdown-VxtPJ_yh.mjs.map} +1 -1
  15. package/dist/{MarkdownRendererContext-B_AKdPAN.mjs → MarkdownRendererContext-EobUsERg.mjs} +1 -1
  16. package/dist/{MarkdownRendererContext-B_AKdPAN.mjs.map → MarkdownRendererContext-EobUsERg.mjs.map} +1 -1
  17. package/dist/MarkdownRendererContext-cDEHvbw9.cjs +40 -0
  18. package/dist/{MarkdownRendererContext-BRNe808d.cjs.map → MarkdownRendererContext-cDEHvbw9.cjs.map} +1 -1
  19. package/dist/chunk-C0xms8kb.cjs +34 -0
  20. package/dist/components/index.cjs +6 -4
  21. package/dist/components/index.cjs.map +1 -1
  22. package/dist/components/index.d.cts +1 -1
  23. package/dist/components/index.d.mts +1 -1
  24. package/dist/components/index.mjs +3 -2
  25. package/dist/components/index.mjs.map +1 -1
  26. package/dist/generative-ui/index.cjs +612 -0
  27. package/dist/generative-ui/index.cjs.map +1 -0
  28. package/dist/generative-ui/index.d.cts +341 -0
  29. package/dist/generative-ui/index.d.mts +341 -0
  30. package/dist/generative-ui/index.mjs +549 -0
  31. package/dist/generative-ui/index.mjs.map +1 -0
  32. package/dist/headless.cjs +2 -3
  33. package/dist/headless.d.cts +2 -2
  34. package/dist/headless.d.mts +2 -2
  35. package/dist/headless.mjs +1 -2
  36. package/dist/index.cjs +8 -7
  37. package/dist/index.cjs.map +1 -1
  38. package/dist/index.d.cts +3 -3
  39. package/dist/index.d.mts +2 -2
  40. package/dist/index.mjs +4 -4
  41. package/dist/polyfills/encoding.cjs +113 -3
  42. package/dist/polyfills/encoding.cjs.map +1 -1
  43. package/dist/polyfills/encoding.d.cts +31 -1
  44. package/dist/polyfills/encoding.d.mts +31 -1
  45. package/dist/polyfills/encoding.mjs +109 -3
  46. package/dist/polyfills/encoding.mjs.map +1 -1
  47. package/dist/polyfills/streams.cjs +1 -1
  48. package/dist/polyfills.cjs +218 -3
  49. package/dist/polyfills.cjs.map +1 -1
  50. package/dist/polyfills.mjs +217 -2
  51. package/dist/polyfills.mjs.map +1 -1
  52. package/package.json +13 -5
  53. package/project.json +6 -1
  54. package/scripts/__tests__/verify-polyfill-barrel.test.mjs +150 -0
  55. package/scripts/verify-polyfill-barrel.mjs +154 -5
  56. package/src/__tests__/generative-ui-harness.tsx +243 -0
  57. package/src/__tests__/generative-ui-provider-props.test-d.tsx +106 -0
  58. package/src/__tests__/generative-ui-rn-mock.tsx +54 -0
  59. package/src/__tests__/generative-ui-wiring.test.tsx +720 -0
  60. package/src/__tests__/generative-ui.test.tsx +1000 -0
  61. package/src/__tests__/headless-entry-surface.test.ts +979 -60
  62. package/src/components/index.ts +6 -0
  63. package/src/generative-ui/GenerativeUIActivity.tsx +235 -0
  64. package/src/generative-ui/GenerativeUIProvider.tsx +171 -0
  65. package/src/generative-ui/GenerativeUISurface.tsx +303 -0
  66. package/src/generative-ui/host.tsx +138 -0
  67. package/src/generative-ui/index.ts +93 -0
  68. package/src/generative-ui/internal.ts +55 -0
  69. package/src/index.ts +8 -3
  70. package/src/polyfills/__tests__/{utf8.test.ts → encoding-utf8.test.ts} +1 -1
  71. package/src/polyfills/encoding.ts +156 -1
  72. package/tsdown.config.ts +1 -0
  73. package/dist/MarkdownRendererContext-BRNe808d.cjs +0 -72
  74. package/dist/streaming-fetch-CLHG3Z1H.mjs +0 -219
  75. package/dist/streaming-fetch-CLHG3Z1H.mjs.map +0 -1
  76. package/dist/streaming-fetch-DbDALGya.cjs +0 -225
  77. package/dist/streaming-fetch-DbDALGya.cjs.map +0 -1
  78. package/dist/utf8-BIN9t4Oy.mjs +0 -113
  79. package/dist/utf8-BIN9t4Oy.mjs.map +0 -1
  80. package/dist/utf8-Cf3Ssy33.cjs +0 -125
  81. package/dist/utf8-Cf3Ssy33.cjs.map +0 -1
  82. package/src/polyfills/utf8.ts +0 -151
@@ -1,151 +0,0 @@
1
- /**
2
- * UTF-8 `TextEncoder` and `TextDecoder`, for runtimes that have neither.
3
- *
4
- * CopilotKit only reads and writes UTF-8, so these classes support only that
5
- * encoding. The decoder follows the WHATWG UTF-8 decode algorithm, so its
6
- * output, including U+FFFD for invalid bytes and `{ stream: true }` chunks,
7
- * matches the built-in `TextDecoder`.
8
- */
9
-
10
- const REPLACEMENT = 0xfffd;
11
-
12
- export class Utf8TextEncoder {
13
- readonly encoding = "utf-8";
14
-
15
- encode(input = ""): Uint8Array {
16
- const bytes: number[] = [];
17
- for (const char of input) {
18
- let codePoint = char.codePointAt(0)!;
19
- // A lone surrogate is not a Unicode scalar value.
20
- if (codePoint >= 0xd800 && codePoint <= 0xdfff) codePoint = REPLACEMENT;
21
- if (codePoint < 0x80) bytes.push(codePoint);
22
- else if (codePoint < 0x800)
23
- bytes.push(0xc0 | (codePoint >> 6), 0x80 | (codePoint & 0x3f));
24
- else if (codePoint < 0x10000)
25
- bytes.push(
26
- 0xe0 | (codePoint >> 12),
27
- 0x80 | ((codePoint >> 6) & 0x3f),
28
- 0x80 | (codePoint & 0x3f),
29
- );
30
- else
31
- bytes.push(
32
- 0xf0 | (codePoint >> 18),
33
- 0x80 | ((codePoint >> 12) & 0x3f),
34
- 0x80 | ((codePoint >> 6) & 0x3f),
35
- 0x80 | (codePoint & 0x3f),
36
- );
37
- }
38
- return new Uint8Array(bytes);
39
- }
40
- }
41
-
42
- export class Utf8TextDecoder {
43
- readonly encoding = "utf-8";
44
- readonly fatal: boolean;
45
- readonly ignoreBOM: boolean;
46
-
47
- #codePoint = 0;
48
- #bytesNeeded = 0;
49
- #bytesSeen = 0;
50
- #lowerBoundary = 0x80;
51
- #upperBoundary = 0xbf;
52
- #atStart = true;
53
-
54
- constructor(
55
- label = "utf-8",
56
- options: { fatal?: boolean; ignoreBOM?: boolean } = {},
57
- ) {
58
- const normalized = String(label).trim().toLowerCase();
59
- if (normalized !== "utf-8" && normalized !== "utf8") {
60
- throw new RangeError(`The "${label}" encoding is not supported.`);
61
- }
62
- this.fatal = options.fatal ?? false;
63
- this.ignoreBOM = options.ignoreBOM ?? false;
64
- }
65
-
66
- decode(
67
- input?: ArrayBuffer | ArrayBufferView,
68
- options: { stream?: boolean } = {},
69
- ): string {
70
- const bytes =
71
- input === undefined
72
- ? new Uint8Array(0)
73
- : ArrayBuffer.isView(input)
74
- ? new Uint8Array(input.buffer, input.byteOffset, input.byteLength)
75
- : new Uint8Array(input);
76
- const codePoints: number[] = [];
77
-
78
- for (let i = 0; i < bytes.length; i++) {
79
- const byte = bytes[i];
80
- if (this.#bytesNeeded === 0) {
81
- if (byte <= 0x7f) codePoints.push(byte);
82
- else if (byte >= 0xc2 && byte <= 0xdf) this.#start(1, byte & 0x1f);
83
- else if (byte >= 0xe0 && byte <= 0xef) {
84
- if (byte === 0xe0) this.#lowerBoundary = 0xa0;
85
- if (byte === 0xed) this.#upperBoundary = 0x9f;
86
- this.#start(2, byte & 0x0f);
87
- } else if (byte >= 0xf0 && byte <= 0xf4) {
88
- if (byte === 0xf0) this.#lowerBoundary = 0x90;
89
- if (byte === 0xf4) this.#upperBoundary = 0x8f;
90
- this.#start(3, byte & 0x07);
91
- } else codePoints.push(this.#error());
92
- continue;
93
- }
94
- if (byte < this.#lowerBoundary || byte > this.#upperBoundary) {
95
- // The sequence ends early. Read this byte again as a new sequence.
96
- this.#reset();
97
- codePoints.push(this.#error());
98
- i--;
99
- continue;
100
- }
101
- this.#lowerBoundary = 0x80;
102
- this.#upperBoundary = 0xbf;
103
- this.#codePoint = (this.#codePoint << 6) | (byte & 0x3f);
104
- if (++this.#bytesSeen === this.#bytesNeeded) {
105
- codePoints.push(this.#codePoint);
106
- this.#reset();
107
- }
108
- }
109
-
110
- if (!options.stream && this.#bytesNeeded > 0) {
111
- this.#reset();
112
- codePoints.push(this.#error());
113
- }
114
- if (this.#atStart && codePoints.length > 0) {
115
- this.#atStart = false;
116
- if (!this.ignoreBOM && codePoints[0] === 0xfeff) codePoints.shift();
117
- }
118
- if (!options.stream) this.#atStart = true;
119
- return codePointsToString(codePoints);
120
- }
121
-
122
- #start(bytesNeeded: number, codePoint: number): void {
123
- this.#bytesNeeded = bytesNeeded;
124
- this.#codePoint = codePoint;
125
- }
126
-
127
- #reset(): void {
128
- this.#codePoint = 0;
129
- this.#bytesNeeded = 0;
130
- this.#bytesSeen = 0;
131
- this.#lowerBoundary = 0x80;
132
- this.#upperBoundary = 0xbf;
133
- }
134
-
135
- #error(): number {
136
- if (this.fatal) {
137
- this.#atStart = true;
138
- throw new TypeError("The encoded data was not valid utf-8.");
139
- }
140
- return REPLACEMENT;
141
- }
142
- }
143
-
144
- function codePointsToString(codePoints: number[]): string {
145
- let out = "";
146
- // Stay under the engine's limit on function arguments.
147
- for (let i = 0; i < codePoints.length; i += 0x8000) {
148
- out += String.fromCodePoint(...codePoints.slice(i, i + 0x8000));
149
- }
150
- return out;
151
- }