Skip to content

Latest commit

 

History

History
154 lines (111 loc) · 4.15 KB

developing.md

File metadata and controls

154 lines (111 loc) · 4.15 KB

Development Guide

Quick Start Commands

Installation

# Install dependencies
npm run install:all

# Start development server
npm run start:app         # or cd noodles-editor && npm start

Development URLs

  • Local: http://localhost:5173/examples/nyc-taxis
  • Specific Project: Replace nyc-taxis with project name from noodles-editor/src/examples/
  • Safe Mode: Add ?safeMode=true to disable code execution

Build & Test

# Run tests
cd noodles-editor && npm test

# Run specific test file
npm test src/visualizations/noodles/noodles.test.ts

# Run test with specific name
npm test -- -t "should transform graph"

# Build for production
npm run build:all

Linting & Formatting

# Run linter
cd noodles-editor && npm run lint

# Automatically fix linting issues
cd noodles-editor && npm run fix-lint

# Type checking
npm run typecheck

Environment Setup

Environment Variables

Copy .env.local.example to .env.local and fill in required API keys:

  • Google Maps API key
  • Mapbox API key
  • MapTiler API key
  • Cesium API key

Development Tools

The project uses:

  • Biome for fast linting and formatting (replaces ESLint/Prettier)
  • TypeScript for type checking
  • Vitest for unit testing
  • Playwright for end-to-end testing

Tracing Dirty Operators

To diagnose a graph that keeps executing, enable pull logs together with the causal dirty trace in the browser console, then reload:

localStorage.debug = 'noodles:executor:pull,noodles-trace:dirty'
location.reload()

noodles-trace:dirty records the operator's prior state, the field or subsystem that started the dirty wave, its downstream count, and the caller stack. It is intentionally excluded from noodles:* because collecting stacks is expensive. When the namespace is disabled, no stacks are captured and no trace state is retained.

Disable it after investigating:

localStorage.debug = ''
location.reload()

Code Style Guidelines

  • TypeScript: Use strict typing with detailed interfaces/types
  • Imports: Group and sort imports (React, external libs, project imports, CSS). Use ESM imports instead of CJS
  • Components: Use functional components with React hooks
  • Naming:
    • PascalCase for components and classes
    • camelCase for variables and functions
    • Use descriptive names for operators (with 'Op' suffix)
  • Comments: Use inline comments (//) for non-obvious code. Avoid jsdoc-style block comments (/** */) in favor of concise inline comments.
  • Async Functions: Use async/await for async operations with try/catch for error handling
  • Side Effects: Minimize side effects in functions, use hooks for managing state
  • Styling: Use CSS modules for component-specific styles
  • State Management: Use React context with custom hooks
  • Testing: Use vitest with mock data and snapshots

Best Practices

Graph Design

  • Minimize connections to reduce complexity
  • Group related operations in containers
  • Use descriptive node and field names
  • Document complex transformations

Performance

  • Avoid deep graph nesting
  • Batch related changes together
  • Profile and optimize hot paths
  • Use DuckDB for heavy data operations

Code Quality

  • Follow Biome configuration in biome.json (2 spaces, no semicolons, single quotes)
  • Write unit tests for operators
  • Use TypeScript strictly
  • Comment complex logic
  • Avoid constructor.name - it gets minified in production builds. Use static displayName/description properties and access them via (operator.constructor as typeof Operator).displayName

Maintenance

  • Add migration scripts for schema changes
  • Version control graph changes
  • Keep documentation up-to-date
  • Test operators in isolation

Batching Updates

// Batch multiple changes to avoid cascading updates
batch(() => {
  node1.fields.param1.setValue(value1)
  node2.fields.param2.setValue(value2)
})

Project Structure

  • Visualizations are composed of nodes with inputs/outputs
  • Operators (Op) define the behavior of nodes
  • React Flow used for node graph visualization
  • Native timeline system used for keyframe animation