|
| 1 | +# Contributing to Watching-You |
| 2 | +We welcome contributions to improve this DOM animation library that enables element tracking across multiple frameworks. This document provides essential guidelines for setting up your development environment, implementing new features. |
| 3 | + |
| 4 | +## Development Environment Setup |
| 5 | +### Prerequisites |
| 6 | +- Node.js v20.18.3: We recommend using a version manager like [asdf](https://github.com/asdf-vm/asdf) for easy version switching |
| 7 | +- Yarn v4.6.0: |
| 8 | + - [how to install yarn/berry](https://yarnpkg.com/getting-started/install) |
| 9 | + - [(optional) corepack](https://yarnpkg.com/corepack) |
| 10 | + |
| 11 | +### Initial Setup |
| 12 | +1. Fork repository |
| 13 | +2. Clone repository: `git clone https://github.com/[your-username]/watching-you.git` // e.g. `git clone https://github.com/[your-username]/watching-you.git` |
| 14 | +3. Install dependencies: `yarn install` from root directory |
| 15 | + |
| 16 | +## Building and Running |
| 17 | +### Core Development |
| 18 | +```bash |
| 19 | +cd packages/core |
| 20 | +yarn start # Starts core package in dev mode |
| 21 | +``` |
| 22 | + |
| 23 | +### Framework |
| 24 | +For framework-specific development (React, Vue, etc.): |
| 25 | + |
| 26 | +```bash |
| 27 | +cd packages/[framework-name] |
| 28 | +yarn start # Starts framework implementation in dev mode |
| 29 | +``` |
| 30 | + |
| 31 | +## Tips |
| 32 | + |
| 33 | +### Implementing New Targets |
| 34 | +Targets define coordinate calculation logic for different element types. To create a new target type: |
| 35 | + |
| 36 | +1. Create new file in `packages/core/src/targetPlugin` folder |
| 37 | +2. Implement class extending BaseTarget interface ([packages/core/src/type/Target.ts](https://github.com/jj811208/watching-you/blob/main/packages/core/src/type/Target.ts)): |
| 38 | +3. Register target in plugin index: |
| 39 | + |
| 40 | +```diff |
| 41 | +// packages/core/src/targetPlugin/index.ts |
| 42 | ++ import NewTarget from './NewTarget'; |
| 43 | + |
| 44 | +const targetPlugins = { |
| 45 | + // Existing targets |
| 46 | + mouse: MouseTarget, |
| 47 | + // Add new entry |
| 48 | ++ newTarget: NewTarget |
| 49 | +}; |
| 50 | +``` |
| 51 | + |
| 52 | +You can refer to other files in `packages/core/src/targetPlugin/*` for details on how to develop `watching-you` target |
| 53 | + |
| 54 | +### Support a New Framework |
| 55 | +1. Create new package in `packages` folder |
| 56 | +2. implementing (ref: [package/react](https://github.com/jj811208/watching-you/tree/main/packages/react)) |
| 57 | + |
| 58 | +### Testing |
| 59 | +Our testing strategy focuses on real-world usage scenarios (after build): |
| 60 | + |
| 61 | +1. Build all dependencies: Always run `yarn build` in both core and all relevant framework packages before testing |
| 62 | +```bash |
| 63 | +cd packages/core |
| 64 | +yarn build |
| 65 | +cd ../react |
| 66 | +yarn build |
| 67 | +cd ../vue |
| 68 | +yarn build |
| 69 | +``` |
| 70 | + |
| 71 | +2. Start test environment: |
| 72 | +```bash |
| 73 | +cd packages/tests |
| 74 | +yarn start |
| 75 | +``` |
| 76 | + |
| 77 | +### PULL REQUEST |
| 78 | + |
| 79 | +Feel free to open PRs, but please note that more comprehensive descriptions will help reviewers better understand your contributions and increase the likelihood of merging. |
| 80 | + |
| 81 | +Here are some tips to improve merge probability: |
| 82 | + |
| 83 | +1. **PR Description**: Provide complete and clear documentation of your contribution in the pull request description |
| 84 | +2. **Commit Hygiene**: Maintain clean, atomic commits |
| 85 | +3. **Test Coverage**: When contributing new features or bug fixes, please add corresponding test cases in `packages/tests` to validate functionality |
| 86 | + |
0 commit comments