diff --git a/packages/playground/devEnv/build.ts b/packages/playground/devEnv/build.ts index 975b881..b798136 100644 --- a/packages/playground/devEnv/build.ts +++ b/packages/playground/devEnv/build.ts @@ -176,6 +176,7 @@ export async function start(options: { 'window.__IS_VISUAL_REGRESSION_TESTING': JSON.stringify( options.isVisualRegressionTesting, ), + 'process.env.BUILT_FOR_PLAYGROUND': JSON.stringify('true'), }, banner: liveReload?.esbuildBanner, watch: liveReload?.esbuildWatch && { diff --git a/theatre/devEnv/definedGlobals.ts b/theatre/devEnv/definedGlobals.ts index 63a36fb..b5ff2c6 100644 --- a/theatre/devEnv/definedGlobals.ts +++ b/theatre/devEnv/definedGlobals.ts @@ -1,3 +1,7 @@ +/** + * @see `../globals.d.ts` for the types of these globals + * TODO make the globals typesafe + */ export const definedGlobals = { 'process.env.THEATRE_VERSION': JSON.stringify( require('../studio/package.json').version, @@ -5,4 +9,5 @@ export const definedGlobals = { // json-touch-patch (an unmaintained package) reads this value. We patch it to just 'Set', becauce // this is only used in `@theatre/studio`, which only supports evergreen browsers 'global.Set': 'Set', + 'process.env.BUILT_FOR_PLAYGROUND': JSON.stringify('false'), } diff --git a/theatre/globals.d.ts b/theatre/globals.d.ts index fed1867..7b0f9a9 100644 --- a/theatre/globals.d.ts +++ b/theatre/globals.d.ts @@ -11,7 +11,10 @@ interface NodeModule { interface ProcessEnv { NODE_ENV: 'development' | 'production' | 'test' + // The version of the package, as defined in package.json THEATRE_VERSION: string + // This is set to 'true' when building the playground + BUILT_FOR_PLAYGROUND: 'true' | 'false' } declare module '*.svg' { diff --git a/theatre/studio/src/checkForUpdates.ts b/theatre/studio/src/checkForUpdates.ts index b5ea02a..15794ad 100644 --- a/theatre/studio/src/checkForUpdates.ts +++ b/theatre/studio/src/checkForUpdates.ts @@ -28,6 +28,16 @@ async function waitTilUIIsVisible(): Promise { } export default async function checkForUpdates() { + if (process.env.BUILT_FOR_PLAYGROUND === 'true') { + // Build for playground. Skipping update check + return + } + + if (process.env.THEATRE_VERSION?.match(/COMPAT/)) { + // Built for compat tests. Skipping update check + return + } + // let's wait a bit in case the user has called for the UI to be hidden. await wait(500) await waitTilUIIsVisible()