Skip to content

Commit

Permalink
deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
Zoltan Erdos committed Sep 29, 2024
1 parent 81605cf commit 6df4754
Show file tree
Hide file tree
Showing 62 changed files with 245 additions and 4,450 deletions.
5 changes: 4 additions & 1 deletion packages/code/esbuild-dev.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@

import {
buildMainBundle,
buildMainScripts,
buildServiceWorker,
buildWasm,
buildWorkers,
} from "@/lib/esbuild-build-tasks";

import { stop } from "@/lib/esbuild-operations";

const getWasmFile = async (): Promise<string> => {
const getWasmFile = async () => {
const { promises } = await import("node:fs");
const { readdir } = promises;

Expand All @@ -19,6 +21,7 @@ const getWasmFile = async (): Promise<string> => {
return file;
}
}

console.error("WASM file not found in ./dist");
throw new Error("WASM file not found");
};
Expand Down
45 changes: 45 additions & 0 deletions packages/code/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// eslint.config.mjs

import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import { FlatCompat } from '@eslint/eslintrc';

const compat = new FlatCompat();

export default [
eslint.configs.recommended,
...tseslint.configs.recommended,
...compat.extends('plugin:@typescript-eslint/recommended'),
{
ignores: [
'**/*.js',
'**/*.jsx',
'**/*.cjs',
"dist/**",
"dts/**",
"tw-chunk**",
'node_modules/**',
'_old_tailwind.config.js',
'.eslintrc.cjs'
],
},
{
files: ['**/*.ts', '**/*.tsx'],
languageOptions: {
parser: tseslint.parser,
parserOptions: {
project: './tsconfig.json',
},
},
rules: {
'@typescript-eslint/consistent-type-imports': [
'error',
{
prefer: 'type-imports',
disallowTypeAnnotations: true,
fixStyle: 'separate-type-imports',
},
],
},
},
];
6 changes: 3 additions & 3 deletions packages/code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,11 @@
"@testing-library/react": "^16.0.1",
"@testing-library/react-hooks": "^8.0.1",
"@testing-library/user-event": "^14.5.2",
"@types/eslint__js": "^8.42.3",
"@types/mime-db": "^1.43.5",
"@types/mime-types": "^2.1.4",
"@types/node": "^22.7.4",
"@types/path-browserify": "^1.0.3",
"@types/postcss-js": "^4",
"@types/react": "18.3.10",
"@types/react-dom": "18.3.0",
"@types/react-syntax-highlighter": "^15.5.13",
Expand All @@ -240,7 +240,7 @@
"concurrently": "^9.0.1",
"crypto-browserify": "^3.12.0",
"esbuild": "^0.24.0",
"eslint": "9.11.1",
"eslint": "^9.11.1",
"eslint-plugin-react": "7.37.0",
"happy-dom": "^15.7.4",
"jsdom": "^25.0.1",
Expand All @@ -250,7 +250,7 @@
"tslib": "2.7.0",
"tty-browserify": "^0.0.1",
"typescript": "^5.6.2",
"typescript-eslint": "8.7.0",
"typescript-eslint": "^8.7.0",
"uvu": "0.5.6",
"vite": "^5.4.8",
"vite-tsconfig-paths": "^5.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/code/src/@/components/app/chat-container.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useState, useCallback } from "react";
import { ChatContainerProps } from "@/lib/interfaces";
import type { ChatContainerProps } from "@/lib/interfaces";

import { ChatMessage } from "@/components/app/chat-message";
import { motion } from "framer-motion";
Expand Down
2 changes: 1 addition & 1 deletion packages/code/src/@/components/app/chat-header.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useMemo } from "react";
import { Button } from "@/components/ui/button";
import { RefreshCw, X } from "@/external/lucideReact";
import { ChatHeaderProps } from "@/lib/interfaces";
import type { ChatHeaderProps } from "@/lib/interfaces";
import { ThemeToggle } from "@/components/ui/theme-toggle";
import { cn } from "@/lib/utils";

Expand Down
3 changes: 2 additions & 1 deletion packages/code/src/@/components/ui/bg-effect.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useState, useEffect, ReactNode } from "react";
import type { ReactNode } from "react";
import { useState, useEffect } from "react";
import { keyframes } from "@emotion/react";
import { cn } from "@/lib/utils";
import { useDarkMode } from "@/hooks/use-dark-mode";
Expand Down
9 changes: 5 additions & 4 deletions packages/code/src/@/components/ui/form.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import * as React from "react"
import * as LabelPrimitive from "@radix-ui/react-label"
import type * as LabelPrimitive from "@radix-ui/react-label"
import { Slot } from "@radix-ui/react-slot"
import {
Controller,
import type {
ControllerProps,
FieldPath,
FieldValues,
FieldValues} from "react-hook-form";
import {
Controller,
FormProvider,
useFormContext,
} from "react-hook-form"
Expand Down
3 changes: 2 additions & 1 deletion packages/code/src/@/components/ui/pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import * as React from "react"
import { ChevronLeft, ChevronRight, MoreHorizontal } from "lucide-react"

import { cn } from "@/lib/utils"
import { ButtonProps, buttonVariants } from "@/components/ui/button"
import type { ButtonProps} from "@/components/ui/button";
import { buttonVariants } from "@/components/ui/button"

const Pagination = ({ className, ...props }: React.ComponentProps<"nav">) => (
<nav
Expand Down
3 changes: 2 additions & 1 deletion packages/code/src/@/external/CodeBlock.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Prism as SyntaxHighlighter } from "@/external/reactSyntaxHighlighter";
import { tomorrow } from "@/external/reactSyntaxHighlighterPrism";
import { ClipboardDocumentIcon, ClipboardIcon, DocumentDuplicateIcon } from "@heroicons/react/20/solid";
import { FC, memo, useState } from "react";
import type { FC} from "react";
import { memo, useState } from "react";

interface Props {
language: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/code/src/@/lib/chat-utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { replacePreservingWhitespace } from "@/lib/diff-utils";
import { Message } from "@/lib/interfaces";
import type { Message } from "@/lib/interfaces";

const CODE_MODIFICATION_REGEX = /<<<<<<< SEARCH[\s\S]*?=======[\s\S]*?>>>>>>> REPLACE/g;
const SEARCH_REPLACE_MARKERS = ["<<<<<<< SEARCH", "=======", ">>>>>>> REPLACE"];
Expand Down
2 changes: 1 addition & 1 deletion packages/code/src/@/lib/get-parts.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LanguageMap } from "@/lib/interfaces";
import type { LanguageMap } from "@/lib/interfaces";

const programmingLanguages: LanguageMap = {
javascript: ".js",
Expand Down
2 changes: 1 addition & 1 deletion packages/code/src/@/lib/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { EmotionCache } from "@emotion/cache";
import { ReactNode } from "react";
import type { ReactNode } from "react";
import type { Root } from "react-dom/client";

export interface ChatHeaderProps {
Expand Down
2 changes: 1 addition & 1 deletion packages/code/src/@/lib/make-sess.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ICodeSession } from "@/lib/interfaces";
import type { ICodeSession } from "@/lib/interfaces";
import diff from "fast-diff";
import { hash, Record } from "immutable";

Expand Down
2 changes: 1 addition & 1 deletion packages/code/src/@/lib/md5.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function intToString(n: number): string {
let alphaPart = "";
let alphanumericPart = "";

for (let char of base62) {
for (const char of base62) {
if (alphaPart.length === 0 || alpha.includes(char)) {
alphaPart += char;
} else {
Expand Down
2 changes: 1 addition & 1 deletion packages/code/src/@/lib/prettier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const addSomeFixesIfNeeded = (_code: string): string => {
const formatCssContent = (cssContent: string, indent: string): string => {
// Replace interpolations with placeholders
const placeholderPrefix = "__INTERPOLATION_PLACEHOLDER_";
let interpolations: string[] = [];
const interpolations: string[] = [];
let placeholderIndex = 0;

const contentWithPlaceholders = cssContent.replace(/\${(.*?)}/g, (match) => {
Expand Down
3 changes: 2 additions & 1 deletion packages/code/src/@/lib/render-messages.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { FC, memo, useMemo } from "react";
import type { FC} from "react";
import React, { memo, useMemo } from "react";
import { getParts } from "@/lib/get-parts";
import { cn } from "@/lib/utils";
import Markdown from "@/external/Markdown";
Expand Down
4 changes: 2 additions & 2 deletions packages/code/src/@/lib/shared.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import AlwaysSupportedSharedWorker from "@/external/shared-worker";
import { ICodeSession } from "@/lib/interfaces";
import type { ICodeSession } from "@/lib/interfaces";
import { Mutex } from "async-mutex";
import { getTransferables, hasTransferables } from "transferables";
import { RpcProvider } from "worker-rpc";
Expand Down Expand Up @@ -58,7 +58,7 @@ class WorkerPool {
let availableWorker = this.workers.find((worker) => !worker.busy && worker.tag === tag);

if (!availableWorker) {
let nonBusyWorker = this.workers.find((worker) => !worker.busy);
const nonBusyWorker = this.workers.find((worker) => !worker.busy);
if (nonBusyWorker) {
nonBusyWorker.tag = tag;
nonBusyWorker.busy = true;
Expand Down
3 changes: 2 additions & 1 deletion packages/code/src/@/lib/transpile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { makeEnv } from "@/lib/esbuild-make-env";
import importMap, { importMapReplace } from "@/lib/importmap-utils";
import { wasmFile } from "@src/esbuildWASM";
import { Mutex } from "async-mutex";
import { build as esmBuild, BuildOptions, initialize, transform } from "esbuild-wasm";
import type { BuildOptions } from "esbuild-wasm";
import { build as esmBuild, initialize, transform } from "esbuild-wasm";

export { wasmFile };

Expand Down
2 changes: 1 addition & 1 deletion packages/code/src/@/workers/ata-worker.worker.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ICodeSession } from "@/lib/interfaces";
import type { ICodeSession } from "@/lib/interfaces";
import { lazyLoadScript } from "@/lib/lazy-load-scripts";
import { RpcProvider } from "worker-rpc";

Expand Down
2 changes: 1 addition & 1 deletion packages/code/src/@/workers/ata.worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export async function ata({

const impRes: Record<string, { url: string; content: string; ref: string }> = {};

let res = (await tsx(code)).filter((x) => x.includes("@/"));
const res = (await tsx(code)).filter((x) => x.includes("@/"));
try {
await Promise.all(
res.map(async function(r: string) {
Expand Down
6 changes: 4 additions & 2 deletions packages/code/src/@/workers/lang-chain.worker.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { ChatAnthropic } from "@langchain/anthropic";
import { AIMessage, BaseMessage, HumanMessage } from "@langchain/core/messages";
import type { BaseMessage } from "@langchain/core/messages";
import { AIMessage, HumanMessage } from "@langchain/core/messages";
import { tool } from "@langchain/core/tools";
import { StateGraph, StateGraphArgs } from "@langchain/langgraph";
import type { StateGraphArgs } from "@langchain/langgraph";
import { StateGraph } from "@langchain/langgraph";
import { MemorySaver } from "@langchain/langgraph";
import { ToolNode } from "@langchain/langgraph/prebuilt";
import { z } from "zod";
Expand Down
5 changes: 3 additions & 2 deletions packages/code/src/@/workers/socket.worker.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type { ICodeSession } from "@/lib/interfaces";
import { lazyLoadScript } from "@/lib/lazy-load-scripts";
import { applyCodePatch, createPatch, makeHash, makeSession, stringifySession } from "@/lib/make-sess";
import { BufferedSocket, Socket, StableSocket } from "@github/stable-socket";
import type { Socket } from "@github/stable-socket";
import { BufferedSocket, StableSocket } from "@github/stable-socket";
import { Mutex } from "async-mutex";

// Define the properties of `self` with proper types
declare var self: SharedWorkerGlobalScope & {
declare let self: SharedWorkerGlobalScope & {
ata: unknown;
connections: Map<string, Connection>;
prettierCss: unknown;
Expand Down
5 changes: 3 additions & 2 deletions packages/code/src/AppToRender.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { FC, useState } from 'react';
import type { FC} from 'react';
import { useState } from 'react';
import { SignedIn, SignedOut, SignInButton, UserButton } from "@clerk/clerk-react";
import { Bot, History } from "@/external/lucideReact";

Expand All @@ -10,7 +11,7 @@ import { RainbowWrapper } from "./components/Rainbow";
import { DraggableWindow } from "./DraggableWindow";
import { useAuth } from "@clerk/clerk-react";

import { ICode } from '@/lib/interfaces';
import type { ICode } from '@/lib/interfaces';
import { cn } from "@/lib/utils";

const Header: FC = () => (
Expand Down
2 changes: 1 addition & 1 deletion packages/code/src/AppToRenderNew.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {ChatInterface} from "./ChatInterface";
import { CodeHistoryCarousel } from "./components/AutoSaveHistory";
import { Editor } from "./components/Editor";
import { RainbowWrapper } from "./components/Rainbow";
import { ICode } from "@/lib/interfaces";
import type { ICode } from "@/lib/interfaces";

const ResizeHandle = () => (
<PanelResizeHandle className="w-2 bg-white/20 hover:bg-white/40 transition-colors">
Expand Down
4 changes: 2 additions & 2 deletions packages/code/src/ChatInterface.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { useDarkMode } from "@/hooks/use-dark-mode";
import React, { useCallback, useEffect, useMemo } from "react";
import { ChatDrawer } from "@/components/app/chat-drawer";
import { ICode } from "@/lib/interfaces";
import type { ICode } from "@/lib/interfaces";
import { useChat } from "./hooks/useChat";
import { useCodeSpace } from "@/hooks/use-code-space";
import { useMessageHandling } from "./hooks/useMessageHandling";
import { useScreenshot } from "./hooks/useScreenshot";
import { ImageData, Message } from "@/lib/interfaces";
import type { ImageData, Message } from "@/lib/interfaces";


export const ChatInterface: React.FC<{
Expand Down
3 changes: 2 additions & 1 deletion packages/code/src/DraggableWindow.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { MotionConfig } from "framer-motion";
import { FC, useEffect, useState } from "react";
import type { FC} from "react";
import { useEffect, useState } from "react";
import { useWindowSize } from "react-use";
import { DraggableWindowContent } from "./components/DraggableWindowContent";
import { MotionContainer } from "./components/MotionContainer";
Expand Down
2 changes: 1 addition & 1 deletion packages/code/src/__tests__/AIHandler.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Message } from "@/lib/interfaces";
import type { Message } from "@/lib/interfaces";
import { cSessMock } from "@src/config/cSessMock";
import { beforeEach, describe, expect, test, vi } from "vitest";
import { AIHandler } from "../AIHandler";
Expand Down
2 changes: 1 addition & 1 deletion packages/code/src/__tests__/AIService.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Message } from "@/lib/interfaces";
import type { Message } from "@/lib/interfaces";
import { cSessMock } from "@src/config/cSessMock";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { AIService } from "../services/AIService";
Expand Down
Loading

0 comments on commit 6df4754

Please sign in to comment.