Skip to content

Commit 369dd58

Browse files
chore(safari): enable terminal on Safari 16.4 (#31)
1 parent 4a6eceb commit 369dd58

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

docs/.vitepress/theme/components/Examples/WCEmbed/utils.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
11
/**
22
* Checks if WebContainer is supported on the current browser.
33
*/
4-
export function isWebContainerSupported() {
4+
export function isWebContainerSupported() {
55
const hasSharedArrayBuffer = 'SharedArrayBuffer' in window;
66
const looksLikeChrome = navigator.userAgent.toLowerCase().includes('chrome');
77
const looksLikeFirefox = navigator.userAgent.includes('Firefox');
8+
const looksLikeSafari = navigator.userAgent.includes('Safari');
89

910
if (hasSharedArrayBuffer && (looksLikeChrome || looksLikeFirefox)) {
1011
return true;
1112
}
1213

14+
if (hasSharedArrayBuffer && looksLikeSafari) {
15+
// we only support Safari 16.4 and up so we check for the version here
16+
const match = navigator.userAgent.match(/Version\/(\d+)\.(\d+) (?:Mobile\/.*?)?Safari/);
17+
const majorVersion = match ? Number(match?.[1]) : 0;
18+
const minorVersion = match ? Number(match?.[2]) : 0;
19+
20+
return majorVersion > 16 || (majorVersion === 16 && minorVersion >= 4);
21+
}
22+
1323
// Allow overriding the support check with localStorage.webcontainer_any_ua = 1
1424
try {
1525
return Boolean(localStorage.getItem('webcontainer_any_ua'));

docs/.vitepress/theme/components/Examples/WCEmbed/webcontainer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ async function bootWebContainer(terminal: import('xterm').Terminal) {
112112
[
113113
red('Incompatible Web Browser'),
114114
'',
115-
`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.`,
115+
`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.`,
116116
'',
117117
'Read more about browser support:',
118118
'https://webcontainers.io/guides/browser-support',

0 commit comments

Comments
 (0)