Skip to content

Conversation

@saseungmin
Copy link
Member

@saseungmin saseungmin commented Jun 17, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Improved reliability of command execution and error handling within the YouTube player.
    • Enhanced style application for the YouTube player wrapper to ensure consistent rendering.
  • Chores

    • Updated internal scripts for launching Android and iOS apps.
    • Adjusted dependency versions for improved compatibility and stability.
    • Updated ignore rules to exclude native directories from version control.
    • Refined CI cache strategy and installation steps for more consistent dependency management.
  • New Features

    • Embedded enhanced messaging support in YouTube iframe for improved command handling.

@coderabbitai
Copy link

coderabbitai bot commented Jun 17, 2025

Walkthrough

The updates include changes to project configuration and source files. The .gitignore now excludes native build directories. The example/package.json modifies script commands and adjusts dependency versions. The main package.json updates a devDependency. In the source, YoutubePlayer.tsx refines command handling and WebView messaging, while YoutubePlayerWrapper.tsx now flattens style arrays before applying them. The GitHub Actions cache keys and install step conditions were also adjusted. Additionally, a new JavaScript snippet for command execution was added to youtubeIframeScripts and integrated into the local player HTML generation.

Changes

File(s) Change Summary
.gitignore Added example/ios/ and example/android/ to ignore list under "expo native" section.
example/package.json Changed Android/iOS scripts to use expo run:* commands; downgraded react-native-webview; updated a devDependency.
package.json Updated react-native-builder-bob devDependency version.
src/YoutubePlayer.tsx Improved command messaging: switched to injected JS for commands, added error/result handling, memoized dataDetectorTypes.
src/YoutubePlayerWrapper.tsx Used StyleSheet.flatten to combine style arrays into a single object before passing to View.
.github/actions/setup/action.yml Modified Bun cache restore keys to a more specific pattern; removed conditional install step to always run install.
src/hooks/useCreateLocalPlayerHtml.ts Inserted youtubeIframeScripts.receiveMessage snippet into generated iframe HTML script section.
src/hooks/youtubeIframeScripts.ts Added receiveMessage snippet defining window.__execCommand for command execution and messaging in iframe.

Sequence Diagram(s)

sequenceDiagram
    participant ReactNativeApp
    participant YoutubePlayer
    participant WebView
    participant JSPlayerCommands

    ReactNativeApp->>YoutubePlayer: sendCommand(command, args)
    YoutubePlayer->>WebView: injectJavaScript (calls window.__execCommand with commandData)
    WebView->>JSPlayerCommands: Execute command
    alt Success with id
        JSPlayerCommands->>WebView: Result
        WebView->>YoutubePlayer: postMessage({ type: "commandResult", result, id })
    else Command not found or error
        JSPlayerCommands->>WebView: Error
        WebView->>YoutubePlayer: postMessage({ type: "commandResult", error, id })
    end
Loading

Possibly related PRs

  • feat: support youtube iframe for web #1: Introduces a web-specific YoutubePlayer component and handles command messaging between React Native and YouTube iframe, related to the added window.__execCommand function and iframe messaging.

Poem

A hop and a skip, some code to ignore,
Native folders hidden—no clutter anymore!
Scripts now run smoother, dependencies aligned,
Commands in the player more neatly defined.
Styles are now flat, not stacked in a heap—
This bunny’s code garden is tidy and neat! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eb74a1b and f5adb30.

📒 Files selected for processing (1)
  • src/hooks/youtubeIframeScripts.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/hooks/youtubeIframeScripts.ts
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build-web
  • GitHub Check: Cloudflare Pages
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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? Create a ticket on our support page 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 docstrings to generate docstrings for this 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.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jun 17, 2025

Deploying react-native-youtube-bridge with  Cloudflare Pages  Cloudflare Pages

Latest commit: f5adb30
Status: ✅  Deploy successful!
Preview URL: https://d7a6703c.react-native-youtube-bridge.pages.dev
Branch Preview URL: https://fix-android-webview.react-native-youtube-bridge.pages.dev

View logs

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (3)
example/package.json (1)

20-20: Version divergence for react-native-webview

The example app pins 13.13.5 while the root devDependency is ^13.15.0.
Two versions in the mono-repo can bloat bundle size or mask bugs. Consider aligning both to the same minor.

src/YoutubePlayer.tsx (2)

46-47: useMemo here is unnecessary overhead

['none'] is a literal; creating it each render is negligible. Dropping useMemo simplifies the code.

-const dataDetectorTypes = useMemo(() => ['none'] as DataDetectorTypes[], []);
+const dataDetectorTypes: DataDetectorTypes[] = ['none'];

137-138: Guard verbose logs for production

console.warn inside the timeout will surface in release builds.
Wrap with if (__DEV__) to avoid leaking internal diagnostics to end-users.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 373359c and afa4f79.

⛔ Files ignored due to path filters (2)
  • bun.lock is excluded by !**/*.lock
  • example/bun.lock is excluded by !**/*.lock
📒 Files selected for processing (5)
  • .gitignore (1 hunks)
  • example/package.json (2 hunks)
  • package.json (1 hunks)
  • src/YoutubePlayer.tsx (5 hunks)
  • src/YoutubePlayerWrapper.tsx (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (5)
package.json (1)

79-79: Dev-tool bump looks fine

react-native-builder-bob moves to ^0.40.12; no red flags.

.gitignore (1)

82-85: Good call adding native build dirs

Ignoring example/ios/ and example/android/ avoids huge generated blobs in Git. 👍

example/package.json (2)

7-8: expo run:* scripts LGTM

Switching to expo run:android / ios aligns with the new native flow.


24-24: Bob dev-tool bump matches root

Consistent version across workspaces – good.

src/YoutubePlayerWrapper.tsx (1)

12-15: Style flattening improves reliability

Using StyleSheet.flatten avoids nested arrays and guarantees a single object – nice touch.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
src/hooks/youtubeIframeScripts.ts (1)

210-214: Nit: keep export list alphabetically sorted

receiveMessage was appended at an arbitrary spot. Sorting this object (or at least grouping the tracking helpers together) improves scan-ability and reduces merge conflicts.

src/hooks/useCreateLocalPlayerHtml.ts (1)

75-76: Duplicate command bridges – pick one to avoid confusion

receiveMessage introduces the new window.__execCommand API, but the old
window.addEventListener('message', …) bridge (lines 178-198) is still present.
Maintaining two parallel channels:

  • Increases bundle size.
  • Creates ambiguity about the “official” path.
  • Risks diverging behaviour.

If mobile code has migrated to __execCommand, consider removing the legacy
message listener (or guarding it behind a feature flag) to keep the surface
area minimal.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1b829ea and eb74a1b.

📒 Files selected for processing (3)
  • src/YoutubePlayer.tsx (5 hunks)
  • src/hooks/useCreateLocalPlayerHtml.ts (1 hunks)
  • src/hooks/youtubeIframeScripts.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/YoutubePlayer.tsx
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/hooks/useCreateLocalPlayerHtml.ts (1)
src/hooks/youtubeIframeScripts.ts (1)
  • youtubeIframeScripts (210-220)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build-web
  • GitHub Check: Cloudflare Pages

@saseungmin saseungmin merged commit 1226e11 into main Jun 17, 2025
6 checks passed
@saseungmin saseungmin deleted the fix/android-webview branch June 17, 2025 02:28
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