|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +Guidance for AI agents working in this repository. [CONTRIBUTING.md](CONTRIBUTING.md) is the |
| 4 | +authoritative contributor doc — this file is a quick-reference summary of it. |
| 5 | + |
| 6 | +## What this is |
| 7 | + |
| 8 | +Norigin Spatial Navigation — a library for directional (D-pad / remote control) focus management |
| 9 | +on TVs and web apps. The core engine is framework-agnostic; a React binding wraps it. |
| 10 | + |
| 11 | +## Repository layout |
| 12 | + |
| 13 | +[Turborepo](https://turbo.build/) monorepo using [npm workspaces](https://docs.npmjs.com/cli/v10/using-npm/workspaces): |
| 14 | + |
| 15 | +``` |
| 16 | +apps/ |
| 17 | + react-demo/ # Example React app for trying changes end-to-end |
| 18 | +packages/ |
| 19 | + core/ # @noriginmedia/norigin-spatial-navigation-core (the engine) |
| 20 | + react/ # @noriginmedia/norigin-spatial-navigation-react (useFocusable hook) |
| 21 | + legacy/ # @noriginmedia/norigin-spatial-navigation (re-exports core + react) |
| 22 | +``` |
| 23 | + |
| 24 | +The bulk of the logic lives in `packages/core/src/SpatialNavigation.ts`. `legacy` is a thin |
| 25 | +`export *` of core + react, so additive changes to those packages flow through automatically. |
| 26 | + |
| 27 | +## Commands |
| 28 | + |
| 29 | +Requires Node.js 20+ and npm 10+. Run everything **from the repository root** — Turbo and npm |
| 30 | +workspaces handle cross-package symlinking, so there is no need to `npm install` inside packages. |
| 31 | + |
| 32 | +| Command | What it does | |
| 33 | +| ---------------------- | ----------------------------------------------------- | |
| 34 | +| `npm install` | Install all workspaces; also sets up the Husky hooks. | |
| 35 | +| `npm run start` | Build packages and run the demo app via Turbo. | |
| 36 | +| `npm run build` | Build every package via Turbo. | |
| 37 | +| `npm run test` | Run the test suite for every package that has tests. | |
| 38 | +| `npm run lint` | ESLint check across all workspaces. | |
| 39 | +| `npm run prettier` | Prettier format check across the repo. | |
| 40 | +| `npm run prettier:fix` | Auto-format files with Prettier. | |
| 41 | +| `npm run changeset` | Generate a changeset for user-visible changes. | |
| 42 | + |
| 43 | +## Code style |
| 44 | + |
| 45 | +- **ESLint** — configured at the root (`.eslintrc.json`), inherited by each package. |
| 46 | +- **Prettier** — configured at the root (`.prettierrc`). |
| 47 | + |
| 48 | +Both run automatically on commit via a [Husky](https://typicode.github.io/husky/) `pre-commit` |
| 49 | +hook (installed by `npm install`) and again in CI on every pull request. If a commit is rejected, |
| 50 | +run `npm run lint` and `npm run prettier` to see what needs fixing. |
| 51 | + |
| 52 | +## Testing |
| 53 | + |
| 54 | +Jest + ts-jest, running in jsdom. Tests live in `**/__tests__/**/*.test.[jt]s?(x)` alongside the |
| 55 | +source they cover (e.g. `packages/core/src/__tests__/SpatialNavigation.test.ts`). `domNodes.ts` |
| 56 | +provides helpers for building focusable layouts in tests. |
| 57 | + |
| 58 | +## Changesets |
| 59 | + |
| 60 | +Any **user-visible** change needs a changeset. Run `npm run changeset` (interactive) or add a |
| 61 | +markdown file under `.changeset/` directly. The format is YAML frontmatter mapping each affected |
| 62 | +package name to its semver bump (`patch` / `minor` / `major`), followed by a one-paragraph summary |
| 63 | +written for end users: |
| 64 | + |
| 65 | +```markdown |
| 66 | +--- |
| 67 | +'@noriginmedia/norigin-spatial-navigation-core': minor |
| 68 | +'@noriginmedia/norigin-spatial-navigation-react': minor |
| 69 | +'@noriginmedia/norigin-spatial-navigation': minor |
| 70 | +--- |
| 71 | + |
| 72 | +Short, user-facing description of the change. |
| 73 | +``` |
| 74 | + |
| 75 | +Versioning and publishing are handled by CI after merge. Changes to internal tooling, docs, tests, |
| 76 | +CI, or the demo app do **not** need a changeset. |
| 77 | + |
| 78 | +## Pull request process |
| 79 | + |
| 80 | +1. Branch from `main`. |
| 81 | +2. Make the change. If it touches the public API, update the docs under `docs/` (and the demo app |
| 82 | + in `apps/react-demo/` if applicable). |
| 83 | +3. Run `npm run lint`, `npm run prettier`, and `npm run test` locally. |
| 84 | +4. Generate a changeset (unless the change is tooling-only). |
| 85 | +5. Open the PR; once approved, use "Squash and Merge" and delete the branch. |
| 86 | + |
| 87 | +## Library usage reference |
| 88 | + |
| 89 | +For how to _use_ the library (the `useFocusable` hook, `init` options, common patterns), see |
| 90 | +`skills/norigin-spatial-navigation-react/SKILL.md` and the full docs under `docs/`. |
0 commit comments