Skip to content

Commit 0558241

Browse files
committed
chore: dedupe common modules in -app and -web-app
1 parent f14d38d commit 0558241

9 files changed

Lines changed: 4 additions & 167 deletions

File tree

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,4 @@
11
export const DEBUG = process.env.NODE_ENV === "development";
22

3-
export const LOCAL_STORAGE_KEY = "raga-app";
43
export const DEFAULT_AUDIO_FILES_SERVER_PORT = 8457;
54
export const DEFAULT_ID3_TAG_USER_EMAIL = "abc@123.com";
6-
7-
// communication intervals & timeouts
8-
export const AUDIO_FILES_SERVER_PING_INTERVAL = 10_000;
9-
export const AUDIO_FILES_SERVER_PING_TIMEOUT = 1_000;
10-
export const LOAD_SWINSIAN_LIBRARY_TIMEOUT = 10_000;
11-
export const WRITE_AUDIO_FILE_TAG_TIMEOUT = 2_000;
12-
export const WRITE_MODIFIED_LIBRARY_TIMEOUT = 20_000;
13-
export const ANALYZE_AUDIO_FILE_TIMEOUT = 4_000;
14-
15-
// UI settings
16-
// TODO: make track table row height configurable
17-
export const TRACK_TABLE_ROW_HEIGHT = 24;
18-
export const TRACK_TABLE_HEADER_HEIGHT = 30;
19-
export const TRACK_TABLE_FILTER_BAR_HEIGHT = 30 + 1; // add a pixel for border
Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,10 @@
1-
import { serializeError } from "serialize-error";
2-
3-
const CLIENT = "[client]";
4-
5-
export const ClientErrors = {
6-
analyzeTrackFailed: (trackID: number, err: Error) =>
7-
`${CLIENT} error analyzing track ${trackID.toString()}: ${JSON.stringify(serializeError(err))}`,
8-
analyzeTrackTimedOut: (trackID: number) =>
9-
`${CLIENT} timed out while analyzing track ${trackID.toString()}`,
10-
analyzeTrackInPlaylistFailed: (trackID: number, playlistID: string, err: Error) =>
11-
`${CLIENT} error analyzing track ${trackID.toString()} in playlist ${playlistID}: ${JSON.stringify(
12-
serializeError(err),
13-
)}`,
14-
analyzePlaylistFailed: (playlistID: string) =>
15-
`${CLIENT} Unable to analyze playlist ${playlistID}, libraryPlaylists is undefined`,
16-
17-
contextBridgeResponseTimeout: (channel: string) =>
18-
`${CLIENT} Timed out waiting for response to ${channel} event`,
19-
20-
libraryFailedToLoad: (err: Error) => `${CLIENT} Failed to load library: ${err.message}`,
21-
libraryNoTracksFoundForPlaylist: (playlistID: string) =>
22-
`${CLIENT} No track definitions found for playlist ${playlistID}`,
23-
libraryNoTrackDefFound: (trackID: number) =>
24-
`${CLIENT} No track definition found for track ${trackID.toString()}`,
25-
libraryWriteTagFailedFileNotFound: (filePath: string) =>
26-
`${CLIENT} Failed to write tag to track at ${filePath}: file not found`,
27-
28-
APP_RENDER_FAILED: `${CLIENT} Failed to render application: no root DOM node available`,
29-
LIBRARY_NOT_LOADED: `${CLIENT} Library is not loaded`,
30-
LIBRARY_WRITE_NO_OUTPUT_FILEPATH: `${CLIENT} No output filepath specified`,
31-
LIBRARY_WRITE_TIMED_OUT: `${CLIENT} Timed out while writing library to disk`,
32-
};
33-
341
export const ServerErrors = {
352
AUDIO_FILE_NOT_FOUND: `Audio file not found`,
363
AUDIO_FILES_ROOT_FOLDER_NOT_FOUND: `Audio files root folder does not exist or is empty`,
374
FFMPEG_UNAVAILABLE: `ffmpeg is not available, cannot convert audio files`,
385
MP3_CODEC_UNAVAILABLE: `No MP3 codec is available`,
396
INVALID_CONVERSION_REQUEST: `Invalid MP3 conversion request`,
407
CONVERTED_AUDIO_FILE_NOT_FOUND: `Converted audio file not found`,
8+
libraryWriteTagFailedFileNotFound: (filePath: string) =>
9+
`Failed to write tag to track at ${filePath}: file not found`,
4110
};

packages/raga-app/src/common/format.ts

Lines changed: 0 additions & 17 deletions
This file was deleted.

packages/raga-app/src/common/trackUtils.ts

Lines changed: 0 additions & 38 deletions
This file was deleted.

packages/raga-app/src/common/webAudioUtils.ts

Lines changed: 0 additions & 23 deletions
This file was deleted.

packages/raga-app/src/server/writeAudioFileTag.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
import { isString } from "radash";
1212

1313
import { DEFAULT_ID3_TAG_USER_EMAIL } from "../common/constants";
14-
import { ClientErrors } from "../common/errorMessages";
14+
import { ServerErrors } from "../common/errorMessages";
1515
import { type WriteAudioFileTagOptions } from "../common/events";
1616

1717
/** @throws if unsuccessful */
@@ -24,7 +24,7 @@ export function writeAudioFileTag({
2424
const filepath = fileLocation.includes("file://") ? fileURLToPath(fileLocation) : fileLocation;
2525

2626
if (!existsSync(filepath)) {
27-
throw new Error(ClientErrors.libraryWriteTagFailedFileNotFound(filepath));
27+
throw new Error(ServerErrors.libraryWriteTagFailedFileNotFound(filepath));
2828
}
2929

3030
const file = TaglibFile.createFromPath(filepath);

packages/raga-web-app/src/common/constants.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ export const DEBUG = process.env.NODE_ENV === "development";
22

33
export const LOCAL_STORAGE_KEY = "raga-app";
44
export const DEFAULT_AUDIO_FILES_SERVER_PORT = 8457;
5-
export const DEFAULT_ID3_TAG_USER_EMAIL = "abc@123.com";
65

76
// communication intervals & timeouts
87
export const AUDIO_FILES_SERVER_PING_INTERVAL = 10_000;

packages/raga-web-app/src/common/errorMessages.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,3 @@ export const ClientErrors = {
3030
LIBRARY_WRITE_NO_OUTPUT_FILEPATH: `${CLIENT} No output filepath specified`,
3131
LIBRARY_WRITE_TIMED_OUT: `${CLIENT} Timed out while writing library to disk`,
3232
};
33-
34-
export const ServerErrors = {
35-
AUDIO_FILE_NOT_FOUND: `Audio file not found`,
36-
AUDIO_FILES_ROOT_FOLDER_NOT_FOUND: `Audio files root folder does not exist or is empty`,
37-
FFMPEG_UNAVAILABLE: `ffmpeg is not available, cannot convert audio files`,
38-
MP3_CODEC_UNAVAILABLE: `No MP3 codec is available`,
39-
INVALID_CONVERSION_REQUEST: `Invalid MP3 conversion request`,
40-
CONVERTED_AUDIO_FILE_NOT_FOUND: `Converted audio file not found`,
41-
};

packages/raga-web-app/src/common/logUtils.ts

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)