Version 2.2.0.

* Adds support for custom injected scripts with automatic reload
* Refactors extension
This commit is contained in:
Henning Dieterichs
2021-06-18 20:26:51 +02:00
parent 6ce5d666a3
commit d22e5d4111
46 changed files with 1421 additions and 716 deletions

View File

@@ -21,6 +21,29 @@ export class Config {
{ serializer: serializerWithDefault<DebugAdapterConfigs>({}) }
);
private readonly _customScriptPaths = new VsCodeSetting(
"debugVisualizer.js.customScriptPaths",
{ serializer: serializerWithDefault<string[]>([]) }
);
public get customScriptPaths(): string[] {
return this._customScriptPaths.get().map(p => {
const tpl = new SimpleTemplate(p);
return tpl.render({
workspaceFolder: () => {
const workspaceFolder = (workspace.workspaceFolders ||
[])[0];
if (!workspaceFolder) {
throw new Error(
`Cannot get workspace folder - '${p}' cannot be evaluated!`
);
}
return workspaceFolder.uri.fsPath;
},
});
});
}
@observable
private _vsCodeTheme = window.activeColorTheme;
@@ -85,3 +108,13 @@ function evaluateTemplate(
}
return result;
}
export class SimpleTemplate {
constructor(private readonly str: string) {}
render(data: Record<string, () => string>): string {
return this.str.replace(/\$\{([a-zA-Z0-9]+)\}/g, (substr, grp1) => {
return data[grp1]();
});
}
}