Skip to content

chore(safari): enable terminal on Safari 16.4 #31

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

Merged
merged 1 commit into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion docs/.vitepress/theme/components/Examples/WCEmbed/utils.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
/**
* Checks if WebContainer is supported on the current browser.
*/
export function isWebContainerSupported() {
export function isWebContainerSupported() {
const hasSharedArrayBuffer = 'SharedArrayBuffer' in window;
const looksLikeChrome = navigator.userAgent.toLowerCase().includes('chrome');
const looksLikeFirefox = navigator.userAgent.includes('Firefox');
const looksLikeSafari = navigator.userAgent.includes('Safari');

if (hasSharedArrayBuffer && (looksLikeChrome || looksLikeFirefox)) {
return true;
}

if (hasSharedArrayBuffer && looksLikeSafari) {
// we only support Safari 16.4 and up so we check for the version here
const match = navigator.userAgent.match(/Version\/(\d+)\.(\d+) (?:Mobile\/.*?)?Safari/);
const majorVersion = match ? Number(match?.[1]) : 0;
const minorVersion = match ? Number(match?.[2]) : 0;

return majorVersion > 16 || (majorVersion === 16 && minorVersion >= 4);
}

// Allow overriding the support check with localStorage.webcontainer_any_ua = 1
try {
return Boolean(localStorage.getItem('webcontainer_any_ua'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ async function bootWebContainer(terminal: import('xterm').Terminal) {
[
red('Incompatible Web Browser'),
'',
`WebContainers currently work in Chromium-based browsers and Firefox. We're hoping to add support for more browsers as they implement the necessary Web Platform features.`,
`WebContainers currently work in Chromium-based browsers, Firefox, and Safari 16.4. We're hoping to add support for more browsers as they implement the necessary Web Platform features.`,
'',
'Read more about browser support:',
'https://webcontainers.io/guides/browser-support',
Expand Down