Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Configurable Globals #186

Merged
merged 14 commits into from
Dec 20, 2024
Merged

feat: Configurable Globals #186

merged 14 commits into from
Dec 20, 2024

Conversation

huntabyte
Copy link
Member

@huntabyte huntabyte commented Dec 20, 2024

This pull request introduces a significant update, but no breaking changes to the library, focusing on making global objects like window, document, and navigator configurable. This allows for better flexibility and testing capabilities.

Configurable Globals:

  • New Types and Defaults:
    • Added new types ConfigurableWindow, ConfigurableDocument, ConfigurableDocumentOrShadowRoot, ConfigurableNavigator, and ConfigurableLocation to allow custom global objects.
    • Defined default global objects based on the environment (BROWSER).

Utility Functions and Classes:

  • AnimationFrames:

    • Updated the AnimationFrames class to accept a configurable window object and use it for requestAnimationFrame and cancelAnimationFrame.
  • ElementRect:

    • Modified the ElementRect class to accept a configurable window object and use it in useResizeObserver and useMutationObserver.
    • Modified the state to be deeply reactive, rather than reassigning the entire object each update.
  • ElementSize:

    • Updated the ElementSize class to accept a configurable window object and use it for ResizeObserver.
  • IsFocusWithin:

    • Enhanced the IsFocusWithin class to accept configurable document and window objects and use a new useActiveElement utility.
  • IsIdle:

    • Updated the IsIdle class to accept configurable document and window objects and use them for event listeners and visibility change detection.

Testing:

  • IsFocusWithin Tests:
    • Replaced the Svelte component-based tests with direct class tests, adding more comprehensive test cases including shadow DOM scenarios.

These changes improve the flexibility and testability of Runed by allowing custom global objects to be used in various utilities and classes.

Closes #167

Copy link

changeset-bot bot commented Dec 20, 2024

🦋 Changeset detected

Latest commit: e2d4637

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
runed Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented Dec 20, 2024

built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
runed ✅ Ready (View Log) Visit Preview e2d4637

@huntabyte huntabyte merged commit 6f8c3c4 into main Dec 20, 2024
4 checks passed
@huntabyte huntabyte deleted the configurable-globals branch December 20, 2024 16:53
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.

Feature Request: Configurable Browser Globals
1 participant