Custom Config

Register Custom Preferences

There are two main ways to register frequently-used customized configurations:

  1. Register on the integration side by using module contribution points.
  2. Register by using Configurations contribution points of extensions.

OpenSumi provides custom configuration capabilities based on OpenSumi's Contribution Point mechanism. You only need to implement PreferenceContribution to register the configuration.

For example, we can register the runtime configuration in the project by creating a DemoPreferenceContribution with the following pseudo code:

import { PreferenceContribution } from '@opensumi/ide-core-browser';
import { Domain, PreferenceSchema } from '@opensumi/ide-core-common';

export const DemoPreferenceSchema: PreferenceSchema = {
  type: 'object',
  properties: {
    testValue: {
      type: 'string',
      default: 'test',
      description: 'test'
    }
  }
};

@Domain(PreferenceContribution)
export class DemoPreferenceContribution implements PreferenceContribution {
  public schema: PreferenceSchema = DemoPreferenceSchema;
}

By introducing the DemoPreferenceContribution into the Providers declaration in the module, it can be used in other modules in the following way:

@Autowired(PreferenceService)
protected readonly preferenceService: PreferenceService;

...
this.preferenceService.get('testValue')

Another way to register is to use extensions configuration Contribution points.

Customize Integration Parameters

When integrating OpenSumi framework, we often need to perform independent configurations, and the following table lists some parameters that can be configured during the integration phase by passing in configuration items.

In Electron IDE Sample, you can find the renderApp initialization method in src/browser/index.ts#L113 and add the following:

renderApp({
  // add your configuration
  appName: 'OpenSumi',
  ...
})

Also you can find the same configuration logic on WebIDE Sample, see src/browser/index.ts#L12.

The complete configuration file can be found in the live code packages/core-browser/src/react-providers/config-provider.tsx#L14~#L245.

Browser Configuration

The definition can be found in the AppConfig definition in @opensumi/ide-core-browser.

parameterParameter instructiondefault value
appNameA unique name for a client, usually represent when the client starts up, and also show as the client name output by the extension processOpenSumi
uriSchemeMainly used to register the client protocol in Electron version to promote protocolsumi
workspaceDirWorkspace path, usually a folder or a workspace file of *.sumi-workspace. When the value passed is empty, the file tree on the left side of the editor will show the button to open the folder.Null
didRenderedCall after the DOM has been rendered for the first time. This means that the IDE interface has been rendered and is ready for operation, you can pass in a function here to handle the interface Loading, see DidRenderedNull
extensionDirExtension directory pathNull
extensionCandidateAn additional specified extension path, typically for built-in extensionsNull
storageDirNameSet the folder name for global storage, mainly for the folder name configuration when using the Storage module related storage service.sumi
preferenceDirNameSet the folder name for the workspace profile. For integrated environments, we recommend using workspacePreferenceDirName and userPreferenceDirName for more fine-grained configuration storage folder name Preference.sumi
workspacePreferenceDirNameA more fine-grained project workspace configuration storage location,that is, when preferenceDirName = '.sumi' , workspacePreferenceDirName = '.kt',the corresponding global configuration is ~/.sumi/settings.json , the workspace configuration is {workspaceDir}/.kt/settings.json.sumi
userPreferenceDirNameA more fine-grained project workspace configuration storage location, that is, when preferenceDirName = '.sumi' , userPreferenceDirName = '.kt', the corresponding global configuration is ~/.sumi/settings.json , and the workspace configuration is {userDir}/.kt/settings.json.sumi
extensionStorageDirNameGlobal extension data storage directory name, .sumi by default, data stored at {userDir}/.sumi.sumi
defaultPreferencesInitial definition of the client overall configurations, and common customizable parameters includes color theme: general.theme, icon theme: general.icon, language: general.language, exclude file option: filesExclude and exclude file listener option: watchExclude, which theoretically allows you to set default values for all configurations defined in the IDENull
injectorInitialized DI instances, which can be passed in generally after the external DI initialization to facilitate the initialization of some dependencies in advanceNull
wsPathDefault WebScoket communication pathNull
layoutConfigDefine the default loaded modules in each layout block of the IDE, which can add, remove or change target modules.see default-config.tsx
layoutConponentDefine the overall layout of the IDE. You can pass in a custom layout to define the default options, such as size of each block and scalingsee default-layout.tsx
panelSizesPanel size, width/height can be defined on the basis of layoutComponent configurationNull
defaultPanelsDefine the default panel for each block, for example: defaultPanels: { [SlotLocation.bottom]: '@opensumi/ide-terminal-next' }Null
webviewEndpointThe iframe address used to mount the webviewhttp://${deviceIp}:${port}/webview
extWorkerHostDefault startup path of the Worker extensionhttps://dev.g.alicdn.com/tao-ide/ide-lite/${version}/worker-host.js
staticServicePathDefine the static resource path. The default load path within the framework ishttp://127.0.0.1:8000/assets/${path}http://127.0.0.1:8000/assets/${path}
extensionDevelopmentHostDefines whether to start in extension development modefalse
editorBackgroundImageDefine the background image of the editor interface
useExperimentalShadowDomDefine whether ShadowDom mode is enabled in the extensiom environment. It is recommended to turn it on. After enabling ShadowDom mode, the view extension style will be isolated from the global environmentfalse
useIframeWrapWorkerHostUse iframe wrap when loading workerHost. For cross-domain scenarios, the workerHost will be loaded, use base64 encoding, and will be introduced by using importScripts (importScripts are not subject to cross-domain restrictions), but this will make the origin of the workerHost be null, leaving some requests failfalse
clientIdCustomize client ID, which is the unique identifier of the websocket service and the unique identifier passed to the backend Service that declares backServices. Be careful to keep this ID uniqueNull
noExtHostWhether to disable the extension processfalse
extraContextProviderExtra ConfigProvider that when the ReactDOM.render call within OpenSumi, it will be wrapped by a layer of extraContextProvider for additional Context transferring effectsNull
allowSetDocumentTitleFollowWorkspaceDirAllow dynamic setting of document#title by workspace pathtrue
remoteHostnameRemote access address through which you can access container serviceswindow.location.hostname
enableDebugExtensionHostEnable the debugging capability of the extension processfalse
extensionFetchCredentialsFetch credentials option when loading extension frontend resources, optionally "include""omit"
extensionConnectOptionreference:ExtensionConnectOptionNull

Node Configuration

The definition can be found in the AppConfig definition in @opensumi/ide-core-node.

ParametersParameter InstructionsDefault Value
InjectorThe initialized DI instance can be passed in after DI initialized externally to facilitate dependency initialization in advance
marketplacesee MarketplaceConfig
logLevelSet log placement level. The default is Info level log levelLogLevel.Info
logDirDefine the log placement path~/.sumi/logs
LogServiceClassILogService to be deprecated, set externally, replacing the default logService, which can be done by initializing ILogService on the passed injectorNull
maxExtProcessCountDefine the maximum number of extension processes enabledNull
extLogServiceClassPathDefine a custom implementation path for extension loggingNull
processCloseExitThresholdDefine extension process shutdown timeNull
terminalPtyCloseThresholdDefine terminal pty process exit timeNull
staticAllowOriginAccess origin allowed by static resourcesNull
staticAllowPathAllowed path for accessing static resources. Used to configure the whitelist rule for static resourcesNull
blockPatternsPaths to which access is disabled by the file service, using glob to matchNull
extHostNode extension process entry fileNull
extHostIPCSockPathThe extension process that stores the sock address for communication/tmp
extHostForkOptionsExtension process fork configurationNull

For more configurations, please see the OpenSumi source code.