Custom Config
Register Custom Preferences
There are two main ways to register frequently-used customized configurations:
- Register on the integration side by using module contribution points.
- 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
.
parameter | Parameter instruction | default value |
---|---|---|
appName | A unique name for a client, usually represent when the client starts up, and also show as the client name output by the extension process | OpenSumi |
uriScheme | Mainly used to register the client protocol in Electron version to promote protocol | sumi |
workspaceDir | Workspace 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 |
didRendered | Call 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 DidRendered | Null |
extensionDir | Extension directory path | Null |
extensionCandidate | An additional specified extension path, typically for built-in extensions | Null |
storageDirName | Set the folder name for global storage, mainly for the folder name configuration when using the Storage module related storage service | .sumi |
preferenceDirName | Set 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 |
workspacePreferenceDirName | A 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 |
userPreferenceDirName | A 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 |
extensionStorageDirName | Global extension data storage directory name, .sumi by default, data stored at {userDir}/.sumi | .sumi |
defaultPreferences | Initial 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 IDE | Null |
injector | Initialized DI instances, which can be passed in generally after the external DI initialization to facilitate the initialization of some dependencies in advance | Null |
wsPath | Default WebScoket communication path | Null |
layoutConfig | Define the default loaded modules in each layout block of the IDE, which can add, remove or change target modules. | see default-config.tsx |
layoutConponent | Define 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 scaling | see default-layout.tsx |
panelSizes | Panel size, width/height can be defined on the basis of layoutComponent configuration | Null |
defaultPanels | Define the default panel for each block, for example: defaultPanels: { [SlotLocation.bottom]: '@opensumi/ide-terminal-next' } | Null |
webviewEndpoint | The iframe address used to mount the webview | http://${deviceIp}:${port}/webview |
extWorkerHost | Default startup path of the Worker extension | https://dev.g.alicdn.com/tao-ide/ide-lite/${version}/worker-host.js |
staticServicePath | Define 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} |
extensionDevelopmentHost | Defines whether to start in extension development mode | false |
editorBackgroundImage | Define the background image of the editor interface | |
useExperimentalShadowDom | Define 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 environment | false |
useIframeWrapWorkerHost | Use 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 fail | false |
clientId | Customize 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 unique | Null |
noExtHost | Whether to disable the extension process | false |
extraContextProvider | Extra ConfigProvider that when the ReactDOM.render call within OpenSumi, it will be wrapped by a layer of extraContextProvider for additional Context transferring effects | Null |
allowSetDocumentTitleFollowWorkspaceDir | Allow dynamic setting of document#title by workspace path | true |
remoteHostname | Remote access address through which you can access container services | window.location.hostname |
enableDebugExtensionHost | Enable the debugging capability of the extension process | false |
extensionFetchCredentials | Fetch credentials option when loading extension frontend resources, optionally "include" | "omit" |
extensionConnectOption | reference:ExtensionConnectOption | Null |
Node Configuration
The definition can be found in the AppConfig
definition in @opensumi/ide-core-node
.
Parameters | Parameter Instructions | Default Value |
---|---|---|
Injector | The initialized DI instance can be passed in after DI initialized externally to facilitate dependency initialization in advance | |
marketplace | see MarketplaceConfig | |
logLevel | Set log placement level. The default is Info level log level | LogLevel.Info |
logDir | Define the log placement path | ~/.sumi/logs |
LogServiceClass | ILogService to be deprecated, set externally, replacing the default logService, which can be done by initializing ILogService on the passed injector | Null |
maxExtProcessCount | Define the maximum number of extension processes enabled | Null |
extLogServiceClassPath | Define a custom implementation path for extension logging | Null |
processCloseExitThreshold | Define extension process shutdown time | Null |
terminalPtyCloseThreshold | Define terminal pty process exit time | Null |
staticAllowOrigin | Access origin allowed by static resources | Null |
staticAllowPath | Allowed path for accessing static resources. Used to configure the whitelist rule for static resources | Null |
blockPatterns | Paths to which access is disabled by the file service, using glob to match | Null |
extHost | Node extension process entry file | Null |
extHostIPCSockPath | The extension process that stores the sock address for communication | /tmp |
extHostForkOptions | Extension process fork configuration | Null |
For more configurations, please see the OpenSumi source code.