Skip to content

Commit

Permalink
fix: undo moving internal utils to /react/internal (#620)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yonom authored Jul 30, 2024
1 parent 91bcb3b commit 134d39e
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 50 deletions.
10 changes: 10 additions & 0 deletions .changeset/wet-pillows-hope.md
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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[],
Expand Down
Original file line number Diff line number Diff line change
@@ -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<VercelUseChatThreadRuntime> {
private readonly _proxyConfigProvider = new ProxyConfigProvider();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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[],
Expand Down
5 changes: 3 additions & 2 deletions packages/react-markdown/src/primitives/MarkdownText.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client";

import { useContentPartText } from "@assistant-ui/react";
import { INTERNAL, useContentPartText } from "@assistant-ui/react";
import {
ElementRef,
ElementType,
Expand All @@ -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<typeof Primitive.div>;
type PrimitiveDivProps = ComponentPropsWithoutRef<typeof Primitive.div>;

Expand Down
5 changes: 3 additions & 2 deletions packages/react-markdown/src/ui/code-header.tsx
Original file line number Diff line number Diff line change
@@ -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<CodeHeaderProps> = ({ language, code }) => {
const {
strings: {
Expand Down
7 changes: 3 additions & 4 deletions packages/react-markdown/src/ui/markdown-text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
8 changes: 3 additions & 5 deletions packages/react-playground/src/lib/playground-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ModelConfig>(() => ({
system: "",
Expand Down
1 change: 0 additions & 1 deletion packages/react/internal/README.md

This file was deleted.

5 changes: 0 additions & 5 deletions packages/react/internal/package.json

This file was deleted.

11 changes: 0 additions & 11 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -83,7 +73,6 @@
"files": [
"dist",
"edge",
"internal",
"tailwindcss",
"README.md"
],
Expand Down
16 changes: 10 additions & 6 deletions packages/react/scripts/build.mts
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,27 @@ 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";',
};
},
});

// 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({
Expand Down
3 changes: 0 additions & 3 deletions packages/react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

0 comments on commit 134d39e

Please sign in to comment.