tweak uuid import (#2001)

This commit is contained in:
Kurt Hutten
2024-04-03 19:38:16 +11:00
committed by GitHub
parent b045a89854
commit 1a7a19ee85
12 changed files with 13 additions and 28 deletions

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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 {

View File

@ -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'

View File

@ -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'

View File

@ -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.

View File

@ -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'

View File

@ -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]]

View File

@ -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')
})
})

View File

@ -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
}

View File

@ -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'