Fix issue window undefined error in bundled studio (#280)

* Fix issue window undefined error in bundled studio

* Fix Studio.ts UI import
This commit is contained in:
Elliot 2022-08-19 10:25:22 -04:00 committed by GitHub
parent 898c3b7a48
commit dbe6a6176e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,6 +1,6 @@
import Scrub from '@theatre/studio/Scrub' import Scrub from '@theatre/studio/Scrub'
import type {StudioHistoricState} from '@theatre/studio/store/types/historic' 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 type {Pointer} from '@theatre/dataverse'
import {Atom, PointerProxy, valueDerivation} from '@theatre/dataverse' import {Atom, PointerProxy, valueDerivation} from '@theatre/dataverse'
import type { import type {
@ -25,6 +25,9 @@ import checkForUpdates from './checkForUpdates'
export type CoreExports = typeof _coreExports 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: 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' import studio from '@theatre/studio'
@ -96,7 +99,7 @@ export class Studio {
this.publicApi = new TheatreStudio(this) this.publicApi = new TheatreStudio(this)
if (process.env.NODE_ENV !== 'test' && typeof window !== 'undefined') { if (process.env.NODE_ENV !== 'test' && typeof window !== 'undefined') {
this.ui = new UI(this) this.ui = new UIConstructor(this)
} }
this._attachToIncomingProjects() this._attachToIncomingProjects()