environment.ts (884B)
1 /** 2 * @license 3 * Copyright 2020 Google Inc. 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 import type FS from 'node:fs'; 8 import type Path from 'node:path'; 9 10 import type {ScreenRecorder} from './node/ScreenRecorder.js'; 11 12 /** 13 * @internal 14 */ 15 export const isNode = !!(typeof process !== 'undefined' && process.version); 16 17 export interface EnvironmentDependencies { 18 fs: typeof FS; 19 path?: typeof Path; 20 ScreenRecorder: typeof ScreenRecorder; 21 } 22 23 /** 24 * Holder for environment dependencies. These dependencies cannot 25 * be used during the module instantiation. 26 */ 27 export const environment: { 28 value: EnvironmentDependencies; 29 } = { 30 value: { 31 get fs(): typeof FS { 32 throw new Error('fs is not available in this environment'); 33 }, 34 get ScreenRecorder(): typeof ScreenRecorder { 35 throw new Error('ScreenRecorder is not available in this environment'); 36 }, 37 }, 38 };