diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..fe1a61f --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,57 @@ +# Repository Guidelines + +## Project Structure & Module Organization + +This repository is a Vue 3 + TypeScript waveform component library with a Vite demo. +Production exports are defined in `src/index.ts`; demo entry points are `src/main.ts` and +`src/App.vue`. The main chart is `src/components/WaveformChart.vue`, with focused modules under +`src/components/{core,data,rendering,interaction,annotation}`. Shared types live in `src/types`, +data normalization and chart logic in `src/core` and `src/utils`, styles in `src/styles.css`, and +sample data in `src/data`. Tests are colocated with implementation files (`*.test.ts`), with shared +setup in `src/test/setup.ts`. `dist/` and `dist-demo/` are generated; do not edit them. + +## Build, Test, and Development Commands + +Use pnpm (the lockfile is `pnpm-lock.yaml`) and Node.js 22 as CI does. + +```bash +pnpm install # Install locked dependencies +pnpm dev # Start the Vite demo server +pnpm typecheck # Run vue-tsc checks +pnpm lint # Run ESLint with zero warnings allowed +pnpm test # Run Vitest once +pnpm test:coverage # Run tests and enforce coverage thresholds +pnpm build # Type-check and build library plus demo bundles +pnpm preview # Preview the production demo build +``` + +Run `pnpm format` to apply the repository Prettier configuration. + +## Coding Style & Naming Conventions + +Use TypeScript and Vue 3 Composition API with two-space indentation, single quotes, no semicolons, +and a 100-column print width. Prettier and ESLint are authoritative. +Use PascalCase for Vue components, component filenames, and types; use camelCase for functions, +variables, and composables (for example, `useWaveformData`). Keep public exports deliberate and +preserve stable series IDs for multi-channel data. + +## Testing Guidelines + +Vitest with `@vue/test-utils` and jsdom is used. Name tests `*.test.ts` beside the +code they cover. Exercise normalization, rendering/layout helpers, formatting, and component +interactions, including empty, non-finite, and multi-series inputs. Coverage thresholds are 80% +for lines/statements/functions and 75% for branches; run `pnpm test:coverage` before submitting. + +## Commit & Pull Request Guidelines + +The current history contains only `first commit`, so no established convention exists yet. Use short, +imperative messages, preferably scoped (for example, `feat(chart): ...`, `fix(annotation): ...`, or +`test: ...`). Pull requests should explain API or user-visible changes, list verification commands, +link an issue or plan, and include screenshots or a short recording for visual changes. Keep generated +files and unrelated refactors out of the change. + +## CI and Configuration + +GitHub Actions runs install, typecheck, lint, coverage, build, and `pnpm pack --dry-run` on pushes and +pull requests. Do not commit secrets or local environment files; review the staged file list before +opening a pull request. diff --git a/README.md b/README.md index 7916952..bdaa85a 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,26 @@ import { WaveformChart } from './index' 多通道数据应为每个 `WaveformSeries` 提供稳定的 `id`。内部时间坐标始终使用秒, `timeUnit` 只控制坐标轴和 tooltip 的显示单位。 +### 绘图区域尺寸 + +`width` 和 `height` 接收像素数值,并且可以独立设置。指定的维度使用固定尺寸,未指定的 +维度自适应填满父容器: + +```vue +
+ +
+ + +``` + +自适应高度要求父容器具有明确高度;父容器未定高时,组件使用最低 `180px` 高度。 +显式高度同样保留 `180px` 下限。非有限尺寸按未指定处理,负宽度归零。 + ## 大数据渲染 组件按不可变数据处理:替换 `data` 引用会重新过滤、排序和缓存坐标域,并重置视口; diff --git a/src/App.vue b/src/App.vue index b333283..9adbf10 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,6 +1,6 @@