@ai-sdk/rsc 3.0.122 → 3.0.124

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/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # @ai-sdk/rsc
2
2
 
3
+ ## 3.0.124
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [8c65988]
8
+ - Updated dependencies [527a163]
9
+ - ai@7.0.124
10
+ - @ai-sdk/provider@4.0.21
11
+ - @ai-sdk/provider-utils@5.0.53
12
+
13
+ ## 3.0.123
14
+
15
+ ### Patch Changes
16
+
17
+ - ede5b89: chore: migrate package builds from tsup to tsdown
18
+ - Updated dependencies [05cdac6]
19
+ - Updated dependencies [4514fc1]
20
+ - Updated dependencies [ede5b89]
21
+ - Updated dependencies [2a625cf]
22
+ - Updated dependencies [50a26d5]
23
+ - ai@7.0.123
24
+ - @ai-sdk/provider@4.0.20
25
+ - @ai-sdk/provider-utils@5.0.52
26
+
3
27
  ## 3.0.122
4
28
 
5
29
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1,55 +1,55 @@
1
- import { LanguageModelV4, LanguageModelV4StreamResult } from '@ai-sdk/provider';
2
- import { ProviderOptions, InferSchema } from '@ai-sdk/provider-utils';
3
- import { Schema, LanguageModelCallOptions, RequestOptions, Prompt, ToolChoice, FinishReason, LanguageModelUsage, CallWarning } from 'ai';
4
- import { ReactNode } from 'react';
5
- import * as z3 from 'zod/v3';
6
- import * as z4 from 'zod/v4';
7
-
8
- type JSONValue = string | number | boolean | JSONObject | JSONArray;
1
+ import { LanguageModelV4, LanguageModelV4StreamResult } from "@ai-sdk/provider";
2
+ import { InferSchema, ProviderOptions } from "@ai-sdk/provider-utils";
3
+ import { CallWarning, FinishReason, LanguageModelCallOptions, LanguageModelUsage, Prompt, RequestOptions, Schema, ToolChoice } from "ai";
4
+ import { ReactNode } from "react";
5
+ import * as z3 from "zod/v3";
6
+ import * as z4 from "zod/v4";
7
+ //#region src/types.d.ts
8
+ export type JSONValue = string | number | boolean | JSONObject | JSONArray;
9
9
  interface JSONObject {
10
- [x: string]: JSONValue | undefined;
10
+ [x: string]: JSONValue | undefined;
11
11
  }
12
- interface JSONArray extends Array<JSONValue> {
13
- }
14
- type AIAction<T = any, R = any> = (...args: T[]) => Promise<R>;
15
- type AIActions<T = any, R = any> = Record<string, AIAction<T, R>>;
16
- type ServerWrappedAction<T = unknown> = (aiState: T, ...args: unknown[]) => Promise<[Promise<T>, unknown]>;
17
- type ServerWrappedActions<T = unknown> = Record<string, ServerWrappedAction<T>>;
18
- type InternalAIProviderProps<AIState = any, UIState = any> = {
19
- children: React.ReactNode;
20
- initialUIState: UIState;
21
- initialAIState: AIState;
22
- initialAIStatePatch: undefined | Promise<AIState>;
23
- wrappedActions: ServerWrappedActions<AIState>;
24
- wrappedSyncUIState?: ServerWrappedAction<AIState>;
12
+ interface JSONArray extends Array<JSONValue> {}
13
+ export type AIAction<T = any, R = any> = (...args: T[]) => Promise<R>;
14
+ export type AIActions<T = any, R = any> = Record<string, AIAction<T, R>>;
15
+ export type ServerWrappedAction<T = unknown> = (aiState: T, ...args: unknown[]) => Promise<[Promise<T>, unknown]>;
16
+ export type ServerWrappedActions<T = unknown> = Record<string, ServerWrappedAction<T>>;
17
+ export type InternalAIProviderProps<AIState = any, UIState = any> = {
18
+ children: React.ReactNode;
19
+ initialUIState: UIState;
20
+ initialAIState: AIState;
21
+ initialAIStatePatch: undefined | Promise<AIState>;
22
+ wrappedActions: ServerWrappedActions<AIState>;
23
+ wrappedSyncUIState?: ServerWrappedAction<AIState>;
25
24
  };
26
- type AIProviderProps<AIState = any, UIState = any, Actions = any> = {
27
- children: React.ReactNode;
28
- initialAIState?: AIState;
29
- initialUIState?: UIState;
30
- /** $ActionTypes is only added for type inference and is never used at runtime **/
31
- $ActionTypes?: Actions;
25
+ export type AIProviderProps<AIState = any, UIState = any, Actions = any> = {
26
+ children: React.ReactNode;
27
+ initialAIState?: AIState;
28
+ initialUIState?: UIState;
29
+ /** $ActionTypes is only added for type inference and is never used at runtime **/
30
+ $ActionTypes?: Actions;
32
31
  };
33
- type AIProvider<AIState = any, UIState = any, Actions = any> = (props: AIProviderProps<AIState, UIState, Actions>) => Promise<React.ReactElement>;
34
- type InferAIState<T, Fallback> = T extends AIProvider<infer AIState, any, any> ? AIState : Fallback;
35
- type InferUIState<T, Fallback> = T extends AIProvider<any, infer UIState, any> ? UIState : Fallback;
36
- type InferActions<T, Fallback> = T extends AIProvider<any, any, infer Actions> ? Actions : Fallback;
37
- type InternalAIStateStorageOptions = {
38
- onSetAIState?: OnSetAIState<any>;
32
+ export type AIProvider<AIState = any, UIState = any, Actions = any> = (props: AIProviderProps<AIState, UIState, Actions>) => Promise<React.ReactElement>;
33
+ export type InferAIState<T, Fallback> = T extends AIProvider<infer AIState, any, any> ? AIState : Fallback;
34
+ export type InferUIState<T, Fallback> = T extends AIProvider<any, infer UIState, any> ? UIState : Fallback;
35
+ export type InferActions<T, Fallback> = T extends AIProvider<any, any, infer Actions> ? Actions : Fallback;
36
+ export type InternalAIStateStorageOptions = {
37
+ onSetAIState?: OnSetAIState<any>;
39
38
  };
40
- type OnSetAIState<S> = ({ key, state, done, }: {
41
- key: string | number | symbol | undefined;
42
- state: S;
43
- done: boolean;
39
+ export type OnSetAIState<S> = ({ key, state, done }: {
40
+ key: string | number | symbol | undefined;
41
+ state: S;
42
+ done: boolean;
44
43
  }) => void | Promise<void>;
45
- type OnGetUIState<S> = AIAction<void, S | undefined>;
46
- type ValueOrUpdater<T> = T | ((current: T) => T);
47
- type MutableAIState<AIState> = {
48
- get: () => AIState;
49
- update: (newState: ValueOrUpdater<AIState>) => void;
50
- done: ((newState: AIState) => void) | (() => void);
44
+ export type OnGetUIState<S> = AIAction<void, S | undefined>;
45
+ export type ValueOrUpdater<T> = T | ((current: T) => T);
46
+ export type MutableAIState<AIState> = {
47
+ get: () => AIState;
48
+ update: (newState: ValueOrUpdater<AIState>) => void;
49
+ done: ((newState: AIState) => void) | (() => void);
51
50
  };
52
-
51
+ //#endregion
52
+ //#region src/ai-state.d.ts
53
53
  /**
54
54
  * Get the current AI state.
55
55
  * If `key` is provided, it will return the value of the specified key in the
@@ -80,185 +80,182 @@ declare function getAIState<AI extends AIProvider = any>(key: keyof InferAIState
80
80
  */
81
81
  declare function getMutableAIState<AI extends AIProvider = any>(): MutableAIState<InferAIState<AI, any>>;
82
82
  declare function getMutableAIState<AI extends AIProvider = any>(key: keyof InferAIState<AI, any>): MutableAIState<InferAIState<AI, any>[typeof key]>;
83
-
84
- declare function createAI<AIState = any, UIState = any, Actions extends AIActions = {}>({ actions, initialAIState, initialUIState, onSetAIState, onGetUIState, }: {
85
- actions: Actions;
86
- initialAIState?: AIState;
87
- initialUIState?: UIState;
88
- /**
89
- * This function is called whenever the AI state is updated by an Action.
90
- * You can use this to persist the AI state to a database, or to send it to a
91
- * logging service.
92
- */
93
- onSetAIState?: OnSetAIState<AIState>;
94
- /**
95
- * This function is used to retrieve the UI state based on the AI state.
96
- * For example, to render the initial UI state based on a given AI state, or
97
- * to sync the UI state when the application is already loaded.
98
- *
99
- * If returning `undefined`, the client side UI state will not be updated.
100
- *
101
- * This function must be annotated with the `"use server"` directive.
102
- *
103
- * @example
104
- * ```tsx
105
- * onGetUIState: async () => {
106
- * 'use server';
107
- *
108
- * const currentAIState = getAIState();
109
- * const externalAIState = await loadAIStateFromDatabase();
110
- *
111
- * if (currentAIState === externalAIState) return undefined;
112
- *
113
- * // Update current AI state and return the new UI state
114
- * const state = getMutableAIState()
115
- * state.done(externalAIState)
116
- *
117
- * return <div>...</div>;
118
- * }
119
- * ```
120
- */
121
- onGetUIState?: OnGetUIState<UIState>;
83
+ //#endregion
84
+ //#region src/provider.d.ts
85
+ export declare function createAI<AIState = any, UIState = any, Actions extends AIActions = {}>({ actions, initialAIState, initialUIState, onSetAIState, onGetUIState }: {
86
+ actions: Actions;
87
+ initialAIState?: AIState;
88
+ initialUIState?: UIState;
89
+ /**
90
+ * This function is called whenever the AI state is updated by an Action.
91
+ * You can use this to persist the AI state to a database, or to send it to a
92
+ * logging service.
93
+ */
94
+ onSetAIState?: OnSetAIState<AIState>;
95
+ /**
96
+ * This function is used to retrieve the UI state based on the AI state.
97
+ * For example, to render the initial UI state based on a given AI state, or
98
+ * to sync the UI state when the application is already loaded.
99
+ *
100
+ * If returning `undefined`, the client side UI state will not be updated.
101
+ *
102
+ * This function must be annotated with the `"use server"` directive.
103
+ *
104
+ * @example
105
+ * ```tsx
106
+ * onGetUIState: async () => {
107
+ * 'use server';
108
+ *
109
+ * const currentAIState = getAIState();
110
+ * const externalAIState = await loadAIStateFromDatabase();
111
+ *
112
+ * if (currentAIState === externalAIState) return undefined;
113
+ *
114
+ * // Update current AI state and return the new UI state
115
+ * const state = getMutableAIState()
116
+ * state.done(externalAIState)
117
+ *
118
+ * return <div>...</div>;
119
+ * }
120
+ * ```
121
+ */
122
+ onGetUIState?: OnGetUIState<UIState>;
122
123
  }): AIProvider<AIState, UIState, Actions>;
123
-
124
+ //#endregion
125
+ //#region src/stream-ui/stream-ui.d.ts
124
126
  type Streamable = ReactNode | Promise<ReactNode>;
125
127
  type Renderer<T extends Array<any>> = (...args: T) => Streamable | Generator<Streamable, Streamable, void> | AsyncGenerator<Streamable, Streamable, void>;
126
128
  type RenderTool<INPUT_SCHEMA extends z4.core.$ZodType | z3.Schema | Schema = any> = {
127
- description?: string;
128
- inputSchema: INPUT_SCHEMA;
129
- generate?: Renderer<[
130
- InferSchema<INPUT_SCHEMA>,
131
- {
132
- toolName: string;
133
- toolCallId: string;
134
- }
135
- ]>;
129
+ description?: string;
130
+ inputSchema: INPUT_SCHEMA;
131
+ generate?: Renderer<[InferSchema<INPUT_SCHEMA>, {
132
+ toolName: string;
133
+ toolCallId: string;
134
+ }]>;
136
135
  };
137
- type RenderText = Renderer<[
138
- {
139
- /**
140
- * The full text content from the model so far.
141
- */
142
- content: string;
143
- /**
144
- * The new appended text content from the model since the last `text` call.
145
- */
146
- delta: string;
147
- /**
148
- * Whether the model is done generating text.
149
- * If `true`, the `content` will be the final output and this call will be the last.
150
- */
151
- done: boolean;
152
- }
153
- ]>;
136
+ type RenderText = Renderer<[{
137
+ /**
138
+ * The full text content from the model so far.
139
+ */
140
+ content: string;
141
+ /**
142
+ * The new appended text content from the model since the last `text` call.
143
+ */
144
+ delta: string;
145
+ /**
146
+ * Whether the model is done generating text.
147
+ * If `true`, the `content` will be the final output and this call will be the last.
148
+ */
149
+ done: boolean;
150
+ }]>;
154
151
  type RenderResult = {
155
- value: ReactNode;
152
+ value: ReactNode;
156
153
  } & LanguageModelV4StreamResult;
157
154
  /**
158
155
  * `streamUI` is a helper function to create a streamable UI from LLMs.
159
156
  */
160
- declare function streamUI<TOOLS extends {
161
- [name: string]: z4.core.$ZodType | z3.Schema | Schema;
157
+ export declare function streamUI<TOOLS extends {
158
+ [name: string]: z4.core.$ZodType | z3.Schema | Schema;
162
159
  } = {}>({ model, tools, toolChoice, instructions, system, prompt, messages, allowSystemInMessages, maxRetries, abortSignal, headers, initial, text, providerOptions, onFinish, ...settings }: LanguageModelCallOptions & Omit<RequestOptions, 'timeout'> & Prompt & {
160
+ /**
161
+ * The language model to use.
162
+ */
163
+ model: LanguageModelV4;
164
+ /**
165
+ * The tools that the model can call. The model needs to support calling tools.
166
+ */
167
+ tools?: { [name in keyof TOOLS]: RenderTool<TOOLS[name]>; };
168
+ /**
169
+ * The tool choice strategy. Default: 'auto'.
170
+ */
171
+ toolChoice?: ToolChoice<TOOLS>;
172
+ text?: RenderText;
173
+ initial?: ReactNode;
174
+ /**
175
+ * Additional provider-specific options. They are passed through
176
+ * to the provider from the AI SDK and enable provider-specific
177
+ * functionality that can be fully encapsulated in the provider.
178
+ */
179
+ providerOptions?: ProviderOptions;
180
+ /**
181
+ * Callback that is called when the LLM response and the final object validation are finished.
182
+ */
183
+ onFinish?: (event: {
163
184
  /**
164
- * The language model to use.
185
+ * The reason why the generation finished.
165
186
  */
166
- model: LanguageModelV4;
187
+ finishReason: FinishReason;
167
188
  /**
168
- * The tools that the model can call. The model needs to support calling tools.
189
+ * The token usage of the generated response.
169
190
  */
170
- tools?: {
171
- [name in keyof TOOLS]: RenderTool<TOOLS[name]>;
172
- };
191
+ usage: LanguageModelUsage;
173
192
  /**
174
- * The tool choice strategy. Default: 'auto'.
193
+ * The final ui node that was generated.
175
194
  */
176
- toolChoice?: ToolChoice<TOOLS>;
177
- text?: RenderText;
178
- initial?: ReactNode;
195
+ value: ReactNode;
179
196
  /**
180
- * Additional provider-specific options. They are passed through
181
- * to the provider from the AI SDK and enable provider-specific
182
- * functionality that can be fully encapsulated in the provider.
197
+ * Warnings from the model provider (e.g. unsupported settings)
183
198
  */
184
- providerOptions?: ProviderOptions;
199
+ warnings?: CallWarning[];
185
200
  /**
186
- * Callback that is called when the LLM response and the final object validation are finished.
201
+ * Optional response data.
187
202
  */
188
- onFinish?: (event: {
189
- /**
190
- * The reason why the generation finished.
191
- */
192
- finishReason: FinishReason;
193
- /**
194
- * The token usage of the generated response.
195
- */
196
- usage: LanguageModelUsage;
197
- /**
198
- * The final ui node that was generated.
199
- */
200
- value: ReactNode;
201
- /**
202
- * Warnings from the model provider (e.g. unsupported settings)
203
- */
204
- warnings?: CallWarning[];
205
- /**
206
- * Optional response data.
207
- */
208
- response?: {
209
- /**
210
- * Response headers.
211
- */
212
- headers?: Record<string, string>;
213
- };
214
- }) => Promise<void> | void;
203
+ response?: {
204
+ /**
205
+ * Response headers.
206
+ */
207
+ headers?: Record<string, string>;
208
+ };
209
+ }) => Promise<void> | void;
215
210
  }): Promise<RenderResult>;
216
-
211
+ //#endregion
212
+ //#region src/streamable-ui/create-streamable-ui.d.ts
217
213
  type StreamableUIWrapper = {
218
- /**
219
- * The value of the streamable UI. This can be returned from a Server Action and received by the client.
220
- */
221
- readonly value: React.ReactNode;
222
- /**
223
- * This method updates the current UI node. It takes a new UI node and replaces the old one.
224
- */
225
- update(value: React.ReactNode): StreamableUIWrapper;
226
- /**
227
- * This method is used to append a new UI node to the end of the old one.
228
- * Once appended a new UI node, the previous UI node cannot be updated anymore.
229
- *
230
- * @example
231
- * ```jsx
232
- * const ui = createStreamableUI(<div>hello</div>)
233
- * ui.append(<div>world</div>)
234
- *
235
- * // The UI node will be:
236
- * // <>
237
- * // <div>hello</div>
238
- * // <div>world</div>
239
- * // </>
240
- * ```
241
- */
242
- append(value: React.ReactNode): StreamableUIWrapper;
243
- /**
244
- * This method is used to signal that there is an error in the UI stream.
245
- * It will be thrown on the client side and caught by the nearest error boundary component.
246
- */
247
- error(error: any): StreamableUIWrapper;
248
- /**
249
- * 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.
250
- * Once called, the UI node cannot be updated or appended anymore.
251
- *
252
- * This method is always **required** to be called, otherwise the response will be stuck in a loading state.
253
- */
254
- done(...args: [React.ReactNode] | []): StreamableUIWrapper;
214
+ /**
215
+ * The value of the streamable UI. This can be returned from a Server Action and received by the client.
216
+ */
217
+ readonly value: React.ReactNode;
218
+ /**
219
+ * This method updates the current UI node. It takes a new UI node and replaces the old one.
220
+ */
221
+ update(value: React.ReactNode): StreamableUIWrapper;
222
+ /**
223
+ * This method is used to append a new UI node to the end of the old one.
224
+ * Once appended a new UI node, the previous UI node cannot be updated anymore.
225
+ *
226
+ * @example
227
+ * ```jsx
228
+ * const ui = createStreamableUI(<div>hello</div>)
229
+ * ui.append(<div>world</div>)
230
+ *
231
+ * // The UI node will be:
232
+ * // <>
233
+ * // <div>hello</div>
234
+ * // <div>world</div>
235
+ * // </>
236
+ * ```
237
+ */
238
+ append(value: React.ReactNode): StreamableUIWrapper;
239
+ /**
240
+ * This method is used to signal that there is an error in the UI stream.
241
+ * It will be thrown on the client side and caught by the nearest error boundary component.
242
+ */
243
+ error(error: any): StreamableUIWrapper;
244
+ /**
245
+ * 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.
246
+ * Once called, the UI node cannot be updated or appended anymore.
247
+ *
248
+ * This method is always **required** to be called, otherwise the response will be stuck in a loading state.
249
+ */
250
+ done(...args: [React.ReactNode] | []): StreamableUIWrapper;
255
251
  };
256
252
  /**
257
253
  * Create a piece of changeable UI that can be streamed to the client.
258
254
  * On the client side, it can be rendered as a normal React node.
259
255
  */
260
256
  declare function createStreamableUI(initialValue?: React.ReactNode): StreamableUIWrapper;
261
-
257
+ //#endregion
258
+ //#region src/streamable-value/streamable-value.d.ts
262
259
  declare const __internal_curr: unique symbol;
263
260
  declare const __internal_error: unique symbol;
264
261
  /**
@@ -266,56 +263,58 @@ declare const __internal_error: unique symbol;
266
263
  * To read the streamed values, use the `readStreamableValue` or `useStreamableValue` APIs.
267
264
  */
268
265
  type StreamableValue<T = any, E = any> = {
269
- [__internal_curr]?: T;
270
- [__internal_error]?: E;
266
+ [__internal_curr]?: T;
267
+ [__internal_error]?: E;
271
268
  };
272
-
269
+ //#endregion
270
+ //#region src/streamable-value/create-streamable-value.d.ts
273
271
  /**
274
272
  * Create a wrapped, changeable value that can be streamed to the client.
275
273
  * On the client side, the value can be accessed via the readStreamableValue() API.
276
274
  */
277
275
  declare function createStreamableValue<T = any, E = any>(initialValue?: T | ReadableStream<T>): StreamableValueWrapper<T, E>;
278
276
  type StreamableValueWrapper<T, E> = {
279
- /**
280
- * The value of the streamable. This can be returned from a Server Action and
281
- * received by the client. To read the streamed values, use the
282
- * `readStreamableValue` or `useStreamableValue` APIs.
283
- */
284
- readonly value: StreamableValue<T, E>;
285
- /**
286
- * This method updates the current value with a new one.
287
- */
288
- update(value: T): StreamableValueWrapper<T, E>;
289
- /**
290
- * This method is used to append a delta string to the current value. It
291
- * requires the current value of the streamable to be a string.
292
- *
293
- * @example
294
- * ```jsx
295
- * const streamable = createStreamableValue('hello');
296
- * streamable.append(' world');
297
- *
298
- * // The value will be 'hello world'
299
- * ```
300
- */
301
- append(value: T): StreamableValueWrapper<T, E>;
302
- /**
303
- * This method is used to signal that there is an error in the value stream.
304
- * It will be thrown on the client side when consumed via
305
- * `readStreamableValue` or `useStreamableValue`.
306
- */
307
- error(error: any): StreamableValueWrapper<T, E>;
308
- /**
309
- * This method marks the value as finalized. You can either call it without
310
- * any parameters or with a new value as the final state.
311
- * Once called, the value cannot be updated or appended anymore.
312
- *
313
- * This method is always **required** to be called, otherwise the response
314
- * will be stuck in a loading state.
315
- */
316
- done(...args: [T] | []): StreamableValueWrapper<T, E>;
277
+ /**
278
+ * The value of the streamable. This can be returned from a Server Action and
279
+ * received by the client. To read the streamed values, use the
280
+ * `readStreamableValue` or `useStreamableValue` APIs.
281
+ */
282
+ readonly value: StreamableValue<T, E>;
283
+ /**
284
+ * This method updates the current value with a new one.
285
+ */
286
+ update(value: T): StreamableValueWrapper<T, E>;
287
+ /**
288
+ * This method is used to append a delta string to the current value. It
289
+ * requires the current value of the streamable to be a string.
290
+ *
291
+ * @example
292
+ * ```jsx
293
+ * const streamable = createStreamableValue('hello');
294
+ * streamable.append(' world');
295
+ *
296
+ * // The value will be 'hello world'
297
+ * ```
298
+ */
299
+ append(value: T): StreamableValueWrapper<T, E>;
300
+ /**
301
+ * This method is used to signal that there is an error in the value stream.
302
+ * It will be thrown on the client side when consumed via
303
+ * `readStreamableValue` or `useStreamableValue`.
304
+ */
305
+ error(error: any): StreamableValueWrapper<T, E>;
306
+ /**
307
+ * This method marks the value as finalized. You can either call it without
308
+ * any parameters or with a new value as the final state.
309
+ * Once called, the value cannot be updated or appended anymore.
310
+ *
311
+ * This method is always **required** to be called, otherwise the response
312
+ * will be stuck in a loading state.
313
+ */
314
+ done(...args: [T] | []): StreamableValueWrapper<T, E>;
317
315
  };
318
-
316
+ //#endregion
317
+ //#region src/streamable-value/read-streamable-value.d.ts
319
318
  /**
320
319
  * `readStreamableValue` takes a streamable value created via the `createStreamableValue().value` API,
321
320
  * and returns an async iterator.
@@ -346,8 +345,9 @@ type StreamableValueWrapper<T, E> = {
346
345
  *
347
346
  * This logs out 1, 2, 3 on console.
348
347
  */
349
- declare function readStreamableValue<T = unknown>(streamableValue: StreamableValue<T>): AsyncIterable<T | undefined>;
350
-
348
+ export declare function readStreamableValue<T = unknown>(streamableValue: StreamableValue<T>): AsyncIterable<T | undefined>;
349
+ //#endregion
350
+ //#region src/streamable-value/use-streamable-value.d.ts
351
351
  /**
352
352
  * `useStreamableValue` is a React hook that takes a streamable value created via the `createStreamableValue().value` API,
353
353
  * and returns the current value, error, and pending state.
@@ -365,18 +365,14 @@ declare function readStreamableValue<T = unknown>(streamableValue: StreamableVal
365
365
  * }
366
366
  * ```
367
367
  */
368
- declare function useStreamableValue<T = unknown, Error = unknown>(streamableValue?: StreamableValue<T>): [data: T | undefined, error: Error | undefined, pending: boolean];
369
-
370
- declare function useUIState<AI extends AIProvider = any>(): [InferUIState<AI, any>, (v: InferUIState<AI, any> | ((v_: InferUIState<AI, any>) => InferUIState<AI, any>)) => void];
371
- declare function useAIState<AI extends AIProvider = any>(): [
372
- InferAIState<AI, any>,
373
- (newState: ValueOrUpdater<InferAIState<AI, any>>) => void
374
- ];
375
- declare function useAIState<AI extends AIProvider = any>(key: keyof InferAIState<AI, any>): [
376
- InferAIState<AI, any>[typeof key],
377
- (newState: ValueOrUpdater<InferAIState<AI, any>[typeof key]>) => void
378
- ];
379
- declare function useActions<AI extends AIProvider = any>(): InferActions<AI, any>;
380
- declare function useSyncUIState(): () => Promise<void>;
381
-
382
- export { AIAction, AIActions, AIProvider, AIProviderProps, InferAIState, InferActions, InferUIState, InternalAIProviderProps, InternalAIStateStorageOptions, JSONValue, MutableAIState, OnGetUIState, OnSetAIState, ServerWrappedAction, ServerWrappedActions, StreamableValue, ValueOrUpdater, createAI, createStreamableUI, createStreamableValue, getAIState, getMutableAIState, readStreamableValue, streamUI, useAIState, useActions, useStreamableValue, useSyncUIState, useUIState };
368
+ export declare function useStreamableValue<T = unknown, Error = unknown>(streamableValue?: StreamableValue<T>): [data: T | undefined, error: Error | undefined, pending: boolean];
369
+ //#endregion
370
+ //#region src/shared-client/context.d.ts
371
+ export declare function useUIState<AI extends AIProvider = any>(): [InferUIState<AI, any>, (v: InferUIState<AI, any> | ((v_: InferUIState<AI, any>) => InferUIState<AI, any>)) => void];
372
+ declare function useAIState<AI extends AIProvider = any>(): [InferAIState<AI, any>, (newState: ValueOrUpdater<InferAIState<AI, any>>) => void];
373
+ declare function useAIState<AI extends AIProvider = any>(key: keyof InferAIState<AI, any>): [InferAIState<AI, any>[typeof key], (newState: ValueOrUpdater<InferAIState<AI, any>[typeof key]>) => void];
374
+ export declare function useActions<AI extends AIProvider = any>(): InferActions<AI, any>;
375
+ export declare function useSyncUIState(): () => Promise<void>;
376
+ //#endregion
377
+ export { type StreamableValue, createStreamableUI, createStreamableValue, getAIState, getMutableAIState, useAIState };
378
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/ai-state.tsx","../src/provider.tsx","../src/stream-ui/stream-ui.tsx","../src/streamable-ui/create-streamable-ui.tsx","../src/streamable-value/streamable-value.ts","../src/streamable-value/create-streamable-value.ts","../src/streamable-value/read-streamable-value.tsx","../src/streamable-value/use-streamable-value.tsx","../src/shared-client/context.tsx"],"mappings":";;;;;;;YAAY,wCAAwC,aAAa;UAEvD;GACP,YAAY;;UAGL,kBAAkB,MAAM;YAEtB,SAAS,SAAS,eAAe,MAAM,QAAQ,QAAQ;YACvD,UAAU,SAAS,WAAW,eAAe,SAAS,GAAG;YAEzD,oBAAoB,gBAC9B,SAAS,MACN,oBACA,SAAS,QAAQ;YACV,qBAAqB,eAAe,eAE9C,oBAAoB;YAGV,wBAAwB,eAAe;EACjD,UAAU,MAAM;EAChB,gBAAgB;EAChB,gBAAgB;EAChB,iCAAiC,QAAQ;EACzC,gBAAgB,qBAAqB;EACrC,qBAAqB,oBAAoB;;YAG/B,gBAAgB,eAAe,eAAe;EACxD,UAAU,MAAM;EAChB,iBAAiB;EACjB,iBAAiB;;EAEjB,eAAe;;YAGL,WAAW,eAAe,eAAe,kBACnD,OA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AW,sBAC7B,aAAa,WACZ,UAAU,eAAe,aAAa;iBAEhC,WAAW,WAAW,kBAC7B,WAAW,aAAa,YAExB,aAAa,gBAAgB,OAC5B,UAAU,eAAe,aAAa,gBAAgB;wBAkDzC,WAAW,WAAW,qBAAgB,aAAA;wBAOtC,wBAC6B"}
@@ -1 +1,2 @@
1
- export { readStreamableValue, useAIState, useActions, useStreamableValue, useSyncUIState, useUIState } from './rsc-shared.js';
1
+ import { readStreamableValue, useAIState, useActions, useStreamableValue, useSyncUIState, useUIState } from "./rsc-shared.js";
2
+ export { readStreamableValue, useAIState, useActions, useStreamableValue, useSyncUIState, useUIState };
@@ -1,18 +1,2 @@
1
- // src/rsc-client.ts
2
- import {
3
- readStreamableValue,
4
- useStreamableValue,
5
- useUIState,
6
- useAIState,
7
- useActions,
8
- useSyncUIState
9
- } from "./rsc-shared.js";
10
- export {
11
- readStreamableValue,
12
- useAIState,
13
- useActions,
14
- useStreamableValue,
15
- useSyncUIState,
16
- useUIState
17
- };
18
- //# sourceMappingURL=rsc-client.js.map
1
+ import { readStreamableValue, useAIState, useActions, useStreamableValue, useSyncUIState, useUIState } from "./rsc-shared.js";
2
+ export { readStreamableValue, useAIState, useActions, useStreamableValue, useSyncUIState, useUIState };