Skip to content

Commit 1d863f8

Browse files
committed
chore: remove deprecated ai/rsc
1 parent c57e248 commit 1d863f8

40 files changed

+115
-75
lines changed

Diff for: packages/ai/core/prompt/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,5 @@ export type {
2626
ToolContent,
2727
UserContent,
2828
} from './message';
29+
export type { Prompt } from './prompt';
30+
export type { CallSettings } from './call-settings';

Diff for: packages/ai/core/types/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ export type {
1919
export type { LanguageModelRequestMetadata } from './language-model-request-metadata';
2020
export type { LanguageModelResponseMetadata } from './language-model-response-metadata';
2121
export type { Provider } from './provider';
22-
export type { ProviderMetadata } from './provider-metadata';
22+
export type { ProviderOptions, ProviderMetadata } from './provider-metadata';
2323
export type { EmbeddingModelUsage, LanguageModelUsage } from './usage';

Diff for: packages/ai/internal/index.ts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export { standardizePrompt } from '../core/prompt/standardize-prompt';
2+
export { prepareToolsAndToolChoice } from '../core/prompt/prepare-tools-and-tool-choice';
3+
export { prepareRetries } from '../core/prompt/prepare-retries';
4+
export { prepareCallSettings } from '../core/prompt/prepare-call-settings';
5+
export { convertToLanguageModelPrompt } from '../core/prompt/convert-to-language-model-prompt';
6+
export { calculateLanguageModelUsage } from '../core/types/usage';
7+
8+
export * from '../util/constants';

Diff for: packages/ai/package.json

+5-11
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,17 @@
4141
"import": "./dist/index.mjs",
4242
"require": "./dist/index.js"
4343
},
44+
"./internal": {
45+
"types": "./dist/internal/index.d.ts",
46+
"import": "./dist/index.mjs",
47+
"require": "./dist/index.js"
48+
},
4449
"./test": {
4550
"types": "./test/dist/index.d.ts",
4651
"import": "./test/dist/index.mjs",
4752
"module": "./test/dist/index.mjs",
4853
"require": "./test/dist/index.js"
4954
},
50-
"./rsc": {
51-
"types": "./rsc/dist/index.d.ts",
52-
"react-server": "./rsc/dist/rsc-server.mjs",
53-
"import": "./rsc/dist/rsc-client.mjs"
54-
},
5555
"./mcp-stdio": {
5656
"types": "./mcp-stdio/dist/index.d.ts",
5757
"import": "./mcp-stdio/dist/index.mjs",
@@ -81,14 +81,8 @@
8181
"zod": "3.23.8"
8282
},
8383
"peerDependencies": {
84-
"react": "^18 || ^19 || ^19.0.0-rc",
8584
"zod": "^3.23.8"
8685
},
87-
"peerDependenciesMeta": {
88-
"react": {
89-
"optional": true
90-
}
91-
},
9286
"engines": {
9387
"node": ">=18"
9488
},

Diff for: packages/ai/rsc/package.json

-13
This file was deleted.

Diff for: packages/ai/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "./node_modules/@vercel/ai-tsconfig/react-library.json",
2+
"extends": "./node_modules/@vercel/ai-tsconfig/base.json",
33
"compilerOptions": {
44
"target": "ES2018",
55
"stripInternal": true,

Diff for: packages/ai/tsup.config.ts

+11-32
Original file line numberDiff line numberDiff line change
@@ -9,47 +9,26 @@ export default defineConfig([
99
dts: true,
1010
sourcemap: true,
1111
},
12-
// Test utilities
12+
// Internal APIs
1313
{
14-
entry: ['test/index.ts'],
15-
outDir: 'test/dist',
14+
entry: ['internal/index.ts'],
15+
// This bundle isn't actually used,
16+
// we export the internal bundle with @internal from the root package
17+
// and provide different types in package.json for the exports
18+
// to save duplicating 40kb for bundle size
19+
outDir: 'dist/internal',
1620
format: ['cjs', 'esm'],
1721
dts: true,
1822
sourcemap: true,
1923
},
20-
// RSC APIs - shared client
21-
{
22-
// Entry is `.mts` as the entrypoints that import it will be ESM so it needs exact imports that includes the `.mjs` extension.
23-
entry: ['rsc/rsc-shared.mts'],
24-
outDir: 'rsc/dist',
25-
format: ['esm'],
26-
external: ['react', 'zod'],
27-
dts: true,
28-
sourcemap: true,
29-
},
30-
// RSC APIs - server, client
24+
// Test utilities
3125
{
32-
entry: ['rsc/rsc-server.ts', 'rsc/rsc-client.ts'],
33-
outDir: 'rsc/dist',
34-
format: ['esm'],
35-
external: ['react', 'zod', /\/rsc-shared/],
26+
entry: ['test/index.ts'],
27+
outDir: 'test/dist',
28+
format: ['cjs', 'esm'],
3629
dts: true,
3730
sourcemap: true,
3831
},
39-
// RSC APIs - types
40-
{
41-
entry: ['rsc/index.ts'],
42-
outDir: 'rsc/dist',
43-
dts: true,
44-
outExtension() {
45-
return {
46-
// It must be `.d.ts` instead of `.d.mts` to support node resolution.
47-
// See https://github.com/vercel/ai/issues/1028.
48-
dts: '.d.ts',
49-
js: '.mjs',
50-
};
51-
},
52-
},
5332
// MCP stdio
5433
{
5534
entry: ['mcp-stdio/index.ts'],

Diff for: packages/react/package.json

+8-1
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,24 @@
2222
"types": "./dist/index.d.ts",
2323
"import": "./dist/index.mjs",
2424
"require": "./dist/index.js"
25+
},
26+
"./rsc": {
27+
"types": "./dist/rsc/index.d.ts",
28+
"import": "./dist/rsc/index.mjs",
29+
"require": "./dist/rsc/index.js"
2530
}
2631
},
2732
"files": [
2833
"dist/**/*",
2934
"CHANGELOG.md"
3035
],
3136
"dependencies": {
37+
"ai": "5.0.0-canary.0",
3238
"@ai-sdk/provider-utils": "3.0.0-canary.1",
3339
"@ai-sdk/ui-utils": "2.0.0-canary.1",
3440
"swr": "^2.2.5",
35-
"throttleit": "2.1.0"
41+
"throttleit": "2.1.0",
42+
"jsondiffpatch": "0.6.0"
3643
},
3744
"devDependencies": {
3845
"@testing-library/jest-dom": "^6.6.3",
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Diff for: packages/ai/rsc/stream-ui/stream-ui.tsx renamed to packages/react/src/rsc/stream-ui/stream-ui.tsx

+13-13
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@ import { LanguageModelV2 } from '@ai-sdk/provider';
22
import { safeParseJSON } from '@ai-sdk/provider-utils';
33
import { ReactNode } from 'react';
44
import { z } from 'zod';
5-
import { CallSettings } from '../../core/prompt/call-settings';
6-
import { convertToLanguageModelPrompt } from '../../core/prompt/convert-to-language-model-prompt';
7-
import { prepareCallSettings } from '../../core/prompt/prepare-call-settings';
8-
import { prepareRetries } from '../../core/prompt/prepare-retries';
9-
import { prepareToolsAndToolChoice } from '../../core/prompt/prepare-tools-and-tool-choice';
10-
import { Prompt } from '../../core/prompt/prompt';
11-
import { standardizePrompt } from '../../core/prompt/standardize-prompt';
125
import {
136
CallWarning,
147
FinishReason,
158
ProviderMetadata,
9+
ProviderOptions,
10+
LanguageModelUsage,
1611
ToolChoice,
17-
} from '../../core/types';
18-
import { ProviderOptions } from '../../core/types/provider-metadata';
12+
Prompt,
13+
CallSettings,
14+
InvalidToolArgumentsError,
15+
NoSuchToolError,
16+
} from 'ai';
1917
import {
20-
LanguageModelUsage,
2118
calculateLanguageModelUsage,
22-
} from '../../core/types/usage';
23-
import { InvalidToolArgumentsError } from '../../errors/invalid-tool-arguments-error';
24-
import { NoSuchToolError } from '../../errors/no-such-tool-error';
19+
standardizePrompt,
20+
prepareToolsAndToolChoice,
21+
prepareRetries,
22+
prepareCallSettings,
23+
convertToLanguageModelPrompt,
24+
} from 'ai/internal';
2525
import { createResolvablePromise } from '../../util/create-resolvable-promise';
2626
import { isAsyncGenerator } from '../../util/is-async-generator';
2727
import { isGenerator } from '../../util/is-generator';

Diff for: packages/ai/rsc/streamable-ui/create-streamable-ui.tsx renamed to packages/react/src/rsc/streamable-ui/create-streamable-ui.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { HANGING_STREAM_WARNING_TIME_MS } from '../../util/constants';
1+
import { HANGING_STREAM_WARNING_TIME_MS } from 'ai';
22
import { createResolvablePromise } from '../../util/create-resolvable-promise';
33
import { createSuspendedChunk } from './create-suspended-chunk';
44

Diff for: packages/ai/rsc/streamable-value/create-streamable-value.ts renamed to packages/react/src/rsc/streamable-value/create-streamable-value.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { HANGING_STREAM_WARNING_TIME_MS } from '../../util/constants';
1+
import { HANGING_STREAM_WARNING_TIME_MS } from 'ai';
22
import { createResolvablePromise } from '../../util/create-resolvable-promise';
33
import {
44
STREAMABLE_VALUE_TYPE,
File renamed without changes.
File renamed without changes.

Diff for: packages/react/src/util/create-resolvable-promise.ts

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* Creates a Promise with externally accessible resolve and reject functions.
3+
*
4+
* @template T - The type of the value that the Promise will resolve to.
5+
* @returns An object containing:
6+
* - promise: A Promise that can be resolved or rejected externally.
7+
* - resolve: A function to resolve the Promise with a value of type T.
8+
* - reject: A function to reject the Promise with an error.
9+
*/
10+
export function createResolvablePromise<T = any>(): {
11+
promise: Promise<T>;
12+
resolve: (value: T) => void;
13+
reject: (error: unknown) => void;
14+
} {
15+
let resolve: (value: T) => void;
16+
let reject: (error: unknown) => void;
17+
18+
const promise = new Promise<T>((res, rej) => {
19+
resolve = res;
20+
reject = rej;
21+
});
22+
23+
return {
24+
promise,
25+
resolve: resolve!,
26+
reject: reject!,
27+
};
28+
}
File renamed without changes.
File renamed without changes.

Diff for: packages/react/tsup.config.ts

+34
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,38 @@ export default defineConfig([
1010
dts: true,
1111
sourcemap: true,
1212
},
13+
14+
// RSC APIs - shared client
15+
{
16+
// Entry is `.mts` as the entrypoints that import it will be ESM so it needs exact imports that includes the `.mjs` extension.
17+
entry: ['src/rsc/rsc-shared.mts'],
18+
outDir: 'dist/rsc',
19+
format: ['esm'],
20+
external: ['react', 'zod'],
21+
dts: true,
22+
sourcemap: true,
23+
},
24+
// RSC APIs - server, client
25+
{
26+
entry: ['src/rsc/rsc-server.ts', 'src/rsc/rsc-client.ts'],
27+
outDir: 'dist/rsc',
28+
format: ['esm'],
29+
external: ['react', 'zod', /\/rsc-shared/],
30+
dts: true,
31+
sourcemap: true,
32+
},
33+
// RSC APIs - types
34+
{
35+
entry: ['src/rsc/index.ts'],
36+
outDir: 'dist/rsc',
37+
dts: true,
38+
outExtension() {
39+
return {
40+
// It must be `.d.ts` instead of `.d.mts` to support node resolution.
41+
// See https://github.com/vercel/ai/issues/1028.
42+
dts: '.d.ts',
43+
js: '.mjs',
44+
};
45+
},
46+
},
1347
]);

Diff for: tools/tsconfig/base.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"forceConsistentCasingInFileNames": true,
1010
"inlineSources": false,
1111
"isolatedModules": true,
12-
"moduleResolution": "node",
12+
"module": "ESNext",
13+
"moduleResolution": "Bundler",
1314
"noUnusedLocals": false,
1415
"noUnusedParameters": false,
1516
"preserveWatchOutput": true,

0 commit comments

Comments
 (0)