mirror of
https://github.com/CopilotKit/CopilotKit.git
synced 2026-09-14 16:26:20 +08:00
96885b5959
Flatten all packages from packages/v1/* and packages/v2/* into packages/* — every package now lives directly under the @copilotkit/ scope with no v1/v2 subdirectories. - Move all v1 packages (react-core, react-ui, runtime, shared, etc.) from packages/v1/* to packages/* - Absorb v2 react code into packages/react-core/src/v2/ (exported via /v2 subpath) - Absorb v2 agent code into packages/runtime/src/agent/ (exported via /v2 subpath) - Move v2 packages (core, angular, demo-agents, etc.) to packages/* - Replace all @copilotkitnext/* imports with @copilotkit/* equivalents - Keep @copilotkitnext/angular as the sole exception (angular remains on next) - Update CI workflows, renovate config, release scripts for flat structure - No public API surface changes — all exports fields are preserved Co-authored-by: Alem Tuzlak <t.zlak@hotmail.com> Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
54 lines
1.3 KiB
TypeScript
54 lines
1.3 KiB
TypeScript
import { clsx, type ClassValue } from "clsx";
|
|
import { twMerge } from "tailwind-merge";
|
|
|
|
export function cn(...inputs: ClassValue[]) {
|
|
return twMerge(clsx(inputs));
|
|
}
|
|
|
|
export async function fetcher<JSON = any>(
|
|
input: RequestInfo,
|
|
init?: RequestInit,
|
|
): Promise<JSON> {
|
|
const res = await fetch(input, init);
|
|
|
|
if (!res.ok) {
|
|
const json = await res.json();
|
|
if (json.error) {
|
|
const error = new Error(json.error) as Error & {
|
|
status: number;
|
|
};
|
|
error.status = res.status;
|
|
throw error;
|
|
} else {
|
|
throw new Error("An unexpected error occurred");
|
|
}
|
|
}
|
|
|
|
return res.json();
|
|
}
|
|
|
|
export function formatDate(input: string | number | Date): string {
|
|
const date = new Date(input);
|
|
return date.toLocaleDateString("en-US", {
|
|
month: "long",
|
|
day: "numeric",
|
|
year: "numeric",
|
|
});
|
|
}
|
|
|
|
export const arraysAreEqual = (arr1: number[], arr2: number[]): boolean =>
|
|
arr1.length === arr2.length &&
|
|
arr1.every((value, index) => value === arr2[index]);
|
|
|
|
export function nullableCompatibleEqualityCheck<T>(
|
|
naiveEqualityCheck: (a: T, b: T) => boolean,
|
|
a: T | null | undefined,
|
|
b: T | null | undefined,
|
|
): boolean {
|
|
if (a === null || a === undefined || b === null || b === undefined) {
|
|
return a === b;
|
|
}
|
|
|
|
return naiveEqualityCheck(a, b);
|
|
}
|