Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix Issue #1165: Navigator is not defined.
Cause: Today many people use NextJS for building webapps. But when they importing Peer from peerjs they get this error because when webpack compile it in server side, navigator is not present there.
Issue: link
Changes Made:
In peerjs/dist/bundel.mjs : I made change in this file as given below literally remove the error from compiling and building in simple import without using useeffect or dynamic import. Only 'use client' is defined at top.
So this means, checking the navigator in support.ts is able to solve this problem.
Now :
readonly isIOS = ["iPad", "iPhone", "iPod"].includes(navigator.platform);
Change to :
readonly isIOS = typeof navigator !== "undefined" ? (["iPad", "iPhone", "iPod"].includes(navigator.platform)) : false;;
The navigator.platform only works when navigator is available else isIOS assigned false.
Reviewer Requests:
@jonasgloning : Please review the changes and provide feedback.