mirror of
https://github.com/Ku6epXBOCTuK/easy-png-tools.git
synced 2026-09-14 21:46:35 +00:00
refactor: move old libs and components to old folder
This commit is contained in:
@@ -17,16 +17,7 @@
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
|
||||
const DEFAULT_OLD = [
|
||||
"routes/(old)/**",
|
||||
"lib/registry/**",
|
||||
"lib/registry.ts",
|
||||
"lib/registry-helpers.ts",
|
||||
"lib/categories.ts",
|
||||
"lib/tools/**",
|
||||
"lib/components/**",
|
||||
"!lib/components/kit/**",
|
||||
];
|
||||
const DEFAULT_OLD = ["routes/(old)/**", "lib/old/**"];
|
||||
|
||||
const DEFAULT_NEW = [
|
||||
"routes/preview/**",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { CategoryId } from "../categories";
|
||||
import type { CategoryId } from "../old/categories";
|
||||
|
||||
export const LOCALES = ["ru", "en"] as const;
|
||||
export type Locale = (typeof LOCALES)[number];
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { TOOLS } from "../registry";
|
||||
import { TOOLS } from "../old/registry";
|
||||
import { normalizeForSearch, scoreDoc, type SearchDoc } from "./matching";
|
||||
import { setLocale } from "./locale.svelte";
|
||||
import { toolSearchDoc } from "./tool-strings";
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { TOOLS } from "../registry";
|
||||
import { TOOLS } from "../old/registry";
|
||||
import { normalizeForSearch, scoreDoc } from "./matching";
|
||||
import { toolSearchDoc } from "./tool-strings";
|
||||
import { isChainable } from "../registry";
|
||||
import { isChainable } from "../old/registry";
|
||||
|
||||
function hits(q: string): string[] {
|
||||
const nq = normalizeForSearch(q);
|
||||
|
||||
@@ -4,7 +4,7 @@ import { t } from "./t";
|
||||
import { LOCALE_TAGS } from "./dict";
|
||||
import { normalizeForSearch, scoreDoc } from "./matching";
|
||||
import { toolSearchDoc } from "./tool-strings";
|
||||
import { TOOLS } from "../registry";
|
||||
import { TOOLS } from "../old/registry";
|
||||
|
||||
afterEach(() => {
|
||||
setLocale("ru");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { ParamDef, ToolEntry } from "$lib/registry";
|
||||
import type { ParamDef, ToolEntry } from "$lib/old/registry";
|
||||
import type { SearchDoc } from "./matching";
|
||||
import { getMergedDict } from "./locale.svelte";
|
||||
import { ru } from "./ru";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { TOOLS } from "../registry";
|
||||
import { TOOLS } from "../old/registry";
|
||||
import { en } from "./en";
|
||||
import { ru } from "./ru";
|
||||
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
import Button from "./ui/Button.svelte";
|
||||
import { downloadBlob, encode } from "$lib/core/io";
|
||||
import type { PixelImage } from "$lib/core/types";
|
||||
import type { OutputFormat } from "$lib/registry";
|
||||
import type { OutputFormat } from "$lib/old/registry";
|
||||
import { t } from "$lib/i18n/t";
|
||||
|
||||
interface Props {
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
import SelectField from "./ui/SelectField.svelte";
|
||||
import SliderField from "./ui/SliderField.svelte";
|
||||
import TextField from "./ui/TextField.svelte";
|
||||
import type { ParamDef, ToolEntry } from "$lib/registry";
|
||||
import type { ParamDef, ToolEntry } from "$lib/old/registry";
|
||||
import { optionLabel, paramLabel } from "$lib/i18n/tool-strings";
|
||||
import { t } from "$lib/i18n/t";
|
||||
|
||||
@@ -13,21 +13,24 @@
|
||||
outputOf,
|
||||
sanitizeParams,
|
||||
type ToolEntry,
|
||||
} from "$lib/registry";
|
||||
} from "$lib/old/registry";
|
||||
import {
|
||||
loadStoredSteps,
|
||||
newStepId,
|
||||
saveSteps,
|
||||
type PipelineStep,
|
||||
} from "$lib/tools/pipeline";
|
||||
import { TOOL_ICONS } from "$lib/tools/tool-icons";
|
||||
} from "$lib/old/tools/pipeline";
|
||||
import { TOOL_ICONS } from "$lib/old/tools/tool-icons";
|
||||
import DownloadButton from "./DownloadButton.svelte";
|
||||
import ParamForm from "./ParamForm.svelte";
|
||||
import Preview from "./Preview.svelte";
|
||||
import ToolSearch from "./search/ToolSearch.svelte";
|
||||
import { createAutoRunner } from "$lib/tools/auto-run";
|
||||
import { executeStep } from "$lib/tools/executor";
|
||||
import { clearOverlay, setOverlay } from "$lib/tools/overlay-store.svelte";
|
||||
import { createAutoRunner } from "$lib/old/tools/auto-run";
|
||||
import { executeStep } from "$lib/old/tools/executor";
|
||||
import {
|
||||
clearOverlay,
|
||||
setOverlay,
|
||||
} from "$lib/old/tools/overlay-store.svelte";
|
||||
import { t } from "$lib/i18n/t";
|
||||
import { toolDescription, toolTitle } from "$lib/i18n/tool-strings";
|
||||
import type { StageStatus } from "./stage/stage-props";
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { outputOf, sanitizeParams, type ToolEntry } from "$lib/registry";
|
||||
import { outputOf, sanitizeParams, type ToolEntry } from "$lib/old/registry";
|
||||
import type { PixelImage } from "$lib/core/types";
|
||||
import { t } from "$lib/i18n/t";
|
||||
import { toolTitle } from "$lib/i18n/tool-strings";
|
||||
@@ -8,7 +8,7 @@
|
||||
import EmptyState from "../ui/EmptyState.svelte";
|
||||
import ParamsCard from "../tool/ParamsCard.svelte";
|
||||
import Preview from "../Preview.svelte";
|
||||
import { TOOL_ICONS } from "$lib/tools/tool-icons";
|
||||
import { TOOL_ICONS } from "$lib/old/tools/tool-icons";
|
||||
|
||||
interface Props {
|
||||
index: number;
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { TOOL_ICONS } from "$lib/tools/tool-icons";
|
||||
import { TOOL_ICONS } from "$lib/old/tools/tool-icons";
|
||||
|
||||
interface Props {
|
||||
toolId: string;
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { isChainable, TOOLS } from "$lib/registry";
|
||||
import { isChainable, TOOLS } from "$lib/old/registry";
|
||||
import { LOCALE_TAGS } from "$lib/i18n/dict";
|
||||
import { getLocale } from "$lib/i18n/locale.svelte";
|
||||
import { normalizeForSearch, scoreDoc } from "$lib/i18n/matching";
|
||||
+2
-2
@@ -1,11 +1,11 @@
|
||||
<script lang="ts">
|
||||
import type { Snippet } from "svelte";
|
||||
import { outputOf, sanitizeParams, type ToolEntry } from "$lib/registry";
|
||||
import { outputOf, sanitizeParams, type ToolEntry } from "$lib/old/registry";
|
||||
import type { ImageInfo } from "$lib/core/analyze";
|
||||
import type { PixelImage } from "$lib/core/types";
|
||||
import { t } from "$lib/i18n/t";
|
||||
import { toolTitle } from "$lib/i18n/tool-strings";
|
||||
import { TOOL_ICONS } from "$lib/tools/tool-icons";
|
||||
import { TOOL_ICONS } from "$lib/old/tools/tool-icons";
|
||||
import DownloadButton from "../DownloadButton.svelte";
|
||||
import Button from "../ui/Button.svelte";
|
||||
import EmptyState from "../ui/EmptyState.svelte";
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import type { ImageInfo } from "$lib/core/analyze";
|
||||
import type { PixelImage } from "$lib/core/types";
|
||||
import type { ToolEntry } from "$lib/registry";
|
||||
import type { ToolEntry } from "$lib/old/registry";
|
||||
|
||||
export type StageStatus = "idle" | "loaded" | "processing" | "error";
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import ParamForm from "../ParamForm.svelte";
|
||||
import type { ParamDef, ToolEntry } from "$lib/registry";
|
||||
import type { ParamDef, ToolEntry } from "$lib/old/registry";
|
||||
import { t } from "$lib/i18n/t";
|
||||
|
||||
interface Props {
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
import TextResult from "./TextResult.svelte";
|
||||
import type { ImageInfo } from "$lib/core/analyze";
|
||||
import type { PixelImage } from "$lib/core/types";
|
||||
import { outputOf, type ToolEntry } from "$lib/registry";
|
||||
import { outputOf, type ToolEntry } from "$lib/old/registry";
|
||||
import { t } from "$lib/i18n/t";
|
||||
|
||||
type Status = "idle" | "loaded" | "processing" | "error";
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ToolError } from "./core/errors";
|
||||
import { ToolError } from "../core/errors";
|
||||
|
||||
export function num(params: Record<string, unknown>, id: string): number {
|
||||
const v = params[id];
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { CategoryId } from "./categories";
|
||||
import type { OutputMime } from "./core/io";
|
||||
import type { PixelImage } from "./core/types";
|
||||
import type { OutputMime } from "../core/io";
|
||||
import type { PixelImage } from "../core/types";
|
||||
|
||||
import { alphaEntries } from "./registry/alpha";
|
||||
import { analyzeEntries } from "./registry/analyze";
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { ToolEntry } from "../registry";
|
||||
import { ToolError } from "../core/errors";
|
||||
import { ToolError } from "../../core/errors";
|
||||
import {
|
||||
colorMask,
|
||||
extractAlphaMask,
|
||||
@@ -9,8 +9,8 @@ import {
|
||||
removeColorToAlpha,
|
||||
roundCorners,
|
||||
setAlphaChannel,
|
||||
} from "../core/alpha";
|
||||
import { backgroundMaskPreview, removeBackground } from "../core/background";
|
||||
} from "../../core/alpha";
|
||||
import { backgroundMaskPreview, removeBackground } from "../../core/background";
|
||||
import {
|
||||
closingImage,
|
||||
contourImage,
|
||||
@@ -18,9 +18,9 @@ import {
|
||||
erodeImage,
|
||||
openingImage,
|
||||
strokeImage,
|
||||
} from "../core/morphology";
|
||||
import { featherAlpha, defringe } from "../core/pixel-fx";
|
||||
import { drawImageWatermark } from "../core/domText";
|
||||
} from "../../core/morphology";
|
||||
import { featherAlpha, defringe } from "../../core/pixel-fx";
|
||||
import { drawImageWatermark } from "../../core/domText";
|
||||
import { getOverlay } from "../tools/overlay-store.svelte";
|
||||
import {
|
||||
renderShape,
|
||||
@@ -28,8 +28,8 @@ import {
|
||||
boxTest,
|
||||
starTest,
|
||||
wavyTest,
|
||||
} from "../core/shapes";
|
||||
import type { Position9 } from "../core/textdraw";
|
||||
} from "../../core/shapes";
|
||||
import type { Position9 } from "../../core/textdraw";
|
||||
import { num, str } from "../registry-helpers";
|
||||
|
||||
export function alphaEntries(): ToolEntry[] {
|
||||
@@ -5,12 +5,16 @@ import {
|
||||
luma01,
|
||||
rarityPredicate,
|
||||
renderPredicateMask,
|
||||
} from "../core/masks";
|
||||
import { hasTransparency, isGrayscale, orientationOf } from "../core/analyze";
|
||||
import { looksLikePng, base64ToBytes, stripDataUri } from "../core/textio";
|
||||
import { clonePixelImage, type PixelImage } from "../core/types";
|
||||
import { encode } from "../core/io";
|
||||
import { t } from "../i18n/t";
|
||||
} from "../../core/masks";
|
||||
import {
|
||||
hasTransparency,
|
||||
isGrayscale,
|
||||
orientationOf,
|
||||
} from "../../core/analyze";
|
||||
import { looksLikePng, base64ToBytes, stripDataUri } from "../../core/textio";
|
||||
import { clonePixelImage, type PixelImage } from "../../core/types";
|
||||
import { encode } from "../../core/io";
|
||||
import { t } from "../../i18n/t";
|
||||
import { num, str } from "../registry-helpers";
|
||||
|
||||
type MaskToolSpec = {
|
||||
@@ -17,10 +17,10 @@ import {
|
||||
twoColors,
|
||||
type ChannelSwapPair,
|
||||
type RgbChannel,
|
||||
} from "../core/color";
|
||||
import { renderSpace, SPACES, type SpaceId } from "../core/channels";
|
||||
import { quantizeImage, ditherImage, mapToNearest } from "../core/quantize";
|
||||
import { parseHexList } from "../core/palette";
|
||||
} from "../../core/color";
|
||||
import { renderSpace, SPACES, type SpaceId } from "../../core/channels";
|
||||
import { quantizeImage, ditherImage, mapToNearest } from "../../core/quantize";
|
||||
import { parseHexList } from "../../core/palette";
|
||||
import { num, str } from "../registry-helpers";
|
||||
|
||||
type SpaceEntry = {
|
||||
@@ -1,20 +1,20 @@
|
||||
import type { ToolEntry } from "../registry";
|
||||
import { clonePixelImage } from "../core/types";
|
||||
import { flattenOntoColor } from "../core/alpha";
|
||||
import { toBase64, toDataUrl, decodeSvgText, encode } from "../core/io";
|
||||
import { pixelsToHex, hexToPixels } from "../core/text";
|
||||
import { clonePixelImage } from "../../core/types";
|
||||
import { flattenOntoColor } from "../../core/alpha";
|
||||
import { toBase64, toDataUrl, decodeSvgText, encode } from "../../core/io";
|
||||
import { pixelsToHex, hexToPixels } from "../../core/text";
|
||||
import {
|
||||
imageToByteRows,
|
||||
bytesToImage,
|
||||
imageToRgbValues,
|
||||
rgbValuesToImage,
|
||||
} from "../core/textio";
|
||||
} from "../../core/textio";
|
||||
import {
|
||||
COMPRESSION_LEVELS,
|
||||
findMaxColorsWithin,
|
||||
type CompressionLevel,
|
||||
} from "../core/compress";
|
||||
import { quantizeImage } from "../core/quantize";
|
||||
} from "../../core/compress";
|
||||
import { quantizeImage } from "../../core/quantize";
|
||||
import { num, str } from "../registry-helpers";
|
||||
|
||||
function decodeToPng(
|
||||
@@ -1,13 +1,13 @@
|
||||
import type { ToolEntry } from "../registry";
|
||||
import { gaussianBlur, sharpen as sharpenImage } from "../core/convolution";
|
||||
import { vignette } from "../core/effects";
|
||||
import { gaussianBlur, sharpen as sharpenImage } from "../../core/convolution";
|
||||
import { vignette } from "../../core/effects";
|
||||
import {
|
||||
pixelate,
|
||||
shuffleBlocks,
|
||||
addNoise,
|
||||
silhouette,
|
||||
} from "../core/pixel-fx";
|
||||
import { jpegRoundtrip } from "../core/io";
|
||||
} from "../../core/pixel-fx";
|
||||
import { jpegRoundtrip } from "../../core/io";
|
||||
import { num, str } from "../registry-helpers";
|
||||
|
||||
export function filterEntries(): ToolEntry[] {
|
||||
@@ -1,9 +1,17 @@
|
||||
import type { ToolEntry } from "../registry";
|
||||
import { ToolError } from "../core/errors";
|
||||
import { solidImage, noiseImage, gradientImage } from "../core/generate";
|
||||
import { colorSpectrum, drawGrid, randomColorBlocks } from "../core/gen-tools";
|
||||
import { renderTextToImage, renderEmoji, type TextFont } from "../core/domText";
|
||||
import { changeCanvasSize } from "../core/geometry";
|
||||
import { ToolError } from "../../core/errors";
|
||||
import { solidImage, noiseImage, gradientImage } from "../../core/generate";
|
||||
import {
|
||||
colorSpectrum,
|
||||
drawGrid,
|
||||
randomColorBlocks,
|
||||
} from "../../core/gen-tools";
|
||||
import {
|
||||
renderTextToImage,
|
||||
renderEmoji,
|
||||
type TextFont,
|
||||
} from "../../core/domText";
|
||||
import { changeCanvasSize } from "../../core/geometry";
|
||||
import {
|
||||
renderWheel,
|
||||
renderSwatches,
|
||||
@@ -19,7 +27,7 @@ import {
|
||||
stepColors,
|
||||
sortPalette,
|
||||
type SortKey,
|
||||
} from "../core/palette";
|
||||
} from "../../core/palette";
|
||||
import { num, str, bool } from "../registry-helpers";
|
||||
|
||||
function hexToRgba(hex: string, alpha = 255): [number, number, number, number] {
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { ToolEntry } from "../registry";
|
||||
import { ToolError } from "../core/errors";
|
||||
import { ToolError } from "../../core/errors";
|
||||
import {
|
||||
crop,
|
||||
expandCanvas,
|
||||
@@ -15,13 +15,13 @@ import {
|
||||
symmetricCopy,
|
||||
trimToContent,
|
||||
type Anchor9,
|
||||
} from "../core/geometry";
|
||||
} from "../../core/geometry";
|
||||
import {
|
||||
rotateFreeImage,
|
||||
skewImage,
|
||||
transformImage,
|
||||
zoomImage,
|
||||
} from "../core/affine";
|
||||
} from "../../core/affine";
|
||||
import { num, str } from "../registry-helpers";
|
||||
|
||||
export function geometryEntries(): ToolEntry[] {
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { ToolEntry } from "../registry";
|
||||
import { drawTextBlock, drawTextTile, type TextFont } from "../core/domText";
|
||||
import { formatStamp } from "../core/datefmt";
|
||||
import type { Position9 } from "../core/textdraw";
|
||||
import { drawTextBlock, drawTextTile, type TextFont } from "../../core/domText";
|
||||
import { formatStamp } from "../../core/datefmt";
|
||||
import type { Position9 } from "../../core/textdraw";
|
||||
import { num, str, bool } from "../registry-helpers";
|
||||
|
||||
export function textEntries(): ToolEntry[] {
|
||||
@@ -1,7 +1,7 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { executeStep } from "./executor";
|
||||
import { makeImage } from "../core/test-helpers";
|
||||
import type { PixelImage } from "../core/types";
|
||||
import { makeImage } from "../../core/test-helpers";
|
||||
import type { PixelImage } from "../../core/types";
|
||||
|
||||
function cloneOf(img: PixelImage): PixelImage {
|
||||
return {
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { PixelImage } from "../core/types";
|
||||
import { ToolError } from "../core/errors";
|
||||
import type { PixelImage } from "../../core/types";
|
||||
import { ToolError } from "../../core/errors";
|
||||
|
||||
type MaybeRunnable = {
|
||||
id: string;
|
||||
@@ -1,6 +1,6 @@
|
||||
/// <reference lib="webworker" />
|
||||
import type { PixelImage } from "../core/types";
|
||||
import { ToolError } from "../core/errors";
|
||||
import type { PixelImage } from "../../core/types";
|
||||
import { ToolError } from "../../core/errors";
|
||||
import { getTool, sanitizeParams } from "../registry";
|
||||
|
||||
type WorkerRequest = {
|
||||
@@ -1,5 +1,5 @@
|
||||
import { getTool, sanitizeParams } from "../registry";
|
||||
import { ToolError } from "../core/errors";
|
||||
import { ToolError } from "../../core/errors";
|
||||
|
||||
export type PipelineStep = {
|
||||
id: string;
|
||||
@@ -1,10 +1,10 @@
|
||||
<script lang="ts">
|
||||
import { getTool } from "$lib/registry";
|
||||
import { getTool } from "$lib/old/registry";
|
||||
import { t } from "$lib/i18n/t";
|
||||
import { toolTitle } from "$lib/i18n/tool-strings";
|
||||
import ToolPage from "$lib/components/ToolPage.svelte";
|
||||
import ToolSearch from "$lib/components/search/ToolSearch.svelte";
|
||||
import Button from "$lib/components/ui/Button.svelte";
|
||||
import ToolPage from "$lib/old/components/ToolPage.svelte";
|
||||
import ToolSearch from "$lib/old/components/search/ToolSearch.svelte";
|
||||
import Button from "$lib/old/components/ui/Button.svelte";
|
||||
|
||||
const LAST_TOOL_KEY = "last-tool-id";
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import ToolPage from "$lib/components/ToolPage.svelte";
|
||||
import { getTool } from "$lib/registry";
|
||||
import ToolPage from "$lib/old/components/ToolPage.svelte";
|
||||
import { getTool } from "$lib/old/registry";
|
||||
|
||||
const base = getTool("linear-gradient-png")!;
|
||||
</script>
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<script lang="ts">
|
||||
import { CATEGORIES } from "$lib/categories";
|
||||
import { CATEGORIES } from "$lib/old/categories";
|
||||
import { resolve } from "$app/paths";
|
||||
import { t } from "$lib/i18n/t";
|
||||
import { toolDescription, toolTitle } from "$lib/i18n/tool-strings";
|
||||
import ToolCard from "$lib/components/search/ToolCard.svelte";
|
||||
import { TOOLS } from "$lib/registry";
|
||||
import ToolCard from "$lib/old/components/search/ToolCard.svelte";
|
||||
import { TOOLS } from "$lib/old/registry";
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import ToolPage from "$lib/components/ToolPage.svelte";
|
||||
import { getTool } from "$lib/registry";
|
||||
import ToolPage from "$lib/old/components/ToolPage.svelte";
|
||||
import { getTool } from "$lib/old/registry";
|
||||
import { t } from "$lib/i18n/t";
|
||||
import { toolDescription, toolTitle } from "$lib/i18n/tool-strings";
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { error } from "@sveltejs/kit";
|
||||
import { getTool, TOOLS } from "$lib/registry";
|
||||
import { getTool, TOOLS } from "$lib/old/registry";
|
||||
import { t } from "$lib/i18n/t";
|
||||
import type { EntryGenerator, PageLoad } from "./$types";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user