Skip to content

Conversation

@saseungmin
Copy link
Member

@saseungmin saseungmin commented Jun 23, 2025

Summary by CodeRabbit

  • New Features

    • Introduced a monorepo structure with separate core, React, React Native, and web packages for the YouTube player bridge.
    • Added a web implementation of the YouTube player, including a new React component for embedding and controlling YouTube videos.
    • Provided new React hooks for player control and video ID extraction.
  • Documentation

    • Added comprehensive English and Korean README files and a changelog for the React Native package.
  • Refactor

    • Modularized type definitions, constants, and utility functions for improved maintainability and code sharing.
    • Updated import paths across packages to use shared core modules.
  • Bug Fixes

    • Improved error handling and messaging for player commands and state changes.
  • Chores

    • Updated TypeScript, Babel, and build configurations for all packages.
    • Enhanced CI workflow and pre-commit hooks for better code quality and reliability.

@changeset-bot
Copy link

changeset-bot bot commented Jun 23, 2025

⚠️ No Changeset found

Latest commit: 89c0ffe

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@coderabbitai
Copy link

coderabbitai bot commented Jun 23, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This change restructures the project into a monorepo with distinct core, react, and web packages, centralizing types, constants, and utilities. It introduces new package configurations, refactors imports/exports, and updates build, lint, and typecheck scripts. The YouTube player logic is modularized, with enhanced type safety, error code management, and improved documentation across packages.

Changes

Files / Groups Change Summary
Monorepo/Package Management
package.json, tsconfig.base.json, biome.json, lefthook.yml, .github/workflows/ci.yml
Refactored root configuration for monorepo structure; added workspace management, updated scripts, lint/typecheck/build commands, and CI steps.
Core Package Creation
packages/core/package.json, tsconfig.json, tsdown.config.ts, global.d.ts, src/constants.ts, src/index.ts, src/YoutubePlayerCore.ts, src/types/index.ts, src/types/iframe.ts, src/types/webview.ts, src/utils.ts
Introduced core package with centralized types, constants (e.g., ERROR_CODES), utility functions, and main player logic. Added build/typecheck config and improved type safety.
React Package Creation
packages/react/package.json, tsconfig.json, tsdown.config.ts, src/hooks/index.ts, src/hooks/useYoutubePlayer.ts, src/hooks/useYoutubeVideoId.ts, src/index.ts
Added react-specific hooks, package config, and build/typecheck scripts. Refactored imports to use core package.
Web Package Creation
packages/web/package.json, tsconfig.json, vite-env.d.ts, vite.config.ts, global.d.ts, src/index.ts, src/YoutubePlayer.tsx, src/hooks/useWebView.ts, src/types/message.ts
Added web package with YouTube player implementation, messaging hooks, and build config (Vite). Refactored types and imports to use core package.
React Native Package Updates
packages/react-native-youtube-bridge/package.json, babel.config.js, tsconfig.json, tsconfig.build.json, .gitignore, CHANGELOG.md, README.md, README-ko_kr.md, src/YoutubePlayer.tsx, src/YoutubePlayer.web.tsx, src/hooks/useCreateLocalPlayerHtml.ts, src/index.tsx, src/types/message.ts, src/types/youtube.ts, src/utils/youtube.ts
Updated for monorepo: new docs, changelog, type definitions, refactored imports/exports to use core and react packages, and improved player prop typing.
Example Project
example/babel.config.js, metro.config.js, package.json, tsconfig.json
Updated config to reference new package structure, adjusted Babel and Metro setup, and updated dependencies.
Web App
web/package.json, tsconfig.app.json, vite.config.ts, src/App.tsx, src/utils/index.ts
Simplified web app to use new web package, removed custom logic, and updated module resolution and build scripts.
Removed/Deleted
tsconfig.build.json, web/src/utils/index.ts
Removed obsolete build config and unused utility.

Sequence Diagram(s)

sequenceDiagram
    participant App as App/Example
    participant RN as React Native Package
    participant Core as Core Package
    participant ReactPkg as React Package
    participant Web as Web Package

    App->>RN: Uses YoutubePlayer component
    RN->>Core: Imports types, constants, utils
    RN->>ReactPkg: Imports hooks (useYouTubeVideoId, useYouTubePlayer)
    Web->>ReactPkg: Imports hooks
    ReactPkg->>Core: Imports core logic/types
    App->>Web: Uses YoutubePlayer (web)
    Web->>Core: Uses types, constants, utils
Loading

Possibly related PRs

  • #7: Both PRs modify or enhance the progressInterval property and its handling in the YouTube player component.
  • #29: Both PRs introduce or modify support for rendering modes and configuration, especially the webViewUrl prop for flexible rendering.
  • #18: Both PRs refactor and centralize error code definitions and their usage in player components.

Poem

In a warren of code, the rabbits did hop,
Splitting core from the leaves, right up to the top!
Types and hooks now centralized,
Docs in two tongues, well-organized.
With monorepo magic, the bridge is reborn—
YouTube will play, from dusk until dawn!
🐇✨


📜 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 ec141cc and 89c0ffe.

⛔ Files ignored due to path filters (3)
  • bun.lock is excluded by !**/*.lock
  • example/bun.lock is excluded by !**/*.lock
  • web/bun.lock is excluded by !**/*.lock
📒 Files selected for processing (57)
  • .github/workflows/ci.yml (2 hunks)
  • biome.json (1 hunks)
  • example/babel.config.js (1 hunks)
  • example/metro.config.js (1 hunks)
  • example/package.json (1 hunks)
  • example/tsconfig.json (1 hunks)
  • lefthook.yml (1 hunks)
  • package.json (3 hunks)
  • packages/core/global.d.ts (1 hunks)
  • packages/core/package.json (1 hunks)
  • packages/core/src/YoutubePlayerCore.ts (3 hunks)
  • packages/core/src/constants.ts (1 hunks)
  • packages/core/src/index.ts (1 hunks)
  • packages/core/src/types/iframe.ts (1 hunks)
  • packages/core/src/types/index.ts (2 hunks)
  • packages/core/src/types/webview.ts (1 hunks)
  • packages/core/src/utils.ts (1 hunks)
  • packages/core/tsconfig.json (1 hunks)
  • packages/core/tsdown.config.ts (1 hunks)
  • packages/react-native-youtube-bridge/.gitignore (1 hunks)
  • packages/react-native-youtube-bridge/CHANGELOG.md (1 hunks)
  • packages/react-native-youtube-bridge/README-ko_kr.md (1 hunks)
  • packages/react-native-youtube-bridge/README.md (1 hunks)
  • packages/react-native-youtube-bridge/babel.config.js (1 hunks)
  • packages/react-native-youtube-bridge/package.json (1 hunks)
  • packages/react-native-youtube-bridge/src/YoutubePlayer.tsx (1 hunks)
  • packages/react-native-youtube-bridge/src/YoutubePlayer.web.tsx (1 hunks)
  • packages/react-native-youtube-bridge/src/hooks/useCreateLocalPlayerHtml.ts (1 hunks)
  • packages/react-native-youtube-bridge/src/index.tsx (1 hunks)
  • packages/react-native-youtube-bridge/src/types/message.ts (1 hunks)
  • packages/react-native-youtube-bridge/src/types/youtube.ts (1 hunks)
  • packages/react-native-youtube-bridge/src/utils/youtube.ts (1 hunks)
  • packages/react-native-youtube-bridge/tsconfig.build.json (2 hunks)
  • packages/react-native-youtube-bridge/tsconfig.json (1 hunks)
  • packages/react/package.json (1 hunks)
  • packages/react/src/hooks/index.ts (1 hunks)
  • packages/react/src/hooks/useYoutubePlayer.ts (3 hunks)
  • packages/react/src/hooks/useYoutubeVideoId.ts (1 hunks)
  • packages/react/src/index.ts (1 hunks)
  • packages/react/tsconfig.json (1 hunks)
  • packages/react/tsdown.config.ts (1 hunks)
  • packages/web/global.d.ts (1 hunks)
  • packages/web/package.json (1 hunks)
  • packages/web/src/YoutubePlayer.tsx (1 hunks)
  • packages/web/src/hooks/useWebView.ts (3 hunks)
  • packages/web/src/index.ts (1 hunks)
  • packages/web/src/types/message.ts (1 hunks)
  • packages/web/tsconfig.json (1 hunks)
  • packages/web/vite-env.d.ts (1 hunks)
  • packages/web/vite.config.ts (1 hunks)
  • tsconfig.base.json (1 hunks)
  • tsconfig.build.json (0 hunks)
  • web/package.json (1 hunks)
  • web/src/App.tsx (1 hunks)
  • web/src/utils/index.ts (0 hunks)
  • web/tsconfig.app.json (1 hunks)
  • web/vite.config.ts (1 hunks)
✨ 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

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

Latest commit: a10788d
Status: ✅  Deploy successful!
Preview URL: https://573fa6e8.react-native-youtube-bridge.pages.dev
Branch Preview URL: https://refactor-monorepo.react-native-youtube-bridge.pages.dev

View logs

@cloudflare-workers-and-pages
Copy link

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

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

Latest commit: 89c0ffe
Status: ✅  Deploy successful!
Preview URL: https://56a80029.react-native-youtube-bridge-example.pages.dev
Branch Preview URL: https://refactor-monorepo.react-native-youtube-bridge-example.pages.dev

View logs

@saseungmin saseungmin merged commit 5f9e3ee into main Jun 23, 2025
5 checks passed
@saseungmin saseungmin deleted the refactor/monorepo branch June 23, 2025 14:36
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: 7

🧹 Nitpick comments (10)
packages/react-native-youtube-bridge/.gitignore (1)

1-1: Align .gitignore with monorepo root patterns

Consider extending this .gitignore to include other common build artifacts and OS files (e.g., node_modules/, dist/, .DS_Store) for consistency across all packages.

packages/core/src/constants.ts (1)

14-15: Add unit tests for URL-matching regex

The MATCH_URL_YOUTUBE regex is complex and critical to correct parsing. Consider adding targeted unit tests to cover all supported URL formats and prevent future regressions.

packages/core/src/utils.ts (1)

13-16: Consider extracting video-ID length.
The validateVideoId function hardcodes 11 as the ID length. You may centralize this value (e.g. VIDEO_ID_LENGTH) in constants.ts to keep your ID-validation logic and URL-matching constants in sync.

web/tsconfig.app.json (1)

24-26: Centralize path mappings.
Defining the @react-native-youtube-bridge/web alias here is good for TS resolution. To avoid duplication across apps, consider moving all workspace-package path mappings into a shared base tsconfig.json, then extend it in your app-specific configs.

web/package.json (1)

7-10: Streamlined build script is appropriate.

Dropping the explicit tsc -b in favor of vite build matches the root workflow changes and speeds up the local iteration loop.

Consider adding a "type-check": "tsc --noEmit" script for local type validation if you want IDE/CLI type errors without a full CI run.

packages/web/vite.config.ts (1)

7-15: Consider adding CommonJS format for broader compatibility.

The library build configuration is well-structured with appropriate externals for React dependencies. However, consider adding CommonJS format alongside ES modules for better compatibility with older build tools and Node.js environments.

 build: {
   lib: {
     entry: 'src/index.ts',
-    formats: ['es'],
+    formats: ['es', 'cjs'],
   },
   rollupOptions: {
     external: ['react', 'react-dom'],
   },
 },
packages/react-native-youtube-bridge/CHANGELOG.md (1)

79-79: Minor style improvement suggestion.

Consider using "resolve" instead of "fix" for more formal wording.

-  - fix issue where seekTo doesn't work properly when paused without interval
+  - resolve issue where seekTo doesn't work properly when paused without interval
packages/react-native-youtube-bridge/README-ko_kr.md (2)

27-27: Add alt text for better accessibility.

Consider adding alt text to the image for better accessibility.

-  <img src="./assets/example.gif" width="600" />
+  <img src="./assets/example.gif" alt="React Native YouTube Bridge example demonstration" width="600" />

242-242: Consider using a markdown link for the bare URL.

For better markdown formatting, consider wrapping the bare URL in a link.

-2. **웹뷰 모드** (`useInlineHtml: false`)는 외부 플레이어 페이지를 로드합니다. 기본 URI는 https://react-native-youtube-bridge.pages.dev 입니다.
+2. **웹뷰 모드** (`useInlineHtml: false`)는 외부 플레이어 페이지를 로드합니다. 기본 URI는 <https://react-native-youtube-bridge.pages.dev> 입니다.
packages/web/src/YoutubePlayer.tsx (1)

9-19: Consider extracting URL parameter parsing to a utility function.

The URL parameter parsing logic could be extracted to a reusable utility function with proper type validation for better maintainability and type safety.

Consider creating a utility function:

type PlayerParams = {
  videoId: string;
  startTime: number;
  endTime?: number;
  autoplay: boolean;
  controls: boolean;
  loop: boolean;
  muted: boolean;
  playsinline: boolean;
  rel: boolean;
  origin: string;
};

function parsePlayerParams(searchParams: URLSearchParams): PlayerParams {
  const safeParseNumber = (value: string | null, defaultValue: number = 0): number => {
    const parsed = Number(value);
    return Number.isNaN(parsed) ? defaultValue : parsed;
  };

  const safeParseBool = (value: string | null): boolean => value === 'true';

  return {
    videoId: searchParams.get('videoId') ?? '',
    startTime: safeParseNumber(searchParams.get('startTime')),
    endTime: searchParams.get('endTime') ? safeParseNumber(searchParams.get('endTime')) : undefined,
    autoplay: safeParseBool(searchParams.get('autoplay')),
    controls: safeParseBool(searchParams.get('controls')),
    loop: safeParseBool(searchParams.get('loop')),
    muted: safeParseBool(searchParams.get('muted')),
    playsinline: safeParseBool(searchParams.get('playsinline')),
    rel: safeParseBool(searchParams.get('rel')),
    origin: searchParams.get('origin') ?? '',
  };
}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ec141cc and 8dcdaf8.

⛔ Files ignored due to path filters (3)
  • bun.lock is excluded by !**/*.lock
  • example/bun.lock is excluded by !**/*.lock
  • web/bun.lock is excluded by !**/*.lock
📒 Files selected for processing (57)
  • .github/workflows/ci.yml (1 hunks)
  • biome.json (1 hunks)
  • example/babel.config.js (1 hunks)
  • example/metro.config.js (1 hunks)
  • example/package.json (1 hunks)
  • example/tsconfig.json (1 hunks)
  • lefthook.yml (1 hunks)
  • package.json (3 hunks)
  • packages/core/global.d.ts (1 hunks)
  • packages/core/package.json (1 hunks)
  • packages/core/src/YoutubePlayerCore.ts (3 hunks)
  • packages/core/src/constants.ts (1 hunks)
  • packages/core/src/index.ts (1 hunks)
  • packages/core/src/types/iframe.ts (1 hunks)
  • packages/core/src/types/index.ts (2 hunks)
  • packages/core/src/types/webview.ts (1 hunks)
  • packages/core/src/utils.ts (1 hunks)
  • packages/core/tsconfig.json (1 hunks)
  • packages/core/tsdown.config.ts (1 hunks)
  • packages/react-native-youtube-bridge/.gitignore (1 hunks)
  • packages/react-native-youtube-bridge/CHANGELOG.md (1 hunks)
  • packages/react-native-youtube-bridge/README-ko_kr.md (1 hunks)
  • packages/react-native-youtube-bridge/README.md (1 hunks)
  • packages/react-native-youtube-bridge/babel.config.js (1 hunks)
  • packages/react-native-youtube-bridge/package.json (1 hunks)
  • packages/react-native-youtube-bridge/src/YoutubePlayer.tsx (1 hunks)
  • packages/react-native-youtube-bridge/src/YoutubePlayer.web.tsx (1 hunks)
  • packages/react-native-youtube-bridge/src/hooks/useCreateLocalPlayerHtml.ts (1 hunks)
  • packages/react-native-youtube-bridge/src/index.tsx (1 hunks)
  • packages/react-native-youtube-bridge/src/types/message.ts (1 hunks)
  • packages/react-native-youtube-bridge/src/types/youtube.ts (1 hunks)
  • packages/react-native-youtube-bridge/src/utils/youtube.ts (1 hunks)
  • packages/react-native-youtube-bridge/tsconfig.build.json (2 hunks)
  • packages/react-native-youtube-bridge/tsconfig.json (1 hunks)
  • packages/react/package.json (1 hunks)
  • packages/react/src/hooks/index.ts (1 hunks)
  • packages/react/src/hooks/useYoutubePlayer.ts (3 hunks)
  • packages/react/src/hooks/useYoutubeVideoId.ts (1 hunks)
  • packages/react/src/index.ts (1 hunks)
  • packages/react/tsconfig.json (1 hunks)
  • packages/react/tsdown.config.ts (1 hunks)
  • packages/web/global.d.ts (1 hunks)
  • packages/web/package.json (1 hunks)
  • packages/web/src/YoutubePlayer.tsx (1 hunks)
  • packages/web/src/hooks/useWebView.ts (3 hunks)
  • packages/web/src/index.ts (1 hunks)
  • packages/web/src/types/message.ts (1 hunks)
  • packages/web/tsconfig.json (1 hunks)
  • packages/web/vite-env.d.ts (1 hunks)
  • packages/web/vite.config.ts (1 hunks)
  • tsconfig.base.json (1 hunks)
  • tsconfig.build.json (0 hunks)
  • web/package.json (1 hunks)
  • web/src/App.tsx (1 hunks)
  • web/src/utils/index.ts (0 hunks)
  • web/tsconfig.app.json (1 hunks)
  • web/vite.config.ts (1 hunks)
💤 Files with no reviewable changes (2)
  • tsconfig.build.json
  • web/src/utils/index.ts
🧰 Additional context used
🧬 Code Graph Analysis (5)
packages/core/global.d.ts (1)
packages/core/src/types/iframe.ts (1)
  • IframeApiType (4-6)
packages/core/src/YoutubePlayerCore.ts (1)
packages/core/src/types/index.ts (1)
  • YoutubePlayerConfig (102-106)
packages/react-native-youtube-bridge/src/types/youtube.ts (1)
packages/core/src/types/index.ts (3)
  • YouTubeSource (6-6)
  • YoutubePlayerVars (71-100)
  • PlayerEvents (53-69)
packages/web/src/YoutubePlayer.tsx (3)
packages/core/src/YoutubePlayerCore.ts (1)
  • setProgressInterval (338-350)
packages/web/src/hooks/useWebView.ts (1)
  • useWebView (12-70)
packages/react/src/index.ts (2)
  • useYouTubeVideoId (1-1)
  • useYouTubePlayer (1-1)
packages/core/src/types/index.ts (2)
packages/core/src/constants.ts (1)
  • ERROR_CODES (1-12)
packages/react-native-youtube-bridge/src/index.tsx (7)
  • ERROR_CODES (4-4)
  • ProgressData (7-7)
  • YouTubeError (9-9)
  • PlayerState (5-5)
  • PlaybackQuality (8-8)
  • PlayerInfo (10-10)
  • YoutubePlayerVars (6-6)
🪛 LanguageTool
packages/react-native-youtube-bridge/CHANGELOG.md

[style] ~79-~79: Consider using a different verb for a more formal wording.
Context: ...ive logic for cases without videoId - fix issue where seekTo doesn't work properl...

(FIX_RESOLVE)

🪛 markdownlint-cli2 (0.17.2)
packages/react-native-youtube-bridge/README-ko_kr.md

27-27: Images should have alternate text (alt text)
null

(MD045, no-alt-text)


242-242: Bare URL used
null

(MD034, no-bare-urls)

🔇 Additional comments (64)
packages/core/src/constants.ts (1)

1-12: Centralized YouTube error codes look solid

The ERROR_CODES mapping cleanly centralizes code identifiers and is properly marked as const. This will improve consistency across packages.

tsconfig.base.json (2)

5-5: Verify TS support for moduleResolution: "Bundler"

Confirm that all build tools and CI environments use a TypeScript version ≥5.2 (or appropriate) so they support the "Bundler" resolution strategy.


7-8: Review declaration vs. noEmit configuration

Having "declaration": true together with "noEmit": true may prevent declaration files from being generated. Ensure package-level build configs override noEmit when producing .d.ts.

packages/react-native-youtube-bridge/src/utils/youtube.ts (1)

1-1: Verify core package import path

Please confirm that the @react-native-youtube-bridge/core package actually exports YoutubePlayerVars and that module resolution paths are configured accordingly.

packages/web/vite-env.d.ts (1)

1-1: Add Vite client type declaration.
This file correctly enables TypeScript support for Vite-specific environment variables in the web package.

packages/web/src/types/message.ts (1)

1-1: Centralize PlayerControls import.
Switching to @react-native-youtube-bridge/core for the PlayerControls type aligns with the monorepo’s modular architecture and avoids local duplication.

example/package.json (1)

22-25: Verify example project configuration.
You’ve replaced react-native-builder-bob with babel-plugin-module-resolver in devDependencies. Confirm that your babel.config.js or .babelrc includes the module-resolver plugin setup and remove any stale Builder Bob references from the Metro configuration.

packages/core/src/utils.ts (1)

1-11: Centralize YouTube URL regex.
Importing MATCH_URL_YOUTUBE from constants.ts removes inline duplication and improves maintainability. Ensure that the regex in MATCH_URL_YOUTUBE has a capturing group for the video ID at index 1.

.github/workflows/ci.yml (1)

48-48: ```bash
#!/usr/bin/env bash

Enumerate build scripts in each package.json (excluding node_modules)

find . -type f -name 'package.json' ! -path '/node_modules/' | while IFS= read -r file; do
script=$(jq -r '.scripts.build // "MISSING"' "$file")
echo "$file -> $script"
done


</details>
<details>
<summary>packages/web/global.d.ts (1)</summary>

`1-1`: **Verify `ReceiveMessage` import path and global declaration**  
The import was updated to `./src/types/message`. Ensure that `message.ts` exports `ReceiveMessage` and that this `global.d.ts` is included by TypeScript (via `tsconfig.json` `include` or `typeRoots`).  
  
```shell
#!/bin/bash
# Check that ReceiveMessage is exported correctly
rg -q "export (type )?ReceiveMessage" packages/web/src/types/message.ts \
  && echo "ReceiveMessage export found" || echo "Missing ReceiveMessage export"
packages/web/src/index.ts (1)

1-1: Re-export YoutubePlayer at package entry
This aligns the package’s public API with the new component. Ensure that package.json’s "exports" or "main" field points to this index.ts so consumers can import it directly.

example/tsconfig.json (1)

4-6: Let’s extract the full extraNodeModules block to see if the alias is defined:

#!/bin/bash
# Extract extraNodeModules block from Metro config
awk '/config\.resolver\.extraNodeModules/,/}/' example/metro.config.js
packages/react/src/index.ts (1)

1-1: To confirm exactly how (or if) these hooks are exported, let’s pull up their definitions in packages/react/src/hooks/index.ts:

#!/bin/bash
rg -n "useYouTubePlayer" packages/react/src/hooks/index.ts || echo "useYouTubePlayer not found in hooks index"
rg -n "useYouTubeVideoId" packages/react/src/hooks/index.ts || echo "useYouTubeVideoId not found in hooks index"
packages/react/src/hooks/useYoutubeVideoId.ts (2)

1-7: LGTM! Import migration to core package looks correct.

The centralization of imports from the @react-native-youtube-bridge/core package aligns well with the monorepo structure. This properly abstracts shared types, constants, and utilities.


34-36: ```shell
#!/bin/bash

Description: Locate where ERROR_CODES is defined and confirm presence of key 1002

1. Find definition of ERROR_CODES constant

rg "ERROR_CODES" -n

2. Search for the literal key "1002" in the repo

rg "1002\s*:" -n

3. (Optional AST check) Ensure the object literal for ERROR_CODES includes 1002

ast-grep --pattern 'ERROR_CODES = { $$$ 1002: $_ $$$ }'


</details>
<details>
<summary>biome.json (1)</summary>

`9-11`: **LGTM! Biome configuration properly updated for monorepo.**

The addition of `"packages/**/*"` to includes and `"dist"` to ignore is correct for the monorepo structure. This ensures Biome processes all package source files while excluding build artifacts.

</details>
<details>
<summary>packages/core/tsconfig.json (1)</summary>

`1-8`: **Verify base TypeScript configuration exists.**

The configuration structure looks good for a monorepo package. Please ensure the base configuration file at `../../tsconfig.base.json` exists and contains appropriate settings.


```shell
#!/bin/bash
# Description: Verify the base TypeScript configuration exists
# Expected: Should find the base tsconfig file

fd --type f "tsconfig.base.json" --max-depth 1
web/vite.config.ts (1)

10-12: LGTM! Monorepo aliases configured correctly.

The aliases properly map scoped package names to their respective source entry points. This enables direct development against source files in the workspace.

Verify that the target index files exist:

#!/bin/bash
# Description: Verify alias target files exist
# Expected: All three index.ts files should exist

echo "Checking alias target files:"
ls -la packages/web/src/index.ts packages/core/src/index.ts packages/react/src/index.ts
packages/react-native-youtube-bridge/src/YoutubePlayer.web.tsx (1)

1-6: LGTM! Import reorganization aligns with monorepo structure.

The separation of imports is well-structured:

  • Core types from @react-native-youtube-bridge/core
  • React hooks from @react-native-youtube-bridge/react
  • Component-specific types remain local

This maintains good separation of concerns across packages.

packages/react-native-youtube-bridge/babel.config.js (1)

2-11: Babel overrides correctly separate source from dependencies.

Using react-native-builder-bob for your source files and @react-native/babel-preset for node_modules is the right approach to ensure consistent transpilation within the monorepo.

packages/react-native-youtube-bridge/tsconfig.json (1)

2-6: Base config extension and compiler options look solid.

Extending the root tsconfig.base.json and setting "jsx": "react-native" with the chosen libs aligns with other packages in the monorepo.

packages/react/tsdown.config.ts (1)

1-9: Consistent tsdown config for the React package.

Defining both ESM and CJS outputs with .d.ts generation aligns with other packages. This minimal setup is correct.

packages/react/tsconfig.json (1)

2-9: React package TypeScript settings look good.

Extending the base config, targeting dist, and enabling "jsx": "react-jsx" is consistent and complete.

packages/react/src/hooks/index.ts (1)

1-2: Centralized hooks export: Approved.
Re-exporting hooks simplifies imports for consumers and aligns with the monorepo modularization. Ensure the file name casing and paths (./useYoutubePlayer and ./useYoutubeVideoId) exactly match your filesystem.

packages/web/tsconfig.json (1)

1-9: Validate Web package TS config.
The config correctly extends the base, sets jsx to react-jsx, and scopes includes/excludes appropriately. Confirm that global.d.ts exists at the expected path and that no test files or other directories should be excluded.

packages/react-native-youtube-bridge/tsconfig.build.json (3)

8-8: Review lib ordering.
Targeting ESNext, DOM, and DOM.Iterable is appropriate for modern builds; just verify that DOM.Iterable is needed by your consumer code.


23-23: Verify TS version for verbatimModuleSyntax.
The "verbatimModuleSyntax": true flag requires TS 5+. Ensure your base config and CI environment are on a compatible version.


25-26: Include/exclude adjustments look good.
Explicitly including only src/**/* and excluding lib and test files keeps type-checking focused. Confirm no other directories (e.g., examples, web) need to be excluded in this package.

packages/core/tsdown.config.ts (1)

1-10: Core package build config is correct.
The tsdown setup exports both ESM and CJS bundles with .d.ts and outputs to dist, matching the repo’s build strategy.

packages/react-native-youtube-bridge/src/hooks/useCreateLocalPlayerHtml.ts (2)

1-1: Consolidated core imports: Approved.
Importing YoutubePlayerVars, escapeHtml, safeNumber, and validateVideoId from the core package centralizes validation and sanitization logic. Confirm these symbols are exported by @react-native-youtube-bridge/core.


4-4: Relative import path update: Verify path.
Switching to import { youtubeIframeScripts } from './youtubeIframeScripts' relies on the script file being adjacent. Double-check that youtubeIframeScripts.ts exists in the same directory.

packages/react-native-youtube-bridge/src/YoutubePlayer.tsx (2)

1-2: Import restructuring looks good for monorepo organization.

The imports have been correctly updated to use the new monorepo package structure, separating core functionality from React-specific hooks. This improves modularity and reusability across different platforms.


8-9: Local type imports maintained appropriately.

Good decision to keep platform-specific types (CommandType, YoutubePlayerProps) as local imports while moving shared functionality to the core package.

packages/core/global.d.ts (1)

1-9: Global TypeScript declarations are well-structured.

The global Window interface extension properly types the YouTube iframe API properties. Using a dedicated global.d.ts file is a best practice for organizing global type augmentations. The _ytApiPromise naming with underscore prefix appropriately indicates internal usage.

example/babel.config.js (1)

4-20: Babel configuration correctly updated for monorepo structure.

The migration from dynamic to static configuration makes the setup more explicit and maintainable. The module resolver aliases properly map the monorepo packages to their source directories.

Verify that the alias paths are correct relative to the example directory:

#!/bin/bash
# Verify that the aliased paths exist relative to the example directory
cd example

echo "Checking alias paths..."
for path in "../packages/react-native-youtube-bridge/src/index" "../packages/core/src/index" "../packages/react/src/index"; do
  if [ -f "$path.ts" ] || [ -f "$path.tsx" ] || [ -f "$path.js" ]; then
    echo "✓ Found: $path"
  else
    echo "✗ Missing: $path"
  fi
done
packages/core/src/types/webview.ts (2)

1-1: Import path simplification improves package organization.

The change from './youtube' to './' indicates better type organization within the core package, likely importing from a centralized index file. This aligns well with the monorepo restructuring goals.


42-50: MessageData union type is well-structured for cross-platform communication.

The MessageData type union properly covers all webview communication scenarios and maintains type safety across different message types. This is appropriate for the core package as it provides shared communication contracts.

example/metro.config.js (1)

39-39: LGTM! Metro config simplified for monorepo.

The removal of the explicit options object aligns with the monorepo restructuring. The packageName parameter is no longer needed since module resolution will be handled through the workspace configuration.

packages/react/src/hooks/useYoutubePlayer.ts (2)

1-7: LGTM! Clean import restructuring for monorepo.

The imports have been properly updated to use the centralized @react-native-youtube-bridge/core package, which improves modularity and code organization.


11-11: LGTM! Consistent class naming throughout.

The class name has been consistently updated from YouTubePlayerCore to YoutubePlayerCore across all references, maintaining consistency with the core package's naming convention.

Also applies to: 38-38, 62-62

packages/web/src/hooks/useWebView.ts (3)

1-1: LGTM! Import updated for monorepo structure.

The MessageData import has been correctly updated to use the centralized core package.


4-4: LGTM! Import path corrected.

The import path has been corrected from '../types/messages' to '../types/message', which likely reflects a file rename or consolidation.


16-16: LGTM! Simplified WebView detection.

The direct check for window.ReactNativeWebView removes unnecessary abstraction and makes the code more straightforward and readable.

Also applies to: 62-62

packages/core/src/YoutubePlayerCore.ts (3)

1-4: LGTM! Clean relative imports within the package.

The imports have been properly updated to use relative paths within the core package, improving modularity and maintainability.


6-8: LGTM! Consistent type and class naming.

The type alias has been updated to use YoutubePlayerConfig and the class has been consistently renamed to YoutubePlayerCore, maintaining naming consistency across the monorepo.

Also applies to: 10-10


375-375: LGTM! Export updated to match class name.

The default export has been correctly updated to match the renamed class.

packages/core/package.json (1)

1-47: LGTM! Well-structured core package configuration.

The package.json is properly configured for the monorepo's core package with:

  • Appropriate entry points and exports for both ESM and CommonJS
  • Private package flag for internal use
  • Clean build and type-check scripts
  • Comprehensive metadata and repository information

The configuration supports the modular architecture goals of the monorepo migration.

web/src/App.tsx (1)

1-7: Excellent simplification aligned with the monorepo architecture!

The refactoring effectively delegates YouTube player logic to the dedicated web package, following the single responsibility principle.

packages/react-native-youtube-bridge/src/types/message.ts (1)

1-34: Well-structured type definitions for YouTube player messaging

The union types provide excellent type safety for message handling and command execution in the React Native bridge.

packages/web/package.json (1)

1-57: Well-configured web package for the monorepo

The package setup correctly uses workspace dependencies and appropriate build tooling with Vite. The entry points are properly configured for both CommonJS and ES module consumers.

packages/core/src/types/iframe.ts (1)

1-6: Good architectural decision removing global augmentation

Moving from global Window interface augmentation to an explicit IframeApiType interface improves type safety and prevents global namespace pollution.

packages/react-native-youtube-bridge/src/index.tsx (1)

1-13: LGTM! Clean refactoring to centralize types in core package.

The refactoring to import types from @react-native-youtube-bridge/core instead of local modules is well-executed. This centralization improves code organization and reusability across the monorepo.

packages/core/src/index.ts (1)

1-17: Excellent core package structure with well-organized exports.

The export organization is clean and logical:

  • Types are grouped together (lines 1-12)
  • WebView-specific types are separate (line 13)
  • Core class, utilities, and constants are clearly defined (lines 14-16)

This structure will make the core package easy to consume and maintain.

packages/react-native-youtube-bridge/README.md (1)

1-274: Outstanding comprehensive documentation with excellent examples.

This README provides thorough coverage of all library features:

  • Clear installation and basic usage instructions
  • Comprehensive event handling examples with proper useCallback usage
  • Detailed player control examples
  • Configuration options for parameters and styling
  • Advanced rendering modes and troubleshooting guidance

The documentation quality is exceptional and will greatly help users adopt the library.

packages/react-native-youtube-bridge/CHANGELOG.md (1)

1-92: Well-structured changelog with comprehensive version history.

The changelog effectively documents the library's evolution with clear categorization of changes (breaking changes, features, patches) and good detail level.

packages/react-native-youtube-bridge/README-ko_kr.md (1)

1-274: Excellent Korean documentation with comprehensive coverage.

The Korean README provides thorough translation of all features and examples, maintaining the same high quality as the English version. This will greatly help Korean-speaking developers adopt the library.

packages/web/src/YoutubePlayer.tsx (2)

27-89: Well-structured player configuration with proper event handling.

The YouTube player configuration correctly uses the imported hooks and properly handles all events by sending messages through the WebView interface.


177-188: Clean component structure.

The render method is simple and properly uses the ref from the YouTube player hook.

packages/react-native-youtube-bridge/src/types/youtube.ts (1)

1-50: Well-structured type definitions with comprehensive documentation.

The YoutubePlayerProps type is properly defined with:

  • Clear JSDoc comments explaining each property
  • Platform-specific annotations for native-only properties
  • Proper type imports from the core package
  • Thoughtful property constraints (e.g., WebViewProps exclusions)
packages/react-native-youtube-bridge/package.json (1)

1-108: Properly configured package for the monorepo structure.

The package.json correctly:

  • Uses workspace dependencies for internal packages
  • Defines appropriate peer dependency version ranges
  • Configures react-native-builder-bob for building
  • Includes all necessary files for distribution
package.json (2)

14-14: Verify the change from biome check to biome format.

The lint script was changed from biome check --write . to biome format packages/** --write. This changes the behavior from running both linting and formatting to only formatting.

Was this change intentional? If you want to maintain both linting and formatting, consider:

-"lint": "biome format packages/** --write",
+"lint": "biome check packages/** --write",

Or add separate scripts:

"lint": "biome format packages/** --write",
+"lint:check": "biome check packages/**",
+"format": "biome format packages/** --write",

2-29: Successful monorepo structure transformation.

The package.json has been properly converted to a monorepo root with:

  • Private flag to prevent accidental publishing
  • Workspace configuration for package management
  • Workspace-filtered scripts for building and type checking
  • Removal of package-specific fields
packages/core/src/types/index.ts (2)

1-26: Excellent use of const assertions for type-safe error handling.

The error types are well-defined with:

  • Strong typing using the ERROR_CODES constant
  • Clear type aliases for code and message
  • Proper JSDoc documentation with reference links

27-100: Comprehensive type definitions for the YouTube player core.

The type definitions are well-structured with:

  • Clear enum for PlayerState
  • Flexible YouTubeSource type supporting multiple input formats
  • Detailed JSDoc comments explaining browser policy considerations
  • Optional properties with sensible defaults

Comment on lines 8 to +9
glob: "*.{js,ts, jsx, tsx}"
run: npx tsc
run: bun run typecheck
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix glob pattern spacing in types hook

The glob pattern "*.{js,ts, jsx, tsx}" contains spaces that will prevent matching .jsx and .tsx. Align it with the lint glob: "*.{js,ts,jsx,tsx}".

🤖 Prompt for AI Agents
In lefthook.yml at lines 8 to 9, the glob pattern for the `types` hook includes
spaces inside the braces, which breaks matching for `.jsx` and `.tsx` files.
Remove the spaces so the pattern reads `"*.{js,ts,jsx,tsx}"` to correctly match
all intended file extensions.

"jsx": "react-native",
"lib": ["DOM", "DOM.Iterable", "ESNext"]
},
"include": ["src/*"]
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Include pattern may be too restrictive.

"include": ["src/*"] only matches files directly under src/. To pick up nested directories, change it to:

- "include": ["src/*"]
+ "include": ["src/**/*"]
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"include": ["src/*"]
"include": ["src/**/*"]
🤖 Prompt for AI Agents
In packages/react-native-youtube-bridge/tsconfig.json at line 7, the include
pattern "src/*" only matches files directly inside the src directory and misses
files in nested subdirectories. Change the include pattern to "src/**/*" to
recursively include all files in src and its subdirectories.

}

window.onYouTubeIframeAPIReady = () => {
window.window.onYouTubeIframeAPIReady = () => {
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix the duplicate window reference.

There appears to be a typo with the double window reference. This should likely be window.onYouTubeIframeAPIReady instead of window.window.onYouTubeIframeAPIReady.

-      window.window.onYouTubeIframeAPIReady = () => {
+      window.onYouTubeIframeAPIReady = () => {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
window.window.onYouTubeIframeAPIReady = () => {
window.onYouTubeIframeAPIReady = () => {
🤖 Prompt for AI Agents
In packages/core/src/YoutubePlayerCore.ts at line 52, fix the typo by removing
the duplicate window reference. Change `window.window.onYouTubeIframeAPIReady`
to `window.onYouTubeIframeAPIReady` to correctly assign the callback on the
global window object.

"name": "@react-native-youtube-bridge/react",
"version": "0.0.1",
"description": "React implementation for react-native-youtube-bridge",
"private": true,
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Conflicting package privacy settings

The package is marked as "private": true but has publishConfig.access: "public". If this package is intended for public npm publishing, remove the "private": true field.

-  "private": true,

Also applies to: 41-43

🤖 Prompt for AI Agents
In packages/react/package.json at lines 5 and 41-43, the package is marked as
"private": true but also has publishConfig.access set to "public", which is
conflicting. To fix this, remove the "private": true field if the package is
intended to be published publicly on npm, ensuring the privacy settings are
consistent with the publishConfig.

Comment on lines +164 to +172
if (message.id && window.ReactNativeWebView) {
window.ReactNativeWebView.postMessage(
JSON.stringify({
type: 'commandResult',
id: message.id,
result,
}),
);
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Use sendMessage for consistency.

-if (message.id && window.ReactNativeWebView) {
-  window.ReactNativeWebView.postMessage(
-    JSON.stringify({
-      type: 'commandResult',
-      id: message.id,
-      result,
-    }),
-  );
-}
+if (message.id) {
+  sendMessage({
+    type: 'commandResult',
+    id: message.id,
+    result,
+  });
+}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (message.id && window.ReactNativeWebView) {
window.ReactNativeWebView.postMessage(
JSON.stringify({
type: 'commandResult',
id: message.id,
result,
}),
);
}
if (message.id) {
sendMessage({
type: 'commandResult',
id: message.id,
result,
});
}
🤖 Prompt for AI Agents
In packages/web/src/YoutubePlayer.tsx around lines 164 to 172, the code uses
window.ReactNativeWebView.postMessage to send messages, but for consistency with
the rest of the codebase, replace this call with
window.ReactNativeWebView.sendMessage instead. Update the method call to use
sendMessage while keeping the message payload and structure unchanged.

Comment on lines +112 to +122
if (message.id && window.ReactNativeWebView) {
window.ReactNativeWebView.postMessage(
JSON.stringify({
type: 'error',
id: message.id,
error: { code: -4, message: `Command not found: ${message.command}` },
}),
);
}
return;
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Use the sendMessage function instead of direct WebView access.

The code directly accesses window.ReactNativeWebView to send error messages, which is inconsistent with the sendMessage function provided by useWebView hook. This violates the abstraction layer.

Replace direct WebView access with the sendMessage function:

-if (message.id && window.ReactNativeWebView) {
-  window.ReactNativeWebView.postMessage(
-    JSON.stringify({
-      type: 'error',
-      id: message.id,
-      error: { code: -4, message: `Command not found: ${message.command}` },
-    }),
-  );
-}
+if (message.id) {
+  sendMessage({
+    type: 'error',
+    id: message.id,
+    error: { code: -4, message: `Command not found: ${message.command}` },
+  });
+}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (message.id && window.ReactNativeWebView) {
window.ReactNativeWebView.postMessage(
JSON.stringify({
type: 'error',
id: message.id,
error: { code: -4, message: `Command not found: ${message.command}` },
}),
);
}
return;
}
if (message.id) {
sendMessage({
type: 'error',
id: message.id,
error: { code: -4, message: `Command not found: ${message.command}` },
});
}
return;
}
🤖 Prompt for AI Agents
In packages/web/src/YoutubePlayer.tsx around lines 112 to 122, the code directly
accesses window.ReactNativeWebView to post error messages, bypassing the
abstraction provided by the sendMessage function from the useWebView hook. To
fix this, replace the direct window.ReactNativeWebView.postMessage call with a
call to sendMessage, passing the same error message object serialized as JSON.
This ensures consistent use of the abstraction layer for sending messages.

Comment on lines +140 to +160
if (message.id && window.ReactNativeWebView) {
window.ReactNativeWebView.postMessage(
JSON.stringify({
type: 'commandResult',
id: message.id,
result: r,
}),
);
}
})
.catch((err) => {
if (message.id && window.ReactNativeWebView) {
window.ReactNativeWebView.postMessage(
JSON.stringify({
type: 'error',
id: message.id,
error: { code: -5, message: err?.message || String(err) },
}),
);
}
});
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Refactor message sending to use the sendMessage function consistently.

Similar to the previous comment, these promise handlers should use the sendMessage function for consistency.

Apply this pattern throughout the promise handlers:

-if (message.id && window.ReactNativeWebView) {
-  window.ReactNativeWebView.postMessage(
-    JSON.stringify({
-      type: 'commandResult',
-      id: message.id,
-      result: r,
-    }),
-  );
-}
+if (message.id) {
+  sendMessage({
+    type: 'commandResult',
+    id: message.id,
+    result: r,
+  });
+}

And for the error case:

-if (message.id && window.ReactNativeWebView) {
-  window.ReactNativeWebView.postMessage(
-    JSON.stringify({
-      type: 'error',
-      id: message.id,
-      error: { code: -5, message: err?.message || String(err) },
-    }),
-  );
-}
+if (message.id) {
+  sendMessage({
+    type: 'error',
+    id: message.id,
+    error: { code: -5, message: err?.message || String(err) },
+  });
+}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (message.id && window.ReactNativeWebView) {
window.ReactNativeWebView.postMessage(
JSON.stringify({
type: 'commandResult',
id: message.id,
result: r,
}),
);
}
})
.catch((err) => {
if (message.id && window.ReactNativeWebView) {
window.ReactNativeWebView.postMessage(
JSON.stringify({
type: 'error',
id: message.id,
error: { code: -5, message: err?.message || String(err) },
}),
);
}
});
.then((r) => {
if (message.id) {
sendMessage({
type: 'commandResult',
id: message.id,
result: r,
});
}
})
.catch((err) => {
if (message.id) {
sendMessage({
type: 'error',
id: message.id,
error: { code: -5, message: err?.message || String(err) },
});
}
});
🤖 Prompt for AI Agents
In packages/web/src/YoutubePlayer.tsx between lines 140 and 160, the code
directly calls window.ReactNativeWebView.postMessage to send messages in promise
handlers. Refactor these handlers to use the existing sendMessage function
instead, passing the appropriate message object to it. This ensures consistent
message sending throughout the file.

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