Skip to content

feat: add core range, time and volume range - #23

Merged
luwes merged 7 commits into
mainfrom
core-timerange
Sep 26, 2025
Merged

feat: add core range, time and volume range#23
luwes merged 7 commits into
mainfrom
core-timerange

Conversation

@luwes

@luwes luwes commented Sep 24, 2025

Copy link
Copy Markdown
Collaborator

This is a proof of concept for extracting a core class for both the React and HTML time range.
It's very rough without many things abstracted away.

Used a prefixed underscore for some state props so they can be minified by the bundler.

@luwes
luwes requested a review from Copilot September 24, 2025 21:00
@luwes luwes self-assigned this Sep 24, 2025

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a proof of concept for extracting time range functionality into a core class that can be shared between React and HTML implementations. The change refactors the React TimeRange component to use a new CoreTimeRange class from a @vjs-10/core package, moving the component logic out of React-specific code.

Key changes:

  • Creates a new @vjs-10/core package with a framework-agnostic TimeRange class
  • Refactors the React TimeRange component to use the core class instead of local state management
  • Uses underscore-prefixed state properties for bundler minification optimization

Reviewed Changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
packages/react/react/src/components/TimeRange.tsx Refactored to use CoreTimeRange class, removing local pointer event handling and state management
packages/react/react/package.json Added dependency on the new @vjs-10/core package
packages/core/core/tsdown.config.ts Build configuration for the new core package
packages/core/core/tsconfig.json TypeScript configuration for the core package
packages/core/core/tsconfig.build.json Build-specific TypeScript configuration
packages/core/core/src/index.ts Entry point exporting TimeRange class and types
packages/core/core/src/components/time-range.ts Core TimeRange class implementation with event handling and state management
packages/core/core/package.json Package configuration for the new core package
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread packages/core/core/src/components/time-range.ts Outdated
Comment thread packages/core/core/src/components/time-range.ts Outdated
Comment thread packages/core/core/src/components/time-range.ts Outdated
Comment thread packages/react/react/src/components/TimeRange.tsx Outdated
Comment on lines +185 to +190
const calculateSeekTimeFromPointerEvent = (e: PointerEvent, duration: number): number => {
if (!(e.currentTarget instanceof HTMLElement)) return 0;
const rect = e.currentTarget.getBoundingClientRect();
const ratio = calculatePointerRatio(e.clientX, rect);
return calculateSeekTimeFromRatio(ratio, duration);
};

Copilot AI Sep 24, 2025

Copy link

Choose a reason for hiding this comment

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

The function returns 0 when currentTarget is not an HTMLElement, but this could mask errors. Consider throwing an error or using a more explicit default behavior.

Copilot uses AI. Check for mistakes.
Comment thread packages/react/react/src/components/TimeRange.tsx Outdated
@luwes luwes changed the title feat: add poc for core time range class feat: add core range, time and volume range Sep 26, 2025

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 17 out of 18 changed files in this pull request and generated 3 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread packages/core/core/src/utils/state.ts Outdated
Comment thread packages/core/core/src/components/range.ts Outdated

useEffect(() => {
coreRef.current?.setState(state);
}, [...Object.values(state)]);

Copilot AI Sep 26, 2025

Copy link

Choose a reason for hiding this comment

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

Creating a new array with Object.values(state) on every render is inefficient and may cause unnecessary re-runs. Consider using a more targeted dependency array with specific state properties or use useMemo to memoize the values.

Copilot uses AI. Check for mistakes.
luwes and others added 2 commits September 26, 2025 14:09
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@luwes
luwes merged commit 687b765 into main Sep 26, 2025
@luwes
luwes deleted the core-timerange branch September 26, 2025 19:10
@github-actions github-actions Bot mentioned this pull request Oct 24, 2025
@github-actions github-actions Bot mentioned this pull request Feb 26, 2026
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