Skip to content

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Jul 10, 2025

This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.

Releases

@react-native-youtube-bridge/core@2.0.0

Major Changes

  • ae4cc4d: feat!: introduce hooks-based API for v2.0

    [!important]
    BREAKING CHANGE: Complete API Redesign with React Hooks

    New Hooks-Based Architecture

    • useYouTubePlayer(videoId, config) - Creates a player instance with declarative configuration
    • useYouTubeEvent(player, eventName, intervalOrDefault?, deps?) - Reactive event handling with complete type inference
    • YoutubeView - Simplified view component that accepts a player instance

    Migration from v1 to v2

    Before (v1):

    // Imperative, ref-based API
    const playerRef = useRef < PlayerControls > null;
    
    <YoutubePlayer
      ref={playerRef}
      source={videoId}
      onReady={handleReady}
      onStateChange={handleStateChange}
      onProgress={handleProgress}
      playerVars={{ autoplay: true }}
    />;
    
    // Manual event handlers and state management
    const [isPlaying, setIsPlaying] = useState(false);
    const handleStateChange = (state) =>
      setIsPlaying(state === PlayerState.PLAYING);

    After (v2):

    // Declarative, hooks-based API
    const player = useYouTubePlayer(videoId, {
      autoplay: true,
      controls: true,
      playsinline: true,
    });
    
    <YoutubeView player={player} />;
    
    // Reactive state with automatic updates - two usage patterns:
    
    // 1. State-based (returns reactive values)
    const playbackRate = useYouTubeEvent(player, "playbackRateChange", 1);
    const progress = useYouTubeEvent(player, "progress", 1000); // 1000ms interval
    const state = useYouTubeEvent(player, "stateChange");
    
    const isPlaying = state === PlayerState.PLAYING;
    
    // 2. Callback-based (for side effects)
    useYouTubeEvent(player, "ready", (playerInfo) => {
      console.log("Player ready:", playerInfo);
    });
    
    useYouTubeEvent(player, "error", (error) => {
      console.error("Player error:", error);
    });

    ✨ New Features

    • Declarative Configuration: Configure player options directly in useYouTubePlayer hook
    • Automatic State Management: No need to manually manage state for common use cases
    • Reactive Events: useYouTubeEvent with two usage patterns - state-based for reactive values and callback-based for side effects
    • Better TypeScript Support: Improved type inference and autocomplete
    • Reduced Boilerplate: Significantly less code required for common operations
    • Automatic Cleanup: Hooks handle cleanup automatically, preventing memory leaks

    🎯 Improvements

    • Reduced Coupling: Eliminated ref dependencies between parent and child components
    • Simplified API: Fewer props to manage, more intuitive usage patterns
    • Better Developer Experience: Following established React Native patterns (expo-audio, expo-video)
    • Performance: More efficient event handling with automatic cleanup
    • Maintainability: Cleaner separation of concerns

    📦 Component Changes

    Removed

    • YoutubePlayer component (replaced by YoutubeView)
    • PlayerControls ref interface
    • ❌ Direct event props (onReady, onStateChange, onProgress, etc.)

    Added

    • YoutubeView component
    • useYouTubePlayer hook
    • useYouTubeEvent hook
    • ✅ Simplified prop interface

    📚 Migration Guide

    For detailed migration examples and step-by-step instructions, see our Migration Guide.

    Key migration steps:

    1. Replace YoutubePlayer with YoutubeView + useYouTubePlayer
    2. Convert event props to useYouTubeEvent hooks (state-based or callback-based)
    3. Move playerVars to useYouTubePlayer config
    4. Replace ref-based method calls with direct player method calls
    5. Remove manual state management for events

    ⚠️ Breaking Changes

    • API Surface: Complete API redesign, no backward compatibility
    • Event Handling: Manual event listeners replaced with reactive hooks
    • Component Structure: YoutubePlayer split into YoutubeView + hooks

    🐛 Bug Fixes

    • Fixed memory leaks from improper event cleanup
    • Better handling of rapid video ID changes
    • Manage multiple players independently

    📖 Documentation

    • Complete API documentation rewrite
    • Added migration guide from v1
    • Updated all examples to use v2 API
    • Added TypeScript usage examples

    Previous Versions

    [1.x.x] - Legacy Version

    See v1 documentation for the previous imperative API.

@react-native-youtube-bridge/react@2.0.0

Major Changes

  • ae4cc4d: feat!: introduce hooks-based API for v2.0

    [!important]
    BREAKING CHANGE: Complete API Redesign with React Hooks

    New Hooks-Based Architecture

    • useYouTubePlayer(videoId, config) - Creates a player instance with declarative configuration
    • useYouTubeEvent(player, eventName, intervalOrDefault?, deps?) - Reactive event handling with complete type inference
    • YoutubeView - Simplified view component that accepts a player instance

    Migration from v1 to v2

    Before (v1):

    // Imperative, ref-based API
    const playerRef = useRef < PlayerControls > null;
    
    <YoutubePlayer
      ref={playerRef}
      source={videoId}
      onReady={handleReady}
      onStateChange={handleStateChange}
      onProgress={handleProgress}
      playerVars={{ autoplay: true }}
    />;
    
    // Manual event handlers and state management
    const [isPlaying, setIsPlaying] = useState(false);
    const handleStateChange = (state) =>
      setIsPlaying(state === PlayerState.PLAYING);

    After (v2):

    // Declarative, hooks-based API
    const player = useYouTubePlayer(videoId, {
      autoplay: true,
      controls: true,
      playsinline: true,
    });
    
    <YoutubeView player={player} />;
    
    // Reactive state with automatic updates - two usage patterns:
    
    // 1. State-based (returns reactive values)
    const playbackRate = useYouTubeEvent(player, "playbackRateChange", 1);
    const progress = useYouTubeEvent(player, "progress", 1000); // 1000ms interval
    const state = useYouTubeEvent(player, "stateChange");
    
    const isPlaying = state === PlayerState.PLAYING;
    
    // 2. Callback-based (for side effects)
    useYouTubeEvent(player, "ready", (playerInfo) => {
      console.log("Player ready:", playerInfo);
    });
    
    useYouTubeEvent(player, "error", (error) => {
      console.error("Player error:", error);
    });

    ✨ New Features

    • Declarative Configuration: Configure player options directly in useYouTubePlayer hook
    • Automatic State Management: No need to manually manage state for common use cases
    • Reactive Events: useYouTubeEvent with two usage patterns - state-based for reactive values and callback-based for side effects
    • Better TypeScript Support: Improved type inference and autocomplete
    • Reduced Boilerplate: Significantly less code required for common operations
    • Automatic Cleanup: Hooks handle cleanup automatically, preventing memory leaks

    🎯 Improvements

    • Reduced Coupling: Eliminated ref dependencies between parent and child components
    • Simplified API: Fewer props to manage, more intuitive usage patterns
    • Better Developer Experience: Following established React Native patterns (expo-audio, expo-video)
    • Performance: More efficient event handling with automatic cleanup
    • Maintainability: Cleaner separation of concerns

    📦 Component Changes

    Removed

    • YoutubePlayer component (replaced by YoutubeView)
    • PlayerControls ref interface
    • ❌ Direct event props (onReady, onStateChange, onProgress, etc.)

    Added

    • YoutubeView component
    • useYouTubePlayer hook
    • useYouTubeEvent hook
    • ✅ Simplified prop interface

    📚 Migration Guide

    For detailed migration examples and step-by-step instructions, see our Migration Guide.

    Key migration steps:

    1. Replace YoutubePlayer with YoutubeView + useYouTubePlayer
    2. Convert event props to useYouTubeEvent hooks (state-based or callback-based)
    3. Move playerVars to useYouTubePlayer config
    4. Replace ref-based method calls with direct player method calls
    5. Remove manual state management for events

    ⚠️ Breaking Changes

    • API Surface: Complete API redesign, no backward compatibility
    • Event Handling: Manual event listeners replaced with reactive hooks
    • Component Structure: YoutubePlayer split into YoutubeView + hooks

    🐛 Bug Fixes

    • Fixed memory leaks from improper event cleanup
    • Better handling of rapid video ID changes
    • Manage multiple players independently

    📖 Documentation

    • Complete API documentation rewrite
    • Added migration guide from v1
    • Updated all examples to use v2 API
    • Added TypeScript usage examples

    Previous Versions

    [1.x.x] - Legacy Version

    See v1 documentation for the previous imperative API.

Patch Changes

  • Updated dependencies [ae4cc4d]
    • @react-native-youtube-bridge/core@2.0.0

react-native-youtube-bridge@2.0.0

Major Changes

  • ae4cc4d: feat!: introduce hooks-based API for v2.0

    [!important]
    BREAKING CHANGE: Complete API Redesign with React Hooks

    New Hooks-Based Architecture

    • useYouTubePlayer(videoId, config) - Creates a player instance with declarative configuration
    • useYouTubeEvent(player, eventName, intervalOrDefault?, deps?) - Reactive event handling with complete type inference
    • YoutubeView - Simplified view component that accepts a player instance

    Migration from v1 to v2

    Before (v1):

    // Imperative, ref-based API
    const playerRef = useRef < PlayerControls > null;
    
    <YoutubePlayer
      ref={playerRef}
      source={videoId}
      onReady={handleReady}
      onStateChange={handleStateChange}
      onProgress={handleProgress}
      playerVars={{ autoplay: true }}
    />;
    
    // Manual event handlers and state management
    const [isPlaying, setIsPlaying] = useState(false);
    const handleStateChange = (state) =>
      setIsPlaying(state === PlayerState.PLAYING);

    After (v2):

    // Declarative, hooks-based API
    const player = useYouTubePlayer(videoId, {
      autoplay: true,
      controls: true,
      playsinline: true,
    });
    
    <YoutubeView player={player} />;
    
    // Reactive state with automatic updates - two usage patterns:
    
    // 1. State-based (returns reactive values)
    const playbackRate = useYouTubeEvent(player, "playbackRateChange", 1);
    const progress = useYouTubeEvent(player, "progress", 1000); // 1000ms interval
    const state = useYouTubeEvent(player, "stateChange");
    
    const isPlaying = state === PlayerState.PLAYING;
    
    // 2. Callback-based (for side effects)
    useYouTubeEvent(player, "ready", (playerInfo) => {
      console.log("Player ready:", playerInfo);
    });
    
    useYouTubeEvent(player, "error", (error) => {
      console.error("Player error:", error);
    });

    ✨ New Features

    • Declarative Configuration: Configure player options directly in useYouTubePlayer hook
    • Automatic State Management: No need to manually manage state for common use cases
    • Reactive Events: useYouTubeEvent with two usage patterns - state-based for reactive values and callback-based for side effects
    • Better TypeScript Support: Improved type inference and autocomplete
    • Reduced Boilerplate: Significantly less code required for common operations
    • Automatic Cleanup: Hooks handle cleanup automatically, preventing memory leaks

    🎯 Improvements

    • Reduced Coupling: Eliminated ref dependencies between parent and child components
    • Simplified API: Fewer props to manage, more intuitive usage patterns
    • Better Developer Experience: Following established React Native patterns (expo-audio, expo-video)
    • Performance: More efficient event handling with automatic cleanup
    • Maintainability: Cleaner separation of concerns

    📦 Component Changes

    Removed

    • YoutubePlayer component (replaced by YoutubeView)
    • PlayerControls ref interface
    • ❌ Direct event props (onReady, onStateChange, onProgress, etc.)

    Added

    • YoutubeView component
    • useYouTubePlayer hook
    • useYouTubeEvent hook
    • ✅ Simplified prop interface

    📚 Migration Guide

    For detailed migration examples and step-by-step instructions, see our Migration Guide.

    Key migration steps:

    1. Replace YoutubePlayer with YoutubeView + useYouTubePlayer
    2. Convert event props to useYouTubeEvent hooks (state-based or callback-based)
    3. Move playerVars to useYouTubePlayer config
    4. Replace ref-based method calls with direct player method calls
    5. Remove manual state management for events

    ⚠️ Breaking Changes

    • API Surface: Complete API redesign, no backward compatibility
    • Event Handling: Manual event listeners replaced with reactive hooks
    • Component Structure: YoutubePlayer split into YoutubeView + hooks

    🐛 Bug Fixes

    • Fixed memory leaks from improper event cleanup
    • Better handling of rapid video ID changes
    • Manage multiple players independently

    📖 Documentation

    • Complete API documentation rewrite
    • Added migration guide from v1
    • Updated all examples to use v2 API
    • Added TypeScript usage examples

    Previous Versions

    [1.x.x] - Legacy Version

    See v1 documentation for the previous imperative API.

Patch Changes

  • Updated dependencies [ae4cc4d]
    • @react-native-youtube-bridge/react@2.0.0
    • @react-native-youtube-bridge/core@2.0.0

@react-native-youtube-bridge/web@2.0.0

Major Changes

  • ae4cc4d: feat!: introduce hooks-based API for v2.0

    [!important]
    BREAKING CHANGE: Complete API Redesign with React Hooks

    New Hooks-Based Architecture

    • useYouTubePlayer(videoId, config) - Creates a player instance with declarative configuration
    • useYouTubeEvent(player, eventName, intervalOrDefault?, deps?) - Reactive event handling with complete type inference
    • YoutubeView - Simplified view component that accepts a player instance

    Migration from v1 to v2

    Before (v1):

    // Imperative, ref-based API
    const playerRef = useRef < PlayerControls > null;
    
    <YoutubePlayer
      ref={playerRef}
      source={videoId}
      onReady={handleReady}
      onStateChange={handleStateChange}
      onProgress={handleProgress}
      playerVars={{ autoplay: true }}
    />;
    
    // Manual event handlers and state management
    const [isPlaying, setIsPlaying] = useState(false);
    const handleStateChange = (state) =>
      setIsPlaying(state === PlayerState.PLAYING);

    After (v2):

    // Declarative, hooks-based API
    const player = useYouTubePlayer(videoId, {
      autoplay: true,
      controls: true,
      playsinline: true,
    });
    
    <YoutubeView player={player} />;
    
    // Reactive state with automatic updates - two usage patterns:
    
    // 1. State-based (returns reactive values)
    const playbackRate = useYouTubeEvent(player, "playbackRateChange", 1);
    const progress = useYouTubeEvent(player, "progress", 1000); // 1000ms interval
    const state = useYouTubeEvent(player, "stateChange");
    
    const isPlaying = state === PlayerState.PLAYING;
    
    // 2. Callback-based (for side effects)
    useYouTubeEvent(player, "ready", (playerInfo) => {
      console.log("Player ready:", playerInfo);
    });
    
    useYouTubeEvent(player, "error", (error) => {
      console.error("Player error:", error);
    });

    ✨ New Features

    • Declarative Configuration: Configure player options directly in useYouTubePlayer hook
    • Automatic State Management: No need to manually manage state for common use cases
    • Reactive Events: useYouTubeEvent with two usage patterns - state-based for reactive values and callback-based for side effects
    • Better TypeScript Support: Improved type inference and autocomplete
    • Reduced Boilerplate: Significantly less code required for common operations
    • Automatic Cleanup: Hooks handle cleanup automatically, preventing memory leaks

    🎯 Improvements

    • Reduced Coupling: Eliminated ref dependencies between parent and child components
    • Simplified API: Fewer props to manage, more intuitive usage patterns
    • Better Developer Experience: Following established React Native patterns (expo-audio, expo-video)
    • Performance: More efficient event handling with automatic cleanup
    • Maintainability: Cleaner separation of concerns

    📦 Component Changes

    Removed

    • YoutubePlayer component (replaced by YoutubeView)
    • PlayerControls ref interface
    • ❌ Direct event props (onReady, onStateChange, onProgress, etc.)

    Added

    • YoutubeView component
    • useYouTubePlayer hook
    • useYouTubeEvent hook
    • ✅ Simplified prop interface

    📚 Migration Guide

    For detailed migration examples and step-by-step instructions, see our Migration Guide.

    Key migration steps:

    1. Replace YoutubePlayer with YoutubeView + useYouTubePlayer
    2. Convert event props to useYouTubeEvent hooks (state-based or callback-based)
    3. Move playerVars to useYouTubePlayer config
    4. Replace ref-based method calls with direct player method calls
    5. Remove manual state management for events

    ⚠️ Breaking Changes

    • API Surface: Complete API redesign, no backward compatibility
    • Event Handling: Manual event listeners replaced with reactive hooks
    • Component Structure: YoutubePlayer split into YoutubeView + hooks

    🐛 Bug Fixes

    • Fixed memory leaks from improper event cleanup
    • Better handling of rapid video ID changes
    • Manage multiple players independently

    📖 Documentation

    • Complete API documentation rewrite
    • Added migration guide from v1
    • Updated all examples to use v2 API
    • Added TypeScript usage examples

    Previous Versions

    [1.x.x] - Legacy Version

    See v1 documentation for the previous imperative API.

Patch Changes

  • Updated dependencies [ae4cc4d]
    • @react-native-youtube-bridge/react@2.0.0
    • @react-native-youtube-bridge/core@2.0.0

@auto-assign auto-assign bot requested a review from saseungmin July 10, 2025 14:39
@coderabbitai
Copy link

coderabbitai bot commented Jul 10, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Join our Discord community for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot force-pushed the changeset-release/main branch from d096f78 to 7954f59 Compare July 15, 2025 06:11
@github-actions github-actions bot force-pushed the changeset-release/main branch from 7954f59 to 7596cbb Compare July 15, 2025 07:56
@saseungmin saseungmin merged commit 323c409 into main Jul 15, 2025
1 check passed
@saseungmin saseungmin deleted the changeset-release/main branch July 15, 2025 07:58
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