Skip to content

Commit 12a1988

Browse files
committed
Fix compilation
Tool: gitpod/catfood.gitpod.cloud
1 parent d5f0784 commit 12a1988

File tree

4 files changed

+32
-13
lines changed

4 files changed

+32
-13
lines changed

src/vs/base/common/uuid.ts

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,34 @@ export function isUUID(value: string): boolean {
1010
return _UUIDPattern.test(value);
1111
}
1212

13+
declare const crypto: undefined | {
14+
//https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues#browser_compatibility
15+
getRandomValues?(data: Uint8Array): Uint8Array;
16+
//https://developer.mozilla.org/en-US/docs/Web/API/Crypto/randomUUID#browser_compatibility
17+
randomUUID?(): string;
18+
};
19+
1320
export const generateUuid = (function (): () => string {
1421

1522
// use `randomUUID` if possible
16-
if (typeof crypto.randomUUID === 'function') {
17-
// see https://developer.mozilla.org/en-US/docs/Web/API/Window/crypto
18-
// > Although crypto is available on all windows, the returned Crypto object only has one
19-
// > usable feature in insecure contexts: the getRandomValues() method.
20-
// > In general, you should use this API only in secure contexts.
21-
23+
if (typeof crypto === 'object' && typeof crypto.randomUUID === 'function') {
2224
return crypto.randomUUID.bind(crypto);
2325
}
2426

27+
// use `randomValues` if possible
28+
let getRandomValues: (bucket: Uint8Array) => Uint8Array;
29+
if (typeof crypto === 'object' && typeof crypto.getRandomValues === 'function') {
30+
getRandomValues = crypto.getRandomValues.bind(crypto);
31+
32+
} else {
33+
getRandomValues = function (bucket: Uint8Array): Uint8Array {
34+
for (let i = 0; i < bucket.length; i++) {
35+
bucket[i] = Math.floor(Math.random() * 256);
36+
}
37+
return bucket;
38+
};
39+
}
40+
2541
// prep-work
2642
const _data = new Uint8Array(16);
2743
const _hex: string[] = [];
@@ -31,7 +47,7 @@ export const generateUuid = (function (): () => string {
3147

3248
return function generateUuid(): string {
3349
// get data
34-
crypto.getRandomValues(_data);
50+
getRandomValues(_data);
3551

3652
// set version bits
3753
_data[6] = (_data[6] & 0x0f) | 0x40;

src/vs/gitpod/browser/workbench/workbench.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
* Copyright (c) Gitpod. All rights reserved.
55
*--------------------------------------------------------------------------------------------*/
66

7-
/// <reference types='@gitpod/gitpod-protocol/lib/typings/globals'/>
7+
/// <reference types='@gitpod/gitpod-protocol/lib/typings/globals.d.ts'/>
88

9-
import type { IDEFrontendState } from '@gitpod/gitpod-protocol/lib/ide-frontend-service';
10-
import type { Status, TunnelStatus } from '@gitpod/local-app-api-grpcweb';
9+
import type { IDEFrontendState } from '@gitpod/gitpod-protocol/lib/ide-frontend-service.js';
10+
import type { Status, TunnelStatus } from '@gitpod/local-app-api-grpcweb/lib/localapp.d.ts';
1111
import { isStandalone } from '../../../base/browser/browser.js';
1212
import { parse } from '../../../base/common/marshalling.js';
1313
import { Emitter, Event } from '../../../base/common/event.js';
@@ -32,7 +32,7 @@ import type { TunnelOptions } from 'vscode';
3232
import { importAMDNodeModule } from '../../../amdX.js';
3333
import { mainWindow } from '../../../base/browser/window.js';
3434

35-
const loadingGrpc = importAMDNodeModule<typeof import('@improbable-eng/grpc-web')>('@improbable-eng/grpc-web', 'dist/grpc-web-client.umd.js');
35+
const loadingGrpc = importAMDNodeModule<typeof import('@improbable-eng/grpc-web/dist/typings/index.d.ts')>('@improbable-eng/grpc-web', 'dist/grpc-web-client.umd.js');
3636

3737
export class LocalStorageSecretStorageProvider implements ISecretStorageProvider {
3838
private readonly _storageKey = 'secrets.provider';

src/vs/gitpod/common/insightsHelper.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Copyright (c) Gitpod. All rights reserved.
55
*--------------------------------------------------------------------------------------------*/
66

7-
import type { IDEMetric } from '@gitpod/ide-metrics-api-grpcweb/lib/index';
7+
import type { IDEMetric } from '@gitpod/ide-metrics-api-grpcweb/lib/index.js';
88

99
export interface ReportErrorParam {
1010
workspaceId: string;
@@ -216,6 +216,7 @@ export function mapTelemetryData(source: 'window' | 'remote-server', eventName:
216216
};
217217
return {
218218
event: 'vscode_browser_remote_connection',
219+
// eslint-disable-next-line local/code-no-dangerous-type-assertions
219220
properties: {
220221
state: getEventName(eventName),
221222
// Time, in ms, until connected / connection failure
@@ -231,6 +232,7 @@ export function mapTelemetryData(source: 'window' | 'remote-server', eventName:
231232
};
232233
return {
233234
event: 'vscode_browser_remote_connection_latency',
235+
// eslint-disable-next-line local/code-no-dangerous-type-assertions
234236
properties: {
235237
latencyMs: data.latencyMs
236238
} as ConnectionLatencyProperties
@@ -250,6 +252,7 @@ export function mapTelemetryData(source: 'window' | 'remote-server', eventName:
250252
};
251253
return {
252254
event: 'vscode_browser_remote_reconnection',
255+
// eslint-disable-next-line local/code-no-dangerous-type-assertions
253256
properties: {
254257
event: getEventName(eventName),
255258
reconnectionToken: data.reconnectionToken,

src/vs/server/node/remoteExtensionsScanner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class RemoteExtensionsScannerService implements IRemoteExtensionsScannerS
4444
private readonly _logService: ILogService,
4545
private readonly _extensionGalleryService: IExtensionGalleryService,
4646
private readonly _languagePackService: ILanguagePackService,
47-
private readonly _extensionManagementService: IExtensionManagementService,,
47+
private readonly _extensionManagementService: IExtensionManagementService,
4848
private readonly _downloadService: IDownloadService,
4949
) {
5050
const builtinExtensionsToInstall = environmentService.args['install-builtin-extension'];

0 commit comments

Comments
 (0)