Skip to content

Commit 70b2089

Browse files
committed
chore: safari support
1 parent a9c544d commit 70b2089

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/lib/client/adapters/webcontainer/index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ const converter = new AnsiToHtml({
1616
/** @type {import('@webcontainer/api').WebContainer} Web container singleton */
1717
let vm;
1818

19+
function webcontainer_is_supported() {
20+
// @ts-ignore
21+
return 'function' === typeof Atomics.waitAsync;
22+
}
23+
1924
/**
2025
* @param {import('svelte/store').Writable<string | null>} base
2126
* @param {import('svelte/store').Writable<Error | null>} error
@@ -25,8 +30,8 @@ let vm;
2530
* @returns {Promise<import('$lib/types').Adapter>}
2631
*/
2732
export async function create(base, error, progress, logs, warnings) {
28-
if (/safari/i.test(navigator.userAgent) && !/chrome/i.test(navigator.userAgent)) {
29-
throw new Error('WebContainers are not supported by Safari');
33+
if (/safari/i.test(navigator.userAgent) && !/chrome/i.test(navigator.userAgent) && !webcontainer_is_supported()) {
34+
throw new Error('WebContainers are not supported by Safari 16.3 or earlier');
3035
}
3136

3237
progress.set({ value: 0, text: 'loading files' });

src/routes/tutorial/[slug]/Loading.svelte

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,16 @@
1010
1111
/** @type {string} */
1212
export let status;
13+
14+
function webcontainer_is_supported() {
15+
// @ts-ignore
16+
return 'function' === typeof Atomics.waitAsync;
17+
}
1318
</script>
1419

1520
<div class="loading" class:error>
1621
{#if error}
17-
{#if /safari/i.test(navigator.userAgent) && !/chrome/i.test(navigator.userAgent)}
22+
{#if /safari/i.test(navigator.userAgent) && !/chrome/i.test(navigator.userAgent) && !webcontainer_is_supported()}
1823
<p>This app requires modern web platform features. Please use a browser other than Safari.</p>
1924
{:else}
2025
<small>{error.message}</small>

0 commit comments

Comments
 (0)