-
-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Improve player initialization and build output #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Remove setTimeout from player initialization in `src/index.ts` to ensure immediate setup on mount. - Add `!playerRef.value` check to prevent re-initialization of the player. - Configure tsup to use `.mjs` for ESM and `.cjs` for CJS output formats in `tsup.config.ts`. - Bump package version to 0.0.5.
WalkthroughThis change updates the package version in Changes
Sequence Diagram(s)sequenceDiagram
participant VueComponent
participant DOM
participant IVLabsPlayer
VueComponent->>DOM: Get container reference
alt Container exists and no player
VueComponent->>IVLabsPlayer: Instantiate player immediately
IVLabsPlayer-->>VueComponent: Player instance ready
else Container missing or player exists
VueComponent-->>VueComponent: Skip initialization
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~7 minutes Possibly related PRs
Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. ✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/index.ts (1)
110-112
: Consider enhancing error handling beyond console logging.While the error handling prevents crashes, consider whether additional error reporting or state management would benefit users of the component.
You could emit an error event or set an error state:
} catch (error) { console.error('Error initializing IVLabsPlayer:', error); + if (props.onAnalyticsEvent) { + props.onAnalyticsEvent('ERROR', { error: error.message }); + } }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
package.json
(1 hunks)src/index.ts
(2 hunks)tsup.config.ts
(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/index.ts (1)
test/InteractiveVideo.test.ts (5)
wrapper
(39-53)beforeEach
(20-78)mockPlayer
(7-18)mockPlayer
(16-16)wrapper
(30-37)
🔇 Additional comments (5)
package.json (1)
3-3
: LGTM! Version bump aligns with feature improvements.The version increment from 0.0.4 to 0.0.5 appropriately reflects the player initialization improvements and build output enhancements described in the PR.
tsup.config.ts (1)
7-11
: LGTM! Build output extensions follow Node.js conventions.The
outExtension
function correctly maps ESM format to.mjs
and CJS format to.cjs
extensions, which aligns with the package.json exports configuration and follows standard Node.js module conventions.src/index.ts (3)
77-77
: LGTM! Improved comment clarity.The updated comment better describes the immediate initialization approach.
79-80
: LGTM! Improved container validation and duplicate prevention.The local variable assignment and the
!playerRef.value
check effectively prevent multiple player initializations while maintaining clear code flow.
89-113
: Tests remain compatible after removing thesetTimeout
wrapper—no changes required.We reviewed the component’s
onMounted
hook insrc/index.ts
(initialization is now immediate) and the test suite intest/InteractiveVideo.test.ts
(which still usesvi.useFakeTimers()
andvi.runAllTimers()
). Since Vue calls themounted
hook synchronously, the player is instantiated immediately upon mounting, and the existing tests still pass without any pending timers.• No failures are introduced by the removal of
setTimeout
.
• TherunAllTimers()
calls are now no-ops but do not break any assertions.
• You may optionally remove the fake-timer setup in tests to simplify, but it isn’t strictly required.
Summary by CodeRabbit