ai 3.1.17 → 3.1.18
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/dist/index.d.mts +46 -38
- package/dist/index.d.ts +46 -38
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/rsc/dist/index.d.ts +17 -22
- package/rsc/dist/rsc-server.d.mts +17 -22
- package/rsc/dist/rsc-server.mjs +0 -69
- package/rsc/dist/rsc-server.mjs.map +1 -1
- package/rsc/dist/rsc-shared.mjs.map +1 -1
package/package.json
CHANGED
package/rsc/dist/index.d.ts
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
2
1
|
import { ReactNode } from 'react';
|
3
2
|
import OpenAI from 'openai';
|
4
3
|
import { z } from 'zod';
|
@@ -66,19 +65,15 @@ declare function getAIState<AI extends AIProvider = any>(key: keyof InferAIState
|
|
66
65
|
declare function getMutableAIState<AI extends AIProvider = any>(): MutableAIState<InferAIState<AI, any>>;
|
67
66
|
declare function getMutableAIState<AI extends AIProvider = any>(key: keyof InferAIState<AI, any>): MutableAIState<InferAIState<AI, any>[typeof key]>;
|
68
67
|
|
69
|
-
|
70
|
-
* Create a piece of changable UI that can be streamed to the client.
|
71
|
-
* On the client side, it can be rendered as a normal React node.
|
72
|
-
*/
|
73
|
-
declare function createStreamableUI(initialValue?: React.ReactNode): {
|
68
|
+
type StreamableUIWrapper = {
|
74
69
|
/**
|
75
70
|
* The value of the streamable UI. This can be returned from a Server Action and received by the client.
|
76
71
|
*/
|
77
|
-
value:
|
72
|
+
readonly value: React.ReactNode;
|
78
73
|
/**
|
79
74
|
* This method updates the current UI node. It takes a new UI node and replaces the old one.
|
80
75
|
*/
|
81
|
-
update(value: React.ReactNode):
|
76
|
+
update(value: React.ReactNode): StreamableUIWrapper;
|
82
77
|
/**
|
83
78
|
* This method is used to append a new UI node to the end of the old one.
|
84
79
|
* Once appended a new UI node, the previous UI node cannot be updated anymore.
|
@@ -95,31 +90,31 @@ declare function createStreamableUI(initialValue?: React.ReactNode): {
|
|
95
90
|
* // </>
|
96
91
|
* ```
|
97
92
|
*/
|
98
|
-
append(value: React.ReactNode):
|
93
|
+
append(value: React.ReactNode): StreamableUIWrapper;
|
99
94
|
/**
|
100
95
|
* This method is used to signal that there is an error in the UI stream.
|
101
96
|
* It will be thrown on the client side and caught by the nearest error boundary component.
|
102
97
|
*/
|
103
|
-
error(error: any):
|
98
|
+
error(error: any): StreamableUIWrapper;
|
104
99
|
/**
|
105
100
|
* This method marks the UI node as finalized. You can either call it without any parameters or with a new UI node as the final state.
|
106
101
|
* Once called, the UI node cannot be updated or appended anymore.
|
107
102
|
*
|
108
103
|
* This method is always **required** to be called, otherwise the response will be stuck in a loading state.
|
109
104
|
*/
|
110
|
-
done(...args: [] | [
|
105
|
+
done(...args: [React.ReactNode] | []): StreamableUIWrapper;
|
111
106
|
};
|
112
|
-
|
107
|
+
/**
|
108
|
+
* Create a piece of changable UI that can be streamed to the client.
|
109
|
+
* On the client side, it can be rendered as a normal React node.
|
110
|
+
*/
|
111
|
+
declare function createStreamableUI(initialValue?: React.ReactNode): StreamableUIWrapper;
|
113
112
|
/**
|
114
113
|
* Create a wrapped, changable value that can be streamed to the client.
|
115
114
|
* On the client side, the value can be accessed via the readStreamableValue() API.
|
116
115
|
*/
|
117
|
-
declare function createStreamableValue<T = any, E = any>(initialValue?: T | ReadableStream<T>):
|
118
|
-
|
119
|
-
* @internal This is an internal lock to prevent the value from being
|
120
|
-
* updated by the user.
|
121
|
-
*/
|
122
|
-
[STREAMABLE_VALUE_INTERNAL_LOCK]: boolean;
|
116
|
+
declare function createStreamableValue<T = any, E = any>(initialValue?: T | ReadableStream<T>): StreamableValueWrapper<T, E>;
|
117
|
+
type StreamableValueWrapper<T, E> = {
|
123
118
|
/**
|
124
119
|
* The value of the streamable. This can be returned from a Server Action and
|
125
120
|
* received by the client. To read the streamed values, use the
|
@@ -129,7 +124,7 @@ declare function createStreamableValue<T = any, E = any>(initialValue?: T | Read
|
|
129
124
|
/**
|
130
125
|
* This method updates the current value with a new one.
|
131
126
|
*/
|
132
|
-
update(value: T):
|
127
|
+
update(value: T): StreamableValueWrapper<T, E>;
|
133
128
|
/**
|
134
129
|
* This method is used to append a delta string to the current value. It
|
135
130
|
* requires the current value of the streamable to be a string.
|
@@ -142,13 +137,13 @@ declare function createStreamableValue<T = any, E = any>(initialValue?: T | Read
|
|
142
137
|
* // The value will be 'hello world'
|
143
138
|
* ```
|
144
139
|
*/
|
145
|
-
append(value: T):
|
140
|
+
append(value: T): StreamableValueWrapper<T, E>;
|
146
141
|
/**
|
147
142
|
* This method is used to signal that there is an error in the value stream.
|
148
143
|
* It will be thrown on the client side when consumed via
|
149
144
|
* `readStreamableValue` or `useStreamableValue`.
|
150
145
|
*/
|
151
|
-
error(error: any):
|
146
|
+
error(error: any): StreamableValueWrapper<T, E>;
|
152
147
|
/**
|
153
148
|
* This method marks the value as finalized. You can either call it without
|
154
149
|
* any parameters or with a new value as the final state.
|
@@ -157,7 +152,7 @@ declare function createStreamableValue<T = any, E = any>(initialValue?: T | Read
|
|
157
152
|
* This method is always **required** to be called, otherwise the response
|
158
153
|
* will be stuck in a loading state.
|
159
154
|
*/
|
160
|
-
done(...args: [] | [
|
155
|
+
done(...args: [T] | []): StreamableValueWrapper<T, E>;
|
161
156
|
};
|
162
157
|
|
163
158
|
type Streamable$1 = ReactNode | Promise<ReactNode>;
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
2
1
|
import { ReactNode } from 'react';
|
3
2
|
import OpenAI from 'openai';
|
4
3
|
import { z } from 'zod';
|
@@ -64,19 +63,15 @@ declare function getAIState<AI extends AIProvider = any>(key: keyof InferAIState
|
|
64
63
|
declare function getMutableAIState<AI extends AIProvider = any>(): MutableAIState<InferAIState<AI, any>>;
|
65
64
|
declare function getMutableAIState<AI extends AIProvider = any>(key: keyof InferAIState<AI, any>): MutableAIState<InferAIState<AI, any>[typeof key]>;
|
66
65
|
|
67
|
-
|
68
|
-
* Create a piece of changable UI that can be streamed to the client.
|
69
|
-
* On the client side, it can be rendered as a normal React node.
|
70
|
-
*/
|
71
|
-
declare function createStreamableUI(initialValue?: React.ReactNode): {
|
66
|
+
type StreamableUIWrapper = {
|
72
67
|
/**
|
73
68
|
* The value of the streamable UI. This can be returned from a Server Action and received by the client.
|
74
69
|
*/
|
75
|
-
value:
|
70
|
+
readonly value: React.ReactNode;
|
76
71
|
/**
|
77
72
|
* This method updates the current UI node. It takes a new UI node and replaces the old one.
|
78
73
|
*/
|
79
|
-
update(value: React.ReactNode):
|
74
|
+
update(value: React.ReactNode): StreamableUIWrapper;
|
80
75
|
/**
|
81
76
|
* This method is used to append a new UI node to the end of the old one.
|
82
77
|
* Once appended a new UI node, the previous UI node cannot be updated anymore.
|
@@ -93,31 +88,31 @@ declare function createStreamableUI(initialValue?: React.ReactNode): {
|
|
93
88
|
* // </>
|
94
89
|
* ```
|
95
90
|
*/
|
96
|
-
append(value: React.ReactNode):
|
91
|
+
append(value: React.ReactNode): StreamableUIWrapper;
|
97
92
|
/**
|
98
93
|
* This method is used to signal that there is an error in the UI stream.
|
99
94
|
* It will be thrown on the client side and caught by the nearest error boundary component.
|
100
95
|
*/
|
101
|
-
error(error: any):
|
96
|
+
error(error: any): StreamableUIWrapper;
|
102
97
|
/**
|
103
98
|
* This method marks the UI node as finalized. You can either call it without any parameters or with a new UI node as the final state.
|
104
99
|
* Once called, the UI node cannot be updated or appended anymore.
|
105
100
|
*
|
106
101
|
* This method is always **required** to be called, otherwise the response will be stuck in a loading state.
|
107
102
|
*/
|
108
|
-
done(...args: [] | [
|
103
|
+
done(...args: [React.ReactNode] | []): StreamableUIWrapper;
|
109
104
|
};
|
110
|
-
|
105
|
+
/**
|
106
|
+
* Create a piece of changable UI that can be streamed to the client.
|
107
|
+
* On the client side, it can be rendered as a normal React node.
|
108
|
+
*/
|
109
|
+
declare function createStreamableUI(initialValue?: React.ReactNode): StreamableUIWrapper;
|
111
110
|
/**
|
112
111
|
* Create a wrapped, changable value that can be streamed to the client.
|
113
112
|
* On the client side, the value can be accessed via the readStreamableValue() API.
|
114
113
|
*/
|
115
|
-
declare function createStreamableValue<T = any, E = any>(initialValue?: T | ReadableStream<T>):
|
116
|
-
|
117
|
-
* @internal This is an internal lock to prevent the value from being
|
118
|
-
* updated by the user.
|
119
|
-
*/
|
120
|
-
[STREAMABLE_VALUE_INTERNAL_LOCK]: boolean;
|
114
|
+
declare function createStreamableValue<T = any, E = any>(initialValue?: T | ReadableStream<T>): StreamableValueWrapper<T, E>;
|
115
|
+
type StreamableValueWrapper<T, E> = {
|
121
116
|
/**
|
122
117
|
* The value of the streamable. This can be returned from a Server Action and
|
123
118
|
* received by the client. To read the streamed values, use the
|
@@ -127,7 +122,7 @@ declare function createStreamableValue<T = any, E = any>(initialValue?: T | Read
|
|
127
122
|
/**
|
128
123
|
* This method updates the current value with a new one.
|
129
124
|
*/
|
130
|
-
update(value: T):
|
125
|
+
update(value: T): StreamableValueWrapper<T, E>;
|
131
126
|
/**
|
132
127
|
* This method is used to append a delta string to the current value. It
|
133
128
|
* requires the current value of the streamable to be a string.
|
@@ -140,13 +135,13 @@ declare function createStreamableValue<T = any, E = any>(initialValue?: T | Read
|
|
140
135
|
* // The value will be 'hello world'
|
141
136
|
* ```
|
142
137
|
*/
|
143
|
-
append(value: T):
|
138
|
+
append(value: T): StreamableValueWrapper<T, E>;
|
144
139
|
/**
|
145
140
|
* This method is used to signal that there is an error in the value stream.
|
146
141
|
* It will be thrown on the client side when consumed via
|
147
142
|
* `readStreamableValue` or `useStreamableValue`.
|
148
143
|
*/
|
149
|
-
error(error: any):
|
144
|
+
error(error: any): StreamableValueWrapper<T, E>;
|
150
145
|
/**
|
151
146
|
* This method marks the value as finalized. You can either call it without
|
152
147
|
* any parameters or with a new value as the final state.
|
@@ -155,7 +150,7 @@ declare function createStreamableValue<T = any, E = any>(initialValue?: T | Read
|
|
155
150
|
* This method is always **required** to be called, otherwise the response
|
156
151
|
* will be stuck in a loading state.
|
157
152
|
*/
|
158
|
-
done(...args: [] | [
|
153
|
+
done(...args: [T] | []): StreamableValueWrapper<T, E>;
|
159
154
|
};
|
160
155
|
|
161
156
|
type Streamable$1 = ReactNode | Promise<ReactNode>;
|
package/rsc/dist/rsc-server.mjs
CHANGED
@@ -1242,13 +1242,7 @@ function createStreamableUI(initialValue) {
|
|
1242
1242
|
}
|
1243
1243
|
warnUnclosedStream();
|
1244
1244
|
const streamable2 = {
|
1245
|
-
/**
|
1246
|
-
* The value of the streamable UI. This can be returned from a Server Action and received by the client.
|
1247
|
-
*/
|
1248
1245
|
value: row,
|
1249
|
-
/**
|
1250
|
-
* This method updates the current UI node. It takes a new UI node and replaces the old one.
|
1251
|
-
*/
|
1252
1246
|
update(value) {
|
1253
1247
|
assertStream(".update()");
|
1254
1248
|
if (value === currentValue) {
|
@@ -1263,22 +1257,6 @@ function createStreamableUI(initialValue) {
|
|
1263
1257
|
warnUnclosedStream();
|
1264
1258
|
return streamable2;
|
1265
1259
|
},
|
1266
|
-
/**
|
1267
|
-
* This method is used to append a new UI node to the end of the old one.
|
1268
|
-
* Once appended a new UI node, the previous UI node cannot be updated anymore.
|
1269
|
-
*
|
1270
|
-
* @example
|
1271
|
-
* ```jsx
|
1272
|
-
* const ui = createStreamableUI(<div>hello</div>)
|
1273
|
-
* ui.append(<div>world</div>)
|
1274
|
-
*
|
1275
|
-
* // The UI node will be:
|
1276
|
-
* // <>
|
1277
|
-
* // <div>hello</div>
|
1278
|
-
* // <div>world</div>
|
1279
|
-
* // </>
|
1280
|
-
* ```
|
1281
|
-
*/
|
1282
1260
|
append(value) {
|
1283
1261
|
assertStream(".append()");
|
1284
1262
|
const resolvable = createResolvablePromise();
|
@@ -1289,10 +1267,6 @@ function createStreamableUI(initialValue) {
|
|
1289
1267
|
warnUnclosedStream();
|
1290
1268
|
return streamable2;
|
1291
1269
|
},
|
1292
|
-
/**
|
1293
|
-
* This method is used to signal that there is an error in the UI stream.
|
1294
|
-
* It will be thrown on the client side and caught by the nearest error boundary component.
|
1295
|
-
*/
|
1296
1270
|
error(error) {
|
1297
1271
|
assertStream(".error()");
|
1298
1272
|
if (warningTimeout) {
|
@@ -1302,12 +1276,6 @@ function createStreamableUI(initialValue) {
|
|
1302
1276
|
reject(error);
|
1303
1277
|
return streamable2;
|
1304
1278
|
},
|
1305
|
-
/**
|
1306
|
-
* This method marks the UI node as finalized. You can either call it without any parameters or with a new UI node as the final state.
|
1307
|
-
* Once called, the UI node cannot be updated or appended anymore.
|
1308
|
-
*
|
1309
|
-
* This method is always **required** to be called, otherwise the response will be stuck in a loading state.
|
1310
|
-
*/
|
1311
1279
|
done(...args) {
|
1312
1280
|
assertStream(".done()");
|
1313
1281
|
if (warningTimeout) {
|
@@ -1420,24 +1388,12 @@ function createStreamableValueImpl(initialValue) {
|
|
1420
1388
|
currentValue = value;
|
1421
1389
|
}
|
1422
1390
|
const streamable2 = {
|
1423
|
-
/**
|
1424
|
-
* @internal This is an internal lock to prevent the value from being
|
1425
|
-
* updated by the user.
|
1426
|
-
*/
|
1427
1391
|
set [STREAMABLE_VALUE_INTERNAL_LOCK](state) {
|
1428
1392
|
locked = state;
|
1429
1393
|
},
|
1430
|
-
/**
|
1431
|
-
* The value of the streamable. This can be returned from a Server Action and
|
1432
|
-
* received by the client. To read the streamed values, use the
|
1433
|
-
* `readStreamableValue` or `useStreamableValue` APIs.
|
1434
|
-
*/
|
1435
1394
|
get value() {
|
1436
1395
|
return createWrapped(true);
|
1437
1396
|
},
|
1438
|
-
/**
|
1439
|
-
* This method updates the current value with a new one.
|
1440
|
-
*/
|
1441
1397
|
update(value) {
|
1442
1398
|
assertStream(".update()");
|
1443
1399
|
const resolvePrevious = resolvable.resolve;
|
@@ -1448,18 +1404,6 @@ function createStreamableValueImpl(initialValue) {
|
|
1448
1404
|
warnUnclosedStream();
|
1449
1405
|
return streamable2;
|
1450
1406
|
},
|
1451
|
-
/**
|
1452
|
-
* This method is used to append a delta string to the current value. It
|
1453
|
-
* requires the current value of the streamable to be a string.
|
1454
|
-
*
|
1455
|
-
* @example
|
1456
|
-
* ```jsx
|
1457
|
-
* const streamable = createStreamableValue('hello');
|
1458
|
-
* streamable.append(' world');
|
1459
|
-
*
|
1460
|
-
* // The value will be 'hello world'
|
1461
|
-
* ```
|
1462
|
-
*/
|
1463
1407
|
append(value) {
|
1464
1408
|
assertStream(".append()");
|
1465
1409
|
if (typeof currentValue !== "string" && typeof currentValue !== "undefined") {
|
@@ -1486,11 +1430,6 @@ function createStreamableValueImpl(initialValue) {
|
|
1486
1430
|
warnUnclosedStream();
|
1487
1431
|
return streamable2;
|
1488
1432
|
},
|
1489
|
-
/**
|
1490
|
-
* This method is used to signal that there is an error in the value stream.
|
1491
|
-
* It will be thrown on the client side when consumed via
|
1492
|
-
* `readStreamableValue` or `useStreamableValue`.
|
1493
|
-
*/
|
1494
1433
|
error(error) {
|
1495
1434
|
assertStream(".error()");
|
1496
1435
|
if (warningTimeout) {
|
@@ -1502,14 +1441,6 @@ function createStreamableValueImpl(initialValue) {
|
|
1502
1441
|
resolvable.resolve({ error });
|
1503
1442
|
return streamable2;
|
1504
1443
|
},
|
1505
|
-
/**
|
1506
|
-
* This method marks the value as finalized. You can either call it without
|
1507
|
-
* any parameters or with a new value as the final state.
|
1508
|
-
* Once called, the value cannot be updated or appended anymore.
|
1509
|
-
*
|
1510
|
-
* This method is always **required** to be called, otherwise the response
|
1511
|
-
* will be stuck in a loading state.
|
1512
|
-
*/
|
1513
1444
|
done(...args) {
|
1514
1445
|
assertStream(".done()");
|
1515
1446
|
if (warningTimeout) {
|