|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +React-Ace is a React component library providing wrapper components for the Ace Editor. This is a TypeScript-first library that has migrated from Brace to ace-builds and supports React 0.13+ through 19.0.0. |
| 8 | + |
| 9 | +## Key Commands |
| 10 | + |
| 11 | +### Build Commands |
| 12 | +- `npm run build` - Full build (lib + UMD) |
| 13 | +- `npm run build:lib` - TypeScript compilation to CommonJS (lib/) |
| 14 | +- `npm run build:umd` - Vite UMD build for browsers (dist/) |
| 15 | +- `npm run build:umd:min` - Minified UMD build (production mode) |
| 16 | + |
| 17 | +### Development Commands |
| 18 | +- `npm run example` - Start Vite development server for examples |
| 19 | +- `npm run build:example` - Build examples for production |
| 20 | +- `npm test` - Run Vitest tests |
| 21 | +- `npm run test:ui` - Run Vitest with UI |
| 22 | +- `npm run coverage` - Generate test coverage report |
| 23 | +- `npm run prettier` - Format code with Prettier |
| 24 | + |
| 25 | +### Maintenance Commands |
| 26 | +- `npm run clean` - Remove lib/ and dist/ directories |
| 27 | +- `npm run lint` - Currently a no-op (echo 'foo') |
| 28 | + |
| 29 | +## Code Architecture |
| 30 | + |
| 31 | +### Core Components |
| 32 | +The library provides three main editor components in `/src/`: |
| 33 | + |
| 34 | +1. **`ace.tsx`** - Main editor component with comprehensive prop interface (`IAceEditorProps`) |
| 35 | +2. **`split.tsx`** - Split-view editor for side-by-side editing (`ISplitEditorProps`) |
| 36 | +3. **`diff.tsx`** - Diff editor for comparing content (`IDiffEditorProps`) |
| 37 | + |
| 38 | +### Key Files |
| 39 | +- **`src/index.ts`** - Main entry point, exports all components and TypeScript interfaces |
| 40 | +- **`src/types.ts`** - Comprehensive TypeScript type definitions |
| 41 | +- **`src/editorOptions.ts`** - Editor configuration utilities and Ace instance management |
| 42 | + |
| 43 | +### Build System |
| 44 | +- **TypeScript** - Primary language with strict typing |
| 45 | +- **Vite** - Modern build tool with fast dev server and optimized builds |
| 46 | +- **Babel** - JavaScript transpilation with React/TypeScript presets |
| 47 | +- **Vitest** - Testing framework with jsdom environment |
| 48 | + |
| 49 | +### Dependencies |
| 50 | +- **ace-builds** - Modern Ace editor (replaces legacy brace) |
| 51 | +- **diff-match-patch** - Powers diff editor functionality |
| 52 | +- **lodash.get**, **lodash.isequal** - Minimal lodash utilities |
| 53 | +- **prop-types** - Runtime type checking for older React versions |
| 54 | + |
| 55 | +## Development Notes |
| 56 | + |
| 57 | +### TypeScript Integration |
| 58 | +- All components have comprehensive TypeScript interfaces |
| 59 | +- Strict typing with `noImplicitAny: true` |
| 60 | +- Generated declarations in `lib/index.d.ts` |
| 61 | + |
| 62 | +### Testing |
| 63 | +- Vitest with React Testing Library |
| 64 | +- jsdom environment for DOM testing |
| 65 | +- Coverage reporting (HTML, LCOV, text formats) |
| 66 | +- UI mode available with `npm run test:ui` |
| 67 | + |
| 68 | +### Code Quality |
| 69 | +- Prettier formatting (no single quotes, no trailing commas, avoid arrow parens) |
| 70 | +- Husky pre-commit hooks with pretty-quick |
| 71 | +- PropTypes for runtime validation |
| 72 | + |
| 73 | +### Build Outputs |
| 74 | +- **`lib/`** - CommonJS build (main entry point) |
| 75 | +- **`dist/`** - UMD builds for browser usage |
| 76 | +- **`example/`** - Working examples and development server |
| 77 | + |
| 78 | +### Key Patterns |
| 79 | +- Ace builds integration instead of legacy brace |
| 80 | +- Comprehensive event callback system |
| 81 | +- Flexible editor configuration through props |
| 82 | +- Multi-format build system (CommonJS + UMD) with Vite |
| 83 | +- TypeScript-first development approach |
| 84 | +- Fast development server with HMR |
0 commit comments