From 134d39ebb46c2a760a915603934c6c5d57be4b26 Mon Sep 17 00:00:00 2001 From: Simon Farshid Date: Tue, 30 Jul 2024 16:34:32 -0700 Subject: [PATCH] fix: undo moving internal utils to /react/internal (#620) --- .changeset/wet-pillows-hope.md | 10 ++++++++++ .../use-assistant/VercelUseAssistantRuntime.tsx | 12 +++++++----- .../src/ui/use-chat/VercelUseChatRuntime.tsx | 8 +++----- .../ui/use-chat/VercelUseChatThreadRuntime.tsx | 4 +++- .../src/primitives/MarkdownText.tsx | 5 +++-- packages/react-markdown/src/ui/code-header.tsx | 5 +++-- packages/react-markdown/src/ui/markdown-text.tsx | 7 +++---- .../src/lib/playground-runtime.ts | 8 +++----- packages/react/internal/README.md | 1 - packages/react/internal/package.json | 5 ----- packages/react/package.json | 11 ----------- packages/react/scripts/build.mts | 16 ++++++++++------ packages/react/src/index.ts | 3 --- 13 files changed, 45 insertions(+), 50 deletions(-) create mode 100644 .changeset/wet-pillows-hope.md delete mode 100644 packages/react/internal/README.md delete mode 100644 packages/react/internal/package.json diff --git a/.changeset/wet-pillows-hope.md b/.changeset/wet-pillows-hope.md new file mode 100644 index 000000000..df3cb0211 --- /dev/null +++ b/.changeset/wet-pillows-hope.md @@ -0,0 +1,10 @@ +--- +"@assistant-ui/react-syntax-highlighter": patch +"@assistant-ui/react-playground": patch +"@assistant-ui/react-hook-form": patch +"@assistant-ui/react-markdown": patch +"@assistant-ui/react-ai-sdk": patch +"@assistant-ui/react": patch +--- + +fix: undo moving internal utilities to /react/internal diff --git a/packages/react-ai-sdk/src/ui/use-assistant/VercelUseAssistantRuntime.tsx b/packages/react-ai-sdk/src/ui/use-assistant/VercelUseAssistantRuntime.tsx index 9cfb639a4..a65414754 100644 --- a/packages/react-ai-sdk/src/ui/use-assistant/VercelUseAssistantRuntime.tsx +++ b/packages/react-ai-sdk/src/ui/use-assistant/VercelUseAssistantRuntime.tsx @@ -1,11 +1,13 @@ -import { type ThreadMessage, ModelConfigProvider } from "@assistant-ui/react"; -import { useAssistant } from "ai/react"; import { - ProxyConfigProvider, - BaseAssistantRuntime, -} from "@assistant-ui/react/internal"; + type ThreadMessage, + INTERNAL, + ModelConfigProvider, +} from "@assistant-ui/react"; +import { useAssistant } from "ai/react"; import { VercelUseAssistantThreadRuntime } from "./VercelUseAssistantThreadRuntime"; +const { ProxyConfigProvider, BaseAssistantRuntime } = INTERNAL; + export const hasUpcomingMessage = ( isRunning: boolean, messages: ThreadMessage[], diff --git a/packages/react-ai-sdk/src/ui/use-chat/VercelUseChatRuntime.tsx b/packages/react-ai-sdk/src/ui/use-chat/VercelUseChatRuntime.tsx index 84904673a..16c78c9c2 100644 --- a/packages/react-ai-sdk/src/ui/use-chat/VercelUseChatRuntime.tsx +++ b/packages/react-ai-sdk/src/ui/use-chat/VercelUseChatRuntime.tsx @@ -1,11 +1,9 @@ -import { - ProxyConfigProvider, - BaseAssistantRuntime, -} from "@assistant-ui/react/internal"; -import { ModelConfigProvider } from "@assistant-ui/react"; +import { INTERNAL, ModelConfigProvider } from "@assistant-ui/react"; import { useChat } from "ai/react"; import { VercelUseChatThreadRuntime } from "./VercelUseChatThreadRuntime"; +const { ProxyConfigProvider, BaseAssistantRuntime } = INTERNAL; + export class VercelUseChatRuntime extends BaseAssistantRuntime { private readonly _proxyConfigProvider = new ProxyConfigProvider(); diff --git a/packages/react-ai-sdk/src/ui/use-chat/VercelUseChatThreadRuntime.tsx b/packages/react-ai-sdk/src/ui/use-chat/VercelUseChatThreadRuntime.tsx index a6a324d60..1d9862384 100644 --- a/packages/react-ai-sdk/src/ui/use-chat/VercelUseChatThreadRuntime.tsx +++ b/packages/react-ai-sdk/src/ui/use-chat/VercelUseChatThreadRuntime.tsx @@ -4,8 +4,8 @@ import { type AppendMessage, type ThreadMessage, AddToolResultOptions, + INTERNAL, } from "@assistant-ui/react"; -import { MessageRepository } from "@assistant-ui/react/internal"; import type { Message } from "ai"; import { type StoreApi, type UseBoundStore, create } from "zustand"; import { useChat } from "ai/react"; @@ -14,6 +14,8 @@ import { sliceMessagesUntil } from "../utils/sliceMessagesUntil"; import { useVercelAIComposerSync } from "../utils/useVercelAIComposerSync"; import { useVercelAIThreadSync } from "../utils/useVercelAIThreadSync"; +const { MessageRepository } = INTERNAL; + export const hasUpcomingMessage = ( isRunning: boolean, messages: ThreadMessage[], diff --git a/packages/react-markdown/src/primitives/MarkdownText.tsx b/packages/react-markdown/src/primitives/MarkdownText.tsx index 0da7f660e..c2f0eeb29 100644 --- a/packages/react-markdown/src/primitives/MarkdownText.tsx +++ b/packages/react-markdown/src/primitives/MarkdownText.tsx @@ -1,6 +1,6 @@ "use client"; -import { useContentPartText } from "@assistant-ui/react"; +import { INTERNAL, useContentPartText } from "@assistant-ui/react"; import { ElementRef, ElementType, @@ -21,10 +21,11 @@ import { } from "../overrides/defaultComponents"; import { useCallbackRef } from "@radix-ui/react-use-callback-ref"; import { CodeOverride } from "../overrides/CodeOverride"; -import { useSmooth } from "@assistant-ui/react/internal"; import { Primitive } from "@radix-ui/react-primitive"; import classNames from "classnames"; +const { useSmooth } = INTERNAL; + type MarkdownTextPrimitiveElement = ElementRef; type PrimitiveDivProps = ComponentPropsWithoutRef; diff --git a/packages/react-markdown/src/ui/code-header.tsx b/packages/react-markdown/src/ui/code-header.tsx index a5511839d..637821ba7 100644 --- a/packages/react-markdown/src/ui/code-header.tsx +++ b/packages/react-markdown/src/ui/code-header.tsx @@ -1,11 +1,12 @@ import { FC } from "react"; import { CheckIcon, CopyIcon } from "lucide-react"; -import { useThreadConfig } from "@assistant-ui/react"; -import { TooltipIconButton } from "@assistant-ui/react/internal"; +import { INTERNAL, useThreadConfig } from "@assistant-ui/react"; import { CodeHeaderProps } from "../overrides/types"; import { useCopyToClipboard } from "./useCopyToClipboard"; +const { TooltipIconButton } = INTERNAL; + export const CodeHeader: FC = ({ language, code }) => { const { strings: { diff --git a/packages/react-markdown/src/ui/markdown-text.tsx b/packages/react-markdown/src/ui/markdown-text.tsx index c8591964b..566597e25 100644 --- a/packages/react-markdown/src/ui/markdown-text.tsx +++ b/packages/react-markdown/src/ui/markdown-text.tsx @@ -5,10 +5,9 @@ import { MarkdownTextPrimitive, MarkdownTextPrimitiveProps, } from "../primitives/MarkdownText"; -import { - withSmoothContextProvider, - useSmoothStatus, -} from "@assistant-ui/react/internal"; +import { INTERNAL } from "@assistant-ui/react"; + +const { withSmoothContextProvider, useSmoothStatus } = INTERNAL; export type MakeMarkdownTextProps = MarkdownTextPrimitiveProps; diff --git a/packages/react-playground/src/lib/playground-runtime.ts b/packages/react-playground/src/lib/playground-runtime.ts index 77ab768a5..8041ae0ba 100644 --- a/packages/react-playground/src/lib/playground-runtime.ts +++ b/packages/react-playground/src/lib/playground-runtime.ts @@ -22,16 +22,14 @@ import { ChatModelRunResult, CoreMessage, fromCoreMessage, + INTERNAL, } from "@assistant-ui/react"; -import { - BaseAssistantRuntime, - ProxyConfigProvider, - generateId, -} from "@assistant-ui/react/internal"; import { LanguageModelV1FunctionTool } from "@ai-sdk/provider"; import { useState } from "react"; import { create } from "zustand"; +const { BaseAssistantRuntime, ProxyConfigProvider, generateId } = INTERNAL; + const makeModelConfigStore = () => create(() => ({ system: "", diff --git a/packages/react/internal/README.md b/packages/react/internal/README.md deleted file mode 100644 index 4e793a189..000000000 --- a/packages/react/internal/README.md +++ /dev/null @@ -1 +0,0 @@ -This directory exists to support subpath imports for TypeScript projects using --moduleResolution node. \ No newline at end of file diff --git a/packages/react/internal/package.json b/packages/react/internal/package.json deleted file mode 100644 index c3871fef6..000000000 --- a/packages/react/internal/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "main": "../dist/internal.js", - "module": "../dist/internal.mjs", - "types": "../dist/internal.d.ts" -} \ No newline at end of file diff --git a/packages/react/package.json b/packages/react/package.json index 45c70e249..a5718d27c 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -52,16 +52,6 @@ "default": "./dist/edge.js" } }, - "./internal": { - "import": { - "types": "./dist/internal.d.mts", - "default": "./dist/internal.mjs" - }, - "require": { - "types": "./dist/internal.d.ts", - "default": "./dist/internal.js" - } - }, "./tailwindcss": { "import": { "types": "./dist/tailwindcss/index.d.mts", @@ -83,7 +73,6 @@ "files": [ "dist", "edge", - "internal", "tailwindcss", "README.md" ], diff --git a/packages/react/scripts/build.mts b/packages/react/scripts/build.mts index 78d067afb..a73acdbed 100644 --- a/packages/react/scripts/build.mts +++ b/packages/react/scripts/build.mts @@ -3,16 +3,12 @@ import { copyFileSync, mkdirSync } from "node:fs"; // JS await build({ - entry: [ - "src/index.ts", - "src/edge.ts", - "src/tailwindcss/index.ts", - "src/internal.ts", - ], + entry: ["src/index.ts", "src/edge.ts", "src/tailwindcss/index.ts"], format: ["cjs", "esm"], dts: true, sourcemap: true, clean: true, + splitting: true, esbuildOptions: (options) => { options.banner = { js: '"use client";', @@ -20,6 +16,14 @@ await build({ }, }); +// TODO find a way to bundle edge with the rest of the package +await build({ + entry: ["src/edge.ts"], + format: ["cjs", "esm"], + dts: true, + sourcemap: true, +}); + // css await build({ diff --git a/packages/react/src/index.ts b/packages/react/src/index.ts index e042de458..0d89c2c22 100644 --- a/packages/react/src/index.ts +++ b/packages/react/src/index.ts @@ -7,7 +7,4 @@ export * from "./runtimes"; export * from "./types"; export * from "./ui"; -/** - * @deprecated Use `@assistant-ui/react/internal` instead. This will be removed in 0.6.0. - */ export * as INTERNAL from "./internal";