From 171b6368f3b2e7291dcb0ecb77ef1d71614d8b30 Mon Sep 17 00:00:00 2001 From: Julien Sulpis <22420399+jsulpis@users.noreply.github.com> Date: Mon, 6 May 2024 20:18:58 +0200 Subject: [PATCH] fix: prevent a javascript error on the server side (#14) --- src/WebGPURenderer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/WebGPURenderer.ts b/src/WebGPURenderer.ts index de187eb..caf74e4 100644 --- a/src/WebGPURenderer.ts +++ b/src/WebGPURenderer.ts @@ -115,7 +115,7 @@ const STORAGE_REGEX = /var\s*<\s*storage[^>]+>\s*(\w+)/g */ const WORKGROUP_REGEX = /@workgroup_size\s*\(([^)]+)\)/ -const _adapter = typeof navigator !== 'undefined' && (await navigator.gpu?.requestAdapter()) +const _adapter = typeof navigator !== 'undefined' ? (await navigator.gpu?.requestAdapter()) : null; const _device = await (_adapter as GPUAdapter | null)?.requestDevice() /**