How hesprs/pointeract works
1. Repo shape
- This is a TypeScript monorepo managed with pnpm workspaces and Turborepo.
- It contains one publishable library package, one shared utility package, and a separate documentation site.
- The architecture is intentionally split between the runtime library and the docs/test infrastructure around it.
2. Primary product: packages/core
- packages/core is the actual Pointeract library users import.
- Its public surface is centered on Pointeract, with a module-based extension model built on BaseModule.
- The core package also defines the library’s type system and internal utilities, which keep gesture detection and event emission consistent.
3. Module-based gesture architecture
- Gestures are implemented as discrete modules under packages/core/src/modules.
- The built-in modules cover Click, Drag, Swipe, WheelPanZoom, MultitouchPanZoom, PreventDefault, and Lubricator.
- This makes the library tree-shakeable: the runtime is small, and behavior is composed by selecting only the modules needed.
4. Event/data flow
- Input begins from DOM pointer, touch, wheel, and multitouch interactions on a target element.
- Pointeract coordinates module lifecycle and routes raw interaction state into module logic.
- Modules then detect higher-level gestures and emit normalized gesture events such as drag, swipe, pan, zoom, and click variants.
- The architecture is event-driven rather than DOM-mutation-driven; the README explicitly notes that the library avoids modifying the DOM except for PreventDefault.
5. Runtime boundaries
- Pointeract is the orchestration boundary; modules are the behavior boundary.
- BaseModule likely defines shared lifecycle and hooks so every module can be started, stopped, updated, and cleaned up consistently.
- packages/core/src/types.ts and utils.ts support the cross-module contract, keeping event shapes and calculations aligned.
6. Shared package
- packages/shared is a separate internal package, likely for code reused between core and docs or between core sub-areas.
- Keeping shared code isolated prevents circular dependencies and makes the core package easier to bundle and publish cleanly.
7. Testing architecture
- The core package has a substantial test suite covering individual gestures and integration behavior.
- There are dedicated tests for click, drag, swipe, wheel, multitouch, and lubricator behavior.
- packages/core/tests/dev provides a browser-based test harness, suggesting some interaction scenarios are validated in a real DOM environment rather than only unit tests.
8. Documentation site
- docs is a VitePress site, separate from the library build.
- It contains user-facing docs for getting started, basic types, module guides, events, and development topics like custom modules and testing.
- There is also a playground component, which implies interactive examples are part of the docs architecture.
9. Build and release pipeline
- The library uses tsdown for packaging/build output, with Vite for local development/tests.
- GitHub Actions handles CI, docs checks, routine maintenance, and publishing.
- publish.yml indicates the repo is configured as a distributable npm package, while ci-test.yml and related workflows gate changes on tests and documentation.
10. Operational characteristics
- Pointeract is designed as a lightweight gesture engine for DOM elements, not a UI framework.
- The important architectural promise is composability: one core runtime, many small modules, strict typing, and minimal bundle cost.
- For an architecture diagram, the central box should be Pointeract in packages/core, surrounded by gesture modules, with docs/tests/CI as supporting subsystems rather than runtime dependencies.
Main entry points: config.ts Docs site · BaseModule.ts BaseModule · integration.test.ts Core tests · index.ts Public API
Components 21
Monorepo
Workspace root and shared tooling
- Workspace · Repository root with workspace and task orchestration
- Shared · Reusable package shared across repository areas
packages/shared/index.ts
Core package
Publishable gesture runtime
- Public API · Package export surface for the core library
packages/core/src/index.ts - Pointeract · Coordinates pointer interaction state and module lifecycle
packages/core/src/Pointeract.ts - BaseModule · Shared module lifecycle and hook contract
packages/core/src/BaseModule.ts - Types · Cross-module gesture and event shapes
packages/core/src/types.ts - Utils · Common calculations and internal helpers
packages/core/src/utils.ts - Click · Detects click variants and emits click events
packages/core/src/modules/Click.ts - Drag · Detects drag gestures and movement events
packages/core/src/modules/Drag.ts - Swipe · Detects swipe gestures from pointer motion
packages/core/src/modules/Swipe.ts - WheelPanZoom · Maps wheel input to pan and zoom gestures
packages/core/src/modules/WheelPanZoom.ts - MultitouchPanZoom · Handles multi-touch pan and zoom interactions
packages/core/src/modules/MultitouchPanZoom.ts - PreventDefault · Only module that mutates DOM defaults to suppress native behavior
packages/core/src/modules/PreventDefault.ts - Lubricator · Adjusts interaction handling to smooth gesture flow
packages/core/src/modules/Lubricator.ts - Core tests · Gesture and integration coverage for the runtime
packages/core/tests/integration.test.ts - Dev harness · Browser-based interaction harness for real DOM scenarios
packages/core/tests/dev/index.html
Docs site
VitePress documentation and playground
- Docs site · User documentation and playground examples
docs/.vitepress/config.ts - Playground · Interactive example component embedded in docs
docs/components/playground.vue
Connections 40
- Workspace → Public API: contains · Workspace includes the core package entrypoint
- Workspace → Shared: contains · Workspace includes the shared internal package
- Workspace → Docs site: contains · Workspace includes the documentation site
- Public API → Pointeract: exports · Public API exposes the runtime orchestrator
- Public API → BaseModule: exports · Public API exposes the module base class
- Public API → Types: exports · Public API exposes shared library types
- Pointeract → BaseModule: loads · Orchestrator instantiates and manages modules through the shared contract
- Pointeract → Utils: uses · Runtime uses internal helpers for consistent gesture processing
- Pointeract → Types: uses · Runtime routes typed interaction state and emitted events
- BaseModule → Click: implements · Concrete modules follow the shared lifecycle contract
- BaseModule → Drag: implements · Concrete modules follow the shared lifecycle contract
- BaseModule → Swipe: implements · Concrete modules follow the shared lifecycle contract
- BaseModule → WheelPanZoom: implements · Concrete modules follow the shared lifecycle contract
- BaseModule → MultitouchPanZoom: implements · Concrete modules follow the shared lifecycle contract
- BaseModule → PreventDefault: implements · Concrete modules follow the shared lifecycle contract
- BaseModule → Lubricator: implements · Concrete modules follow the shared lifecycle contract
- Click → Utils: uses · Gesture detection relies on shared helpers
- Drag → Utils: uses · Gesture detection relies on shared helpers
- Swipe → Utils: uses · Gesture detection relies on shared helpers
- WheelPanZoom → Utils: uses · Gesture detection relies on shared helpers
- MultitouchPanZoom → Utils: uses · Gesture detection relies on shared helpers
- PreventDefault → Types: uses · Behavior module participates in the shared event contract
- Lubricator → Types: uses · Behavior module participates in the shared event contract
- Core tests → Click: covers · Dedicated tests validate click behavior
- Core tests → Drag: covers · Dedicated tests validate drag behavior
- Core tests → Swipe: covers · Dedicated tests validate swipe behavior
- Core tests → WheelPanZoom: covers · Dedicated tests validate wheel pan/zoom behavior
- Core tests → MultitouchPanZoom: covers · Dedicated tests validate multitouch pan/zoom behavior
- Core tests → Lubricator: covers · Dedicated tests validate lubricator behavior
- Dev harness → Pointeract: exercises · Browser harness drives the runtime in a real DOM
- Docs site → Playground: includes · Docs site embeds an interactive playground
- Docs site → Public API: documents · Docs explain library usage and API concepts
- Docs site → Click: documents · Docs include module guides and examples
- Docs site → Drag: documents · Docs include module guides and examples
- Docs site → Swipe: documents · Docs include module guides and examples
- Docs site → WheelPanZoom: documents · Docs include module guides and examples
- Docs site → MultitouchPanZoom: documents · Docs include module guides and examples
- CI test → Core tests: runs · CI gates changes on the core test suite
- CI docs → Docs site: runs · CI validates the documentation site
- Publish → Public API: publishes · Release workflow packages the core library