Files
esengine/packages/framework/core/src/RuntimeConfig.ts

51 lines
1.2 KiB
TypeScript
Raw Normal View History

import type { RuntimeEnvironment } from './Types';
/**
* @zh
* @en Global runtime configuration
*
* @zh Core Scene
* @en Standalone module to avoid circular dependency between Core and Scene
*/
class RuntimeConfigClass {
private _runtimeEnvironment: RuntimeEnvironment = 'standalone';
/**
* @zh
* @en Get runtime environment
*/
get runtimeEnvironment(): RuntimeEnvironment {
return this._runtimeEnvironment;
}
/**
* @zh
* @en Set runtime environment
*/
set runtimeEnvironment(value: RuntimeEnvironment) {
this._runtimeEnvironment = value;
}
/**
* @zh
* @en Whether running on server
*/
get isServer(): boolean {
return this._runtimeEnvironment === 'server';
}
/**
* @zh
* @en Whether running on client
*/
get isClient(): boolean {
return this._runtimeEnvironment === 'client';
}
}
/**
* @zh
* @en Global runtime configuration singleton
*/
export const RuntimeConfig = new RuntimeConfigClass();