diff --git a/src/lib/client/adapters/webcontainer/index.js b/src/lib/client/adapters/webcontainer/index.js index 3b98cd5ca..274ef154d 100644 --- a/src/lib/client/adapters/webcontainer/index.js +++ b/src/lib/client/adapters/webcontainer/index.js @@ -4,7 +4,6 @@ import AnsiToHtml from 'ansi-to-html'; import * as yootils from 'yootils'; import { escape_html, get_depth } from '../../../utils.js'; import { ready } from '../common/index.js'; -import { isWebContainerSupported } from './utils.js'; /** * @typedef {import("../../../../routes/tutorial/[slug]/state.js").CompilerWarning} CompilerWarning @@ -26,10 +25,6 @@ let vm; * @returns {Promise} */ export async function create(base, error, progress, logs, warnings) { - if (!isWebContainerSupported()) { - throw new Error('WebContainers are not supported by Safari 16.3 or earlier'); - } - progress.set({ value: 0, text: 'loading files' }); const q = yootils.queue(1); diff --git a/src/lib/client/adapters/webcontainer/utils.js b/src/lib/client/adapters/webcontainer/utils.js deleted file mode 100644 index 1d6c6a569..000000000 --- a/src/lib/client/adapters/webcontainer/utils.js +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Checks if WebContainer is supported on the current browser. - * This function is borrowed from [stackblitz/webcontainer-docs](https://github.com/stackblitz/webcontainer-docs/blob/369dd58b2749b085ed7642f22108a9bcbcd68fc4/docs/.vitepress/theme/components/Examples/WCEmbed/utils.ts#L4-L29) - */ -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')); - } catch { - return false; - } -} diff --git a/src/routes/tutorial/[slug]/Loading.svelte b/src/routes/tutorial/[slug]/Loading.svelte index 7563a6514..264af6f74 100644 --- a/src/routes/tutorial/[slug]/Loading.svelte +++ b/src/routes/tutorial/[slug]/Loading.svelte @@ -1,6 +1,4 @@ -
+
{#if error} - {#if !isWebContainerSupported()} -

This app requires modern web platform features. Please use a browser other than Safari.

- {:else} +
+
+

Yikes!

+ {#if error.message === 'Your browser does not support all necessary features'} +

+ This app requires modern web platform features. Please use a browser other than Safari. +

+ {:else if /firefox/i.test(navigator.userAgent)} +

+ We couldn't start the app. Please ensure + + third party cookies + are enabled for this site, and disable Enhanced Tracking Protection. +

+

+ If you have 'Delete cookies and site data when Firefox is closed' enabled in + about:preferences#privacy, make sure learn.svelte.dev is included + as an exception. +

+ {:else if /chrome/i.test(navigator.userAgent) && !/edg/i.test(navigator.userAgent)} +

+ We couldn't start the app. Please ensure third party cookies are enabled for this site — + click the + + eye + + + icon in the URL bar or go to + chrome://settings/cookies and add learn.svelte.dev to 'Sites that + can always use cookies'. +

+ {:else} +

+ We couldn't start the app. Please ensure third party cookies are enabled for this site. +

+ {/if} +
+ {error.message} -

Yikes!

- {#if /firefox/i.test(navigator.userAgent)} -

- We couldn't start the app. Please ensure - - third party cookies - are enabled for this site, and disable Enhanced Tracking Protection. -

-

- If you have 'Delete cookies and site data when Firefox is closed' enabled in - about:preferences#privacy, make sure learn.svelte.dev is included - as an exception. -

- {:else if /chrome/i.test(navigator.userAgent) && !/edg/i.test(navigator.userAgent)} -

- We couldn't start the app. Please ensure third party cookies are enabled for this site — - click the - - eye - - - icon in the URL bar or go to - chrome://settings/cookies and add learn.svelte.dev to 'Sites that - can always use cookies'. -

- {:else} -

- We couldn't start the app. Please ensure third party cookies are enabled for this site. -

- {/if} - {/if} +
{:else}