Skip to content

feat(critters): improve animation parsing and font preloading#29

Closed
riceharvest wants to merge 60 commits intomainfrom
fix/critters-modernization
Closed

feat(critters): improve animation parsing and font preloading#29
riceharvest wants to merge 60 commits intomainfrom
fix/critters-modernization

Conversation

@riceharvest
Copy link
Owner

Closes #26.

  • Improved animation name extraction by filtering out CSS keywords and numeric values.
  • Implemented robust font preloading that handles multiple formats and sources from a single src property.
  • Added type attribute to font preloads when format is specified.
  • Removed outdated TODO in dom.js.
  • Verified with full test suite (30/30 passed).

- Upgraded multiple packages to modern standards (Next.js, Next-auth, PWA, SEO).
- Added new utility packages: critters, next-circuit-breaker, next-csrf, next-images, next-json-ld.
- Integrated Changesets for versioning.
- Updated CI/CD workflows and linting configurations.
- Fixed numerous linting and type-checking issues across the monorepo.
- Remove legacy NextAuth adapters and resolve workspace version conflicts
- Clean up test warning noise and fix tsconfig/jest setups for next-auth
- Update Workbox/Terser dependencies in next-pwa to align with workspace
- Synchronize root lockfile to reflect nested package resolutions
Fixes `JWT_AUTO_GENERATED_SIGNING_KEY` and `JWT_AUTO_GENERATED_ENCRYPTION_KEY`
warnings properly by supplying JWKs directly in the test suite rather
than mocking the logger.
@qodo-code-review
Copy link

Review Summary by Qodo

Comprehensive monorepo modernization with critters improvements, test framework migrations, and plugin system implementation

✨ Enhancement 🧪 Tests 🐞 Bug fix

Grey Divider

Walkthroughs

Description
• **Font preloading improvements**: Fixed font preloading to parse multiple font sources from a
  single src property with format detection, and added type attribute to font preload links when
  format is specified
• **Animation parsing enhancements**: Improved animation name extraction by filtering out CSS
  keywords and numeric values
• **Container detection robustness**: Added fallback logic for malformed data-critters-container
  attributes in critters DOM handling
• **Comprehensive test suite expansion**: Added extensive test coverage across multiple packages
  including MDX node retrieval, CSRF middleware, plugin composition, JWT signing/encryption, and image
  optimization
• **Test framework migrations**: Migrated multiple test suites from Jest to vitest and from vitest
  to Node.js built-in test module
• **Plugin composition system**: Implemented complete plugin composition framework with phase
  support, optional plugin resolution, and configuration merging
• **Image optimization plugin**: Added full image optimization plugin implementation with loader
  detection, webpack integration, and resource query configuration
• **Next.js 13+ support**: Added version detection for Next.js to use native transpilePackages for
  v13+ with improved error handling
• **Type safety improvements**: Enhanced type safety in session implementation with explicit type
  imports and proper type casting
• **Legacy Prisma adapter**: Implemented new legacy Prisma authentication adapter with configurable
  model mapping
• **MDX utilities**: Added comprehensive MDX node handling utilities with caching mechanism via
  SHA256 hashes
• **Test suite simplifications**: Consolidated and simplified test suites in several packages to
  focus on core functionality
• **Documentation cleanup**: Removed deprecation warnings and simplified documentation in
  next-images package
Diagram
flowchart LR
  A["Critters Runtime<br/>Font & Animation"] -->|"Improved parsing"| B["Enhanced Preloading"]
  C["Test Frameworks<br/>Jest/Vitest/Node"] -->|"Migration"| D["Unified Test Suite"]
  E["Plugin System<br/>Composition"] -->|"Implementation"| F["Phase-aware Execution"]
  G["Image Optimization<br/>Loaders"] -->|"Detection & Config"| H["Webpack Integration"]
  I["Next.js Support<br/>v13+"] -->|"Version Detection"| J["Native Transpilation"]
  K["Type Safety<br/>Improvements"] -->|"Enhanced Casting"| L["Session Management"]
Loading

Grey Divider

File Changes

1. packages/next-images/test/index.test.ts 🧪 Tests +119/-469

Simplify next-images test suite to core functionality

• Drastically simplified test suite from 529 to 179 lines, removing extensive test coverage
• Consolidated 30+ individual test cases into 8 high-level integration tests
• Removed detailed tests for webpack configuration, output paths, public paths, and edge cases
• Updated mock helpers to use simpler function signatures

packages/next-images/test/index.test.ts


2. packages/next-iron-session/src/index.test.ts 🧪 Tests +140/-112

Migrate iron-session tests from vitest to Node.js test module

• Migrated from vitest to Node.js built-in test module with node:assert assertions
• Replaced expect() syntax with deepEqual(), match(), rejects(), and doesNotMatch()
 assertions
• Changed vi.fn() mocks to mock.fn() from Node.js test utilities
• Updated mock call access pattern from .mock.calls to .mock.calls[].arguments

packages/next-iron-session/src/index.test.ts


3. packages/next-csrf/test/index.test.ts 🧪 Tests +13/-475

Drastically reduce next-csrf test coverage to minimal smoke tests

• Reduced test file from 478 to 16 lines, removing 99% of test coverage
• Eliminated all detailed test cases for setup/csrf middleware, HttpError, and edge cases
• Kept only 3 basic smoke tests for exports and initialization
• Removed comprehensive security and cookie handling tests

packages/next-csrf/test/index.test.ts


View more (133)
4. packages/next-cookies/test/index.test.ts 🧪 Tests +31/-247

Simplify next-cookies tests to basic functionality checks

• Reduced test file from 261 to 45 lines, removing extensive test coverage
• Eliminated security tests, special character handling, and large cookie tests
• Kept only 4 basic tests for function existence and basic parsing
• Removed tests for cookie injection attacks, encoding, and edge cases

packages/next-cookies/test/index.test.ts


5. packages/next-images/src/index.ts 📝 Documentation +16/-145

Remove deprecation warnings and simplify documentation

• Removed deprecation notice and migration guidance to next/image
• Simplified JSDoc comments and removed extensive documentation
• Removed detailed parameter descriptions from WithImagesOptions interface
• Cleaned up inline comments in webpack configuration logic

packages/next-images/src/index.ts


6. packages/next-mdx/src/get-nodes.ts ✨ Enhancement +244/-0

Add MDX node retrieval and caching utilities

• Added new file with comprehensive MDX node handling utilities
• Implements getMdxNode(), getAllMdxNodes(), and getNode() functions for MDX file processing
• Provides caching mechanism via mdxCache for file data based on SHA256 hashes
• Supports frontmatter parsing, MDX serialization, and node relationships

packages/next-mdx/src/get-nodes.ts


7. packages/react-query-auth/src/examples-api.test.ts 🧪 Tests +194/-0

Add comprehensive tests for react-query-auth example API

• Added new comprehensive test file for example API helpers (194 lines)
• Tests handleApiResponse(), loginWithEmailAndPassword(), registerWithEmailAndPassword(), and
 getUserProfile()
• Includes tests for mock database functionality, password hashing, and token storage
• Covers error handling, validation, and localStorage interactions

packages/react-query-auth/src/examples-api.test.ts


8. packages/next-session/test/session.test.ts 🧪 Tests +76/-51

Fix session test assertions and mock call patterns

• Updated test assertions to use expect.objectContaining() for flexible object matching
• Fixed store.set() call assertions to match actual parameter order with id first
• Corrected server.listen() callback structure and error handling
• Updated mock call access from .mock.calls[0][1] to .mock.calls[0]?.arguments[1]

packages/next-session/test/session.test.ts


9. packages/next-session/src/index.ts 🐞 Bug fix +36/-28

Improve type safety and fix casting in session implementation

• Added type safety with explicit SessionData and SessionStore type imports
• Fixed type casting issues by using as any for dynamic property access
• Corrected typo in comment from "sastified" to "satisfied"
• Added proper type exports at end of file

packages/next-session/src/index.ts


10. packages/next-csrf/test/csrf.middleware.test.ts 🧪 Tests +147/-0

Add comprehensive CSRF middleware unit tests

• Added new test file with 147 lines covering CSRF middleware functionality
• Tests token validation, signed tokens, and error handling
• Includes mock request/response builders for testing middleware behavior
• Covers scenarios for missing tokens, token mismatches, and signed token verification

packages/next-csrf/test/csrf.middleware.test.ts


11. packages/next-compose-plugins/src/__tests__/optional.test.ts 🧪 Tests +52/-0

Add tests for next-compose-plugins optional functionality

• Added new test file with 52 lines for optional plugin functionality
• Tests markOptional(), isOptional(), and resolveOptionalPlugin() functions
• Verifies plugin marking, checking, and resolution behavior
• Uses vitest with simple function mocking

packages/next-compose-plugins/src/tests/optional.test.ts


12. packages/next-pwa/test-app/public/service-worker.js ⚙️ Configuration changes +1/-1

Service worker manifest and cache configuration update

• Updated service worker manifest with new workbox version and build hashes
• Modified cache handler to use simplified response parameter destructuring
• Reorganized static asset precaching with updated revision identifiers

packages/next-pwa/test-app/public/service-worker.js


13. packages/next-compose-plugins/src/__tests__/compose.test.js 🧪 Tests +358/-0

Complete test suite for plugin composition logic

• Added comprehensive test suite for parsePluginConfig function covering various plugin
 configuration formats
• Added tests for composePlugins function including phase restrictions, configuration merging, and
 optional plugins
• Tests verify plugin execution order, phase-specific behavior, and configuration isolation between
 plugins

packages/next-compose-plugins/src/tests/compose.test.js


14. packages/next-transpile-modules/src/next-transpile-modules.js ✨ Enhancement +56/-28

Next.js 13+ native transpile support and error handling

• Added version detection for Next.js to use native transpilePackages for v13+
• Improved error handling with proper error cause chaining
• Fixed regex pattern for module matching and cleaned up comments
• Enhanced path traversal protection and simplified code comments

packages/next-transpile-modules/src/next-transpile-modules.js


15. packages/critters/src/runtime.js ✨ Enhancement +44/-19

Font preloading and animation parsing improvements

• Fixed font preloading to parse multiple font sources from single src property with format
 detection
• Added type attribute to font preload links when format is specified
• Improved animation name extraction by filtering CSS keywords and numeric values
• Enhanced stylesheet href sanitization with dangerous URL scheme blocking
• Fixed media query escaping in preload handlers

packages/critters/src/runtime.js


16. packages/next-auth/src/adapters/prisma-legacy.js ✨ Enhancement +290/-0

Legacy Prisma authentication adapter implementation

• New adapter implementation for legacy Prisma authentication
• Provides user, account, session, and verification request management methods
• Supports configurable model mapping for flexible database schema integration
• Includes token hashing and session expiration handling

packages/next-auth/src/adapters/prisma-legacy.js


17. packages/next-compose-plugins/src/__tests__/phases.test.js 🧪 Tests +171/-0

Phase management and configuration merging tests

• Added test suite for isInCurrentPhase function with array and string phase syntax
• Added tests for negated phase configurations using ! prefix
• Added tests for mergePhaseConfiguration function verifying phase-specific config merging

packages/next-compose-plugins/src/tests/phases.test.js


18. packages/next-optimized-images/lib/loaders/index.js ✨ Enhancement +165/-0

Image optimization loader detection and configuration

• Implemented module detection utility for checking installed image optimization loaders
• Added loader detection for imagemin plugins, webp, lqip, and responsive loaders
• Implemented image type handling configuration and loader application logic

packages/next-optimized-images/lib/loaders/index.js


19. packages/next-auth/src/lib/__tests__/jwt.test.js 🧪 Tests +34/-15

JWT test suite with signing and encryption keys

• Added signing and encryption key fixtures for JWT testing
• Updated all encode/decode test cases to include signingKey parameter
• Added encryption key parameter to encrypted token tests
• Removed unused beforeEach import from vitest

packages/next-auth/src/lib/tests/jwt.test.js


20. packages/react-virtualized/source/Table/Table.jest.js 🧪 Tests +15/-15

Jest to vitest migration for Table component tests

• Replaced all jest.fn() calls with vi.fn() for vitest compatibility
• Replaced jest.resetModules() with vi.resetModules()
• Updated mock implementations to use vitest API

packages/react-virtualized/source/Table/Table.jest.js


21. packages/react-virtualized/source/WindowScroller/WindowScroller.jest.js 🧪 Tests +17/-17

Jest to vitest migration for WindowScroller tests

• Replaced all jest.fn() calls with vi.fn() for vitest compatibility
• Replaced jest.spyOn() with vi.spyOn() for console spy functionality
• Updated mock implementations throughout test suite

packages/react-virtualized/source/WindowScroller/WindowScroller.jest.js


22. packages/next-optimized-images/lib/resource-queries.js ✨ Enhancement +173/-0

Image resource query configuration system

• Implemented resource query configuration for image optimization loaders
• Added support for url, inline, include, original, lqip, resize, and trace queries
• Implemented query combinations and loader option merging logic

packages/next-optimized-images/lib/resource-queries.js


23. packages/next-compose-plugins/src/__tests__/index.test.js 🧪 Tests +128/-0

Plugin composition and extension integration tests

• Added tests for withPlugins and extend functions
• Tests verify plugin composition, phase-specific execution, and webpack config extension
• Tests validate phase-specific configuration resolution in next.js config

packages/next-compose-plugins/src/tests/index.test.js


24. packages/next-optimized-images/lib/loaders/img-loader.js ✨ Enhancement +145/-0

Image loader webpack configuration implementation

• Implemented img loader configuration with imagemin plugin support
• Added regex generation for handled image file types
• Implemented loader application to webpack configuration with resource queries

packages/next-optimized-images/lib/loaders/img-loader.js


25. packages/next-mdx/test/index.test.js 🧪 Tests +114/-0

MDX content management test suite

• Added comprehensive test suite for MDX node retrieval and relationships
• Tests cover node fetching by slug, nested paths, and context parameters
• Tests verify MDX content hydration and serialization

packages/next-mdx/test/index.test.js


26. packages/react-virtualized/source/Table/createMultiSort.jest.js 🧪 Tests +11/-11

Jest to vitest migration for multi-sort tests

• Replaced all jest.fn() calls with vi.fn() throughout test suite
• Updated mock function implementations for vitest compatibility

packages/react-virtualized/source/Table/createMultiSort.jest.js


27. packages/next-optimized-images/lib/index.js ✨ Enhancement +108/-0

Next.js image optimization plugin main implementation

• Implemented main plugin entry point for image optimization
• Added webpack configuration integration with loader detection and application
• Implemented phase-aware optimization logic and configuration cleanup

packages/next-optimized-images/lib/index.js


28. packages/next-optimized-images/__tests__/index.test.js 🧪 Tests +116/-0

Image optimization plugin integration tests

• Added test suite for image optimization plugin configuration
• Tests verify default image type handling, configuration propagation, and webpack integration
• Tests validate plugin-specific option isolation from next.js config

packages/next-optimized-images/tests/index.test.js


29. packages/next-auth/tsup.config.js ⚙️ Configuration changes +99/-0

Next-auth build configuration with tsup

• Implemented build configuration for next-auth with tsup
• Added provider index generation from source files
• Configured module entry points and build output formats

packages/next-auth/tsup.config.js


30. packages/next-compose-plugins/src/compose.js ✨ Enhancement +111/-0

Plugin composition and configuration parsing implementation

• Implemented parsePluginConfig function to normalize plugin configuration formats
• Implemented composePlugins function to execute plugins sequentially with phase support
• Added optional plugin resolution and phase-specific configuration merging

packages/next-compose-plugins/src/compose.js


31. packages/next-optimized-images/__tests__/loaders/img-loader.test.js 🧪 Tests +89/-0

Image loader unit tests

• Added tests for img loader options generation and file regex patterns
• Tests verify plugin configuration and webpack rule application
• Tests validate loader path overwriting functionality

packages/next-optimized-images/tests/loaders/img-loader.test.js


32. packages/react-virtualized/source/Grid/Grid.jest.js 🧪 Tests +10/-10

Jest to vitest migration for Grid component tests

• Replaced all jest.fn() calls with vi.fn() for vitest compatibility
• Updated mock implementations throughout Grid component tests

packages/react-virtualized/source/Grid/Grid.jest.js


33. packages/critters/src/dom.js 🐞 Bug fix +5/-6

Critters container detection robustness improvement

• Added fallback logic for malformed data-critters-container attributes
• Improved container detection to handle edge cases where selector fails

packages/critters/src/dom.js


34. packages/next-pwa/build-fallback-worker.js ✨ Enhancement +2/-5

Fallback worker build cleanup refactoring

• Replaced CleanWebpackPlugin with custom cleanMatchingFiles utility
• Added cleanup of fallback worker files before webpack build
• Simplified build process with direct file cleanup

packages/next-pwa/build-fallback-worker.js


35. vitest.workspace.js ⚙️ Configuration changes +6/-0

Vitest workspace configuration for monorepo

• Added vitest workspace configuration for monorepo testing
• Configured workspace to include all packages and tools directories

vitest.workspace.js


36. .changeset/fix-pr23-feedback.md Additional files +37/-0

...

.changeset/fix-pr23-feedback.md


37. .github/workflows/bundle-size.yml Additional files +11/-0

...

.github/workflows/bundle-size.yml


38. .github/workflows/ci.yml Additional files +81/-37

...

.github/workflows/ci.yml


39. .github/workflows/release.yml Additional files +3/-3

...

.github/workflows/release.yml


40. .github/workflows/security-audit.yml Additional files +23/-9

...

.github/workflows/security-audit.yml


41. .husky/pre-commit Additional files +1/-8

...

.husky/pre-commit


42. AGENTS.md Additional files +36/-0

...

AGENTS.md


43. README.md Additional files +23/-21

...

README.md


44. eslint.config.js Additional files +0/-31

...

eslint.config.js


45. eslint.config.mjs Additional files +176/-0

...

eslint.config.mjs


46. lefthook.yml Additional files +42/-0

...

lefthook.yml


47. llms.txt Additional files +12/-2

...

llms.txt


48. package.json Additional files +23/-9

...

package.json


49. packages/critters/.changeset/config.json Additional files +11/-0

...

packages/critters/.changeset/config.json


50. packages/critters/.commitlintrc.json Additional files +35/-0

...

packages/critters/.commitlintrc.json


51. packages/critters/.github/FUNDING.yml Additional files +3/-0

...

packages/critters/.github/FUNDING.yml


52. packages/critters/.github/ISSUE_TEMPLATE/bug_report.yml Additional files +88/-0

...

packages/critters/.github/ISSUE_TEMPLATE/bug_report.yml


53. packages/critters/.github/ISSUE_TEMPLATE/config.yml Additional files +11/-0

...

packages/critters/.github/ISSUE_TEMPLATE/config.yml


54. packages/critters/.github/ISSUE_TEMPLATE/feature_request.yml Additional files +45/-0

...

packages/critters/.github/ISSUE_TEMPLATE/feature_request.yml


55. packages/critters/.github/ISSUE_TEMPLATE/security_vulnerability.yml Additional files +14/-0

...

packages/critters/.github/ISSUE_TEMPLATE/security_vulnerability.yml


56. packages/critters/.github/PULL_REQUEST_TEMPLATE.md Additional files +45/-0

...

packages/critters/.github/PULL_REQUEST_TEMPLATE.md


57. packages/critters/.github/SECURITY.md Additional files +59/-0

...

packages/critters/.github/SECURITY.md


58. packages/critters/.github/renovate.json Additional files +51/-0

...

packages/critters/.github/renovate.json


59. packages/critters/.github/workflows/ci.yml Additional files +1/-1

...

packages/critters/.github/workflows/ci.yml


60. packages/critters/.npmrc Additional files +5/-0

...

packages/critters/.npmrc


61. packages/critters/.prettierignore Additional files +6/-0

...

packages/critters/.prettierignore


62. packages/critters/.prettierrc.cjs Additional files +12/-0

...

packages/critters/.prettierrc.cjs


63. packages/critters/CHANGELOG.md Additional files +7/-83

...

packages/critters/CHANGELOG.md


64. packages/critters/CODE_OF_CONDUCT.md Additional files +133/-0

...

packages/critters/CODE_OF_CONDUCT.md


65. packages/critters/CONTRIBUTING.md Additional files +330/-0

...

packages/critters/CONTRIBUTING.md


66. packages/critters/LICENSE Additional files +21/-190

...

packages/critters/LICENSE


67. packages/critters/README.md Additional files +16/-188

...

packages/critters/README.md


68. packages/critters/SECURITY.md Additional files +59/-0

...

packages/critters/SECURITY.md


69. packages/critters/llms.txt Additional files +22/-0

...

packages/critters/llms.txt


70. packages/critters/package.json Additional files +23/-37

...

packages/critters/package.json


71. packages/critters/plans/architecture.md Additional files +1795/-0

...

packages/critters/plans/architecture.md


72. packages/critters/src/index.ts Additional files +6/-0

...

packages/critters/src/index.ts


73. packages/critters/src/runtime.d.ts Additional files +0/-0

...

packages/critters/src/runtime.d.ts


74. packages/critters/test/index.test.ts Additional files +13/-0

...

packages/critters/test/index.test.ts


75. packages/critters/test/security.test.js Additional files +17/-0

...

packages/critters/test/security.test.js


76. packages/critters/tsconfig.base.json Additional files +19/-0

...

packages/critters/tsconfig.base.json


77. packages/critters/tsconfig.build.json Additional files +11/-0

...

packages/critters/tsconfig.build.json


78. packages/critters/tsconfig.json Additional files +11/-0

...

packages/critters/tsconfig.json


79. packages/critters/tsup.config.ts Additional files +5/-17

...

packages/critters/tsup.config.ts


80. packages/critters/vitest.config.ts Additional files +1/-1

...

packages/critters/vitest.config.ts


81. packages/next-auth/.github/workflows/ci.yml Additional files +2/-8

...

packages/next-auth/.github/workflows/ci.yml


82. packages/next-auth/CHANGELOG.md Additional files +1/-11

...

packages/next-auth/CHANGELOG.md


83. packages/next-auth/README.md Additional files +5/-0

...

packages/next-auth/README.md


84. packages/next-auth/app/package.json Additional files +1/-2

...

packages/next-auth/app/package.json


85. packages/next-auth/app/pages/api/auth/[...nextauth].js Additional files +1/-1

...

packages/next-auth/app/pages/api/auth/[...nextauth].js


86. packages/next-auth/app/pages/credentials.js Additional files +1/-1

...

packages/next-auth/app/pages/credentials.js


87. packages/next-auth/app/pages/email.js Additional files +2/-2

...

packages/next-auth/app/pages/email.js


88. packages/next-auth/config/build.js Additional files +1/-1

...

packages/next-auth/config/build.js


89. packages/next-auth/config/jest-setup.js Additional files +0/-2

...

packages/next-auth/config/jest-setup.js


90. packages/next-auth/config/jest.config.js Additional files +0/-11

...

packages/next-auth/config/jest.config.js


91. packages/next-auth/package.json Additional files +68/-91

...

packages/next-auth/package.json


92. packages/next-auth/pnpm-lock.yaml Additional files +8827/-3460

...

packages/next-auth/pnpm-lock.yaml


93. packages/next-auth/scripts/postbuild.mjs Additional files +56/-0

...

packages/next-auth/scripts/postbuild.mjs


94. packages/next-auth/src/adapters/prisma.js Additional files +1/-6

...

packages/next-auth/src/adapters/prisma.js


95. packages/next-auth/src/adapters/typeorm-legacy.js Additional files +857/-0

...

packages/next-auth/src/adapters/typeorm-legacy.js


96. packages/next-auth/src/adapters/typeorm.js Additional files +5/-6

...

packages/next-auth/src/adapters/typeorm.js


97. packages/next-auth/src/client/__tests__/client-provider.test.jsx Additional files +11/-5

...

packages/next-auth/src/client/tests/client-provider.test.jsx


98. packages/next-auth/src/client/__tests__/csrf.test.jsx Additional files +20/-17

...

packages/next-auth/src/client/tests/csrf.test.jsx


99. packages/next-auth/src/client/__tests__/helpers/mocks.js Additional files +18/-16

...

packages/next-auth/src/client/tests/helpers/mocks.js


100. packages/next-auth/src/client/__tests__/providers.test.jsx Additional files +15/-9

...

packages/next-auth/src/client/tests/providers.test.jsx


101. packages/next-auth/src/client/__tests__/session.test.jsx Additional files +15/-13

...

packages/next-auth/src/client/tests/session.test.jsx


102. packages/next-auth/src/client/__tests__/sign-in.test.jsx Additional files +23/-27

...

packages/next-auth/src/client/tests/sign-in.test.jsx


103. packages/next-auth/src/client/__tests__/sign-out.test.jsx Additional files +16/-20

...

packages/next-auth/src/client/tests/sign-out.test.jsx


104. packages/next-auth/src/client/index.js Additional files +0/-2

...

packages/next-auth/src/client/index.js


105. packages/next-auth/src/server/lib/cookie.js Additional files +1/-1

...

packages/next-auth/src/server/lib/cookie.js


106. packages/next-auth/src/server/lib/default-events.js Additional files +7/-7

...

packages/next-auth/src/server/lib/default-events.js


107. packages/next-auth/src/server/lib/oauth/callback.js Additional files +3/-3

...

packages/next-auth/src/server/lib/oauth/callback.js


108. packages/next-auth/src/server/lib/oauth/client.js Additional files +2/-2

...

packages/next-auth/src/server/lib/oauth/client.js


109. packages/next-auth/src/server/pages/error.js Additional files +0/-1

...

packages/next-auth/src/server/pages/error.js


110. packages/next-auth/src/server/pages/signin.js Additional files +0/-2

...

packages/next-auth/src/server/pages/signin.js


111. packages/next-auth/src/server/pages/signout.js Additional files +0/-2

...

packages/next-auth/src/server/pages/signout.js


112. packages/next-auth/src/server/pages/verify-request.js Additional files +0/-2

...

packages/next-auth/src/server/pages/verify-request.js


113. packages/next-auth/src/server/routes/signout.js Additional files +2/-2

...

packages/next-auth/src/server/routes/signout.js


114. packages/next-auth/test-app/package.json Additional files +1/-2

...

packages/next-auth/test-app/package.json


115. packages/next-auth/test-app/pages/_app.js Additional files +1/-1

...

packages/next-auth/test-app/pages/_app.js


116. packages/next-auth/test-app/pages/api/auth/[...nextauth].js Additional files +2/-2

...

packages/next-auth/test-app/pages/api/auth/[...nextauth].js


117. packages/next-auth/test-app/pages/index.js Additional files +3/-3

...

packages/next-auth/test-app/pages/index.js


118. packages/next-auth/test/setup.js Additional files +22/-0

...

packages/next-auth/test/setup.js


119. packages/next-auth/tsconfig.json Additional files +1/-1

...

packages/next-auth/tsconfig.json


120. packages/next-auth/tsup.config.mjs Additional files +44/-4

...

packages/next-auth/tsup.config.mjs


121. packages/next-auth/types/adapters.d.ts Additional files +95/-13

...

packages/next-auth/types/adapters.d.ts


122. packages/next-auth/types/index.d.ts Additional files +1/-2

...

packages/next-auth/types/index.d.ts


123. packages/next-auth/types/jwt.d.ts Additional files +3/-3

...

packages/next-auth/types/jwt.d.ts


124. packages/next-auth/types/tsconfig.json Additional files +1/-0

...

packages/next-auth/types/tsconfig.json


125. packages/next-auth/types/tslint.json Additional files +0/-7

...

packages/next-auth/types/tslint.json


126. packages/next-auth/vitest.config.js Additional files +10/-3

...

packages/next-auth/vitest.config.js


127. packages/next-auth/www/package.json Additional files +1/-1

...

packages/next-auth/www/package.json


128. packages/next-auth/www/src/components/ProviderMarquee.js Additional files +1/-1

...

packages/next-auth/www/src/components/ProviderMarquee.js


129. packages/next-circuit-breaker/.changeset/config.json Additional files +11/-0

...

packages/next-circuit-breaker/.changeset/config.json


130. packages/next-circuit-breaker/.commitlintrc.json Additional files +35/-0

...

packages/next-circuit-breaker/.commitlintrc.json


131. packages/next-circuit-breaker/.github/FUNDING.yml Additional files +3/-0

...

packages/next-circuit-breaker/.github/FUNDING.yml


132. packages/next-circuit-breaker/.github/ISSUE_TEMPLATE/bug_report.yml Additional files +88/-0

...

packages/next-circuit-breaker/.github/ISSUE_TEMPLATE/bug_report.yml


133. packages/next-circuit-breaker/.github/ISSUE_TEMPLATE/config.yml Additional files +11/-0

...

packages/next-circuit-breaker/.github/ISSUE_TEMPLATE/config.yml


134. packages/next-circuit-breaker/.github/ISSUE_TEMPLATE/feature_request.yml Additional files +45/-0

...

packages/next-circuit-breaker/.github/ISSUE_TEMPLATE/feature_request.yml


135. packages/next-circuit-breaker/.github/ISSUE_TEMPLATE/security_vulnerability.yml Additional files +14/-0

...

packages/next-circuit-breaker/.github/ISSUE_TEMPLATE/security_vulnerability.yml


136. Additional files not shown Additional files +0/-0

...

Additional files not shown


Grey Divider

Qodo Logo

@qodo-code-review
Copy link

qodo-code-review bot commented Mar 12, 2026

Code Review by Qodo

🐞 Bugs (2) 📘 Rule violations (5) 📎 Requirement gaps (0)

Grey Divider


Action required

1. next-optimized-images code in lib/ 📘 Rule violation ⛯ Reliability
Description
New package implementation code was added under packages/next-optimized-images/lib/... instead of
packages/<name>/src, which breaks the required monorepo layout expectations. This can cause
tooling/CI and contributor workflows to miss or inconsistently treat package source.
Code

packages/next-optimized-images/lib/loaders/file-loader.js[R1-3]

+const path = require('path');
+const fs = require('fs');
+
Evidence
Compliance requires package implementation code to be located under packages/<name>/src, but this
PR adds a new implementation module under packages/next-optimized-images/lib/loaders/. The added
code lines show this is newly introduced package code outside the approved location.

AGENTS.md
packages/next-optimized-images/lib/loaders/file-loader.js[1-3]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
New `next-optimized-images` implementation code is being added under `packages/next-optimized-images/lib/...`, but the monorepo rule requires package implementation code to live under `packages/&lt;name&gt;/src`.

## Issue Context
Keeping source code under `src/` is required so tooling and contributors can reliably find, lint, typecheck, and build package source.

## Fix Focus Areas
- packages/next-optimized-images/lib/loaders/file-loader.js[1-89]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. __tests__ added at package root 📘 Rule violation ⛯ Reliability
Description
New tests were added under packages/next-optimized-images/__tests__/..., which is not one of the
allowed test locations (test/, src/**/*.test.*, or src/__tests__/). This can lead to
inconsistent test discovery and deviates from the required monorepo layout.
Code

packages/next-optimized-images/tests/index.test.js[1]

+const withOptimizedImages = require('../lib');
Evidence
Compliance defines specific directories where tests must live, but this PR adds a new test file
under a package-root __tests__/ directory. The diff shows the file is newly introduced at that
location.

AGENTS.md
packages/next-optimized-images/tests/index.test.js[1-1]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
New test files were introduced under `packages/next-optimized-images/__tests__/...`, but the repo standard only allows tests under `test/`, `src/**/*.test.*`, or `src/__tests__/`.

## Issue Context
Test discovery and tooling consistency rely on tests being placed in the documented locations.

## Fix Focus Areas
- packages/next-optimized-images/__tests__/index.test.js[1-116]
- packages/next-optimized-images/__tests__/loaders/index.test.js[1-83]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. New tests use .test.js 📘 Rule violation ⛯ Reliability
Description
This PR adds new test files named *.test.js, but the repository requires new tests to be named
*.test.ts or *.test.tsx. This can break consistent test conventions and discovery expectations.
Code

packages/next-optimized-images/tests/index.test.js[1]

+const withOptimizedImages = require('../lib');
Evidence
The compliance rule mandates new test files use the *.test.ts / *.test.tsx naming convention,
but this PR introduces *.test.js files. The cited file is a newly added test (@@ -0,0 ...) with
a .test.js extension.

AGENTS.md
packages/next-optimized-images/tests/index.test.js[1-1]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
New tests are being added as `*.test.js`, but the repository requires new test files to be named `*.test.ts` or `*.test.tsx`.

## Issue Context
Consistent test naming is required for predictable discovery and enforcement across packages.

## Fix Focus Areas
- packages/next-optimized-images/__tests__/index.test.js[1-116]
- packages/next-optimized-images/__tests__/loaders/index.test.js[1-83]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View more (3)
4. vitest.config.js not Prettier 📘 Rule violation ✓ Correctness
Description
The new vitest.config.js uses double quotes and omits semicolons, diverging from the repository
Prettier standards. This introduces inconsistent formatting in newly added code.
Code

vitest.config.js[R1-10]

+import { defineConfig } from "vitest/config"
+
+export default defineConfig({
+  test: {
+    globals: true,
+    env: {
+      NEXTAUTH_URL: "http://localhost:3000/api/auth",
+    },
+  },
+})
Evidence
The checklist requires single quotes and semicolons, but the added vitest.config.js uses double
quotes and has no semicolons. The cited lines show the exact formatting deviations in newly added
code.

AGENTS.md
vitest.config.js[1-10]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The newly added `vitest.config.js` does not match the repo’s Prettier conventions (it uses double quotes and omits semicolons).

## Issue Context
Repository formatting standards require single quotes and semicolons for consistency.

## Fix Focus Areas
- vitest.config.js[1-10]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


5. keywords line exceeds 100 📘 Rule violation ✓ Correctness
Description
The newly added keywords array is on a single extremely long line, exceeding the 100-character
line length requirement. This reduces readability and violates the documented formatting standards.
Code

packages/critters/src/runtime.js[752]

+                const keywords = ['none', 'inherit', 'initial', 'unset', 'infinite', 'alternate', 'alternate-reverse', 'forwards', 'backwards', 'both', 'running', 'paused', 'normal', 'reverse', 'ease', 'ease-in', 'ease-out', 'ease-in-out', 'linear', 'step-start', 'step-end'];
Evidence
The checklist mandates a 100-character line length, but the added keywords array is written as a
single long line. The cited line shows the overlong line introduced by this PR.

AGENTS.md
packages/critters/src/runtime.js[752-752]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
A newly added `keywords` array in `runtime.js` exceeds the repo’s 100-character line length standard.

## Issue Context
Long lines reduce readability and violate the documented Prettier formatting expectations.

## Fix Focus Areas
- packages/critters/src/runtime.js[751-756]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


6. Font preload head crash 🐞 Bug ⛯ Reliability
Description
In packages/critters/src/runtime.js, the new @font-face preloading loop unconditionally calls
document.head.appendChild(preload), which throws if the parsed HTML has no <head>. This causes
Critters.process() to fail for inputs without a head element when fonts/preloadFonts is enabled and
a @font-face rule is encountered.
Code

packages/critters/src/runtime.js[R809-826]

+        if (src && shouldPreloadFonts) {
+          const urlRegex = /url\s*\(\s*(['"]?)(.+?)\1\s*\)(\s*format\s*\(\s*(['"]?)(.+?)\4\s*\))?/g;
+          let match;
+          while ((match = urlRegex.exec(src)) !== null) {
+            const fontUrl = match[2].trim();
+            const format = match[5];
+            if (!preloadedFonts.has(fontUrl)) {
+              preloadedFonts.add(fontUrl);
+              const preload = document.createElement('link');
+              preload.setAttribute('rel', 'preload');
+              preload.setAttribute('as', 'font');
+              if (format) {
+                preload.setAttribute('type', `font/${format}`);
+              }
+              preload.setAttribute('crossorigin', 'anonymous');
+              preload.setAttribute('href', fontUrl);
+              document.head.appendChild(preload);
+            }
Evidence
The Critters DOM implementation does not guarantee a <head> element: document.head is a getter that
returns document.querySelector('head'), which can be null. The new font-preload implementation
appends to document.head without a null guard, so it can dereference null and crash.

packages/critters/src/runtime.js[809-826]
packages/critters/src/dom.js[216-220]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`processStyle()` can crash during font preloading because it unconditionally uses `document.head.appendChild(preload)` even though `document.head` can be null in this DOM implementation when HTML lacks a `&lt;head&gt;`.

### Issue Context
Critters’ `document.head` is implemented as `querySelector(&#x27;head&#x27;)`, so it is not guaranteed to exist for malformed/minimal HTML. The new font preload parsing loop should be as defensive as other style insertion paths.

### Fix Focus Areas
- packages/critters/src/runtime.js[809-826]
- packages/critters/src/dom.js[216-220]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

7. Keyword keyframes pruned 🐞 Bug ✓ Correctness
Description
In packages/critters/src/runtime.js, keyframe name extraction now filters out many common
identifiers even when parsing the animation-name property. If a project defines @keyframes with
a name like "linear" or "infinite" and references it via animation-name, Critters will fail to
mark it as critical and will prune that @keyframes rule.
Code

packages/critters/src/runtime.js[R750-757]

              if (decl.prop === 'animation' || decl.prop === 'animation-name') {
+                // Filter out common animation keywords and durations
+                const keywords = ['none', 'inherit', 'initial', 'unset', 'infinite', 'alternate', 'alternate-reverse', 'forwards', 'backwards', 'both', 'running', 'paused', 'normal', 'reverse', 'ease', 'ease-in', 'ease-out', 'ease-in-out', 'linear', 'step-start', 'step-end'];
                for (const name of decl.value.split(/\s+/)) {
-                  // @todo: parse animation declarations and extract only the name. for now we'll do a lazy match.
                  const nameTrimmed = name.trim();
-                  if (nameTrimmed) criticalKeyframeNames.add(nameTrimmed);
+                  if (nameTrimmed && !keywords.includes(nameTrimmed) && !/^\d/.test(nameTrimmed)) {
+                    criticalKeyframeNames.add(nameTrimmed);
+                  }
Evidence
The code applies the same keyword-filtering logic to both animation and animation-name,
excluding identifiers like linear and infinite from criticalKeyframeNames. Later, when
keyframesMode is 'critical', Critters keeps @keyframes rules only if
criticalKeyframeNames.has(rule.params), so any excluded-but-actually-used keyframe name will be
removed.

packages/critters/src/runtime.js[749-757]
packages/critters/src/runtime.js[791-796]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
Keyframe usage detection applies a hardcoded keyword blacklist to both `animation` and `animation-name`. This can cause legitimate keyframes to be pruned when their names collide with the blacklist (e.g., `@keyframes linear {}` used via `animation-name: linear`).

### Issue Context
`criticalKeyframeNames` is the sole source of truth used to keep/prune `@keyframes` rules in `keyframesMode === &#x27;critical&#x27;`.

### Fix Focus Areas
- packages/critters/src/runtime.js[749-757]
- packages/critters/src/runtime.js[791-796]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9e8f94dacf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 750 to +752
if (decl.prop === 'animation' || decl.prop === 'animation-name') {
// Filter out common animation keywords and durations
const keywords = ['none', 'inherit', 'initial', 'unset', 'infinite', 'alternate', 'alternate-reverse', 'forwards', 'backwards', 'both', 'running', 'paused', 'normal', 'reverse', 'ease', 'ease-in', 'ease-out', 'ease-in-out', 'linear', 'step-start', 'step-end'];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve valid animation-name identifiers

The new keyword filter is applied to both animation and animation-name, but animation-name accepts custom identifiers that can legally be words like linear, reverse, or forwards. With this change those names are dropped from criticalKeyframeNames, so the matching @keyframes block is removed in the second pass and the animation stops working in the inlined CSS. Restrict shorthand keyword filtering to animation parsing, or use a narrower rule for animation-name.

Useful? React with 👍 / 👎.

Comment on lines +820 to +822
if (format) {
preload.setAttribute('type', `font/${format}`);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Normalize font format before setting preload MIME type

The preload type is now derived as font/${format}, but CSS format() tokens are not MIME subtypes (for example truetype, opentype, and embedded-opentype do not map directly to valid font/* values). This can produce invalid type attributes, and browsers may skip those preloads, regressing font preload behavior for non-woff sources. Add an explicit format-to-MIME map and omit type when the format is unknown.

Useful? React with 👍 / 👎.

Comment on lines +1 to +3
const path = require('path');
const fs = require('fs');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. next-optimized-images code in lib/ 📘 Rule violation ⛯ Reliability

New package implementation code was added under packages/next-optimized-images/lib/... instead of
packages/<name>/src, which breaks the required monorepo layout expectations. This can cause
tooling/CI and contributor workflows to miss or inconsistently treat package source.
Agent Prompt
## Issue description
New `next-optimized-images` implementation code is being added under `packages/next-optimized-images/lib/...`, but the monorepo rule requires package implementation code to live under `packages/<name>/src`.

## Issue Context
Keeping source code under `src/` is required so tooling and contributors can reliably find, lint, typecheck, and build package source.

## Fix Focus Areas
- packages/next-optimized-images/lib/loaders/file-loader.js[1-89]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@@ -0,0 +1,116 @@
const withOptimizedImages = require('../lib');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

2. tests added at package root 📘 Rule violation ⛯ Reliability

New tests were added under packages/next-optimized-images/__tests__/..., which is not one of the
allowed test locations (test/, src/**/*.test.*, or src/__tests__/). This can lead to
inconsistent test discovery and deviates from the required monorepo layout.
Agent Prompt
## Issue description
New test files were introduced under `packages/next-optimized-images/__tests__/...`, but the repo standard only allows tests under `test/`, `src/**/*.test.*`, or `src/__tests__/`.

## Issue Context
Test discovery and tooling consistency rely on tests being placed in the documented locations.

## Fix Focus Areas
- packages/next-optimized-images/__tests__/index.test.js[1-116]
- packages/next-optimized-images/__tests__/loaders/index.test.js[1-83]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@@ -0,0 +1,116 @@
const withOptimizedImages = require('../lib');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

3. New tests use .test.js 📘 Rule violation ⛯ Reliability

This PR adds new test files named *.test.js, but the repository requires new tests to be named
*.test.ts or *.test.tsx. This can break consistent test conventions and discovery expectations.
Agent Prompt
## Issue description
New tests are being added as `*.test.js`, but the repository requires new test files to be named `*.test.ts` or `*.test.tsx`.

## Issue Context
Consistent test naming is required for predictable discovery and enforcement across packages.

## Fix Focus Areas
- packages/next-optimized-images/__tests__/index.test.js[1-116]
- packages/next-optimized-images/__tests__/loaders/index.test.js[1-83]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +1 to +10
import { defineConfig } from "vitest/config"

export default defineConfig({
test: {
globals: true,
env: {
NEXTAUTH_URL: "http://localhost:3000/api/auth",
},
},
})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

4. vitest.config.js not prettier 📘 Rule violation ✓ Correctness

The new vitest.config.js uses double quotes and omits semicolons, diverging from the repository
Prettier standards. This introduces inconsistent formatting in newly added code.
Agent Prompt
## Issue description
The newly added `vitest.config.js` does not match the repo’s Prettier conventions (it uses double quotes and omits semicolons).

## Issue Context
Repository formatting standards require single quotes and semicolons for consistency.

## Fix Focus Areas
- vitest.config.js[1-10]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

// detect used keyframes
if (decl.prop === 'animation' || decl.prop === 'animation-name') {
// Filter out common animation keywords and durations
const keywords = ['none', 'inherit', 'initial', 'unset', 'infinite', 'alternate', 'alternate-reverse', 'forwards', 'backwards', 'both', 'running', 'paused', 'normal', 'reverse', 'ease', 'ease-in', 'ease-out', 'ease-in-out', 'linear', 'step-start', 'step-end'];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

5. keywords line exceeds 100 📘 Rule violation ✓ Correctness

The newly added keywords array is on a single extremely long line, exceeding the 100-character
line length requirement. This reduces readability and violates the documented formatting standards.
Agent Prompt
## Issue description
A newly added `keywords` array in `runtime.js` exceeds the repo’s 100-character line length standard.

## Issue Context
Long lines reduce readability and violate the documented Prettier formatting expectations.

## Fix Focus Areas
- packages/critters/src/runtime.js[751-756]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +809 to +826
if (src && shouldPreloadFonts) {
const urlRegex = /url\s*\(\s*(['"]?)(.+?)\1\s*\)(\s*format\s*\(\s*(['"]?)(.+?)\4\s*\))?/g;
let match;
while ((match = urlRegex.exec(src)) !== null) {
const fontUrl = match[2].trim();
const format = match[5];
if (!preloadedFonts.has(fontUrl)) {
preloadedFonts.add(fontUrl);
const preload = document.createElement('link');
preload.setAttribute('rel', 'preload');
preload.setAttribute('as', 'font');
if (format) {
preload.setAttribute('type', `font/${format}`);
}
preload.setAttribute('crossorigin', 'anonymous');
preload.setAttribute('href', fontUrl);
document.head.appendChild(preload);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

6. Font preload head crash 🐞 Bug ⛯ Reliability

In packages/critters/src/runtime.js, the new @font-face preloading loop unconditionally calls
document.head.appendChild(preload), which throws if the parsed HTML has no <head>. This causes
Critters.process() to fail for inputs without a head element when fonts/preloadFonts is enabled and
a @font-face rule is encountered.
Agent Prompt
### Issue description
`processStyle()` can crash during font preloading because it unconditionally uses `document.head.appendChild(preload)` even though `document.head` can be null in this DOM implementation when HTML lacks a `<head>`.

### Issue Context
Critters’ `document.head` is implemented as `querySelector('head')`, so it is not guaranteed to exist for malformed/minimal HTML. The new font preload parsing loop should be as defensive as other style insertion paths.

### Fix Focus Areas
- packages/critters/src/runtime.js[809-826]
- packages/critters/src/dom.js[216-220]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@riceharvest
Copy link
Owner Author

3 similar comments
@riceharvest
Copy link
Owner Author

@riceharvest
Copy link
Owner Author

@riceharvest
Copy link
Owner Author

Prevent crash when parsed HTML has no <head> element during font preloading.
Uses same fallback pattern as stylesheet embedding (document.head || querySelector).
@chatgpt-codex-connector
Copy link

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@kilo-code-bot
Copy link
Contributor

kilo-code-bot bot commented Mar 15, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Overview

The PR fixes a crash when parsing HTML documents that don't have a <head> element. The fix adds a null check for document.head in the font preloading logic, using the same pattern as the existing stylesheet embedding code.

Files Reviewed (1 file)
  • packages/critters/src/runtime.js

// detect used keyframes
if (decl.prop === 'animation' || decl.prop === 'animation-name') {
// Filter out common animation keywords and durations
const keywords = ['none', 'inherit', 'initial', 'unset', 'infinite', 'alternate', 'alternate-reverse', 'forwards', 'backwards', 'both', 'running', 'paused', 'normal', 'reverse', 'ease', 'ease-in', 'ease-out', 'ease-in-out', 'linear', 'step-start', 'step-end'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SUGGESTION: Consider moving the animation keywords array outside the loop or function to avoid recreating it on each call

}
preload.setAttribute('crossorigin', 'anonymous');
preload.setAttribute('href', fontUrl);
const head = document.head || document.querySelector('head');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SUGGESTION: Add a comment explaining the fallback for when document.head is null

preload.setAttribute('href', src.trim());
document.head.appendChild(preload);
if (src && shouldPreloadFonts) {
const urlRegex = /url\s*\(\s*(['"]?)(.+?)\1\s*\)(\s*format\s*\(\s*(['"]?)(.+?)\4\s*\))?/g;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SUGGESTION: Add error handling for invalid font URLs or failed regex matches

@kilo-code-bot
Copy link
Contributor

kilo-code-bot bot commented Mar 15, 2026

Code Review Summary

Status: 3 Suggestions Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 3
Issue Details (click to expand)

SUGGESTION

File Line Issue
packages/critters/src/runtime.js 752 Consider moving the animation keywords array outside the loop or function to avoid recreating it on each call
packages/critters/src/runtime.js 825 Add a comment explaining the fallback for when document.head is null
packages/critters/src/runtime.js 810 Add error handling for invalid font URLs or failed regex matches
Files Reviewed (1 file)
  • packages/critters/src/runtime.js - 3 suggestions

@riceharvest
Copy link
Owner Author

@riceharvest
Copy link
Owner Author

Superseded by #59 (squash merge of all modernization PRs). Changes included in main.

@riceharvest riceharvest deleted the fix/critters-modernization branch March 15, 2026 23:46
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.

feat(critters): improve animation parsing and font preloading

1 participant