From 9164f1d4c256bcd64b7c46ac86fd292d222b3f47 Mon Sep 17 00:00:00 2001 From: Kreijstal Date: Tue, 19 Nov 2024 17:58:15 +0100 Subject: [PATCH] globalThis error should not be handled by vite otherwise creates dependency there --- packages/core/src/context.ts | 2 +- packages/react/src/components/Sheet/index.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core/src/context.ts b/packages/core/src/context.ts index 9fde196c..52ead069 100644 --- a/packages/core/src/context.ts +++ b/packages/core/src/context.ts @@ -227,7 +227,7 @@ export function defaultContext(refs: RefValues): Context { defaultrowNum: 84, addDefaultRows: 50, fullscreenmode: true, - devicePixelRatio: (globalThis || window).devicePixelRatio, + devicePixelRatio: (typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : {}).devicePixelRatio, contextMenu: {}, sheetTabContextMenu: {}, diff --git a/packages/react/src/components/Sheet/index.tsx b/packages/react/src/components/Sheet/index.tsx index 0c61a0d0..31f6421d 100644 --- a/packages/react/src/components/Sheet/index.tsx +++ b/packages/react/src/components/Sheet/index.tsx @@ -30,7 +30,7 @@ const Sheet: React.FC = ({ sheet }) => { if (!data) return; setContext((draftCtx) => { if (settings.devicePixelRatio === 0) { - draftCtx.devicePixelRatio = (globalThis || window).devicePixelRatio; + draftCtx.devicePixelRatio = (typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : {}).devicePixelRatio; } updateContextWithSheetData(draftCtx, data); updateContextWithCanvas(