From dbe6a6176e3bc8ce7f112e61c656aaf0c4db70de Mon Sep 17 00:00:00 2001 From: Elliot Date: Fri, 19 Aug 2022 10:25:22 -0400 Subject: [PATCH] Fix issue window undefined error in bundled studio (#280) * Fix issue window undefined error in bundled studio * Fix Studio.ts UI import --- theatre/studio/src/Studio.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/theatre/studio/src/Studio.ts b/theatre/studio/src/Studio.ts index 0c77dad..bd144fd 100644 --- a/theatre/studio/src/Studio.ts +++ b/theatre/studio/src/Studio.ts @@ -1,6 +1,6 @@ import Scrub from '@theatre/studio/Scrub' import type {StudioHistoricState} from '@theatre/studio/store/types/historic' -import UI from '@theatre/studio/UI' +import type UI from '@theatre/studio/UI' import type {Pointer} from '@theatre/dataverse' import {Atom, PointerProxy, valueDerivation} from '@theatre/dataverse' import type { @@ -25,6 +25,9 @@ import checkForUpdates from './checkForUpdates' export type CoreExports = typeof _coreExports +let {default: UIConstructor} = + typeof window !== 'undefined' ? require('./UI') : null + const STUDIO_NOT_INITIALIZED_MESSAGE = `You seem to have imported '@theatre/studio' but haven't initialized it. You can initialize the studio by: \`\`\` import studio from '@theatre/studio' @@ -96,7 +99,7 @@ export class Studio { this.publicApi = new TheatreStudio(this) if (process.env.NODE_ENV !== 'test' && typeof window !== 'undefined') { - this.ui = new UI(this) + this.ui = new UIConstructor(this) } this._attachToIncomingProjects()