Skip to content

Commit 354a05d

Browse files
authored
Remove dependency on uuid (#33230)
* Remove dependency on `uuid` * Delint
1 parent 86ea6bd commit 354a05d

File tree

6 files changed

+3
-13
lines changed

6 files changed

+3
-13
lines changed

apps/web/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@
104104
"sanitize-html": "2.17.3",
105105
"tar-js": "^0.3.0",
106106
"ua-parser-js": "1.0.40",
107-
"uuid": "^13.0.0",
108107
"what-input": "^5.2.10"
109108
},
110109
"devDependencies": {

apps/web/src/components/views/dialogs/devtools/StickyEventState.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import React, { type ChangeEvent, useContext, useEffect, useMemo, useState } fro
99
import { Pill } from "@element-hq/web-shared-components";
1010
import { MatrixEvent, type IContent, RoomStickyEventsEvent } from "matrix-js-sdk/src/matrix";
1111
import { Alert, Form, SettingsToggleInput } from "@vector-im/compound-web";
12-
import { v4 as uuidv4 } from "uuid";
1312

1413
import BaseTool, { DevtoolsContext, type IDevtoolsProps } from "./BaseTool.tsx";
1514
import { _t, _td, UserFriendlyError } from "../../../../languageHandler.tsx";
@@ -330,7 +329,7 @@ export const StickyEventEditor: React.FC<IEditorProps> = ({ mxEvent, onBack }) =
330329
const defaultContent = mxEvent
331330
? stringify(mxEvent.getContent())
332331
: stringify({
333-
msc4354_sticky_key: uuidv4(),
332+
msc4354_sticky_key: window.crypto.randomUUID(),
334333
});
335334
return <EventEditor fieldDefs={fields} defaultContent={defaultContent} onSend={onSend} onBack={onBack} />;
336335
};

apps/web/src/stores/room-list-v3/section.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
* Please see LICENSE files in the repository root for full details.
66
*/
77

8-
import { v4 as uuidv4 } from "uuid";
9-
108
import { SettingLevel } from "../../settings/SettingLevel";
119
import SettingsStore from "../../settings/SettingsStore";
1210
import Modal from "../../Modal";
@@ -43,7 +41,7 @@ export async function createSection(): Promise<boolean> {
4341
const [shouldCreateSection, sectionName] = await modal.finished;
4442
if (!shouldCreateSection || !sectionName) return false;
4543

46-
const tag = `element.io.section.${uuidv4()}`;
44+
const tag = `element.io.section.${window.crypto.randomUUID()}`;
4745
const newSection: CustomSection = { tag, name: sectionName };
4846

4947
// Save the new section data

apps/web/src/utils/SessionLock.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ Please see LICENSE files in the repository root for full details.
77
*/
88

99
import { logger } from "matrix-js-sdk/src/logger";
10-
import { v4 as uuidv4 } from "uuid";
1110

1211
/*
1312
* Functionality for checking that only one instance is running at once
@@ -107,7 +106,7 @@ export function checkSessionLockFree(): boolean {
107106
*/
108107
export async function getSessionLock(onNewInstance: () => Promise<void>): Promise<boolean> {
109108
/** unique ID for this session */
110-
const sessionIdentifier = uuidv4();
109+
const sessionIdentifier = window.crypto.randomUUID();
111110

112111
const prefixedLogger = logger.getChild(`getSessionLock[${sessionIdentifier}]`);
113112

apps/web/test/unit-tests/utils/SessionLock-test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,6 @@ describe("SessionLock", () => {
253253

254254
// import the dependencies of getSessionLock into the new context
255255
// eslint-disable-next-line @typescript-eslint/no-require-imports
256-
window2._uuid = require("uuid");
257-
// eslint-disable-next-line @typescript-eslint/no-require-imports
258256
window2._logger = require("matrix-js-sdk/src/logger");
259257
window2.SESSION_LOCK_CONSTANTS = SESSION_LOCK_CONSTANTS;
260258

pnpm-lock.yaml

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)