diff --git a/src/App.tsx b/src/App.tsx index 9211496bd..fefdb4813 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,6 +1,6 @@ import { useCallback, MouseEventHandler, useEffect } from 'react' import { DebugPanel } from './components/DebugPanel' -import { v4 as uuidv4 } from 'uuid' +import { uuidv4 } from 'lib/utils' import { PaneType, useStore } from './useStore' import { Logs, KCLErrors } from './components/Logs' import { CollapsiblePanel } from './components/CollapsiblePanel' diff --git a/src/clientSideScene/CameraControls.ts b/src/clientSideScene/CameraControls.ts index 1f9e8d2f6..ab712468a 100644 --- a/src/clientSideScene/CameraControls.ts +++ b/src/clientSideScene/CameraControls.ts @@ -21,7 +21,7 @@ import { Subscription, EngineCommandManager, } from 'lang/std/engineConnection' -import { v4 as uuidv4 } from 'uuid' +import { uuidv4 } from 'lib/utils' import { deg2Rad } from 'lib/utils2d' import { isReducedMotion, roundOff, throttle } from 'lib/utils' import * as TWEEN from '@tweenjs/tween.js' diff --git a/src/clientSideScene/sceneEntities.ts b/src/clientSideScene/sceneEntities.ts index 2ff83a25a..3f4f13665 100644 --- a/src/clientSideScene/sceneEntities.ts +++ b/src/clientSideScene/sceneEntities.ts @@ -82,7 +82,7 @@ import { import { getTangentPointFromPreviousArc } from 'lib/utils2d' import { createGridHelper, orthoScale, perspScale } from './helpers' import { Models } from '@kittycad/lib' -import { v4 as uuidv4 } from 'uuid' +import { uuidv4 } from 'lib/utils' import { SketchDetails } from 'machines/modelingMachine' import { EngineCommandManager } from 'lang/std/engineConnection' diff --git a/src/components/SettingsAuthProvider.tsx b/src/components/SettingsAuthProvider.tsx index cb5cfc057..18dc961e1 100644 --- a/src/components/SettingsAuthProvider.tsx +++ b/src/components/SettingsAuthProvider.tsx @@ -19,7 +19,7 @@ import { import { isTauri } from 'lib/isTauri' import { authCommandBarConfig } from 'lib/commandBarConfigs/authCommandConfig' import { kclManager, sceneInfra, engineCommandManager } from 'lib/singletons' -import { v4 as uuidv4 } from 'uuid' +import { uuidv4 } from 'lib/utils' import { IndexLoaderData } from 'lib/types' import { settings } from 'lib/settings/initialSettings' import { diff --git a/src/lang/KclSingleton.ts b/src/lang/KclSingleton.ts index ae51dc5a3..06a40222a 100644 --- a/src/lang/KclSingleton.ts +++ b/src/lang/KclSingleton.ts @@ -1,7 +1,7 @@ import { executeAst, executeCode } from 'useStore' import { Selections } from 'lib/selections' import { KCLError } from './errors' -import { v4 as uuidv4 } from 'uuid' +import { uuidv4 } from 'lib/utils' import { EngineCommandManager } from './std/engineConnection' import { deferExecution } from 'lib/utils' diff --git a/src/lang/std/engineConnection.ts b/src/lang/std/engineConnection.ts index a7b254778..69261272d 100644 --- a/src/lang/std/engineConnection.ts +++ b/src/lang/std/engineConnection.ts @@ -2,7 +2,7 @@ import { PathToNode, Program, SourceRange } from 'lang/wasm' import { VITE_KC_API_WS_MODELING_URL, VITE_KC_CONNECTION_TIMEOUT_MS } from 'env' import { Models } from '@kittycad/lib' import { exportSave } from 'lib/exportSave' -import { v4 as uuidv4 } from 'uuid' +import { uuidv4 } from 'lib/utils' import { getNodePathFromSourceRange } from 'lang/queryAst' import { Themes, getThemeColorForEngine } from 'lib/theme' diff --git a/src/lib/exportFromEngine.ts b/src/lib/exportFromEngine.ts index 3b0674ec5..9889d8d2a 100644 --- a/src/lib/exportFromEngine.ts +++ b/src/lib/exportFromEngine.ts @@ -1,6 +1,6 @@ import { engineCommandManager } from 'lib/singletons' import { type Models } from '@kittycad/lib' -import { v4 as uuidv4 } from 'uuid' +import { uuidv4 } from 'lib/utils' // Isolating a function to call the engine to export the current scene. // Because it has given us trouble in automated testing environments. diff --git a/src/lib/selections.ts b/src/lib/selections.ts index d71646c35..fa1289d78 100644 --- a/src/lib/selections.ts +++ b/src/lib/selections.ts @@ -6,7 +6,7 @@ import { } from 'lib/singletons' import { CallExpression, SourceRange, parse, recast } from 'lang/wasm' import { ModelingMachineEvent } from 'machines/modelingMachine' -import { v4 as uuidv4 } from 'uuid' +import { uuidv4 } from 'lib/utils' import { EditorSelection } from '@codemirror/state' import { SelectionRange } from '@uiw/react-codemirror' import { getNormalisedCoordinates, isOverlap } from 'lib/utils' diff --git a/src/lib/utils.ts b/src/lib/utils.ts index 4c4ac80a0..ec6ba1b3f 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -1,5 +1,9 @@ import { SourceRange } from '../lang/wasm' +import { v4 } from 'uuid' + +export const uuidv4 = v4 + export function isOverlap(a: SourceRange, b: SourceRange) { const [startingRange, secondRange] = a[0] < b[0] ? [a, b] : [b, a] const [lastOfFirst, firstOfSecond] = [startingRange[1], secondRange[0]] diff --git a/src/lib/uuid.test.ts b/src/lib/uuid.test.ts deleted file mode 100644 index 7c97650bd..000000000 --- a/src/lib/uuid.test.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { generateUuidFromHashSeed } from './uuid' - -describe('generateUuidFromHashSeed', () => { - it('generates a UUID from a hash seed', () => { - const inputString = 'Hello, World!' - const uuid = generateUuidFromHashSeed(inputString) - expect(uuid).toEqual('64666664-3630-4231-a262-326264356230') - }) -}) diff --git a/src/lib/uuid.ts b/src/lib/uuid.ts deleted file mode 100644 index 784049086..000000000 --- a/src/lib/uuid.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { v4 as uuidv4 } from 'uuid' -import { SHA256 } from 'crypto-js' - -export function generateUuidFromHashSeed(seed: string): string { - const hashedSeed = SHA256(seed).toString() - const uuid = uuidv4({ - random: hashedSeed.split('').map((c: string) => c.charCodeAt(0)), - }) - return uuid -} diff --git a/src/machines/modelingMachine.ts b/src/machines/modelingMachine.ts index 97dd7c36a..8fc4c13e1 100644 --- a/src/machines/modelingMachine.ts +++ b/src/machines/modelingMachine.ts @@ -42,7 +42,7 @@ import { ModelingCommandSchema } from 'lib/commandBarConfigs/modelingCommandConf import { DefaultPlaneStr } from 'clientSideScene/sceneEntities' import { Vector3 } from 'three' import { quaternionFromUpNForward } from 'clientSideScene/helpers' -import { v4 as uuidv4 } from 'uuid' +import { uuidv4 } from 'lib/utils' export const MODELING_PERSIST_KEY = 'MODELING_PERSIST_KEY'