Skip to content

Commit a1cb124

Browse files
committed
Rebase
1 parent d9c0ed4 commit a1cb124

File tree

5 files changed

+14
-77
lines changed

5 files changed

+14
-77
lines changed

packages/core/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"@types/react-dom": "^18.0.6",
3131
"@types/route-parser": "^0.1.1",
3232
"@types/safer-buffer": "^2.1.0",
33+
"@types/uuid": "^9.0.8",
3334
"@types/ws": "^8.5.5",
3435
"@types/yargs": "^15",
3536
"@vscode/codicons": "*",
@@ -68,6 +69,7 @@
6869
"safer-buffer": "^2.1.2",
6970
"socket.io": "^4.5.3",
7071
"socket.io-client": "^4.5.3",
72+
"uuid": "^9.0.1",
7173
"vscode-languageserver-protocol": "^3.17.2",
7274
"vscode-uri": "^2.1.1",
7375
"ws": "^8.14.1",

packages/core/src/common/uuid.ts

Lines changed: 4 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -21,84 +21,17 @@
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';
24+
import { v4, v5 } from 'uuid';
2525

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

2828
export function isUUID(value: string): boolean {
2929
return _UUIDPattern.test(value);
3030
}
3131

32-
declare const crypto: undefined | {
33-
// https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues#browser_compatibility
34-
getRandomValues?(data: Uint8Array): Uint8Array;
35-
// https://developer.mozilla.org/en-US/docs/Web/API/Crypto/randomUUID#browser_compatibility
36-
randomUUID?(): string;
37-
};
38-
39-
export const generateUuid = (function (): () => string {
40-
41-
// use `randomUUID` if possible
42-
if (typeof crypto === 'object' && typeof crypto.randomUUID === 'function') {
43-
return crypto.randomUUID.bind(crypto);
44-
}
45-
46-
// use `randomValues` if possible
47-
let getRandomValues: (bucket: Uint8Array) => Uint8Array;
48-
if (typeof crypto === 'object' && typeof crypto.getRandomValues === 'function') {
49-
getRandomValues = crypto.getRandomValues.bind(crypto);
50-
51-
} else {
52-
getRandomValues = function (bucket: Uint8Array): Uint8Array {
53-
for (let i = 0; i < bucket.length; i++) {
54-
bucket[i] = Math.floor(Math.random() * 256);
55-
}
56-
return bucket;
57-
};
58-
}
59-
60-
// prep-work
61-
const _data = new Uint8Array(16);
62-
const _hex: string[] = [];
63-
for (let i = 0; i < 256; i++) {
64-
_hex.push(i.toString(16).padStart(2, '0'));
65-
}
66-
67-
// eslint-disable-next-line @typescript-eslint/no-shadow
68-
return function generateUuid(): string {
69-
// get data
70-
getRandomValues(_data);
71-
72-
// set version bits
73-
_data[6] = (_data[6] & 0x0f) | 0x40;
74-
_data[8] = (_data[8] & 0x3f) | 0x80;
75-
76-
// print as string
77-
let i = 0;
78-
let result = '';
79-
result += _hex[_data[i++]];
80-
result += _hex[_data[i++]];
81-
result += _hex[_data[i++]];
82-
result += _hex[_data[i++]];
83-
result += '-';
84-
result += _hex[_data[i++]];
85-
result += _hex[_data[i++]];
86-
result += '-';
87-
result += _hex[_data[i++]];
88-
result += _hex[_data[i++]];
89-
result += '-';
90-
result += _hex[_data[i++]];
91-
result += _hex[_data[i++]];
92-
result += '-';
93-
result += _hex[_data[i++]];
94-
result += _hex[_data[i++]];
95-
result += _hex[_data[i++]];
96-
result += _hex[_data[i++]];
97-
result += _hex[_data[i++]];
98-
result += _hex[_data[i++]];
99-
return result;
100-
};
101-
})();
32+
export function generateUuid(): string {
33+
return v4();
34+
}
10235

10336
const NAMESPACE = '4c90ee4f-d952-44b1-83ca-f04121ab8e05';
10437
/**

packages/notebook/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
"@theia/core": "1.46.0",
77
"@theia/editor": "1.46.0",
88
"@theia/filesystem": "1.46.0",
9-
"@theia/monaco": "1.46.0",
10-
"uuid": "^8.3.2"
9+
"@theia/monaco": "1.46.0"
1110
},
1211
"publishConfig": {
1312
"access": "public"

packages/typehierarchy/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
"description": "Theia - Type Hierarchy Extension",
55
"dependencies": {
66
"@theia/core": "1.46.0",
7-
"@theia/editor": "1.46.0",
8-
"@types/uuid": "^7.0.3",
9-
"uuid": "^8.0.0"
7+
"@theia/editor": "1.46.0"
108
},
119
"publishConfig": {
1210
"access": "public"

yarn.lock

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2272,6 +2272,11 @@
22722272
dependencies:
22732273
"@types/node" "*"
22742274

2275+
"@types/uuid@^9.0.8":
2276+
version "9.0.8"
2277+
resolved "https://registry.yarnpkg.com/@types/uuid/-/uuid-9.0.8.tgz#7545ba4fc3c003d6c756f651f3bf163d8f0f29ba"
2278+
integrity sha512-jg+97EGIcY9AGHJJRaaPVgetKDsrTgbRjQ5Msgjh/DQKEFl0DtyRr/VCOyD1T2R1MNeWPK/u7JoGhlDZnKBAfA==
2279+
22752280
"@types/vscode-notebook-renderer@^1.72.0":
22762281
version "1.72.1"
22772282
resolved "https://registry.yarnpkg.com/@types/vscode-notebook-renderer/-/vscode-notebook-renderer-1.72.1.tgz#5605079fa6f0fa1dddc57ce11315eec0d1a8d869"
@@ -11629,7 +11634,7 @@ uuid@^8.3.2:
1162911634
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
1163011635
integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==
1163111636

11632-
uuid@^9.0.0:
11637+
uuid@^9.0.0, uuid@^9.0.1:
1163311638
version "9.0.1"
1163411639
resolved "https://registry.yarnpkg.com/uuid/-/uuid-9.0.1.tgz#e188d4c8853cc722220392c424cd637f32293f30"
1163511640
integrity sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==

0 commit comments

Comments
 (0)