Skip to content

Conversation

@knowledgecode
Copy link
Owner

Summary

This PR introduces v0.4.0 with significant new features and improvements:

  • React Hook Support: Add useBlokr Hook for element-scoped or global user interaction blocking in React applications
  • Enhanced Event Blocking: Expand blocked event types from 6 to 13 events (added: click, dragstart, mouseup, pointerdown, pointermove, pointerup, selectstart)
  • Dynamic Listener Management: Optimize performance by activating/deactivating event listeners only when needed
  • Improved API: Add comprehensive JSDoc comments and improve type safety with cross-platform timer types
  • Multi-Entry Build: Support both blokr (core) and blokr/react entry points
  • Breaking Change: Remove UMD format (ES modules only)

Key Changes by Commit

  1. Enhanced core event blocking with dynamic listener management
  2. Improved core API with better documentation and type safety
  3. Implemented React Hook (useBlokr)
  4. Added comprehensive test suite for React Hook (834 lines, ~60 test cases)
  5. Updated existing tests for improved accuracy
  6. Configured build system for multi-entry support
  7. Updated ESLint configuration for React
  8. Bumped version to 0.4.0 and updated package configuration
  9. Updated documentation with React Hook examples and comparison table

Test Plan

  • All tests pass (83 tests across 3 files)
  • Build succeeds for both entry points (dist/index.js and dist/react.js)
  • ESLint passes with no errors
  • React Hook tests cover all functionality (basic behavior, ref assignment, memoization, integration, edge cases)
  • Event blocking tests updated to reflect enhanced event coverage
  • Type declarations generated correctly

Breaking Changes

  • UMD format removed: Users relying on UMD builds via CDN should migrate to ES modules or bundle the library

- Add dynamic event listener activation/deactivation (_activate() and _deactivate() methods)
- Expand blocked event types from 6 to 13 events
  - Added: click, dragstart, mouseup, pointerdown, pointermove, pointerup, selectstart
- Optimize performance by removing listeners when no filters are registered
- Improve JSDoc comments for better developer experience
- Add comprehensive JSDoc comments for private properties and factory function
- Improve timer ID type from number to ReturnType<typeof setTimeout> for cross-platform compatibility
- Simplify timer calls from globalThis.setTimeout to setTimeout
- Add type exports to src/index.ts (export type * from './blokr.ts')
- Implement useBlokr Hook for element-scoped or global user interaction blocking
- Provide target ref, lock(), unlock(), and isLocked() methods
- Support allowGlobal parameter for global lock mode
- Enable event blocking at element scope or global scope
- Add comprehensive test suite for useBlokr Hook (834 lines, ~60 test cases)
- Cover basic behavior, ref assignment, function memoization, integration tests, and edge cases
- Ensure full test coverage for React Hook implementation
- Remove afterEach cleanup logic (unnecessary with Vitest browser mode auto-reset)
- Remove redundant test cases and improve test names in blokr.test.ts
- Change event-blocking.test.ts from mousedown to click event tests
- Reflect core improvements from previous commits
- Change to multi-entry configuration (index and react entry points)
- Remove UMD format (ES modules only)
- Configure React as external dependency
- Change exports from 'default' to 'auto'
- Add @vitejs/plugin-react plugin for React support
- Add eslint-plugin-react-hooks for React Hook linting
- Remove unused TypeScript rules
- Add new rule: @typescript-eslint/no-empty-function: 'off'
- Bump version from 0.3.0 to 0.4.0
- Add "sideEffects": false for tree-shaking support
- Add ./react entry point to exports field
- Add React 18/19 as optional peer dependencies
- Add clean command to build scripts
- Add new dev dependencies for React support
- Update multiple package versions
- Add v0.4.0 new features section (React Hook support)
- Update Breaking Changes section (UMD format removal)
- Expand "Why Blokr?" section with comparison table of alternative solutions
- Add React Hook section with usage examples, API, and allowGlobal parameter
- Remove CDN UMD examples
- Simplify "Limitations" section
@knowledgecode knowledgecode merged commit b1256ce into main Jan 29, 2026
2 checks passed
@knowledgecode knowledgecode deleted the develop branch January 29, 2026 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants