Skip to content

Commit

Permalink
Empty VSCode plugin webview editor windows #13258
Browse files Browse the repository at this point in the history
* move uuid v5 hash method to core
  • Loading branch information
jfaltermeier committed Jan 15, 2024
1 parent 50fc6b0 commit 63efe7a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 30 deletions.
12 changes: 12 additions & 0 deletions packages/core/src/common/uuid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

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

import { v5 } from 'uuid';

const _UUIDPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;

export function isUUID(value: string): boolean {
Expand Down Expand Up @@ -97,3 +99,13 @@ export const generateUuid = (function (): () => string {
return result;
};
})();

const NAMESPACE = '4c90ee4f-d952-44b1-83ca-f04121ab8e05';
/**
* This function will hash the given value using SHA1. The result will be a uuid.
* @param value the string to hash
* @returns a uuid
*/
export function hashValue(value: string): string {
return v5(value, NAMESPACE);
}
27 changes: 0 additions & 27 deletions packages/plugin-ext/src/common/hash-uuid.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import { interfaces } from '@theia/core/shared/inversify';
import { WebviewWidget, WebviewWidgetIdentifier, WebviewWidgetExternalEndpoint } from './webview';
import { WebviewEnvironment } from './webview-environment';
import { hashValue } from '../../../common/hash-uuid';
import { hashValue } from '@theia/core/lib/common/uuid';

export class WebviewWidgetFactory {

Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-ext/src/plugin/webview-views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { WebviewImpl, WebviewsExtImpl } from './webviews';
import { WebviewViewProvider } from '@theia/plugin';
import { Emitter, Event } from '@theia/core/lib/common/event';
import * as theia from '@theia/plugin';
import { hashValue } from '../common/hash-uuid';
import { hashValue } from '@theia/core/lib/common/uuid';

export class WebviewViewsExtImpl implements WebviewViewsExt {

Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-ext/src/plugin/webviews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { fromViewColumn, toViewColumn, toWebviewPanelShowOptions } from './type-
import { Disposable, WebviewPanelTargetArea, URI } from './types-impl';
import { WorkspaceExtImpl } from './workspace';
import { PluginIconPath } from './plugin-icon-path';
import { hashValue } from '../common/hash-uuid';
import { hashValue } from '@theia/core/lib/common/uuid';

export class WebviewsExtImpl implements WebviewsExt {
private readonly proxy: WebviewsMain;
Expand Down

0 comments on commit 63efe7a

Please sign in to comment.