From 18580d5487b24bff177c6c52d0810f8f7e457bcf Mon Sep 17 00:00:00 2001 From: Hiroshiba Date: Thu, 14 Nov 2024 10:38:27 +0900 Subject: [PATCH] =?UTF-8?q?uuid=E3=82=92fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/domain/project/index.ts | 3 ++- src/store/project.ts | 3 ++- src/store/singing.ts | 4 ++-- tests/unit/domain/__snapshots__/project.spec.ts.snap | 4 ++-- tests/unit/domain/project.spec.ts | 5 +++++ tests/unit/domain/sing/shouldPlayTracks.spec.ts | 3 ++- 6 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/domain/project/index.ts b/src/domain/project/index.ts index 3f541af269..7319f6d036 100644 --- a/src/domain/project/index.ts +++ b/src/domain/project/index.ts @@ -16,6 +16,7 @@ import { DEFAULT_TPQN, DEFAULT_TRACK_NAME, } from "@/sing/domain"; +import { uuid4 } from "@/helpers/random"; const DEFAULT_SAMPLING_RATE = 24000; @@ -296,7 +297,7 @@ export const migrateProjectFileObject = async ( track.mute = false; track.gain = 1; track.pan = 0; - newTracks[TrackId(crypto.randomUUID())] = track; + newTracks[TrackId(uuid4())] = track; } projectData.song.tracks = newTracks; projectData.song.trackOrder = Object.keys(newTracks); diff --git a/src/store/project.ts b/src/store/project.ts index bbe8023053..2be0be5ca6 100755 --- a/src/store/project.ts +++ b/src/store/project.ts @@ -27,6 +27,7 @@ import { showAlertDialog, showQuestionDialog, } from "@/components/Dialog/Dialog"; +import { uuid4 } from "@/helpers/random"; export const projectStoreState: ProjectStoreState = { savedLastCommandIds: { talk: null, song: null }, @@ -125,7 +126,7 @@ export const projectStore = createPartialStore({ await context.actions.SET_TIME_SIGNATURES({ timeSignatures: [createDefaultTimeSignature(1)], }); - const trackId = TrackId(crypto.randomUUID()); + const trackId = TrackId(uuid4()); await context.actions.SET_TRACKS({ tracks: new Map([[trackId, createDefaultTrack()]]), }); diff --git a/src/store/singing.ts b/src/store/singing.ts index fe81e422ed..f558d24b01 100644 --- a/src/store/singing.ts +++ b/src/store/singing.ts @@ -573,7 +573,7 @@ const singingPitchCache = new Map(); const singingVolumeCache = new Map(); const singingVoiceCache = new Map(); -const initialTrackId = TrackId(crypto.randomUUID()); +const initialTrackId = TrackId(uuid4()); /** * シーケンスの音源の出力を取得する。 @@ -1577,7 +1577,7 @@ export const singingStore = createPartialStore({ CREATE_TRACK: { action() { - const trackId = TrackId(crypto.randomUUID()); + const trackId = TrackId(uuid4()); const track = createDefaultTrack(); return { trackId, track }; diff --git a/tests/unit/domain/__snapshots__/project.spec.ts.snap b/tests/unit/domain/__snapshots__/project.spec.ts.snap index a00269a51f..1066d8ae67 100644 --- a/tests/unit/domain/__snapshots__/project.spec.ts.snap +++ b/tests/unit/domain/__snapshots__/project.spec.ts.snap @@ -19,10 +19,10 @@ exports[`migrateProjectFileObject > v0.14.11 1`] = ` ], "tpqn": 480, "trackOrder": [ - "d5ee646b-bacb-4ed7-adb1-a0dd60e3b868", + "00000000-0000-4000-0000-000000000001", ], "tracks": { - "d5ee646b-bacb-4ed7-adb1-a0dd60e3b868": { + "00000000-0000-4000-0000-000000000001": { "gain": 1, "keyRangeAdjustment": 0, "mute": false, diff --git a/tests/unit/domain/project.spec.ts b/tests/unit/domain/project.spec.ts index f3ae58a0da..c9d85555ab 100644 --- a/tests/unit/domain/project.spec.ts +++ b/tests/unit/domain/project.spec.ts @@ -2,11 +2,16 @@ import path from "path"; import fs from "fs"; import { migrateProjectFileObject } from "@/domain/project"; import { EngineId, SpeakerId, StyleId } from "@/type/preload"; +import { resetMockMode } from "@/helpers/random"; const engineId = EngineId("074fc39e-678b-4c13-8916-ffca8d505d1d"); const vvprojDir = "tests/unit/domain/vvproj/"; +beforeEach(() => { + resetMockMode(); +}); + describe("migrateProjectFileObject", () => { test("v0.14.11", async () => { // 8期生のプロジェクトファイル diff --git a/tests/unit/domain/sing/shouldPlayTracks.spec.ts b/tests/unit/domain/sing/shouldPlayTracks.spec.ts index 0dd166a18e..a019dfc198 100644 --- a/tests/unit/domain/sing/shouldPlayTracks.spec.ts +++ b/tests/unit/domain/sing/shouldPlayTracks.spec.ts @@ -1,3 +1,4 @@ +import { uuid4 } from "@/helpers/random"; import { createDefaultTrack, shouldPlayTracks } from "@/sing/domain"; import { Track } from "@/store/type"; import { TrackId } from "@/type/preload"; @@ -10,7 +11,7 @@ const createTrack = ({ solo, mute }: { solo: boolean; mute: boolean }) => { }; const toTracksMap = (tracks: Track[]) => { return tracks.reduce((acc, track) => { - acc.set(TrackId(crypto.randomUUID()), track); + acc.set(TrackId(uuid4()), track); return acc; }, new Map()); };