Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# PXT Framework Development Instructions

## General Guidelines

- Follow TypeScript strict mode conventions
- Use semantic versioning for all packages
- Maintain backward compatibility when possible
- Write clear, self-documenting code with JSDoc comments
- Follow the existing code style and patterns in each component

## Architecture Principles

- The PXT framework follows a modular architecture with clear separation between:
- Core framework (`pxtlib/`, `pxtcompiler/`)
- Web application (`webapp/`)
- Simulator (`pxtsim/`)
- Target implementations (`pxt-microbit/`, `pxt-common-packages/`)

## Code Generation Standards

- Always include proper type annotations
- Use `export` statements for public APIs
- Prefer `const` over `let` where possible
- Use arrow functions for callbacks and short functions
- Include error handling for async operations

## Testing Requirements

- Write unit tests for new functionality
- Include accessibility tests for UI components
- Test simulator features across different browsers
- Validate TypeScript compilation without errors

## Documentation

- Update relevant README files when adding features
- Include inline documentation for complex algorithms
- Document breaking changes in commit messages
- Provide examples for new API functions
61 changes: 61 additions & 0 deletions .github/instructions/accessibility.instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
description: "Common accessibility guidelines for all PXT components"
applyTo: "**/*.{ts,tsx,less,css}"
---

# PXT Accessibility Instructions

## ARIA Guidelines

- Use semantic HTML elements as the foundation
- Add ARIA roles, properties, and states when semantic HTML is insufficient
- Ensure ARIA labels are descriptive and context-aware
- Follow ARIA authoring practices for complex widgets

## Keyboard Navigation

- Implement logical tab order throughout the interface
- Provide visible focus indicators for all interactive elements
- Support standard keyboard shortcuts and navigation patterns
- Handle focus management for dynamic content changes

## Screen Reader Support

- Provide meaningful alternative text for images and icons
- Use proper heading hierarchy (h1, h2, h3, etc.)
- Announce dynamic content changes with live regions
- Ensure form labels are properly associated with inputs

## Color and Contrast

- Maintain WCAG 2.1 AA contrast ratios (4.5:1 for normal text)
- Don't rely solely on color to convey information
- Support high contrast mode and forced color schemes
- Test with color blindness simulation tools

## WCAG Compliance

- Target WCAG 2.1 AA conformance level
- Test with automated accessibility tools (axe, Lighthouse)
- Conduct manual testing with keyboard and screen readers
- Document accessibility features and testing procedures

## Common Patterns

### Modals and Dialogs
- Trap focus within modal content
- Return focus to trigger element on close
- Provide proper ARIA labeling (aria-labelledby, aria-describedby)
- Support Escape key to close

### Menus and Navigation
- Use proper ARIA menu roles and properties
- Support arrow key navigation within menus
- Indicate current page/section appropriately
- Handle submenu expansion and collapse

### Forms
- Associate labels with form controls
- Provide clear error messages and validation feedback
- Group related form fields with fieldset/legend
- Support autocomplete where appropriate
55 changes: 55 additions & 0 deletions .github/instructions/blocks.instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
description: "Instructions for PXT block editor development"
applyTo: "pxtblocks/**/*.ts"
---

# PXT Blocks Development Instructions

## Blockly Integration

- Follow Blockly extension patterns and APIs
- Maintain compatibility with current Blockly version
- Implement proper block disposal and cleanup
- Handle workspace serialization/deserialization correctly

## Block Definition

- Create accessible block definitions with proper ARIA labels
- Support both beginner and advanced block modes
- Implement proper input validation and type checking
- Provide clear visual feedback for block states

## Custom Field Types

- Extend Blockly field types following established patterns
- Implement proper serialization for custom fields
- Handle focus management and keyboard navigation
- Support theming and customization

## Code Generation

- Generate clean, readable TypeScript/Python code
- Handle proper indentation and formatting
- Support round-trip conversion (blocks ↔ text)
- Maintain source comments and structure

## Accessibility

- Ensure blocks work with screen readers
- Implement proper keyboard navigation
- Provide meaningful descriptions for complex blocks
- Support high contrast and other accessibility features

## Performance

- Optimize block rendering for large workspaces
- Implement efficient block search and filtering
- Handle workspace scaling and zooming smoothly
- Minimize memory usage for block instances

## Localization

- Support right-to-left languages
- Implement proper text measurement and layout
- Handle translation of block text and tooltips
- Maintain block functionality across languages
62 changes: 62 additions & 0 deletions .github/instructions/common.instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
description: "Common development practices shared across all PXT components"
applyTo: "**/*.{ts,tsx,js,jsx}"
---

# Common PXT Development Instructions

## TypeScript Best Practices

- Use strict TypeScript configuration
- Define explicit return types for public functions
- Prefer interfaces over type aliases for object shapes
- Use union types and type guards for type safety
- Avoid `any` type - use `unknown` or proper types instead

## Code Organization

- Follow the established file and folder structure
- Use barrel exports (index.ts) for clean imports
- Keep functions and classes focused on single responsibilities
- Separate business logic from UI presentation logic
- Group related functionality into modules

## Error Handling

- Use typed errors and proper error boundaries
- Provide meaningful error messages for users and developers
- Log errors with sufficient context for debugging
- Handle edge cases and provide graceful degradation
- Implement retry logic for transient failures

## Performance Considerations

- Minimize bundle size through tree shaking
- Use lazy loading for non-critical components
- Implement proper caching strategies
- Profile performance in development and production
- Optimize for both memory usage and execution speed

## Security Guidelines

- Sanitize user inputs and validate data
- Use Content Security Policy (CSP) headers
- Avoid exposing sensitive information in client code
- Implement proper authentication and authorization
- Follow OWASP security best practices

## Git and Version Control

- Write clear, descriptive commit messages
- Use conventional commit format when possible
- Keep commits atomic and focused
- Include tests and documentation in commits
- Update version numbers following semantic versioning

## Dependencies

- Keep dependencies up to date and secure
- Minimize the number of external dependencies
- Use peer dependencies appropriately
- Document dependency requirements and compatibility
- Regular security audits of dependency tree
55 changes: 55 additions & 0 deletions .github/instructions/compiler.instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
description: "Instructions for PXT compiler and language services"
applyTo: "pxtcompiler/**/*.ts,pxtlib/**/*.ts"
---

# PXT Compiler Development Instructions

## TypeScript Compiler Integration

- Extend TypeScript compiler APIs following established patterns
- Maintain compatibility with current TypeScript version
- Handle AST transformations carefully to preserve source maps
- Implement proper error reporting with accurate location information

## Symbol Resolution

- Use the existing symbol table and resolution mechanisms
- Implement proper scoping rules for PXT language features
- Handle namespace resolution and imports correctly
- Support both TypeScript and Python syntax trees

## Code Generation

- Generate efficient target code for embedded devices
- Optimize for memory usage and performance
- Support different target architectures (ARM, ESP32, etc.)
- Implement proper dead code elimination

## Language Services

- Provide accurate IntelliSense and autocomplete
- Implement hover information and documentation
- Support go-to-definition and find-references
- Handle incremental compilation for performance

## API Documentation

- Extract API information from TypeScript declarations
- Generate block definitions from function signatures
- Support localization of API documentation
- Maintain backward compatibility in API changes

## Error Handling

- Provide clear, actionable error messages
- Include source location information
- Support error recovery for better IDE experience
- Implement proper diagnostic reporting

## Performance

- Optimize compilation speed for large projects
- Implement efficient caching strategies
- Support incremental builds
- Profile and optimize hot code paths
52 changes: 52 additions & 0 deletions .github/instructions/simulator.instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
description: "Instructions for PXT simulator development"
applyTo: "pxtsim/**/*.ts,sim/**/*.ts,**/sim/*.ts"
---

# PXT Simulator Development Instructions

## Simulator Architecture

- Follow the modular board/state pattern established in the codebase
- Separate visual rendering from simulation logic
- Use TypeScript interfaces to define board state contracts
- Implement proper cleanup in simulation lifecycle methods

## Audio/Media Handling

- Use Web Audio API for audio processing and effects
- Implement proper gain control and volume management
- Handle browser compatibility issues (Chrome, Firefox, Safari)
- Use MediaStream API for recording functionality
- Always clean up audio resources when stopping simulation

## Visual Components

- Use SVG for scalable simulator graphics
- Implement proper coordinate systems and transforms
- Support both light and dark themes
- Ensure responsive design for different screen sizes
- Use CSS custom properties for theming

## Performance Optimization

- Minimize DOM manipulations during animation
- Use requestAnimationFrame for smooth animations
- Implement efficient update cycles
- Cache frequently accessed DOM elements
- Profile performance in different browsers

## Hardware Simulation

- Accurately model hardware behavior and constraints
- Implement realistic timing and delays
- Handle edge cases and error conditions
- Support debugging and breakpoint functionality
- Maintain compatibility with runtime implementations

## Debugging Support

- Include comprehensive logging for development
- Implement proper error handling and recovery
- Support simulator reset and state inspection
- Provide clear error messages for debugging
55 changes: 55 additions & 0 deletions .github/instructions/styling.instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
description: "Instructions for styling and theming in PXT"
applyTo: "**/*.{less,css}"
---

# PXT Theming and Styling Instructions

## CSS/Less Guidelines

- Use CSS custom properties (variables) for all color values
- Follow the existing naming conventions for variables
- Implement both light and dark theme support
- Use semantic color names rather than specific color values

## Print Styles

- Always provide fallback colors for print media
- Use `@media print` blocks with solid color alternatives
- Apply `print-color-adjust: exact` for variable color preservation
- Test print functionality across different browsers

## Responsive Design

- Use mobile-first responsive design principles
- Implement proper breakpoints for different screen sizes
- Ensure touch-friendly interactions on mobile devices
- Test across different device orientations

## Accessibility

- Maintain sufficient color contrast ratios (WCAG AA)
- Support high contrast mode and forced colors
- Use focus indicators that are clearly visible
- Ensure text remains readable when zoomed to 200%

## Component Styling

- Follow BEM methodology for CSS class naming
- Keep specificity low and avoid !important
- Use flexbox and CSS Grid for layout
- Implement proper component encapsulation

## Performance

- Minimize CSS bundle size
- Use efficient selectors and avoid deep nesting
- Implement critical CSS for above-the-fold content
- Optimize for browser rendering performance

## Browser Compatibility

- Support modern browsers (Chrome, Firefox, Safari, Edge)
- Provide graceful degradation for older browsers
- Test vendor prefixes and feature support
- Handle browser-specific quirks appropriately
Loading