diff --git a/package.json b/package.json index df4da5f8cce40..0ed1ed6324896 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,6 @@ "@types/node": "18", "@types/sinon": "^10.0.6", "@types/temp": "^0.9.1", - "@types/uuid": "^7.0.3", "@typescript-eslint/eslint-plugin": "^4.8.1", "@typescript-eslint/eslint-plugin-tslint": "^4.8.1", "@typescript-eslint/parser": "^4.8.1", @@ -56,7 +55,6 @@ "typedoc": "^0.22.11", "typedoc-plugin-external-module-map": "1.3.2", "typescript": "~4.5.5", - "uuid": "^8.0.0", "yargs": "^15.3.1" }, "scripts": { diff --git a/packages/core/package.json b/packages/core/package.json index 7c642850c2f28..8678059ca038f 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -30,6 +30,7 @@ "@types/react-dom": "^18.0.6", "@types/route-parser": "^0.1.1", "@types/safer-buffer": "^2.1.0", + "@types/uuid": "^9.0.8", "@types/ws": "^8.5.5", "@types/yargs": "^15", "@vscode/codicons": "*", @@ -68,7 +69,7 @@ "safer-buffer": "^2.1.2", "socket.io": "^4.5.3", "socket.io-client": "^4.5.3", - "uuid": "^8.3.2", + "uuid": "^9.0.1", "vscode-languageserver-protocol": "^3.17.2", "vscode-uri": "^2.1.1", "ws": "^8.14.1", diff --git a/packages/core/src/browser/tooltip-service.tsx b/packages/core/src/browser/tooltip-service.tsx index 67fbc10285b56..0857960a434be 100644 --- a/packages/core/src/browser/tooltip-service.tsx +++ b/packages/core/src/browser/tooltip-service.tsx @@ -19,7 +19,7 @@ import * as React from 'react'; import ReactTooltip from 'react-tooltip'; import { ReactRenderer, RendererHost } from './widgets/react-renderer'; import { CorePreferences } from './core-preferences'; -import { v4 } from 'uuid'; +import { generateUuid } from '../common/uuid'; export const TooltipService = Symbol('TooltipService'); @@ -59,7 +59,7 @@ export class TooltipServiceImpl extends ReactRenderer implements TooltipService @inject(RendererHost) @optional() host?: RendererHost ) { super(host); - this.tooltipId = v4(); + this.tooltipId = generateUuid(); } @postConstruct() diff --git a/packages/core/src/common/index.ts b/packages/core/src/common/index.ts index a3f5aeb125e57..ada952513f326 100644 --- a/packages/core/src/common/index.ts +++ b/packages/core/src/common/index.ts @@ -46,5 +46,6 @@ export * from './strings'; export * from './telemetry'; export * from './types'; export { default as URI } from './uri'; +export * from './uuid'; export * from './view-column'; export * from './version'; diff --git a/packages/core/src/common/uuid.ts b/packages/core/src/common/uuid.ts index 1994e29282d30..41561cebc593a 100644 --- a/packages/core/src/common/uuid.ts +++ b/packages/core/src/common/uuid.ts @@ -21,7 +21,7 @@ // based on https://github.com/microsoft/vscode/blob/1.72.2/src/vs/base/common/uuid.ts -import { v5 } from 'uuid'; +import { v4, 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; @@ -29,76 +29,9 @@ export function isUUID(value: string): boolean { return _UUIDPattern.test(value); } -declare const crypto: undefined | { - // https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues#browser_compatibility - getRandomValues?(data: Uint8Array): Uint8Array; - // https://developer.mozilla.org/en-US/docs/Web/API/Crypto/randomUUID#browser_compatibility - randomUUID?(): string; -}; - -export const generateUuid = (function (): () => string { - - // use `randomUUID` if possible - if (typeof crypto === 'object' && typeof crypto.randomUUID === 'function') { - return crypto.randomUUID.bind(crypto); - } - - // use `randomValues` if possible - let getRandomValues: (bucket: Uint8Array) => Uint8Array; - if (typeof crypto === 'object' && typeof crypto.getRandomValues === 'function') { - getRandomValues = crypto.getRandomValues.bind(crypto); - - } else { - getRandomValues = function (bucket: Uint8Array): Uint8Array { - for (let i = 0; i < bucket.length; i++) { - bucket[i] = Math.floor(Math.random() * 256); - } - return bucket; - }; - } - - // prep-work - const _data = new Uint8Array(16); - const _hex: string[] = []; - for (let i = 0; i < 256; i++) { - _hex.push(i.toString(16).padStart(2, '0')); - } - - // eslint-disable-next-line @typescript-eslint/no-shadow - return function generateUuid(): string { - // get data - getRandomValues(_data); - - // set version bits - _data[6] = (_data[6] & 0x0f) | 0x40; - _data[8] = (_data[8] & 0x3f) | 0x80; - - // print as string - let i = 0; - let result = ''; - result += _hex[_data[i++]]; - result += _hex[_data[i++]]; - result += _hex[_data[i++]]; - result += _hex[_data[i++]]; - result += '-'; - result += _hex[_data[i++]]; - result += _hex[_data[i++]]; - result += '-'; - result += _hex[_data[i++]]; - result += _hex[_data[i++]]; - result += '-'; - result += _hex[_data[i++]]; - result += _hex[_data[i++]]; - result += '-'; - result += _hex[_data[i++]]; - result += _hex[_data[i++]]; - result += _hex[_data[i++]]; - result += _hex[_data[i++]]; - result += _hex[_data[i++]]; - result += _hex[_data[i++]]; - return result; - }; -})(); +export function generateUuid(): string { + return v4(); +} const NAMESPACE = '4c90ee4f-d952-44b1-83ca-f04121ab8e05'; /** diff --git a/packages/core/src/electron-main/electron-main-application-module.ts b/packages/core/src/electron-main/electron-main-application-module.ts index 0148dbc6fd77c..a512efb722012 100644 --- a/packages/core/src/electron-main/electron-main-application-module.ts +++ b/packages/core/src/electron-main/electron-main-application-module.ts @@ -15,7 +15,7 @@ // ***************************************************************************** import { ContainerModule } from 'inversify'; -import { v4 } from 'uuid'; +import { generateUuid } from '../common/uuid'; import { bindContributionProvider } from '../common/contribution-provider'; import { RpcConnectionHandler } from '../common/messaging/proxy-factory'; import { ElectronSecurityToken } from '../electron-common/electron-token'; @@ -29,7 +29,7 @@ import { ElectronSecurityTokenService } from './electron-security-token-service' import { ElectronMessagingService } from './messaging/electron-messaging-service'; import { ElectronConnectionHandler } from './messaging/electron-connection-handler'; -const electronSecurityToken: ElectronSecurityToken = { value: v4() }; +const electronSecurityToken: ElectronSecurityToken = { value: generateUuid() }; // eslint-disable-next-line @typescript-eslint/no-explicit-any (global as any)[ElectronSecurityToken] = electronSecurityToken; diff --git a/packages/filesystem/package.json b/packages/filesystem/package.json index fa832e1cfca3e..05cb26103fa10 100644 --- a/packages/filesystem/package.json +++ b/packages/filesystem/package.json @@ -8,7 +8,6 @@ "@types/multer": "^1.4.7", "@types/rimraf": "^2.0.2", "@types/tar-fs": "^1.16.1", - "@types/uuid": "^7.0.3", "async-mutex": "^0.3.1", "body-parser": "^1.18.3", "browserfs": "^1.4.3", @@ -19,7 +18,6 @@ "stat-mode": "^1.0.0", "tar-fs": "^1.16.2", "trash": "^7.2.0", - "uuid": "^8.0.0", "vscode-languageserver-textdocument": "^1.0.1" }, "publishConfig": { diff --git a/packages/filesystem/src/node/disk-file-system-provider.spec.ts b/packages/filesystem/src/node/disk-file-system-provider.spec.ts index 641d8342d2fe3..a2c84055175b2 100644 --- a/packages/filesystem/src/node/disk-file-system-provider.spec.ts +++ b/packages/filesystem/src/node/disk-file-system-provider.spec.ts @@ -25,7 +25,7 @@ import { equal, fail } from 'assert'; import { promises as fs } from 'fs'; import { join } from 'path'; import * as temp from 'temp'; -import { v4 } from 'uuid'; +import { generateUuid } from '@theia/core/lib/common/uuid'; import { FilePermission, FileSystemProviderCapabilities, FileSystemProviderError, FileSystemProviderErrorCode } from '../common/files'; import { DiskFileSystemProvider } from './disk-file-system-provider'; import { bindFileSystemWatcherServer } from './filesystem-backend-module'; @@ -53,7 +53,7 @@ describe('disk-file-system-provider', () => { describe('stat', () => { it("should omit the 'permissions' property of the stat if the file can be both read and write", async () => { const tempDirPath = tracked.mkdirSync(); - const tempFilePath = join(tempDirPath, `${v4()}.txt`); + const tempFilePath = join(tempDirPath, `${generateUuid()}.txt`); await fs.writeFile(tempFilePath, 'some content', { encoding: 'utf8' }); let content = await fs.readFile(tempFilePath, { encoding: 'utf8' }); @@ -70,7 +70,7 @@ describe('disk-file-system-provider', () => { it("should set the 'permissions' property to `Readonly` if the file can be read but not write", async () => { const tempDirPath = tracked.mkdirSync(); - const tempFilePath = join(tempDirPath, `${v4()}.txt`); + const tempFilePath = join(tempDirPath, `${generateUuid()}.txt`); await fs.writeFile(tempFilePath, 'readonly content', { encoding: 'utf8', }); diff --git a/packages/filesystem/src/node/disk-file-system-provider.ts b/packages/filesystem/src/node/disk-file-system-provider.ts index de2132e8a7886..9aad02ded5ecb 100644 --- a/packages/filesystem/src/node/disk-file-system-provider.ts +++ b/packages/filesystem/src/node/disk-file-system-provider.ts @@ -24,7 +24,7 @@ import { injectable, inject, postConstruct } from '@theia/core/shared/inversify'; import { basename, dirname, normalize, join } from 'path'; -import { v4 } from 'uuid'; +import { generateUuid } from '@theia/core/lib/common/uuid'; import * as os from 'os'; import * as fs from 'fs'; import { @@ -530,7 +530,7 @@ export class DiskFileSystemProvider implements Disposable, protected async rimrafMove(path: string): Promise { try { - const pathInTemp = join(os.tmpdir(), v4()); + const pathInTemp = join(os.tmpdir(), generateUuid()); try { await promisify(rename)(path, pathInTemp); } catch (error) { diff --git a/packages/filesystem/src/node/download/file-download-handler.ts b/packages/filesystem/src/node/download/file-download-handler.ts index 7a54513e6bcae..5ebf73e627da7 100644 --- a/packages/filesystem/src/node/download/file-download-handler.ts +++ b/packages/filesystem/src/node/download/file-download-handler.ts @@ -17,7 +17,7 @@ import * as os from 'os'; import * as fs from '@theia/core/shared/fs-extra'; import * as path from 'path'; -import { v4 } from 'uuid'; +import { generateUuid } from '@theia/core/lib/common/uuid'; import { Request, Response } from '@theia/core/shared/express'; import { inject, injectable } from '@theia/core/shared/inversify'; import { OK, BAD_REQUEST, METHOD_NOT_ALLOWED, NOT_FOUND, INTERNAL_SERVER_ERROR, REQUESTED_RANGE_NOT_SATISFIABLE, PARTIAL_CONTENT } from 'http-status-codes'; @@ -135,12 +135,12 @@ export abstract class FileDownloadHandler { end: (isNaN(end) || end > statSize - 1) ? (statSize - 1) : end }; } - protected async archive(inputPath: string, outputPath: string = path.join(os.tmpdir(), v4()), entries?: string[]): Promise { + protected async archive(inputPath: string, outputPath: string = path.join(os.tmpdir(), generateUuid()), entries?: string[]): Promise { await this.directoryArchiver.archive(inputPath, outputPath, entries); return outputPath; } - protected async createTempDir(downloadId: string = v4()): Promise { + protected async createTempDir(downloadId: string = generateUuid()): Promise { const outputPath = path.join(os.tmpdir(), downloadId); await fs.mkdir(outputPath); return outputPath; @@ -221,7 +221,7 @@ export class SingleFileDownloadHandler extends FileDownloadHandler { return; } try { - const downloadId = v4(); + const downloadId = generateUuid(); const options: PrepareDownloadOptions = { filePath, downloadId, remove: false }; if (!stat.isDirectory()) { await this.prepareDownload(request, response, options); @@ -271,7 +271,7 @@ export class MultiFileDownloadHandler extends FileDownloadHandler { } } try { - const downloadId = v4(); + const downloadId = generateUuid(); const outputRootPath = await this.createTempDir(downloadId); const distinctUris = Array.from(new Set(body.uris.map(uri => new URI(uri)))); const tarPaths = []; diff --git a/packages/mini-browser/package.json b/packages/mini-browser/package.json index 8f6ee15eb0961..d9bcf8a352759 100644 --- a/packages/mini-browser/package.json +++ b/packages/mini-browser/package.json @@ -8,7 +8,6 @@ "@types/mime-types": "^2.1.0", "mime-types": "^2.1.18", "pdfobject": "^2.0.201604172", - "uuid": "^8.0.0", "vhost": "^3.0.2" }, "publishConfig": { diff --git a/packages/mini-browser/src/browser/environment/mini-browser-environment.ts b/packages/mini-browser/src/browser/environment/mini-browser-environment.ts index f5253f43708d6..b13b910d5638d 100644 --- a/packages/mini-browser/src/browser/environment/mini-browser-environment.ts +++ b/packages/mini-browser/src/browser/environment/mini-browser-environment.ts @@ -18,7 +18,7 @@ import { Endpoint, FrontendApplicationContribution } from '@theia/core/lib/brows import { EnvVariablesServer } from '@theia/core/lib/common/env-variables'; import { environment } from '@theia/core/shared/@theia/application-package/lib/environment'; import { inject, injectable, postConstruct } from '@theia/core/shared/inversify'; -import { v4 } from 'uuid'; +import { generateUuid } from '@theia/core/lib/common/uuid'; import { MiniBrowserEndpoint } from '../../common/mini-browser-endpoint'; /** @@ -71,7 +71,7 @@ export class MiniBrowserEnvironment implements FrontendApplicationContribution { * Throws if `hostPatternPromise` is not yet resolved. */ getRandomEndpoint(): Endpoint { - return this.getEndpoint(v4()); + return this.getEndpoint(generateUuid()); } protected async getHostPattern(): Promise { diff --git a/packages/notebook/package.json b/packages/notebook/package.json index 5325113d98608..188c1096f41c7 100644 --- a/packages/notebook/package.json +++ b/packages/notebook/package.json @@ -7,8 +7,7 @@ "@theia/editor": "1.46.0", "@theia/filesystem": "1.46.0", "@theia/monaco": "1.46.0", - "react-perfect-scrollbar": "^1.5.8", - "uuid": "^8.3.2" + "react-perfect-scrollbar": "^1.5.8" }, "publishConfig": { "access": "public" diff --git a/packages/notebook/src/browser/service/notebook-execution-state-service.ts b/packages/notebook/src/browser/service/notebook-execution-state-service.ts index 3512293d78b4b..5ac7645373be9 100644 --- a/packages/notebook/src/browser/service/notebook-execution-state-service.ts +++ b/packages/notebook/src/browser/service/notebook-execution-state-service.ts @@ -18,7 +18,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { Disposable, DisposableCollection, Emitter, URI } from '@theia/core'; +import { Disposable, DisposableCollection, Emitter, URI, generateUuid } from '@theia/core'; import { inject, injectable } from '@theia/core/shared/inversify'; import { NotebookService } from './notebook-service'; import { @@ -27,7 +27,6 @@ import { } from '../../common'; import { CellPartialInternalMetadataEditByHandle, CellEditOperation } from '../notebook-types'; import { NotebookModel } from '../view-model/notebook-model'; -import { v4 } from 'uuid'; export type CellExecuteUpdate = CellExecuteOutputEdit | CellExecuteOutputItemEdit | CellExecutionStateUpdate; @@ -178,7 +177,7 @@ export class CellExecution implements Disposable { editType: CellEditType.PartialInternalMetadata, handle: this.cellHandle, internalMetadata: { - executionId: v4(), + executionId: generateUuid(), runStartTime: undefined, runEndTime: undefined, lastRunSuccess: undefined, diff --git a/packages/plugin-ext/package.json b/packages/plugin-ext/package.json index f1ccdb48d1986..9db620bcb8cdf 100644 --- a/packages/plugin-ext/package.json +++ b/packages/plugin-ext/package.json @@ -46,7 +46,6 @@ "mime": "^2.4.4", "ps-tree": "^1.2.0", "semver": "^7.5.4", - "uuid": "^8.0.0", "vhost": "^3.0.2", "vscode-textmate": "^9.0.0" }, diff --git a/packages/plugin-ext/src/main/browser/comments/comments-main.ts b/packages/plugin-ext/src/main/browser/comments/comments-main.ts index 4aab5f5d45914..c4e6051be9764 100644 --- a/packages/plugin-ext/src/main/browser/comments/comments-main.ts +++ b/packages/plugin-ext/src/main/browser/comments/comments-main.ts @@ -38,7 +38,7 @@ import { URI } from '@theia/core/shared/vscode-uri'; import { CancellationToken } from '@theia/core/lib/common'; import { RPCProtocol } from '../../../common/rpc-protocol'; import { interfaces } from '@theia/core/shared/inversify'; -import { v4 as uuidv4 } from 'uuid'; +import { generateUuid } from '@theia/core/lib/common/uuid'; import { CommentsContribution } from './comments-contribution'; /*--------------------------------------------------------------------------------------------- @@ -392,7 +392,7 @@ export class CommentsMainImp implements CommentsMain { } $registerCommentController(handle: number, id: string, label: string): void { - const providerId = uuidv4(); + const providerId = generateUuid(); this.handlers.set(handle, providerId); const provider = new CommentController(this.proxy, this.commentService, handle, providerId, id, label, {}); diff --git a/packages/plugin-ext/src/main/browser/custom-editors/custom-editor-opener.tsx b/packages/plugin-ext/src/main/browser/custom-editors/custom-editor-opener.tsx index 245ab57cb1e29..838c3ad08b162 100644 --- a/packages/plugin-ext/src/main/browser/custom-editors/custom-editor-opener.tsx +++ b/packages/plugin-ext/src/main/browser/custom-editors/custom-editor-opener.tsx @@ -19,7 +19,7 @@ import URI from '@theia/core/lib/common/uri'; import { ApplicationShell, OpenHandler, Widget, WidgetManager, WidgetOpenerOptions } from '@theia/core/lib/browser'; import { CustomEditor, CustomEditorPriority, CustomEditorSelector } from '../../../common'; import { CustomEditorWidget } from './custom-editor-widget'; -import { v4 } from 'uuid'; +import { generateUuid } from '@theia/core/lib/common/uuid'; import { Emitter } from '@theia/core'; import { match } from '@theia/core/lib/common/glob'; @@ -77,7 +77,7 @@ export class CustomEditorOpener implements OpenHandler { const uriString = uri.toString(); let widgetPromise = this.pendingWidgetPromises.get(uriString); if (!widgetPromise) { - const id = v4(); + const id = generateUuid(); widgetPromise = this.widgetManager.getOrCreateWidget(CustomEditorWidget.FACTORY_ID, { id }); this.pendingWidgetPromises.set(uriString, widgetPromise); widget = await widgetPromise; diff --git a/packages/plugin-ext/src/main/browser/notebooks/renderers/cell-output-webview.tsx b/packages/plugin-ext/src/main/browser/notebooks/renderers/cell-output-webview.tsx index dbf7179be3df1..c0be337bfe6d1 100644 --- a/packages/plugin-ext/src/main/browser/notebooks/renderers/cell-output-webview.tsx +++ b/packages/plugin-ext/src/main/browser/notebooks/renderers/cell-output-webview.tsx @@ -21,7 +21,7 @@ import * as React from '@theia/core/shared/react'; import { inject, injectable, interfaces, postConstruct } from '@theia/core/shared/inversify'; import { NotebookRendererMessagingService, CellOutputWebview, NotebookRendererRegistry, NotebookEditorWidgetService, NotebookCellOutputsSplice } from '@theia/notebook/lib/browser'; -import { v4 } from 'uuid'; +import { generateUuid } from '@theia/core/lib/common/uuid'; import { NotebookCellModel } from '@theia/notebook/lib/browser/view-model/notebook-cell-model'; import { WebviewWidget } from '../../webview/webview'; import { Message, WidgetManager } from '@theia/core/lib/browser'; @@ -65,7 +65,7 @@ export class CellOutputWebviewImpl implements CellOutputWebview, Disposable { @inject(QuickPickService) protected readonly quickPickService: QuickPickService; - readonly id = v4(); + readonly id = generateUuid(); protected readonly elementRef = React.createRef(); protected outputPresentationListeners: DisposableCollection = new DisposableCollection(); diff --git a/packages/plugin-ext/src/main/browser/view/plugin-view-registry.ts b/packages/plugin-ext/src/main/browser/view/plugin-view-registry.ts index f11ad8383cfc7..4da0239b8ad4c 100644 --- a/packages/plugin-ext/src/main/browser/view/plugin-view-registry.ts +++ b/packages/plugin-ext/src/main/browser/view/plugin-view-registry.ts @@ -43,7 +43,7 @@ import { TEST_VIEW_CONTAINER_ID } from '@theia/test/lib/browser/view/test-view-c import { WebviewView, WebviewViewResolver } from '../webview-views/webview-views'; import { WebviewWidget, WebviewWidgetIdentifier } from '../webview/webview'; import { CancellationToken } from '@theia/core/lib/common/cancellation'; -import { v4 } from 'uuid'; +import { generateUuid } from '@theia/core/lib/common/uuid'; import { nls } from '@theia/core'; import { TheiaDockPanel } from '@theia/core/lib/browser/shell/theia-dock-panel'; import { Deferred } from '@theia/core/lib/common/promise-util'; @@ -440,7 +440,7 @@ export class PluginViewRegistry implements FrontendApplicationContribution { protected async createNewWebviewView(viewId: string): Promise { const webview = await this.widgetManager.getOrCreateWidget( WebviewWidget.FACTORY_ID, { - id: v4(), + id: generateUuid(), viewId, }); webview.setContentOptions({ allowScripts: true }); diff --git a/packages/plugin-ext/src/main/node/errors.spec.ts b/packages/plugin-ext/src/main/node/errors.spec.ts index 56a20052ba287..b013492a91296 100644 --- a/packages/plugin-ext/src/main/node/errors.spec.ts +++ b/packages/plugin-ext/src/main/node/errors.spec.ts @@ -17,13 +17,13 @@ import { rejects } from 'assert'; import { strictEqual } from 'assert/strict'; import { promises as fs } from 'fs'; -import { v4 } from 'uuid'; +import { generateUuid } from '@theia/core/lib/common/uuid'; import { isENOENT } from '../../common/errors'; describe('errors', () => { describe('errno-exception', () => { it('should be ENOENT error', async () => { - await rejects(fs.readFile(v4()), reason => isENOENT(reason)); + await rejects(fs.readFile(generateUuid()), reason => isENOENT(reason)); }); it('should not be ENOENT error (no code)', () => { diff --git a/packages/plugin-ext/src/plugin/debug/debug-ext.ts b/packages/plugin-ext/src/plugin/debug/debug-ext.ts index d982385f30b82..af9486cab4dca 100644 --- a/packages/plugin-ext/src/plugin/debug/debug-ext.ts +++ b/packages/plugin-ext/src/plugin/debug/debug-ext.ts @@ -28,7 +28,7 @@ import { DEBUG_SCHEME, SCHEME_PATTERN } from '@theia/debug/lib/common/debug-uri- import { Disposable, Breakpoint as BreakpointExt, SourceBreakpoint, FunctionBreakpoint, Location, Range, URI as URIImpl } from '../types-impl'; import { PluginDebugAdapterSession } from './plugin-debug-adapter-session'; import { PluginDebugAdapterTracker } from './plugin-debug-adapter-tracker'; -import uuid = require('uuid'); +import { generateUuid } from '@theia/core/lib/common/uuid'; import { DebugAdapter } from '@theia/debug/lib/common/debug-model'; import { PluginDebugAdapterCreator } from './plugin-debug-adapter-creator'; import { NodeDebugAdapterCreator } from '../node/debug/plugin-node-debug-adapter-creator'; @@ -345,7 +345,7 @@ export class DebugExtImpl implements DebugExt { } async $createDebugSession(debugConfiguration: DebugConfiguration, workspaceFolderUri: string | undefined): Promise { - const sessionId = uuid.v4(); + const sessionId = generateUuid(); const parentSession = debugConfiguration.parentSessionId ? this.sessions.get(debugConfiguration.parentSessionId) : undefined; const theiaSession: theia.DebugSession = { diff --git a/packages/plugin-ext/src/plugin/env.ts b/packages/plugin-ext/src/plugin/env.ts index 5913179816f87..14d2bda0b9878 100644 --- a/packages/plugin-ext/src/plugin/env.ts +++ b/packages/plugin-ext/src/plugin/env.ts @@ -19,7 +19,7 @@ import * as theia from '@theia/plugin'; import { RPCProtocol } from '../common/rpc-protocol'; import { EnvMain, PLUGIN_RPC_CONTEXT } from '../common/plugin-api-rpc'; import { QueryParameters } from '../common/env'; -import { v4 } from 'uuid'; +import { generateUuid } from '@theia/core/lib/common/uuid'; @injectable() export abstract class EnvExtImpl { @@ -38,8 +38,8 @@ export abstract class EnvExtImpl { private _remoteName: string | undefined; constructor() { - this.envSessionId = v4(); - this.envMachineId = v4(); + this.envSessionId = generateUuid(); + this.envMachineId = generateUuid(); this._remoteName = undefined; } diff --git a/packages/plugin-ext/src/plugin/languages/diagnostics.ts b/packages/plugin-ext/src/plugin/languages/diagnostics.ts index ea74544b09ea2..5710b5bf804e6 100644 --- a/packages/plugin-ext/src/plugin/languages/diagnostics.ts +++ b/packages/plugin-ext/src/plugin/languages/diagnostics.ts @@ -22,7 +22,7 @@ import { MarkerData } from '../../common/plugin-api-rpc-model'; import { RPCProtocol } from '../../common/rpc-protocol'; import { PLUGIN_RPC_CONTEXT, LanguagesMain } from '../../common/plugin-api-rpc'; import { URI } from '@theia/core/shared/vscode-uri'; -import { v4 } from 'uuid'; +import { generateUuid } from '@theia/core/lib/common/uuid'; export class DiagnosticCollection implements theia.DiagnosticCollection { private static DIAGNOSTICS_PRIORITY = [ @@ -288,7 +288,7 @@ export class Diagnostics { } private getNextId(): string { - return v4(); + return generateUuid(); } private getAllDiagnosticsForResource(uri: URI): theia.Diagnostic[] { diff --git a/packages/plugin-ext/src/plugin/node/env-node-ext.ts b/packages/plugin-ext/src/plugin/node/env-node-ext.ts index 18ac72b3038d0..92e3f2b594d18 100644 --- a/packages/plugin-ext/src/plugin/node/env-node-ext.ts +++ b/packages/plugin-ext/src/plugin/node/env-node-ext.ts @@ -18,7 +18,7 @@ import { injectable } from '@theia/core/shared/inversify'; import * as mac from 'macaddress'; import { EnvExtImpl } from '../env'; import { createHash } from 'crypto'; -import { v4 } from 'uuid'; +import { generateUuid } from '@theia/core/lib/common/uuid'; import fs = require('fs'); /** @@ -36,7 +36,7 @@ export class EnvNodeExtImpl extends EnvExtImpl { mac.one((err, macAddress) => { if (err) { - this.macMachineId = v4(); + this.macMachineId = generateUuid(); } else { this.macMachineId = createHash('sha256').update(macAddress, 'utf8').digest('hex'); } diff --git a/packages/plugin-ext/src/plugin/preference-registry.ts b/packages/plugin-ext/src/plugin/preference-registry.ts index 7d579ce1c5ef7..29863cfb265b6 100644 --- a/packages/plugin-ext/src/plugin/preference-registry.ts +++ b/packages/plugin-ext/src/plugin/preference-registry.ts @@ -25,7 +25,7 @@ import { IConfigurationOverrides } from '@theia/monaco-editor-core/esm/vs/platfo import { Configuration, ConfigurationModel, ConfigurationModelParser } from '@theia/monaco-editor-core/esm/vs/platform/configuration/common/configurationModels'; import { Workspace, WorkspaceFolder } from '@theia/monaco-editor-core/esm/vs/platform/workspace/common/workspace'; import * as theia from '@theia/plugin'; -import { v4 } from 'uuid'; +import { generateUuid } from '@theia/core/lib/common/uuid'; import { PLUGIN_RPC_CONTEXT, PreferenceChangeExt, PreferenceData, PreferenceRegistryExt, PreferenceRegistryMain @@ -75,7 +75,7 @@ function lookUp(tree: any, key: string): any { export class TheiaWorkspace extends Workspace { constructor(ext: WorkspaceExtImpl) { const folders = (ext.workspaceFolders ?? []).map(folder => new WorkspaceFolder(folder)); - super(v4(), folders, false, ext.workspaceFile ?? null, () => isOSX || isWindows); + super(generateUuid(), folders, false, ext.workspaceFile ?? null, () => isOSX || isWindows); } } diff --git a/packages/plugin-ext/src/plugin/tests.ts b/packages/plugin-ext/src/plugin/tests.ts index 9f1083651123b..48106408d3d47 100644 --- a/packages/plugin-ext/src/plugin/tests.ts +++ b/packages/plugin-ext/src/plugin/tests.ts @@ -34,7 +34,7 @@ import { isDefined } from '@theia/core/lib/common/types'; import { TestingExt, PLUGIN_RPC_CONTEXT, TestingMain } from '../common/plugin-api-rpc'; import { CommandRegistryImpl } from './command-registry'; import { RPCProtocol } from '../common/rpc-protocol'; -import { v4 as uuidv4 } from 'uuid'; +import { generateUuid } from '@theia/core/lib/common/uuid'; import * as Convert from './type-converters'; import { TestItemImpl, TestItemCollection } from './test-item'; import { AccumulatingTreeDeltaEmitter, TreeDelta } from '@theia/test/lib/common/tree-delta'; @@ -257,7 +257,7 @@ class TestRun implements theia.TestRun { readonly name: string, readonly isPersisted: boolean, isRunning: boolean) { - this.id = uuidv4(); + this.id = generateUuid(); this.tokenSource = new CancellationTokenSource(); this.token = this.tokenSource.token; diff --git a/packages/plugin-ext/src/plugin/webviews.ts b/packages/plugin-ext/src/plugin/webviews.ts index 72a2e903fb656..5ad4356ad832b 100644 --- a/packages/plugin-ext/src/plugin/webviews.ts +++ b/packages/plugin-ext/src/plugin/webviews.ts @@ -14,7 +14,7 @@ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 // ***************************************************************************** -import { v4 } from 'uuid'; +import { generateUuid, hashValue } from '@theia/core/lib/common/uuid'; import { inject, injectable, postConstruct } from '@theia/core/shared/inversify'; import { Plugin, WebviewsExt, WebviewPanelViewState, WebviewsMain, PLUGIN_RPC_CONTEXT, WebviewInitData, /* WebviewsMain, PLUGIN_RPC_CONTEXT */ } from '../common/plugin-api-rpc'; import * as theia from '@theia/plugin'; @@ -24,7 +24,6 @@ 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 '@theia/core/lib/common/uuid'; @injectable() export class WebviewsExtImpl implements WebviewsExt { @@ -118,7 +117,7 @@ export class WebviewsExtImpl implements WebviewsExt { options: theia.WebviewPanelOptions & theia.WebviewOptions, plugin: Plugin ): theia.WebviewPanel { - const viewId = v4(); + const viewId = generateUuid(); const webviewShowOptions = toWebviewPanelShowOptions(showOptions); const webviewOptions = WebviewImpl.toWebviewOptions(options, this.workspace, plugin); this.proxy.$createWebviewPanel(viewId, viewType, title, webviewShowOptions, webviewOptions); diff --git a/packages/remote/package.json b/packages/remote/package.json index 770098e651bcd..cd52c26ea0ccb 100644 --- a/packages/remote/package.json +++ b/packages/remote/package.json @@ -15,8 +15,7 @@ "ssh2": "^1.12.0", "ssh2-sftp-client": "^9.1.0", "socket.io": "^4.5.3", - "socket.io-client": "^4.5.3", - "uuid": "^8.0.0" + "socket.io-client": "^4.5.3" }, "publishConfig": { "access": "public" diff --git a/packages/remote/src/electron-node/ssh/remote-ssh-connection-provider.ts b/packages/remote/src/electron-node/ssh/remote-ssh-connection-provider.ts index 3de1a97bea596..a0b20e321c235 100644 --- a/packages/remote/src/electron-node/ssh/remote-ssh-connection-provider.ts +++ b/packages/remote/src/electron-node/ssh/remote-ssh-connection-provider.ts @@ -27,7 +27,7 @@ import { RemoteConnection, RemoteExecOptions, RemoteExecResult, RemoteExecTester import { Deferred, timeout } from '@theia/core/lib/common/promise-util'; import { SSHIdentityFileCollector, SSHKey } from './ssh-identity-file-collector'; import { RemoteSetupService } from '../setup/remote-setup-service'; -import { v4 } from 'uuid'; +import { generateUuid } from '@theia/core/lib/common/uuid'; @injectable() export class RemoteSSHConnectionProviderImpl implements RemoteSSHConnectionProvider { @@ -92,7 +92,7 @@ export class RemoteSSHConnectionProviderImpl implements RemoteSSHConnectionProvi .on('ready', async () => { const connection = new RemoteSSHConnection({ client: sshClient, - id: v4(), + id: generateUuid(), name: hostUrl.hostname, type: 'SSH' }); diff --git a/packages/typehierarchy/package.json b/packages/typehierarchy/package.json index 5df8530b51a38..4efab626c0c08 100644 --- a/packages/typehierarchy/package.json +++ b/packages/typehierarchy/package.json @@ -4,9 +4,7 @@ "description": "Theia - Type Hierarchy Extension", "dependencies": { "@theia/core": "1.46.0", - "@theia/editor": "1.46.0", - "@types/uuid": "^7.0.3", - "uuid": "^8.0.0" + "@theia/editor": "1.46.0" }, "publishConfig": { "access": "public" diff --git a/packages/typehierarchy/src/browser/tree/typehierarchy-tree.ts b/packages/typehierarchy/src/browser/tree/typehierarchy-tree.ts index 517fe17ebc3e4..65aaaa016e965 100644 --- a/packages/typehierarchy/src/browser/tree/typehierarchy-tree.ts +++ b/packages/typehierarchy/src/browser/tree/typehierarchy-tree.ts @@ -17,7 +17,7 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ import { injectable } from '@theia/core/shared/inversify'; -import { v4 } from 'uuid'; +import { generateUuid } from '@theia/core/lib/common/uuid'; import URI from '@theia/core/lib/common/uri'; import { Location } from '@theia/editor/lib/browser/editor'; import { TreeDecoration, DecoratedTreeNode } from '@theia/core/lib/browser/tree/tree-decorator'; @@ -134,7 +134,7 @@ export namespace TypeHierarchyTree { resolved = true; } const node = { - id: v4(), + id: generateUuid(), name: item.name, description: item.detail, parent: undefined, diff --git a/packages/vsx-registry/package.json b/packages/vsx-registry/package.json index 9cb6671888d99..49ed7002fcbd4 100644 --- a/packages/vsx-registry/package.json +++ b/packages/vsx-registry/package.json @@ -13,8 +13,7 @@ "@theia/workspace": "1.46.0", "luxon": "^2.4.0", "p-debounce": "^2.1.0", - "semver": "^7.5.4", - "uuid": "^8.0.0" + "semver": "^7.5.4" }, "publishConfig": { "access": "public" diff --git a/yarn.lock b/yarn.lock index 7d7a29d8e2fa7..944fc49ab9b01 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2272,10 +2272,10 @@ dependencies: "@types/node" "*" -"@types/uuid@^7.0.3": - version "7.0.6" - resolved "https://registry.yarnpkg.com/@types/uuid/-/uuid-7.0.6.tgz#455e838428ae709f82c85c677dcf5115f2061ac1" - integrity sha512-U/wu4HTp6T2dUmKqDtOUKS9cYhawuf8txqKF3Jp1iMDG8fP5HtjSldcN0g4m+/h7XHU1to1/HDCT0qeeUiu0EA== +"@types/uuid@^9.0.8": + version "9.0.8" + resolved "https://registry.yarnpkg.com/@types/uuid/-/uuid-9.0.8.tgz#7545ba4fc3c003d6c756f651f3bf163d8f0f29ba" + integrity sha512-jg+97EGIcY9AGHJJRaaPVgetKDsrTgbRjQ5Msgjh/DQKEFl0DtyRr/VCOyD1T2R1MNeWPK/u7JoGhlDZnKBAfA== "@types/vscode-notebook-renderer@^1.72.0": version "1.72.1" @@ -11629,12 +11629,12 @@ uuid@^7.0.3: resolved "https://registry.yarnpkg.com/uuid/-/uuid-7.0.3.tgz#c5c9f2c8cf25dc0a372c4df1441c41f5bd0c680b" integrity sha512-DPSke0pXhTZgoF/d+WSt2QaKMCFSfx7QegxEWT+JOuHF5aWrKEn0G+ztjuJg/gG8/ItK+rbPCD/yNv8yyih6Cg== -uuid@^8.0.0, uuid@^8.3.2: +uuid@^8.3.2: version "8.3.2" resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg== -uuid@^9.0.0: +uuid@^9.0.0, uuid@^9.0.1: version "9.0.1" resolved "https://registry.yarnpkg.com/uuid/-/uuid-9.0.1.tgz#e188d4c8853cc722220392c424cd637f32293f30" integrity sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==