mirror of
https://github.com/DustinBrett/daedalOS.git
synced 2025-12-06 12:20:20 +01:00
Stable worker naming
This commit is contained in:
parent
f56c33b74d
commit
bafae5b7e8
|
|
@ -25,7 +25,7 @@ export const WALLPAPER_PATHS: Record<
|
|||
VANTA: () => import("components/system/Desktop/Wallpapers/vantaWaves"),
|
||||
};
|
||||
|
||||
export const WALLPAPER_WORKERS: Record<string, (info?: string) => Worker> = {
|
||||
export const WALLPAPER_WORKERS: Record<string, () => Worker> = {
|
||||
COASTAL_LANDSCAPE: (): Worker =>
|
||||
new Worker(
|
||||
new URL(
|
||||
|
|
@ -47,13 +47,13 @@ export const WALLPAPER_WORKERS: Record<string, (info?: string) => Worker> = {
|
|||
new URL("components/apps/StableDiffusion/sd.worker", import.meta.url),
|
||||
{ name: "Wallpaper (Stable Diffusion)" }
|
||||
),
|
||||
VANTA: (info?: string): Worker =>
|
||||
VANTA: (): Worker =>
|
||||
new Worker(
|
||||
new URL(
|
||||
"components/system/Desktop/Wallpapers/vantaWaves/wallpaper.worker",
|
||||
import.meta.url
|
||||
),
|
||||
{ name: `Wallpaper (Vanta Waves)${info ? ` [${info}]` : ""}` }
|
||||
{ name: "Wallpaper (Vanta Waves)" }
|
||||
),
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -63,9 +63,7 @@ const useWallpaper = (
|
|||
);
|
||||
const vantaWireframe = wallpaperImage === "VANTA WIREFRAME";
|
||||
const wallpaperWorker = useWorker<void>(
|
||||
sessionLoaded ? WALLPAPER_WORKERS[wallpaperName] : undefined,
|
||||
undefined,
|
||||
vantaWireframe ? "Wireframe" : ""
|
||||
sessionLoaded ? WALLPAPER_WORKERS[wallpaperName] : undefined
|
||||
);
|
||||
const wallpaperTimerRef = useRef(0);
|
||||
const failedOffscreenContext = useRef(false);
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import processDirectory from "contexts/process/directory";
|
|||
import { useSession } from "contexts/session";
|
||||
import { useProcessesRef } from "hooks/useProcessesRef";
|
||||
import {
|
||||
AI_TITLE,
|
||||
AUDIO_PLAYLIST_EXTENSIONS,
|
||||
CURSOR_FILE_EXTENSIONS,
|
||||
DESKTOP_PATH,
|
||||
|
|
@ -57,10 +58,6 @@ import {
|
|||
import { Share } from "components/system/Menu/MenuIcons";
|
||||
import { useWindowAI } from "hooks/useWindowAI";
|
||||
import { getNavButtonByTitle } from "hooks/useGlobalKeyboardShortcuts";
|
||||
import {
|
||||
AI_DISPLAY_TITLE,
|
||||
AI_STAGE,
|
||||
} from "components/system/Taskbar/AI/constants";
|
||||
import useTransferDialog, {
|
||||
type ObjectReader,
|
||||
} from "components/system/Dialogs/Transfer/useTransferDialog";
|
||||
|
|
@ -552,22 +549,13 @@ const useFileContextMenu = (
|
|||
if (newTopicButton) {
|
||||
newTopicButton?.click();
|
||||
} else {
|
||||
getNavButtonByTitle(AI_DISPLAY_TITLE)?.click();
|
||||
getNavButtonByTitle(AI_TITLE)?.click();
|
||||
}
|
||||
};
|
||||
|
||||
menuItems.unshift(MENU_SEPERATOR, {
|
||||
label: `AI (${AI_STAGE})`,
|
||||
menu: [
|
||||
...(aiEnabled || (hasWindowAI && "summarizer" in window.ai)
|
||||
? [
|
||||
{
|
||||
action: () => aiCommand("Summarize"),
|
||||
label: "Summarize Text",
|
||||
},
|
||||
]
|
||||
: []),
|
||||
],
|
||||
action: () => aiCommand("Summarize"),
|
||||
label: "Summarize Text (AI)",
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,7 @@
|
|||
import { importAIChat } from "components/system/Taskbar/functions";
|
||||
import {
|
||||
AI_DISPLAY_TITLE,
|
||||
WINDOW_ID,
|
||||
} from "components/system/Taskbar/AI/constants";
|
||||
import { AIIcon } from "components/system/Taskbar/AI/icons";
|
||||
import StyledAIButton from "components/system/Taskbar/AI/StyledAIButton";
|
||||
import { DIV_BUTTON_PROPS } from "utils/constants";
|
||||
import { AI_TITLE, AI_WINDOW_ID, DIV_BUTTON_PROPS } from "utils/constants";
|
||||
import { label } from "utils/functions";
|
||||
import useTaskbarContextMenu from "components/system/Taskbar/useTaskbarContextMenu";
|
||||
import { useSession } from "contexts/session";
|
||||
|
|
@ -24,10 +20,10 @@ const AIButton: FC<AIButtonProps> = ({ aiVisible, toggleAI }) => {
|
|||
<StyledAIButton
|
||||
onClick={() => {
|
||||
toggleAI();
|
||||
if (aiVisible) removeFromStack(WINDOW_ID);
|
||||
if (aiVisible) removeFromStack(AI_WINDOW_ID);
|
||||
}}
|
||||
{...DIV_BUTTON_PROPS}
|
||||
{...label(AI_DISPLAY_TITLE)}
|
||||
{...label(AI_TITLE)}
|
||||
{...useTaskbarContextMenu()}
|
||||
{...menuPreloadHandler}
|
||||
>
|
||||
|
|
|
|||
|
|
@ -22,11 +22,8 @@ import {
|
|||
} from "components/system/Taskbar/AI/icons";
|
||||
import useAITransition from "components/system/Taskbar/AI/useAITransition";
|
||||
import {
|
||||
AI_DISPLAY_TITLE,
|
||||
AI_TITLE,
|
||||
AI_WORKER,
|
||||
DEFAULT_CONVO_STYLE,
|
||||
WINDOW_ID,
|
||||
} from "components/system/Taskbar/AI/constants";
|
||||
import StyledAIChat from "components/system/Taskbar/AI/StyledAIChat";
|
||||
import { CloseIcon } from "components/system/Window/Titlebar/WindowActionIcons";
|
||||
|
|
@ -38,7 +35,13 @@ import {
|
|||
label,
|
||||
viewWidth,
|
||||
} from "utils/functions";
|
||||
import { DESKTOP_PATH, PREVENT_SCROLL, SAVE_PATH } from "utils/constants";
|
||||
import {
|
||||
AI_TITLE,
|
||||
AI_WINDOW_ID,
|
||||
DESKTOP_PATH,
|
||||
PREVENT_SCROLL,
|
||||
SAVE_PATH,
|
||||
} from "utils/constants";
|
||||
import {
|
||||
type MessageTypes,
|
||||
type ConvoStyles,
|
||||
|
|
@ -168,7 +171,7 @@ const AIChat: FC<AIChatProps> = ({ toggleAI }) => {
|
|||
useState<HTMLElement | null>();
|
||||
const { removeFromStack, setWallpaper } = useSession();
|
||||
const { zIndex, ...focusableProps } = useFocusable(
|
||||
WINDOW_ID,
|
||||
AI_WINDOW_ID,
|
||||
undefined,
|
||||
containerElement
|
||||
);
|
||||
|
|
@ -371,13 +374,13 @@ const AIChat: FC<AIChatProps> = ({ toggleAI }) => {
|
|||
>
|
||||
<div className="header">
|
||||
<header>
|
||||
{AI_DISPLAY_TITLE}
|
||||
{AI_TITLE} (beta)
|
||||
<nav>
|
||||
<Button
|
||||
className="close"
|
||||
onClick={() => {
|
||||
toggleAI();
|
||||
removeFromStack(WINDOW_ID);
|
||||
removeFromStack(AI_WINDOW_ID);
|
||||
}}
|
||||
{...label("Close")}
|
||||
>
|
||||
|
|
|
|||
|
|
@ -1,11 +1,5 @@
|
|||
import { type ConvoStyles } from "components/system/Taskbar/AI/types";
|
||||
|
||||
export const AI_TITLE = "Talos";
|
||||
|
||||
export const AI_STAGE = "alpha";
|
||||
|
||||
export const AI_DISPLAY_TITLE = `${AI_TITLE} (${AI_STAGE})`;
|
||||
|
||||
export const DEFAULT_CONVO_STYLE: ConvoStyles = "balanced";
|
||||
|
||||
export const AI_WORKER = (): Worker =>
|
||||
|
|
@ -13,5 +7,3 @@ export const AI_WORKER = (): Worker =>
|
|||
new URL("components/system/Taskbar/AI/ai.worker", import.meta.url),
|
||||
{ name: "AI" }
|
||||
);
|
||||
|
||||
export const WINDOW_ID = "ai-chat-window";
|
||||
|
|
|
|||
|
|
@ -19,11 +19,6 @@ import { useMenuPreload } from "hooks/useMenuPreload";
|
|||
|
||||
type ClockWorkerResponse = LocaleTimeDate | "source";
|
||||
|
||||
const ClockSourceMap = {
|
||||
local: "Local",
|
||||
ntp: "Server",
|
||||
};
|
||||
|
||||
const EASTER_EGG_CLICK_COUNT = 7;
|
||||
|
||||
const LARGEST_CLOCK_TEXT = "44:44:44 AM";
|
||||
|
|
@ -85,8 +80,10 @@ const Clock: FC<ClockProps> = ({
|
|||
"components/system/Taskbar/Clock/clock.worker",
|
||||
import.meta.url
|
||||
),
|
||||
{ name: `Clock (${ClockSourceMap[clockSource]})` }
|
||||
{ name: "Clock" }
|
||||
),
|
||||
// NOTE: Need `clockSource` in the dependency array to ensure the worker is rebuilt
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
[clockSource]
|
||||
);
|
||||
const offScreenClockCanvas = useRef<OffscreenCanvas>(undefined);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import { useMemo } from "react";
|
||||
import { AI_TITLE } from "components/system/Taskbar/AI/constants";
|
||||
import { useMenu } from "contexts/menu";
|
||||
import {
|
||||
type ContextMenuCapture,
|
||||
|
|
@ -9,7 +8,7 @@ import { useProcesses } from "contexts/process";
|
|||
import { useSession } from "contexts/session";
|
||||
import { useViewport } from "contexts/viewport";
|
||||
import { useProcessesRef } from "hooks/useProcessesRef";
|
||||
import { MENU_SEPERATOR } from "utils/constants";
|
||||
import { AI_TITLE, MENU_SEPERATOR } from "utils/constants";
|
||||
import { toggleShowDesktop } from "utils/functions";
|
||||
import { useWebGPUCheck } from "hooks/useWebGPUCheck";
|
||||
import { useWindowAI } from "hooks/useWindowAI";
|
||||
|
|
|
|||
|
|
@ -1,15 +1,14 @@
|
|||
import { useEffect, useRef } from "react";
|
||||
|
||||
const useWorker = <T>(
|
||||
workerInit?: (info?: string) => Worker,
|
||||
onMessage?: (message: MessageEvent<T>) => void,
|
||||
workerInfo?: string
|
||||
workerInit?: () => Worker,
|
||||
onMessage?: (message: MessageEvent<T>) => void
|
||||
): React.RefObject<Worker | undefined> => {
|
||||
const worker = useRef<Worker>(undefined);
|
||||
|
||||
useEffect(() => {
|
||||
if (workerInit && !worker.current) {
|
||||
worker.current = workerInit(workerInfo);
|
||||
worker.current = workerInit();
|
||||
|
||||
if (onMessage) {
|
||||
worker.current.addEventListener("message", onMessage, {
|
||||
|
|
@ -24,7 +23,7 @@ const useWorker = <T>(
|
|||
worker.current?.terminate();
|
||||
worker.current = undefined;
|
||||
};
|
||||
}, [onMessage, workerInfo, workerInit]);
|
||||
}, [onMessage, workerInit]);
|
||||
|
||||
return worker;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -211,6 +211,10 @@ export const DESKTOP_PATH = `${HOME}/Desktop`;
|
|||
|
||||
export const START_MENU_PATH = `${HOME}/Start Menu`;
|
||||
|
||||
export const AI_TITLE = "Talos";
|
||||
|
||||
export const AI_WINDOW_ID = "ai-chat-window";
|
||||
|
||||
export const SYSTEM_SHORTCUT_DIRECTORIES = new Set([DESKTOP_PATH]);
|
||||
|
||||
export const TRANSITIONS_IN_MILLISECONDS = {
|
||||
|
|
|
|||
|
|
@ -37,7 +37,9 @@ const decodeJxl = async (image: Buffer): Promise<Buffer> =>
|
|||
(await supportsImageType("image/jxl"))
|
||||
? image
|
||||
: new Promise((resolve) => {
|
||||
const worker = new Worker("System/JXL.js/jxl_dec.js");
|
||||
const worker = new Worker("System/JXL.js/jxl_dec.js", {
|
||||
name: "JXL.js",
|
||||
});
|
||||
|
||||
worker.postMessage({ image, jxlSrc: "image.jxl" });
|
||||
worker.addEventListener("message", (message: JxlDecodeResponse) => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user