69 lines
1.6 KiB
JavaScript
69 lines
1.6 KiB
JavaScript
const configStore = new Map();
|
|
|
|
const config = {
|
|
get: (key, fallback) => configStore.has(key) ? configStore.get(key) : fallback,
|
|
update: async (key, value) => {
|
|
configStore.set(key, value);
|
|
}
|
|
};
|
|
|
|
class EventEmitter {
|
|
constructor() {
|
|
this._listeners = [];
|
|
this.event = (listener) => {
|
|
this._listeners.push(listener);
|
|
return { dispose: () => { this._listeners = this._listeners.filter(l => l !== listener); } };
|
|
};
|
|
}
|
|
fire(value) {
|
|
for (const l of this._listeners.slice()) l(value);
|
|
}
|
|
dispose() {
|
|
this._listeners = [];
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
EventEmitter,
|
|
workspace: {
|
|
workspaceFolders: [],
|
|
getConfiguration: () => config,
|
|
onDidChangeConfiguration: () => ({ dispose: () => {} }),
|
|
fs: {
|
|
writeFile: async () => {},
|
|
delete: async () => {}
|
|
}
|
|
},
|
|
window: {
|
|
createOutputChannel: () => ({
|
|
appendLine: () => {},
|
|
show: () => {},
|
|
dispose: () => {}
|
|
}),
|
|
createStatusBarItem: () => ({
|
|
text: '',
|
|
tooltip: '',
|
|
command: '',
|
|
backgroundColor: undefined,
|
|
show: () => {},
|
|
hide: () => {},
|
|
dispose: () => {}
|
|
}),
|
|
showInformationMessage: async () => undefined,
|
|
showWarningMessage: async () => undefined,
|
|
showErrorMessage: async () => undefined
|
|
},
|
|
StatusBarAlignment: { Right: 2 },
|
|
ThemeColor: class ThemeColor {
|
|
constructor(id) {
|
|
this.id = id;
|
|
}
|
|
},
|
|
Uri: {
|
|
file: (fsPath) => ({ fsPath, scheme: 'file' }),
|
|
joinPath: (base, ...parts) => ({ fsPath: [base.fsPath, ...parts].join('/') })
|
|
},
|
|
ProgressLocation: { Notification: 15 },
|
|
ConfigurationTarget: { Global: 1, Workspace: 2 }
|
|
};
|