mirror of
https://github.com/OpenCut-app/OpenCut.git
synced 2026-07-13 21:52:53 +02:00
refactor: move constants to domain modules
This commit is contained in:
@@ -5,7 +5,7 @@ import type { Transform } from "@/lib/rendering";
|
||||
import {
|
||||
CORNER_RADIUS_MAX,
|
||||
CORNER_RADIUS_MIN,
|
||||
} from "@/constants/text-constants";
|
||||
} from "@/lib/text/background";
|
||||
import {
|
||||
drawTextDecoration,
|
||||
getTextBackgroundRect,
|
||||
|
||||
@@ -11,7 +11,7 @@ import { BlurBackgroundNode } from "./nodes/blur-background-node";
|
||||
import { EffectLayerNode } from "./nodes/effect-layer-node";
|
||||
import type { AnyBaseNode } from "./nodes/base-node";
|
||||
import type { TBackground, TCanvasSize } from "@/lib/project/types";
|
||||
import { DEFAULT_BACKGROUND_BLUR_INTENSITY } from "@/lib/background/constants";
|
||||
import { DEFAULT_BACKGROUND_BLUR_INTENSITY } from "@/lib/background/blur";
|
||||
|
||||
const PREVIEW_MAX_IMAGE_SIZE = 2048;
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import {
|
||||
DEFAULT_BACKGROUND_BLUR_INTENSITY,
|
||||
DEFAULT_BACKGROUND_COLOR,
|
||||
} from "@/lib/background/constants";
|
||||
import { DEFAULT_CANVAS_SIZE } from "@/lib/canvas/constants";
|
||||
} from "@/lib/background/blur";
|
||||
import { DEFAULT_BACKGROUND_COLOR } from "@/lib/background/color";
|
||||
import { DEFAULT_CANVAS_SIZE } from "@/lib/canvas/sizes";
|
||||
const DEFAULT_FPS = 30;
|
||||
import type { MediaAssetData } from "@/services/storage/types";
|
||||
import { getProjectId, transformProjectV1ToV2 } from "../transformers/v1-to-v2";
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { DEFAULT_BLUR_INTENSITY } from "@/constants/project-constants";
|
||||
import { transformProjectV20ToV21 } from "../transformers/v20-to-v21";
|
||||
|
||||
const LEGACY_DEFAULT_BACKGROUND_BLUR_INTENSITY = 50;
|
||||
|
||||
describe("V20 to V21 Migration", () => {
|
||||
test("multiplies blur background intensity by 5", () => {
|
||||
const result = transformProjectV20ToV21({
|
||||
@@ -46,7 +47,9 @@ describe("V20 to V21 Migration", () => {
|
||||
expect(result.skipped).toBe(false);
|
||||
const settings = result.project.settings as Record<string, unknown>;
|
||||
const background = settings.background as Record<string, unknown>;
|
||||
expect(background.blurIntensity).toBe(DEFAULT_BLUR_INTENSITY);
|
||||
expect(background.blurIntensity).toBe(
|
||||
LEGACY_DEFAULT_BACKGROUND_BLUR_INTENSITY,
|
||||
);
|
||||
});
|
||||
|
||||
test("leaves color background unchanged", () => {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import {
|
||||
DEFAULT_BACKGROUND_BLUR_INTENSITY,
|
||||
DEFAULT_BACKGROUND_COLOR,
|
||||
} from "@/lib/background/constants";
|
||||
import { DEFAULT_CANVAS_SIZE } from "@/lib/canvas/constants";
|
||||
} from "@/lib/background/blur";
|
||||
import { DEFAULT_BACKGROUND_COLOR } from "@/lib/background/color";
|
||||
import { DEFAULT_CANVAS_SIZE } from "@/lib/canvas/sizes";
|
||||
const DEFAULT_FPS = 30;
|
||||
import { IndexedDBAdapter } from "@/services/storage/indexeddb-adapter";
|
||||
import type { MediaAssetData } from "@/services/storage/types";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { STICKER_INTRINSIC_SIZE_FALLBACK } from "@/constants/sticker-constants";
|
||||
import { STICKER_INTRINSIC_SIZE_FALLBACK } from "@/lib/stickers/intrinsic-size";
|
||||
import type { MigrationResult, ProjectRecord } from "./types";
|
||||
import { getProjectId, isRecord } from "./utils";
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { DEFAULT_BLUR_INTENSITY } from "@/constants/project-constants";
|
||||
import { INTENSITY_TO_SIGMA_DIVISOR } from "@/lib/effects/definitions/blur";
|
||||
import type { MigrationResult, ProjectRecord } from "./types";
|
||||
import { getProjectId, isRecord } from "./utils";
|
||||
|
||||
const LEGACY_DEFAULT_BACKGROUND_BLUR_INTENSITY = 50;
|
||||
|
||||
export function transformProjectV20ToV21({
|
||||
project,
|
||||
}: {
|
||||
@@ -51,7 +52,7 @@ function migrateBackgroundBlurScale({
|
||||
const blurIntensity =
|
||||
typeof raw === "number" && Number.isFinite(raw)
|
||||
? raw * INTENSITY_TO_SIGMA_DIVISOR
|
||||
: DEFAULT_BLUR_INTENSITY;
|
||||
: LEGACY_DEFAULT_BACKGROUND_BLUR_INTENSITY;
|
||||
|
||||
return {
|
||||
...project,
|
||||
|
||||
@@ -7,7 +7,7 @@ import type {
|
||||
import {
|
||||
DEFAULT_TRANSCRIPTION_MODEL,
|
||||
TRANSCRIPTION_MODELS,
|
||||
} from "@/constants/transcription-constants";
|
||||
} from "@/lib/transcription/models";
|
||||
import type { WorkerMessage, WorkerResponse } from "./worker";
|
||||
|
||||
type ProgressCallback = (progress: TranscriptionProgress) => void;
|
||||
|
||||
@@ -7,7 +7,7 @@ import type { TranscriptionSegment } from "@/lib/transcription/types";
|
||||
import {
|
||||
DEFAULT_CHUNK_LENGTH_SECONDS,
|
||||
DEFAULT_STRIDE_SECONDS,
|
||||
} from "@/constants/transcription-constants";
|
||||
} from "@/lib/transcription/audio";
|
||||
|
||||
export type WorkerMessage =
|
||||
| { type: "init"; modelId: string }
|
||||
|
||||
Reference in New Issue
Block a user