diff --git a/config.ts b/config.ts index 7de739b74d..8355d5e212 100644 --- a/config.ts +++ b/config.ts @@ -6,7 +6,7 @@ import { AspectRatioRange } from './src/utils/aspect-ratio/AspectRatioRange'; import { expectAspectRatioInRange } from './src/utils/aspect-ratio/expectAspectRatioInRange'; import { DigitalOceanSpaces } from './src/utils/cdn/classes/DigitalOceanSpaces'; import { createColorfulComputeImageColorStats15 } from './src/utils/image/palette/15/createColorfulComputeImageColorStats15'; -import { IComputeImageColorStats } from './src/utils/image/utils/IImageColorStats'; +import type { IComputeImageColorStats } from './src/utils/image/utils/IImageColorStats'; import { isRunningInBrowser } from './src/utils/isRunningInWhatever'; import { isUrlOnPrivateNetwork } from './src/utils/validators/isUrlOnPrivateNetwork'; import { validateUuid } from './src/utils/validators/validateUuid'; diff --git a/scripts/generate-wallpapers-color-stats/generate-wallpapers-color-stats.ts b/scripts/generate-wallpapers-color-stats/generate-wallpapers-color-stats.ts index d5be279daf..a1b25c9b44 100644 --- a/scripts/generate-wallpapers-color-stats/generate-wallpapers-color-stats.ts +++ b/scripts/generate-wallpapers-color-stats/generate-wallpapers-color-stats.ts @@ -12,7 +12,7 @@ import YAML from 'yaml'; import { COLORSTATS_DEFAULT_COMPUTE_IN_SCRIPT, MIDJOURNEY_WHOLE_GALLERY_PATH } from '../../config'; import { createImageInNode } from '../../src/utils/image/createImageInNode'; import { serializeColorStats } from '../../src/utils/image/utils/serializeColorStats'; -import { IWallpaperMetadata } from '../../src/utils/IWallpaper'; +import type { IWallpaperMetadata } from '../../src/utils/IWallpaper'; import { commit } from '../utils/autocommit/commit'; import { isWorkingTreeClean } from '../utils/autocommit/isWorkingTreeClean'; import { forEachHardcodedWallpaper } from '../utils/hardcoded-wallpaper/forEachHardcodedWallpaper'; diff --git a/scripts/generate-wallpapers-content/generate-wallpapers-content.ts b/scripts/generate-wallpapers-content/generate-wallpapers-content.ts index 296a3d1330..394cc3455a 100644 --- a/scripts/generate-wallpapers-content/generate-wallpapers-content.ts +++ b/scripts/generate-wallpapers-content/generate-wallpapers-content.ts @@ -7,11 +7,11 @@ import chalk from 'chalk'; import commander from 'commander'; import { readFile, writeFile } from 'fs/promises'; import { join, relative } from 'path'; -import spaceTrim from 'spacetrim'; +import { spaceTrim } from 'spacetrim'; import { forTime } from 'waitasecond'; import { FONTS, OPENAI_API_KEY } from '../../config'; import { extractTitleFromContent } from '../../src/utils/content/extractTitleFromContent'; -import { IWallpaperMetadata } from '../../src/utils/IWallpaper'; +import type { IWallpaperMetadata } from '../../src/utils/IWallpaper'; import { randomItem } from '../../src/utils/randomItem'; import { commit } from '../utils/autocommit/commit'; import { isWorkingTreeClean } from '../utils/autocommit/isWorkingTreeClean'; diff --git a/scripts/generate-wallpapers-content/repair-wallpapers-content.ts b/scripts/generate-wallpapers-content/repair-wallpapers-content.ts index f9f6b48644..cbe4ead243 100644 --- a/scripts/generate-wallpapers-content/repair-wallpapers-content.ts +++ b/scripts/generate-wallpapers-content/repair-wallpapers-content.ts @@ -7,7 +7,7 @@ import chalk from 'chalk'; import commander from 'commander'; import { readFile, writeFile } from 'fs/promises'; import { join } from 'path'; -import spaceTrim from 'spacetrim'; +import { spaceTrim } from 'spacetrim'; import { forTime } from 'waitasecond'; import { FONTS, MAX_CHARS_IN_TITLE, OPENAI_API_KEY } from '../../config'; import { extractTitleFromContent } from '../../src/utils/content/extractTitleFromContent'; diff --git a/scripts/integration-test-with-server/forCondition.ts b/scripts/integration-test-with-server/forCondition.ts index 3704c2167d..2347c0ff75 100644 --- a/scripts/integration-test-with-server/forCondition.ts +++ b/scripts/integration-test-with-server/forCondition.ts @@ -1,4 +1,4 @@ -import { Promisable } from 'type-fest'; +import type { Promisable } from 'type-fest'; import { forTime, forValueDefined } from 'waitasecond'; export async function forCondition( diff --git a/scripts/playground/playground.ts b/scripts/playground/playground.ts index 86e76fee1b..a01c314591 100644 --- a/scripts/playground/playground.ts +++ b/scripts/playground/playground.ts @@ -6,7 +6,7 @@ dotenv.config({ path: '.env' }); import chalk from 'chalk'; import { join } from 'path'; // import { ChatThread } from '../../src/ai/text-to-text/ChatThread'; -import spaceTrim from 'spacetrim'; +import { spaceTrim } from 'spacetrim'; import { getOpenaiForServer } from '../../src/ai/text-to-text/getOpenaiForServer'; if (process.cwd() !== join(__dirname, '../..')) { diff --git a/scripts/utils/autocommit/commit.ts b/scripts/utils/autocommit/commit.ts index 2551d5a5bd..0cab38e054 100644 --- a/scripts/utils/autocommit/commit.ts +++ b/scripts/utils/autocommit/commit.ts @@ -1,7 +1,7 @@ import chalk from 'chalk'; import { mkdir, unlink, writeFile } from 'fs/promises'; import { dirname, join } from 'path'; -import spaceTrim from 'spacetrim'; +import { spaceTrim } from 'spacetrim'; import { execCommand } from '../execCommand/execCommand'; import { isWorkingTreeClean } from './isWorkingTreeClean'; diff --git a/scripts/utils/execCommand/execCommand.ts b/scripts/utils/execCommand/execCommand.ts index bd25786f7c..f27e80109f 100644 --- a/scripts/utils/execCommand/execCommand.ts +++ b/scripts/utils/execCommand/execCommand.ts @@ -1,9 +1,9 @@ import chalk from 'chalk'; import { spawn } from 'child_process'; -import spaceTrim from 'spacetrim'; +import { spaceTrim } from 'spacetrim'; import { forTime } from 'waitasecond'; import { execCommandNormalizeOptions } from './execCommandNormalizeOptions'; -import { IExecCommandOptions } from './IExecCommandOptions'; +import type { IExecCommandOptions } from './IExecCommandOptions'; export function execCommand(options: IExecCommandOptions): Promise { return new Promise((resolve, reject) => { diff --git a/scripts/utils/execCommand/execCommandNormalizeOptions.ts b/scripts/utils/execCommand/execCommandNormalizeOptions.ts index 251743b689..0c30916ca3 100644 --- a/scripts/utils/execCommand/execCommandNormalizeOptions.ts +++ b/scripts/utils/execCommand/execCommandNormalizeOptions.ts @@ -1,4 +1,4 @@ -import { IExecCommandOptions, IExecCommandOptionsAdvanced } from './IExecCommandOptions'; +import type { IExecCommandOptions, IExecCommandOptionsAdvanced } from './IExecCommandOptions'; export function execCommandNormalizeOptions(options: IExecCommandOptions): Pick< IExecCommandOptionsAdvanced, diff --git a/scripts/utils/hardcoded-wallpaper/forEachHardcodedWallpaper.ts b/scripts/utils/hardcoded-wallpaper/forEachHardcodedWallpaper.ts index 583af10713..996e632a28 100644 --- a/scripts/utils/hardcoded-wallpaper/forEachHardcodedWallpaper.ts +++ b/scripts/utils/hardcoded-wallpaper/forEachHardcodedWallpaper.ts @@ -3,7 +3,7 @@ import moment from 'moment'; import { COLORSTATS_DEFAULT_COMPUTE_IN_SCRIPT } from '../../../config'; import { forPlay } from '../forPlay'; import { getHardcodedWallpapersMetadataFilePaths } from './getHardcodedWallpapersMetadataFilePaths'; -import { IHardcodedWallpaperFiles } from './IHardcodedWallpaperFiles'; +import type { IHardcodedWallpaperFiles } from './IHardcodedWallpaperFiles'; /** * Executes a series of async tasks on hardcoded wallpapers diff --git a/scripts/utils/hardcoded-wallpaper/getHardcodedWallpapers.ts b/scripts/utils/hardcoded-wallpaper/getHardcodedWallpapers.ts index 7d3b466936..7b9d6fbd5f 100644 --- a/scripts/utils/hardcoded-wallpaper/getHardcodedWallpapers.ts +++ b/scripts/utils/hardcoded-wallpaper/getHardcodedWallpapers.ts @@ -1,6 +1,6 @@ import chalk from 'chalk'; import { readFile } from 'fs/promises'; -import spaceTrim from 'spacetrim'; +import { spaceTrim } from 'spacetrim'; import YAML from 'yaml'; import { COLORSTATS_DEFAULT_COMPUTE_IN_SCRIPT, @@ -11,8 +11,8 @@ import { import { parseKeywordsFromWallpaper } from '../../../src/components/Gallery/GalleryFilter/utils/parseKeywordsFromWallpaper'; import { FULLHD } from '../../../src/constants'; import { extractTitleFromContent } from '../../../src/utils/content/extractTitleFromContent'; -import { IWallpaperMetadata, IWallpaperSerialized } from '../../../src/utils/IWallpaper'; -import { string_file_path } from '../../../src/utils/typeAliases'; +import type { IWallpaperMetadata, IWallpaperSerialized } from '../../../src/utils/IWallpaper'; +import type { string_file_path } from '../../../src/utils/typeAliases'; import { isFileExisting } from '../isFileExisting'; import { getHardcodedWallpapersMetadataFilePaths } from './getHardcodedWallpapersMetadataFilePaths'; diff --git a/scripts/utils/prettify.ts b/scripts/utils/prettify.ts index 97016737bf..c1b158b0a1 100644 --- a/scripts/utils/prettify.ts +++ b/scripts/utils/prettify.ts @@ -1,7 +1,7 @@ import { readFile } from 'fs'; import { join } from 'path'; import prettier from 'prettier'; -import spaceTrim from 'spacetrim'; +import { spaceTrim } from 'spacetrim'; import { promisify } from 'util'; export async function prettify(fileContents: string, parser = 'typescript'): Promise { diff --git a/src/ai/image-to-text/imageToText.ts b/src/ai/image-to-text/imageToText.ts index 1337dcc816..e8e9ec8b98 100644 --- a/src/ai/image-to-text/imageToText.ts +++ b/src/ai/image-to-text/imageToText.ts @@ -1,7 +1,7 @@ import { ComputerVisionClient } from '@azure/cognitiveservices-computervision'; import { CognitiveServicesCredentials } from '@azure/ms-rest-azure-js'; import { AZURE_COMPUTER_VISION_ENDPOINT, AZURE_COMPUTER_VISION_KEY } from '../../../config'; -import { image_description } from '../../utils/typeAliases'; +import type { image_description } from '../../utils/typeAliases'; /** * Analyzes an image through the Azure Computer vision API diff --git a/src/ai/recommendation/likedStatusToLikeness.ts b/src/ai/recommendation/likedStatusToLikeness.ts index 8a05784643..67b9b4d4e4 100644 --- a/src/ai/recommendation/likedStatusToLikeness.ts +++ b/src/ai/recommendation/likedStatusToLikeness.ts @@ -1,5 +1,5 @@ import type { LikedStatus } from '../../utils/hooks/useLikedStatusOfCurrentWallpaper'; -import { number_likeness } from '../../utils/typeAliases'; +import type { number_likeness } from '../../utils/typeAliases'; const LIKED_STATUS_LIKENESS: Record = { NONE: 0 /* <- TODO: [🧠] Maybe -0.1 or some small negative number, wallpaper user go through and did not react person maybe dislike */, diff --git a/src/ai/recommendation/pickMostRecommended.ts b/src/ai/recommendation/pickMostRecommended.ts index a04cadbcde..cc64cedb0e 100644 --- a/src/ai/recommendation/pickMostRecommended.ts +++ b/src/ai/recommendation/pickMostRecommended.ts @@ -1,6 +1,6 @@ -import { IWallpaper } from '../../utils/IWallpaper'; -import { number_likeness } from '../../utils/typeAliases'; -import { IWallpaperVector } from './IWallpaperVector'; +import type { IWallpaper } from '../../utils/IWallpaper'; +import type { number_likeness } from '../../utils/typeAliases'; +import type { IWallpaperVector } from './IWallpaperVector'; import { wallpaperToVector } from './wallpaperToVector'; import { wallpaperVectorsDistanceSquared } from './wallpaperVectorsDistanceSquared'; diff --git a/src/ai/recommendation/wallpaperToVector.ts b/src/ai/recommendation/wallpaperToVector.ts index 1e43448653..76a80902cd 100644 --- a/src/ai/recommendation/wallpaperToVector.ts +++ b/src/ai/recommendation/wallpaperToVector.ts @@ -1,5 +1,5 @@ -import { IWallpaper } from '../../utils/IWallpaper'; -import { IWallpaperVector } from './IWallpaperVector'; +import type { IWallpaper } from '../../utils/IWallpaper'; +import type { IWallpaperVector } from './IWallpaperVector'; export function wallpaperToVector(wallpaper: IWallpaper): IWallpaperVector { const { red, green, blue } = wallpaper.colorStats.palette[0]!.value; diff --git a/src/ai/recommendation/wallpaperVectorsDistanceSquared.ts b/src/ai/recommendation/wallpaperVectorsDistanceSquared.ts index 68751f455a..a06d485ab3 100644 --- a/src/ai/recommendation/wallpaperVectorsDistanceSquared.ts +++ b/src/ai/recommendation/wallpaperVectorsDistanceSquared.ts @@ -1,4 +1,4 @@ -import { IWallpaperVector } from './IWallpaperVector'; +import type { IWallpaperVector } from './IWallpaperVector'; export function wallpaperVectorsDistanceSquared( wallpaperVector1: IWallpaperVector, diff --git a/src/ai/text-to-text/ChatThread.ts b/src/ai/text-to-text/ChatThread.ts index 88efcd6409..e69432ff04 100644 --- a/src/ai/text-to-text/ChatThread.ts +++ b/src/ai/text-to-text/ChatThread.ts @@ -1,5 +1,5 @@ import { getSupabaseForServer } from '../../utils/supabase/getSupabaseForServer'; -import { string_chat_prompt, string_model_name, uuid } from '../../utils/typeAliases'; +import type { string_chat_prompt, string_model_name, uuid } from '../../utils/typeAliases'; import { getOpenaiForServer } from './getOpenaiForServer'; /** diff --git a/src/ai/text-to-text/completeWithGpt.ts b/src/ai/text-to-text/completeWithGpt.ts index 81c03df205..a1d8e2cc31 100644 --- a/src/ai/text-to-text/completeWithGpt.ts +++ b/src/ai/text-to-text/completeWithGpt.ts @@ -1,5 +1,5 @@ import { getSupabaseForServer } from '../../utils/supabase/getSupabaseForServer'; -import { string_completion_prompt, string_model_name, uuid } from '../../utils/typeAliases'; +import type { string_completion_prompt, string_model_name, uuid } from '../../utils/typeAliases'; import { getOpenaiForServer } from './getOpenaiForServer'; export interface ICompleteWithGptResult { diff --git a/src/ai/text-to-text/prompt-templates/createContentPromptTemplate.ts b/src/ai/text-to-text/prompt-templates/createContentPromptTemplate.ts index 232361ca92..06dcacd279 100644 --- a/src/ai/text-to-text/prompt-templates/createContentPromptTemplate.ts +++ b/src/ai/text-to-text/prompt-templates/createContentPromptTemplate.ts @@ -1,5 +1,5 @@ -import spaceTrim from 'spacetrim'; -import { image_description, string_chat_prompt, string_midjourney_prompt } from '../../../utils/typeAliases'; +import { spaceTrim } from 'spacetrim'; +import type { image_description, string_chat_prompt, string_midjourney_prompt } from '../../../utils/typeAliases'; /** * Generates a template for creating web content based on a given wallpaper description diff --git a/src/ai/text-to-text/prompt-templates/createFontPromptTemplate.ts b/src/ai/text-to-text/prompt-templates/createFontPromptTemplate.ts index 893e50458a..a97b50b8d1 100644 --- a/src/ai/text-to-text/prompt-templates/createFontPromptTemplate.ts +++ b/src/ai/text-to-text/prompt-templates/createFontPromptTemplate.ts @@ -1,6 +1,6 @@ -import spaceTrim from 'spacetrim'; +import { spaceTrim } from 'spacetrim'; import { FONTS } from '../../../../config'; -import { string_chat_prompt } from '../../../utils/typeAliases'; +import type { string_chat_prompt } from '../../../utils/typeAliases'; /** * Generates a template for figuring out best fitting font for the website. diff --git a/src/ai/text-to-text/prompt-templates/createTitlePromptTemplate.ts b/src/ai/text-to-text/prompt-templates/createTitlePromptTemplate.ts index 48255b2d04..72d72a141a 100644 --- a/src/ai/text-to-text/prompt-templates/createTitlePromptTemplate.ts +++ b/src/ai/text-to-text/prompt-templates/createTitlePromptTemplate.ts @@ -1,5 +1,5 @@ -import spaceTrim from 'spacetrim'; -import { image_description, string_chat_prompt, string_midjourney_prompt } from '../../../utils/typeAliases'; +import { spaceTrim } from 'spacetrim'; +import type { image_description, string_chat_prompt, string_midjourney_prompt } from '../../../utils/typeAliases'; /** * Generates a template for creating web title based on a given wallpaper description diff --git a/src/ai/text-to-text/writeWallpaperContent.ts b/src/ai/text-to-text/writeWallpaperContent.ts index 3b03f40b3f..6fd9db3f5e 100644 --- a/src/ai/text-to-text/writeWallpaperContent.ts +++ b/src/ai/text-to-text/writeWallpaperContent.ts @@ -1,4 +1,4 @@ -import spaceTrim from 'spacetrim'; +import { spaceTrim } from 'spacetrim'; import { FONTS } from '../../../config'; import { parseTitleAndTopic } from '../../utils/content/parseTitleAndTopic'; import { removeQuotes } from '../../utils/content/removeQuotes'; diff --git a/src/components/AiComponents/AiComponentsRoot.tsx b/src/components/AiComponents/AiComponentsRoot.tsx index 6b40ebe528..0365f1c2da 100644 --- a/src/components/AiComponents/AiComponentsRoot.tsx +++ b/src/components/AiComponents/AiComponentsRoot.tsx @@ -1,7 +1,8 @@ -import { ReactNode, useContext } from 'react'; -import { Promisable } from 'type-fest'; +import type { ReactNode } from 'react'; +import { useContext } from 'react'; +import type { Promisable } from 'type-fest'; import { ExportContext } from '../../utils/hooks/ExportContext'; -import { string_css_class } from '../../utils/typeAliases'; +import type { string_css_class } from '../../utils/typeAliases'; import { InlineScript } from '../InlineScript/InlineScript'; interface AiComponentsRootProps { diff --git a/src/components/AiComponents/activateGalleryComponent.ts b/src/components/AiComponents/activateGalleryComponent.ts index 861cbc77dc..0ece0736cc 100644 --- a/src/components/AiComponents/activateGalleryComponent.ts +++ b/src/components/AiComponents/activateGalleryComponent.ts @@ -1,5 +1,5 @@ import type { LikedStatus } from '../../utils/hooks/useLikedStatusOfCurrentWallpaper'; -import { string_color, string_wallpaper_id } from '../../utils/typeAliases'; +import type { string_color, string_wallpaper_id } from '../../utils/typeAliases'; export async function activateGalleryComponent(galleryElement: HTMLElement): Promise { const moreButtonHtml = ` diff --git a/src/components/AnalyticsAndIntegrations/AnalyticsAndIntegrations.tsx b/src/components/AnalyticsAndIntegrations/AnalyticsAndIntegrations.tsx index b36f0afca3..cbe6298e85 100644 --- a/src/components/AnalyticsAndIntegrations/AnalyticsAndIntegrations.tsx +++ b/src/components/AnalyticsAndIntegrations/AnalyticsAndIntegrations.tsx @@ -1,5 +1,5 @@ import Script from 'next/script'; -import spaceTrim from 'spacetrim'; +import { spaceTrim } from 'spacetrim'; /** * Renders all the analytics and integrations like Google Analytics, SmartLook, Sentry, ... diff --git a/src/components/AppHead/WallpaperAppHead.tsx b/src/components/AppHead/WallpaperAppHead.tsx index 01153f8da0..b82554b927 100644 --- a/src/components/AppHead/WallpaperAppHead.tsx +++ b/src/components/AppHead/WallpaperAppHead.tsx @@ -1,6 +1,7 @@ import Head from 'next/head'; import { useRouter } from 'next/router'; -import { ReactNode, useContext } from 'react'; +import type { ReactNode } from 'react'; +import { useContext } from 'react'; import { NEXT_PUBLIC_URL } from '../../../config'; import { AnalyticsAndIntegrations } from '../../components/AnalyticsAndIntegrations/AnalyticsAndIntegrations'; import { extractDescriptionFromHtml } from '../../utils/content/extractDescriptionFromHtml'; diff --git a/src/components/AsyncContentComponent/AsyncContentComponent.tsx b/src/components/AsyncContentComponent/AsyncContentComponent.tsx index 51ccbed9ce..882eb176ec 100644 --- a/src/components/AsyncContentComponent/AsyncContentComponent.tsx +++ b/src/components/AsyncContentComponent/AsyncContentComponent.tsx @@ -1,5 +1,5 @@ -import { ReactNode } from 'react'; -import { Promisable } from 'type-fest'; +import type { ReactNode } from 'react'; +import type { Promisable } from 'type-fest'; import { usePromise } from '../../utils/hooks/usePromise'; interface AsyncContentComponentProps { diff --git a/src/components/ColorPreview/ColorInput/ColorInput.tsx b/src/components/ColorPreview/ColorInput/ColorInput.tsx index d6fb29df97..1e74afe08e 100644 --- a/src/components/ColorPreview/ColorInput/ColorInput.tsx +++ b/src/components/ColorPreview/ColorInput/ColorInput.tsx @@ -2,9 +2,9 @@ import { useState } from 'react'; import SketchPicker, { PresetColor } from 'react-color/lib/components/sketch/Sketch'; import { Color } from '../../../utils/color/Color'; import { useClickOutside } from '../../../utils/hooks/useClickOutside'; -import { WithTake } from '../../../utils/take/interfaces/ITakeChain'; +import type { WithTake } from '../../../utils/take/interfaces/ITakeChain'; import { take } from '../../../utils/take/take'; -import { string_css_class } from '../../../utils/typeAliases'; +import type { string_css_class } from '../../../utils/typeAliases'; import { ColorPreview } from '../ColorPreview'; import styles from './ColorInput.module.css'; diff --git a/src/components/ColorPreview/ColorPreview.tsx b/src/components/ColorPreview/ColorPreview.tsx index 28d7a9adb0..554d48fca1 100644 --- a/src/components/ColorPreview/ColorPreview.tsx +++ b/src/components/ColorPreview/ColorPreview.tsx @@ -3,7 +3,7 @@ import { classNames } from '../../utils/classNames'; import { Color } from '../../utils/color/Color'; import { textColor } from '../../utils/color/operators/furthest'; import { take } from '../../utils/take/take'; -import { string_css_class } from '../../utils/typeAliases'; +import type { string_css_class } from '../../utils/typeAliases'; import styles from './ColorPreview.module.css'; interface ColorPreviewProps { diff --git a/src/components/ColorsModal/ColorsModal.tsx b/src/components/ColorsModal/ColorsModal.tsx index 29a3f5b675..3de890541f 100644 --- a/src/components/ColorsModal/ColorsModal.tsx +++ b/src/components/ColorsModal/ColorsModal.tsx @@ -4,6 +4,7 @@ import { Color } from '../../utils/color/Color'; import { textColor } from '../../utils/color/operators/furthest'; import { useCurrentWallpaper } from '../../utils/hooks/useCurrentWallpaper'; import { Modal } from '../Modal/00-Modal'; +import { useCloseWallpaperModalHandler } from '../WallpaperLink/useCloseWallpaperModalHandler'; import styles from './ColorsModal.module.css'; import { ColorsModalColorAlgoritm } from './ColorsModalColorAlgoritm'; @@ -14,7 +15,7 @@ export function ColorsModal() { const [wallpaper, modifyWallpaper] = useCurrentWallpaper(); return ( - +
{wallpaper.src}
@@ -61,7 +62,6 @@ export function ColorsModal() { ); } - /** * TODO: [🦼] Use instead of - */ \ No newline at end of file + */ diff --git a/src/components/ControlPanel/RandomWallpaper/RandomWallpaperManager.ts b/src/components/ControlPanel/RandomWallpaper/RandomWallpaperManager.ts index b813e716cc..306a931c7c 100644 --- a/src/components/ControlPanel/RandomWallpaper/RandomWallpaperManager.ts +++ b/src/components/ControlPanel/RandomWallpaper/RandomWallpaperManager.ts @@ -1,11 +1,11 @@ -import { Promisable } from 'type-fest'; +import type { Promisable } from 'type-fest'; import { forAnimationFrame, forImmediate } from 'waitasecond'; import { IS_DEVELOPMENT, NEXT_PUBLIC_URL } from '../../../../config'; import type { RecommendWallpaperResponse } from '../../../pages/api/recommend-wallpaper'; -import { IWallpaperSerialized } from '../../../utils/IWallpaper'; +import type { IWallpaperSerialized } from '../../../utils/IWallpaper'; import { randomItem } from '../../../utils/randomItem'; import { provideClientIdWithoutVerification } from '../../../utils/supabase/provideClientIdWithoutVerification'; -import { string_wallpaper_id } from '../../../utils/typeAliases'; +import type { string_wallpaper_id } from '../../../utils/typeAliases'; export type IWallpaperInStorage = Pick; diff --git a/src/components/ControlPanel/RandomWallpaper/useRandomWallpaper.ts b/src/components/ControlPanel/RandomWallpaper/useRandomWallpaper.ts index 0e11639db4..4d6c9c3856 100644 --- a/src/components/ControlPanel/RandomWallpaper/useRandomWallpaper.ts +++ b/src/components/ControlPanel/RandomWallpaper/useRandomWallpaper.ts @@ -1,7 +1,8 @@ import { useMemo } from 'react'; import { useCurrentWallpaperId } from '../../../utils/hooks/useCurrentWallpaperId'; import { usePromise } from '../../../utils/hooks/usePromise'; -import { IWallpaperInStorage, RandomWallpaperManager } from './RandomWallpaperManager'; +import type { IWallpaperInStorage } from './RandomWallpaperManager'; +import { RandomWallpaperManager } from './RandomWallpaperManager'; export function useRandomWallpaper(): [ randomWallpaper: IWallpaperInStorage | null, @@ -17,7 +18,7 @@ export function useRandomWallpaper(): [ ); const { value: recommendedWallpaper } = usePromise(randomWallpaperPromise); - console.info(`🎲 Use recommended wallpaper`, {recommendedWallpaper}); + console.info(`🎲 Use recommended wallpaper`, { recommendedWallpaper }); return [ recommendedWallpaper || null, diff --git a/src/components/CopilotPanel/CopilotPanel.tsx b/src/components/CopilotPanel/CopilotPanel.tsx index 6edfb82202..7c93693e20 100644 --- a/src/components/CopilotPanel/CopilotPanel.tsx +++ b/src/components/CopilotPanel/CopilotPanel.tsx @@ -1,7 +1,7 @@ import Image from 'next/image'; import { useRouter } from 'next/router'; import { useCallback, useMemo, useRef, useState } from 'react'; -import spaceTrim from 'spacetrim'; +import { spaceTrim } from 'spacetrim'; import { COPILOT_PLACEHOLDERS, IS_VERIFIED_EMAIL_REQUIRED } from '../../../config'; import type { UpdateWallpaperContentRequest, @@ -17,7 +17,7 @@ import { serializeWallpaper } from '../../utils/hydrateWallpaper'; import { shuffleItems } from '../../utils/shuffleItems'; import { getSupabaseForBrowser } from '../../utils/supabase/getSupabaseForBrowser'; import { provideClientId } from '../../utils/supabase/provideClientId'; -import { string_prompt } from '../../utils/typeAliases'; +import type { string_prompt } from '../../utils/typeAliases'; import { parseKeywordsFromWallpaper } from '../Gallery/GalleryFilter/utils/parseKeywordsFromWallpaper'; import { Hint } from '../Hint/Hint'; import { TorusInteractiveImage } from '../TaskInProgress/TorusInteractiveImage'; diff --git a/src/components/CreateZone/CreateZone.tsx b/src/components/CreateZone/CreateZone.tsx index ac8958ed1b..b77c997201 100644 --- a/src/components/CreateZone/CreateZone.tsx +++ b/src/components/CreateZone/CreateZone.tsx @@ -1,6 +1,6 @@ -import { ReactNode } from 'react'; +import type { ReactNode } from 'react'; import { classNames } from '../../utils/classNames'; -import { string_css_class } from '../../utils/typeAliases'; +import type { string_css_class } from '../../utils/typeAliases'; import { Center } from '../SimpleLayout/Center'; import { TakeNoSpace } from '../SimpleLayout/TakeNoSpace'; import styles from './CreateZone.module.css'; diff --git a/src/components/DeviceIframe/DeviceIframe.tsx b/src/components/DeviceIframe/DeviceIframe.tsx index 5e685a1ceb..66337cde12 100644 --- a/src/components/DeviceIframe/DeviceIframe.tsx +++ b/src/components/DeviceIframe/DeviceIframe.tsx @@ -1,6 +1,6 @@ import Link from 'next/link'; import { classNames } from '../../utils/classNames'; -import { string_css_class, string_url } from '../../utils/typeAliases'; +import type { string_css_class, string_url } from '../../utils/typeAliases'; import styles from './DeviceIframe.module.css'; interface DeviceIframeProps { diff --git a/src/components/Dialogues/Dialogues.module.css b/src/components/Dialogs/Dialogs.module.css similarity index 66% rename from src/components/Dialogues/Dialogues.module.css rename to src/components/Dialogs/Dialogs.module.css index 74537dd0b1..a74e62318b 100644 --- a/src/components/Dialogues/Dialogues.module.css +++ b/src/components/Dialogs/Dialogs.module.css @@ -1,9 +1,18 @@ +.message { + /**/ + outline: 1px dotted rgb(81, 255, 38); + /**/ + + /* + TODO: !!! + */ +} .answer { /*/ outline: 1px dotted rgb(81, 255, 38); /**/ - z-index: 1 /* <- Note: Local order in dialogue */; + z-index: 1 /* <- Note: Local order in dialog */; width: 100%; height: calc(100% - 50px); @@ -22,7 +31,7 @@ outline: 1px dotted rgb(81, 255, 38); /**/ - z-index: 2 /* <- Note: Local order in dialogue */; + z-index: 2 /* <- Note: Local order in dialog */; float: right; diff --git a/src/components/Dialogs/Dialogs.tsx b/src/components/Dialogs/Dialogs.tsx new file mode 100644 index 0000000000..a37beb68cc --- /dev/null +++ b/src/components/Dialogs/Dialogs.tsx @@ -0,0 +1,107 @@ +import { useEffect, useRef, useState } from 'react'; +import { Modal } from '../Modal/00-Modal'; +import styles from './Dialogs.module.css'; +import type { CommonDialogInQueue } from './interfaces/CommonDialogInQueue'; +import { isDialogsRendered } from './locks/isDialogsRendered'; +import { promptDialogQueue } from './queues/prompts'; + +/** + * Renders a place where the dialogs are rendered + * + * The component is initially hidden and is shown when the first dialog is rendered + * Note: There can be only one instance of this component in the app + */ +export function Dialogs() { + useEffect( + () => { + if (isDialogsRendered.value === true) { + throw new Error('There can be only one instance of TasksInProgress in the app'); + } + isDialogsRendered.value = true; + return () => { + isDialogsRendered.value = false; + }; + }, + [ + // Note: Check only once on mount + ], + ); + + const [currentCommonDialogInQueue, setCurrentCommonDialogInQueue] = useState(null); + const textareaRef = useRef(null); + + useEffect(() => { + if (currentCommonDialogInQueue) { + return; + } + + const interval = setInterval(() => { + const promptInQueue = promptDialogQueue.find((promptInQueue) => promptInQueue.answer === undefined); + + if (!promptInQueue) { + return; + } + + setCurrentCommonDialogInQueue(promptInQueue); + if (textareaRef.current) { + textareaRef.current.value = promptInQueue.defaultValue || ''; + } + }, 50 /* <- TODO: DIALOG_POLLING_INTERVAL_MS into config */); + + return () => { + clearInterval(interval); + }; + }, [currentCommonDialogInQueue, textareaRef]); + + if (!currentCommonDialogInQueue) { + return null; + } + + return ( + { + currentCommonDialogInQueue.answer = null; + setCurrentCommonDialogInQueue(null); + }} + > + {currentCommonDialogInQueue.message && ( +
{currentCommonDialogInQueue.message}
+ )} +