Skip to content

Commit 63efe7a

Browse files
committed
Empty VSCode plugin webview editor windows #13258
* move uuid v5 hash method to core
1 parent 50fc6b0 commit 63efe7a

File tree

5 files changed

+15
-30
lines changed

5 files changed

+15
-30
lines changed

packages/core/src/common/uuid.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
// based on https://github.com/microsoft/vscode/blob/1.72.2/src/vs/base/common/uuid.ts
2323

24+
import { v5 } from 'uuid';
25+
2426
const _UUIDPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
2527

2628
export function isUUID(value: string): boolean {
@@ -97,3 +99,13 @@ export const generateUuid = (function (): () => string {
9799
return result;
98100
};
99101
})();
102+
103+
const NAMESPACE = '4c90ee4f-d952-44b1-83ca-f04121ab8e05';
104+
/**
105+
* This function will hash the given value using SHA1. The result will be a uuid.
106+
* @param value the string to hash
107+
* @returns a uuid
108+
*/
109+
export function hashValue(value: string): string {
110+
return v5(value, NAMESPACE);
111+
}

packages/plugin-ext/src/common/hash-uuid.ts

Lines changed: 0 additions & 27 deletions
This file was deleted.

packages/plugin-ext/src/main/browser/webview/webview-widget-factory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import { interfaces } from '@theia/core/shared/inversify';
1818
import { WebviewWidget, WebviewWidgetIdentifier, WebviewWidgetExternalEndpoint } from './webview';
1919
import { WebviewEnvironment } from './webview-environment';
20-
import { hashValue } from '../../../common/hash-uuid';
20+
import { hashValue } from '@theia/core/lib/common/uuid';
2121

2222
export class WebviewWidgetFactory {
2323

packages/plugin-ext/src/plugin/webview-views.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { WebviewImpl, WebviewsExtImpl } from './webviews';
2727
import { WebviewViewProvider } from '@theia/plugin';
2828
import { Emitter, Event } from '@theia/core/lib/common/event';
2929
import * as theia from '@theia/plugin';
30-
import { hashValue } from '../common/hash-uuid';
30+
import { hashValue } from '@theia/core/lib/common/uuid';
3131

3232
export class WebviewViewsExtImpl implements WebviewViewsExt {
3333

packages/plugin-ext/src/plugin/webviews.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { fromViewColumn, toViewColumn, toWebviewPanelShowOptions } from './type-
2323
import { Disposable, WebviewPanelTargetArea, URI } from './types-impl';
2424
import { WorkspaceExtImpl } from './workspace';
2525
import { PluginIconPath } from './plugin-icon-path';
26-
import { hashValue } from '../common/hash-uuid';
26+
import { hashValue } from '@theia/core/lib/common/uuid';
2727

2828
export class WebviewsExtImpl implements WebviewsExt {
2929
private readonly proxy: WebviewsMain;

0 commit comments

Comments
 (0)