Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

fix: Halloween is on now, only inside the app, and anyone can opt out (#2055)

Anshul sharma73d10458289a
diff --git a/.claude/rules/coding-conventions.md b/.claude/rules/coding-conventions.md
index 04071f96c5..3c758c213e 100644
--- a/.claude/rules/coding-conventions.md
+++ b/.claude/rules/coding-conventions.md
@@ -226,25 +226,30 @@ colors per mode (the ERP's onboarding backdrop). Theme names: `zinc`
The choice is a `theme` cookie per browser, never a database column. Each app's
`getTheme` (`services/theme.server.ts`) is the theme to RENDER: it resolves
-through `resolveTheme`, which returns the default for a name no longer in
-`themes`, so removing a theme needs no migration and breaks no browser that
-still holds it. A route that shows or posts back the user's own pick (the
-ERP's onboarding theme step and `x+/account+/theme.tsx`) reads
-`getStoredTheme` (`storedTheme`) instead: in season `getTheme` returns the
-seasonal theme, which `themeColorValidator` refuses. The root `Document`
-renders the loader's name with `themeByName`, so the season is decided once,
-on the server.
-
-A seasonal theme (`seasonalThemes`, never in `themes`) is not a choice: while
-it is in season it replaces every theme for everyone, and when the season
-ends everyone is back on their own cookie. No picker lists it and
-`themeColorValidator` refuses it. While one is on, every picker (the ERP
-avatar menu and mobile profile sheet, the onboarding theme step, Account →
-Appearance) is disabled and shows `SeasonalThemeNotice`; both it and
-`useSeasonalTheme` (`@carbon/react`) read the root loader's theme through
-`isSeasonalTheme`, so they survive the theme's removal. Its season is the `available` window on the
+through `themeForRequest` and `resolveTheme`, which return the default for a
+name no longer in `themes`, so removing a theme needs no migration and breaks
+no browser that still holds it. The pickers show `getTheme` as chosen. The
+root `Document` renders the loader's name with `themeByName`, so the season is
+decided once, on the server.
+
+A seasonal theme (`seasonalThemes`, never in `themes`) shows only inside the
+signed-in app (`isAppPath`, `/x`): every other page (sign-in, shared links,
+onboarding) gets the stored everyday theme, so public pages always show the
+brand, and the onboarding theme step lists only `themes`. Inside the app it is
+on by default while in season: it replaces every theme for everyone who has not
+picked another one, and when the season ends everyone is back on their own
+cookie. While in season every picker inside the app (the ERP avatar menu and
+mobile profile sheet, Account → Appearance) lists it first (`pickableThemes`),
+and `themeColorValidator` accepts it. What a pick writes is
+`themeCookieWrites` (`@carbon/utils`, as data; each app's `setTheme`
+serializes it with its cookie domain): an everyday theme is stored, and when
+picked inside the app (`inApp`) while a seasonal theme is on, a second cookie,
+`SEASONAL_OFF_COOKIE`, holds the seasonal theme's name for 30 days, which
+`themeForRequest` passes to `resolveTheme` as `seasonalOff`. Onboarding's pick
+(`inApp: false`) only stores the theme. Picking the seasonal theme clears that
+cookie and keeps the stored one. Its season is the `available` window on the
theme (`ThemeWindow`, month and day inside one calendar year; Halloween is
-October 31 only), and that window is the only switch: no flag, no deploy on
+October 27 to 31), and that window is the only switch: no flag, no deploy on
the day. The server has no time zone for the user, so `isInSeason` is true
while it is the season anywhere on Earth (UTC+14 reaches `from`, UTC-12 has
not left `to`); a fixed UTC check turned it on hours late east of UTC. To
@@ -272,24 +277,5 @@ stylesheet hangs off `data-user-menu` (ERP avatar trigger), `data-date`
nothing on their own and may stay when the folder is deleted. **The removal
checklist** (theme plus decorations) is the header of
`packages/react/src/Halloween/HalloweenLayer.tsx`: the folder and its
-export, three mounts, the theme file with its two registrations, the doc
+export, two mounts, the theme file with its two registrations, the doc
lines that name them, then `lingui:extract`.
-
-The sign-in page's left panel (`_public+/_layout.tsx`) shows the Night Shift
-while in season: `<HalloweenLoginArt />`, an ASCII story on a canvas
-(`packages/react/src/Halloween/night-shift/`), lazy-loaded behind
-`useHalloween` and only while the panel is shown (it is hidden below `lg`).
-It brings its own headline scrim and forces the panel it
-fills `dark` from an effect, so the layout holds one line. A haunted plant works one
-90-second shift (`ACTS` in `story.ts`) making a jack-o'-lantern; each shift
-is seeded (`planShift`: face, weather, visitor, moon phase, a rare event),
-shipped lanterns stay on the hill, and thirteen rise as the Carbon mark. The
-shift index lives in sessionStorage (`carbon:night-shift`) so a revisit
-continues the story. Everything a frame shows is a pure function of the
-moment (`renderFrame`), pinned by `frame.test.ts` across panel sizes; the
-cast reacts to the form (focus, secret fields, submit, error toasts) through
-DOM events only, and with reduced motion it draws one still frame and
-listens to nothing. The words it shows (stations, the ticket's status, the
-QC stamp) are Lingui strings passed in as `Labels`; the grid draws them as
-`Label`s, whole strings over reserved cells cut to fit, because a
-translation does not keep to one character per cell.
diff --git a/apps/erp/app/components/AvatarMenu.tsx b/apps/erp/app/components/AvatarMenu.tsx
index e79670bdb5..c242d8d994 100644
--- a/apps/erp/app/components/AvatarMenu.tsx
+++ b/apps/erp/app/components/AvatarMenu.tsx
@@ -23,15 +23,14 @@ import {
DropdownMenuTrigger,
getSystemMode,
ItarDisclosure,
- SeasonalThemeNotice,
useDisclosure,
useEdition,
useMode,
useModePreference,
- useSeasonalTheme
+ useThemePreview
} from "@carbon/react";
import type { ModePreference } from "@carbon/utils";
-import { Edition, modeValidator, themes } from "@carbon/utils";
+import { Edition, modeValidator, pickableThemes } from "@carbon/utils";
import { Trans, useLingui } from "@lingui/react/macro";
import { useLocale } from "@react-aria/i18n";
import type { ReactElement, ReactNode } from "react";
@@ -94,9 +93,10 @@ export function useAccountMenu() {
const mode = useMode();
const modePreference = useModePreference();
const serverTheme = useTheme();
- const seasonalTheme = useSeasonalTheme();
+ const themeOptions = pickableThemes();
const fetcher = useFetcher<typeof action>();
+ const previewTheme = useThemePreview(fetcher.state === "idle");
const onModeChange = (value: string) => {
const parsed = modeValidator.shape.mode.safeParse(value);
@@ -128,21 +128,16 @@ export function useAccountMenu() {
);
const onThemeChange = (t: string) => {
- if (seasonalTheme) return;
- const newTheme = themes.find((theme) => theme.name === t);
+ const newTheme = themeOptions.find((theme) => theme.name === t);
if (!newTheme) return;
- const variables =
- mode === "dark" ? newTheme.cssVars.dark : newTheme.cssVars.light;
-
setSelectedTheme(t);
const formData = new FormData();
formData.append("theme", t);
fetcher.submit(formData, { method: "post", action: path.to.theme });
-
- Object.entries(variables).forEach(([key, value]) => {
- document.body.style.setProperty(`--${key}`, value);
- });
+ previewTheme(
+ mode === "dark" ? newTheme.cssVars.dark : newTheme.cssVars.light
+ );
};
const optimisticTheme = selectedTheme ?? serverTheme;
@@ -265,7 +260,7 @@ export function useAccountMenu() {
onModeChange,
optimisticTheme,
onThemeChange,
- seasonalTheme,
+ themeOptions,
languageOptions,
resolvedLocale,
localeFetcher,
@@ -286,7 +281,7 @@ const AvatarMenu = () => {
onModeChange,
optimisticTheme,
onThemeChange,
- seasonalTheme,
+ themeOptions,
languageOptions,
resolvedLocale,
localeFetcher,
@@ -365,16 +360,14 @@ const AvatarMenu = () => {
{item.label}
</DropdownMenuSubTrigger>
<DropdownMenuSubContent>
- <SeasonalThemeNotice className="max-w-56 px-2 py-1.5" />
<DropdownMenuRadioGroup
value={optimisticTheme}
onValueChange={onThemeChange}
>
- {themes.map((t) => (
+ {themeOptions.map((t) => (
<DropdownMenuRadioItem
key={t.name}
value={t.name}
- disabled={seasonalTheme}
onSelect={(e) => e.preventDefault()}
style={
{
diff --git a/apps/erp/app/components/Layout/Mobile/ProfileSheet.tsx b/apps/erp/app/components/Layout/Mobile/ProfileSheet.tsx
index f40d2c8735..548dbea862 100644
--- a/apps/erp/app/components/Layout/Mobile/ProfileSheet.tsx
+++ b/apps/erp/app/components/Layout/Mobile/ProfileSheet.tsx
@@ -14,12 +14,10 @@ import {
cn,
ItarDisclosure,
PrefetchLink,
- SeasonalThemeNotice,
SheetSectionLabel,
sheetRowClassName,
useMode
} from "@carbon/react";
-import { themes } from "@carbon/utils";
import { Trans, useLingui } from "@lingui/react/macro";
import type { ReactNode } from "react";
import { Fragment, useEffect, useState } from "react";
@@ -202,11 +200,9 @@ export function ProfileSheet({
if (item.id === "theme") {
return (
<>
- <SeasonalThemeNotice className="px-4 py-2" />
- {themes.map((theme) => (
+ {menu.themeOptions.map((theme) => (
<SheetRowButton
key={theme.name}
- disabled={menu.seasonalTheme}
onClick={() => menu.onThemeChange(theme.name)}
>
<span
diff --git a/apps/erp/app/root.tsx b/apps/erp/app/root.tsx
index eb846fe215..8935ec6faa 100644
--- a/apps/erp/app/root.tsx
+++ b/apps/erp/app/root.tsx
@@ -212,7 +212,7 @@ export async function action({ request }: ActionFunctionArgs) {
return data(
{},
{
- headers: { "Set-Cookie": setTheme(themeValidation.data.theme) }
+ headers: setTheme(themeValidation.data.theme, { inApp: true })
}
);
}
diff --git a/apps/erp/app/routes/_public+/_layout.tsx b/apps/erp/app/routes/_public+/_layout.tsx
index f5afe409bc..eae56da50e 100644
--- a/apps/erp/app/routes/_public+/_layout.tsx
+++ b/apps/erp/app/routes/_public+/_layout.tsx
@@ -4,7 +4,6 @@
import { CONTROLLED_ENVIRONMENT } from "@carbon/auth";
import { cn, Heading, TooltipProvider } from "@carbon/react";
-import { HalloweenLoginArt } from "@carbon/react/Halloween";
import { Trans } from "@lingui/react/macro";
import { Outlet } from "react-router";
@@ -13,13 +12,11 @@ export default function PublicRoute() {
<TooltipProvider>
<div className="container relative h-full flex-col items-center justify-center grid lg:max-w-none lg:grid-cols-2 lg:px-0 bg-card">
<div className="relative hidden h-full flex-col bg-muted p-10 lg:flex dark:border-r dark:bg-zinc-900 bg-zinc-100">
- {/* Seasonal: shows only with the Halloween theme. */}
- <HalloweenLoginArt />
<img
src="/carbon-word-light.svg"
alt="Carbon Logo"
className={cn(
- "relative max-w-[200px] mb-3 dark:hidden z-50",
+ "max-w-[200px] mb-3 dark:hidden z-50",
CONTROLLED_ENVIRONMENT && "grayscale"
)}
/>
@@ -27,7 +24,7 @@ export default function PublicRoute() {
src="/carbon-word-dark.svg"
alt="Carbon Logo"
className={cn(
- "relative max-w-[200px] mb-3 dark:block hidden z-50",
+ "max-w-[200px] mb-3 dark:block hidden z-50",
CONTROLLED_ENVIRONMENT && "grayscale"
)}
/>
diff --git a/apps/erp/app/routes/onboarding+/theme.tsx b/apps/erp/app/routes/onboarding+/theme.tsx
index 16594c0dd9..c44bec2140 100644
--- a/apps/erp/app/routes/onboarding+/theme.tsx
+++ b/apps/erp/app/routes/onboarding+/theme.tsx
@@ -15,10 +15,9 @@ import {
PrefetchLink,
RadioGroup,
RadioGroupButton,
- SeasonalThemeNotice,
useMode,
useModePreference,
- useSeasonalTheme,
+ useThemePreview,
VStack
} from "@carbon/react";
import type { Theme } from "@carbon/utils";
@@ -40,7 +39,7 @@ import { useOnboarding } from "~/hooks";
import type { Theme as ThemeValue } from "~/modules/settings/settings.models";
import { themeValidator } from "~/modules/settings/settings.models";
import type { action as modeAction } from "~/root";
-import { getStoredTheme, setTheme } from "~/services/theme.server";
+import { getTheme, setTheme } from "~/services/theme.server";
import { ONBOARDING_SHORTCUTS } from "~/shortcuts";
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -52,7 +51,7 @@ export const handle: Handle = {
export async function loader({ request }: LoaderFunctionArgs) {
return {
- theme: getStoredTheme(request)
+ theme: getTheme(request)
};
}
@@ -70,7 +69,7 @@ export async function action({ request }: ActionFunctionArgs) {
if (!next) throw new Error("Fatal: next is required");
throw redirect(next || path.to.onboarding.root, {
- headers: { "Set-Cookie": setTheme(theme) }
+ headers: setTheme(theme, { inApp: false })
});
}
@@ -84,16 +83,12 @@ export default function OnboardingTheme() {
const [picked, setPicked] = useState<ThemeValue | null>(null);
const theme = picked ?? initialTheme;
- const seasonalTheme = useSeasonalTheme();
- const applyThemeColors = (t: Theme) => {
- // In season the page shows the seasonal theme, whatever is picked.
- if (seasonalTheme) return;
- const variables = mode === "dark" ? t.cssVars.dark : t.cssVars.light;
+ // Kept until the step is left: the pick is saved only on Continue.
+ const previewTheme = useThemePreview(false);
- Object.entries(variables).forEach(([key, value]) => {
- document.body.style.setProperty(`--${key}`, value);
- });
+ const applyThemeColors = (t: Theme) => {
+ previewTheme(mode === "dark" ? t.cssVars.dark : t.cssVars.light);
window.dispatchEvent(
new CustomEvent("onboarding-theme-change", { detail: t.name })
@@ -101,7 +96,6 @@ export default function OnboardingTheme() {
};
const onThemeChange = (t: Theme) => {
- if (seasonalTheme) return;
setPicked(t.name);
applyThemeColors(t);
};
@@ -190,10 +184,8 @@ export default function OnboardingTheme() {
<Trans>System</Trans>
</RadioGroupButton>
</RadioGroup>
- <SeasonalThemeNotice />
<RadioGroup
value={theme}
- disabled={seasonalTheme}
onValueChange={(name) => {
const selected = themes.find((entry) => entry.name === name);
if (selected) onThemeChange(selected);
diff --git a/apps/erp/app/routes/x+/account+/theme.tsx b/apps/erp/app/routes/x+/account+/theme.tsx
index 5641b53e3c..c910a84764 100644
--- a/apps/erp/app/routes/x+/account+/theme.tsx
+++ b/apps/erp/app/routes/x+/account+/theme.tsx
@@ -8,7 +8,7 @@ import { msg } from "@lingui/core/macro";
import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
import { data } from "react-router";
import { themeValidator } from "~/modules/settings/settings.models";
-import { getStoredTheme, setTheme } from "~/services/theme.server";
+import { getTheme, setTheme } from "~/services/theme.server";
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -19,7 +19,7 @@ export const handle: Handle = {
export async function loader({ request }: LoaderFunctionArgs) {
return {
- theme: getStoredTheme(request)
+ theme: getTheme(request)
};
}
@@ -36,7 +36,7 @@ export async function action({ request }: ActionFunctionArgs) {
return data(
{},
{
- headers: { "Set-Cookie": setTheme(validation.data.theme) }
+ headers: setTheme(validation.data.theme, { inApp: true })
}
);
}
diff --git a/apps/erp/app/services/theme.server.ts b/apps/erp/app/services/theme.server.ts
index 993258523f..ec1b42fa2d 100644
--- a/apps/erp/app/services/theme.server.ts
+++ b/apps/erp/app/services/theme.server.ts
@@ -4,41 +4,32 @@
import { DOMAIN, getCookieDomain } from "@carbon/auth";
import type { ThemeName } from "@carbon/utils";
-import { resolveTheme, storedTheme } from "@carbon/utils";
+import { themeCookieWrites, themeForRequest } from "@carbon/utils";
import * as cookie from "cookie";
-const cookieName = "theme";
-
-/**
- * The theme to render: a seasonal theme while in season, for everyone;
- * otherwise the cookie's, or the default (`resolveTheme`).
- */
+/** The theme to render (`themeForRequest`). */
export function getTheme(request: Request): ThemeName {
- return resolveTheme(readCookie(request)).name;
-}
-
-/**
- * The everyday theme the user picked, whatever is in season: what a picker
- * shows as chosen and posts back (`storedTheme`).
- */
-export function getStoredTheme(request: Request): ThemeName {
- return storedTheme(readCookie(request)).name;
+ return themeForRequest(
+ request.headers.get("cookie"),
+ new URL(request.url).pathname
+ ).name;
}
-function readCookie(request: Request) {
- const cookieHeader = request.headers.get("cookie");
- return cookieHeader ? cookie.parse(cookieHeader)[cookieName] : null;
-}
-
-export function setTheme(theme: string) {
+/** The `Set-Cookie` headers for a theme pick (`themeCookieWrites`). */
+export function setTheme(theme: string, { inApp }: { inApp: boolean }) {
const cookieDomain = getCookieDomain(DOMAIN);
- const cookieOptions: cookie.SerializeOptions = {
- path: "/",
- sameSite: "lax",
- secure: !!cookieDomain,
- domain: cookieDomain,
- maxAge: 31536000
- };
-
- return cookie.serialize(cookieName, theme, cookieOptions);
+ const headers = new Headers();
+ for (const { name, value, maxAge } of themeCookieWrites(theme, { inApp })) {
+ headers.append(
+ "Set-Cookie",
+ cookie.serialize(name, value, {
+ path: "/",
+ sameSite: "lax",
+ secure: !!cookieDomain,
+ domain: cookieDomain,
+ maxAge
+ })
+ );
+ }
+ return headers;
}
diff --git a/apps/mes/app/root.tsx b/apps/mes/app/root.tsx
index c2f1454742..0bcaffd771 100644
--- a/apps/mes/app/root.tsx
+++ b/apps/mes/app/root.tsx
@@ -188,7 +188,7 @@ export async function action({ request }: ActionFunctionArgs) {
return data(
{},
{
- headers: { "Set-Cookie": setTheme(themeValidation.data.theme) }
+ headers: setTheme(themeValidation.data.theme, { inApp: true })
}
);
}
diff --git a/apps/mes/app/services/theme.server.ts b/apps/mes/app/services/theme.server.ts
index a138f5df19..ec1b42fa2d 100644
--- a/apps/mes/app/services/theme.server.ts
+++ b/apps/mes/app/services/theme.server.ts
@@ -4,28 +4,32 @@
import { DOMAIN, getCookieDomain } from "@carbon/auth";
import type { ThemeName } from "@carbon/utils";
-import { resolveTheme } from "@carbon/utils";
+import { themeCookieWrites, themeForRequest } from "@carbon/utils";
import * as cookie from "cookie";
-const cookieName = "theme";
-
-/**
- * The theme to render: a seasonal theme while in season, for everyone;
- * otherwise the cookie's, or the default (`resolveTheme`).
- */
+/** The theme to render (`themeForRequest`). */
export function getTheme(request: Request): ThemeName {
- const cookieHeader = request.headers.get("cookie");
- const stored = cookieHeader ? cookie.parse(cookieHeader)[cookieName] : null;
- return resolveTheme(stored).name;
+ return themeForRequest(
+ request.headers.get("cookie"),
+ new URL(request.url).pathname
+ ).name;
}
-export function setTheme(theme: string) {
+/** The `Set-Cookie` headers for a theme pick (`themeCookieWrites`). */
+export function setTheme(theme: string, { inApp }: { inApp: boolean }) {
const cookieDomain = getCookieDomain(DOMAIN);
- return cookie.serialize(cookieName, theme, {
- path: "/",
- sameSite: "lax",
- secure: !!cookieDomain,
- domain: cookieDomain,
- maxAge: 31536000
- });
+ const headers = new Headers();
+ for (const { name, value, maxAge } of themeCookieWrites(theme, { inApp })) {
+ headers.append(
+ "Set-Cookie",
+ cookie.serialize(name, value, {
+ path: "/",
+ sameSite: "lax",
+ secure: !!cookieDomain,
+ domain: cookieDomain,
+ maxAge
+ })
+ );
+ }
+ return headers;
}
diff --git a/apps/starter/app/root.tsx b/apps/starter/app/root.tsx
index 9d0bca5800..d882a7c099 100644
--- a/apps/starter/app/root.tsx
+++ b/apps/starter/app/root.tsx
@@ -158,7 +158,7 @@ export async function action({ request }: ActionFunctionArgs) {
return data(
{},
{
- headers: { "Set-Cookie": setTheme(themeValidation.data.theme) }
+ headers: setTheme(themeValidation.data.theme, { inApp: true })
}
);
}
diff --git a/apps/starter/app/services/theme.server.ts b/apps/starter/app/services/theme.server.ts
index 21d97cc8fa..c97dc0f5c8 100644
--- a/apps/starter/app/services/theme.server.ts
+++ b/apps/starter/app/services/theme.server.ts
@@ -3,21 +3,25 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import type { ThemeName } from "@carbon/utils";
-import { resolveTheme } from "@carbon/utils";
+import { themeCookieWrites, themeForRequest } from "@carbon/utils";
import * as cookie from "cookie";
-const cookieName = "theme";
-
-/**
- * The theme to render: a seasonal theme while in season, for everyone;
- * otherwise the cookie's, or the default (`resolveTheme`).
- */
+/** The theme to render (`themeForRequest`). */
export function getTheme(request: Request): ThemeName {
- const cookieHeader = request.headers.get("cookie");
- const stored = cookieHeader ? cookie.parse(cookieHeader)[cookieName] : null;
- return resolveTheme(stored).name;
+ return themeForRequest(
+ request.headers.get("cookie"),
+ new URL(request.url).pathname
+ ).name;
}
-export function setTheme(theme: string) {
- return cookie.serialize(cookieName, theme, { path: "/", maxAge: 31536000 });
+/** The `Set-Cookie` headers for a theme pick (`themeCookieWrites`). */
+export function setTheme(theme: string, { inApp }: { inApp: boolean }) {
+ const headers = new Headers();
+ for (const { name, value, maxAge } of themeCookieWrites(theme, { inApp })) {
+ headers.append(
+ "Set-Cookie",
+ cookie.serialize(name, value, { path: "/", maxAge })
+ );
+ }
+ return headers;
}
diff --git a/packages/account/AGENTS.md b/packages/account/AGENTS.md
index 143f20b68e..17c2aba0bf 100644
--- a/packages/account/AGENTS.md
+++ b/packages/account/AGENTS.md
@@ -28,9 +28,9 @@ and the starter. Each app mounts it once in its shell; it opens over any page.
root action (`/`), which every app's `root.tsx` handles (`modeValidator` /
`themeColorValidator` from `@carbon/utils`). `useOptimisticMode` only counts a `/`
submission carrying `mode`, so the two never read each other's in-flight value.
- The theme grid lists the everyday `themes`. A seasonal theme is never offered; while one is
- in season it renders for everyone, so the grid is disabled and shows `SeasonalThemeNotice`
- (`useSeasonalTheme`, `@carbon/react`).
+ The theme grid lists `pickableThemes()`: the everyday `themes`, with the seasonal theme first
+ while one is in season. Picking an everyday theme then switches the seasonal one off for
+ this browser.
- Panes read with `useLoaderQuery` (`@carbon/query`), so the host app needs a
`QueryClientProvider`, `window.clientCache` and `createInvalidationMiddleware` in its root.
Strings use Lingui macros, so it also needs a `LocaleProvider`; the package is in the erp
diff --git a/packages/account/src/ui/AppearanceSettings.tsx b/packages/account/src/ui/AppearanceSettings.tsx
index 8ba8b2744d..9530c6be4d 100644
--- a/packages/account/src/ui/AppearanceSettings.tsx
+++ b/packages/account/src/ui/AppearanceSettings.tsx
@@ -5,18 +5,20 @@
import {
cn,
getSystemMode,
- SeasonalThemeNotice,
ToggleGroup,
ToggleGroupItem,
useMode,
useModePreference,
useRouteData,
- useSeasonalTheme
+ useThemePreview
} from "@carbon/react";
-import { modeValidator, themeColorValidator, themes } from "@carbon/utils";
+import {
+ modeValidator,
+ pickableThemes,
+ themeColorValidator
+} from "@carbon/utils";
import { Trans, useLingui } from "@lingui/react/macro";
import type { CSSProperties } from "react";
-import { useEffect, useRef } from "react";
import { LuCheck, LuLaptop, LuMoon, LuSun } from "react-icons/lu";
import { useFetcher } from "react-router";
import {
@@ -59,19 +61,10 @@ export default function AppearanceSettings() {
const modeFetcher = useFetcher();
const themeFetcher = useFetcher();
const routeData = useRouteData<{ theme?: string }>(ROOT_ACTION);
- const previewedVariables = useRef<string[]>([]);
- const seasonalTheme = useSeasonalTheme();
-
- // The preview lives on <body> and outranks the theme the root document puts
- // on <html>. Once the save settles, the root loader has revalidated: drop
- // the preview so <html> shows the saved theme — or the old one if it failed.
- useEffect(() => {
- if (themeFetcher.state !== "idle") return;
- for (const key of previewedVariables.current) {
- document.body.style.removeProperty(`--${key}`);
- }
- previewedVariables.current = [];
- }, [themeFetcher.state]);
+ const themeOptions = pickableThemes();
+ // Dropped once the save settles, so <html> shows the saved theme, or the
+ // old one if it failed.
+ const previewTheme = useThemePreview(themeFetcher.state === "idle");
// The in-flight choice wins until the root loader revalidates with it.
const pendingTheme = themeColorValidator.safeParse({
@@ -103,14 +96,10 @@ export default function AppearanceSettings() {
};
const onThemeChange = (value: string) => {
- const next = themes.find((candidate) => candidate.name === value);
- if (seasonalTheme || !next || next.name === theme) return;
+ const next = themeOptions.find((candidate) => candidate.name === value);
+ if (!next || next.name === theme) return;
// Preview at once, until the root loader applies it from the cookie.
- const variables = mode === "dark" ? next.cssVars.dark : next.cssVars.light;
- Object.entries(variables).forEach(([key, color]) => {
- document.body.style.setProperty(`--${key}`, color);
- });
- previewedVariables.current = Object.keys(variables);
+ previewTheme(mode === "dark" ? next.cssVars.dark : next.cssVars.light);
themeFetcher.submit(
{ theme: next.name },
{ method: "post", action: ROOT_ACTION }
@@ -162,17 +151,15 @@ export default function AppearanceSettings() {
title={<Trans>Theme color</Trans>}
description={<Trans>The accent color used across Carbon.</Trans>}
>
- <SeasonalThemeNotice className="mb-2" />
<ToggleGroup
type="single"
size="sm"
value={theme}
- disabled={seasonalTheme}
onValueChange={onThemeChange}
aria-label={t`Theme color`}
className="grid grid-cols-2 gap-2 sm:grid-cols-4"
>
- {themes.map((option) => {
+ {themeOptions.map((option) => {
const active = option.name === theme;
const swatch = option.activeColor[mode];
return (
diff --git a/packages/locale/locales/de/erp.po b/packages/locale/locales/de/erp.po
index 65dd970186..12d38afb91 100644
--- a/packages/locale/locales/de/erp.po
+++ b/packages/locale/locales/de/erp.po
@@ -1504,9 +1504,6 @@ msgstr "Ein Verkaufs-Anfrage (ein Kunde bittet Sie um ein Angebot) oder eine Ein
msgid "A scoped secret sent on the carbon-key request header that authenticates programmatic calls to Carbon, carrying its own permissions and rate limit rather than a user session's."
msgstr "Ein bereichsbegrenztes Geheimnis, das im carbon-key-Anfrage-Header gesendet wird und programmgesteuerte Aufrufe an Carbon authentifiziert, mit eigenen Berechtigungen und Ratenlimit statt einer Benutzersitzung."
-msgid "A seasonal theme is on for everyone today. You can pick yours again once it ends."
-msgstr "Heute gilt für alle ein saisonales Design. Sobald es endet, können Sie wieder Ihr eigenes wählen."
-
msgid "A separate schedule for tax reporting when tax rules require a method different from book depreciation."
msgstr "Ein separater Plan für die Steuermeldung, wenn Steuerregeln eine Methode erfordern, die sich von der buchhalterischen Abschreibung unterscheidet."
@@ -4823,9 +4820,6 @@ msgstr "Spediteur"
msgid "Carrier Account"
msgstr "Spediteurkonto"
-msgid "Carve"
-msgstr "Schnitzen"
-
msgid "Cash & Banking"
msgstr "Kasse & Banken"
@@ -12376,9 +12370,6 @@ msgstr "Sein Design kann sich ändern, bevor die Änderungsmitteilung freigegebe
msgid "Its revenue goes back to what each line has left to recognize."
msgstr "Ihre Umsatzerlöse gehen zurück zu dem, was jede Position noch nicht verbucht hat."
-msgid "Jack-o'-lantern"
-msgstr "Kürbislaterne"
-
msgid "Job"
msgstr "Job"
@@ -12908,9 +12899,6 @@ msgstr "LIFO"
msgid "Light"
msgstr "Hell"
-msgid "Light up"
-msgstr "Anzünden"
-
msgid "Light, dark, or follow your system setting."
msgstr "Hell, dunkel oder Systemeinstellung folgen."
@@ -18065,12 +18053,6 @@ msgstr "GW der Zahlungen"
msgid "PV of Residual"
msgstr "GW des Restwerts"
-msgid "QC"
-msgstr "QS"
-
-msgid "QC passed"
-msgstr "QS bestanden"
-
msgid "QR Code to complete the current operation for this kanban"
msgstr "QR-Code zum Abschließen des aktuellen Arbeitsgangs für diesen Kanban"
@@ -26256,9 +26238,6 @@ msgstr "Warnen Sie, wenn die Person, die einen eingegangenen Artikel prüft, die
msgid "Warning"
msgstr "Warnung"
-msgid "Wash"
-msgstr "Waschen"
-
msgid "Watch"
msgstr "Ansehen"
diff --git a/packages/locale/locales/de/mes.po b/packages/locale/locales/de/mes.po
index 0bf88a13f4..92a39ba094 100644
--- a/packages/locale/locales/de/mes.po
+++ b/packages/locale/locales/de/mes.po
@@ -110,9 +110,6 @@ msgstr "🚨 Hinweis: Am {0} wird Ihr Konto zu erp.try.carbon.ms verschoben"
msgid "A previous completion did not finish. Retrying resumes the remaining steps — quantities are not double-counted."
msgstr "Eine vorherige Fertigstellung wurde nicht abgeschlossen. Ein erneuter Versuch setzt die verbleibenden Schritte fort – Mengen werden nicht doppelt gezählt."
-msgid "A seasonal theme is on for everyone today. You can pick yours again once it ends."
-msgstr "Heute gilt für alle ein saisonales Design. Sobald es endet, können Sie wieder Ihr eigenes wählen."
-
msgid "About"
msgstr "Über"
@@ -343,9 +340,6 @@ msgstr "Carbon Logo"
msgid "Cards"
msgstr "Karten"
-msgid "Carve"
-msgstr "Schnitzen"
-
msgid "Change"
msgstr "Ändern"
@@ -927,9 +921,6 @@ msgstr "Artikelstamm"
msgid "Items"
msgstr "Artikel"
-msgid "Jack-o'-lantern"
-msgstr "Kürbislaterne"
-
msgid "Job"
msgstr "Auftrag"
@@ -984,9 +975,6 @@ msgstr "Lassen Sie uns etwas bauen"
msgid "Light"
msgstr "Hell"
-msgid "Light up"
-msgstr "Anzünden"
-
msgid "Light, dark, or follow your system setting."
msgstr "Hell, dunkel oder Systemeinstellung folgen."
@@ -1563,12 +1551,6 @@ msgstr "Fortschritt"
msgid "Purchasing"
msgstr "Einkauf"
-msgid "QC"
-msgstr "QS"
-
-msgid "QC passed"
-msgstr "QS bestanden"
-
msgid "Quality"
msgstr "Qualität"
@@ -1631,9 +1613,6 @@ msgstr "Ablehnen"
msgid "Reject Lot"
msgstr "Charge ablehnen"
-msgid "Rejected"
-msgstr "Abgelehnt"
-
msgid "Released"
msgstr "Freigegeben"
@@ -2275,9 +2254,6 @@ msgstr "Instandhaltungseinsatz anzeigen"
msgid "View or open"
msgstr "Anzeigen oder Öffnen"
-msgid "Wash"
-msgstr "Waschen"
-
msgid "We've emailed you a sign-in link and a 6-digit code. Follow the link, or enter the code here."
msgstr ""
diff --git a/packages/locale/locales/en/erp.po b/packages/locale/locales/en/erp.po
index e96a712374..a8c6e1ff72 100644
--- a/packages/locale/locales/en/erp.po
+++ b/packages/locale/locales/en/erp.po
@@ -1504,9 +1504,6 @@ msgstr "A sales RFQ (a customer asks you to quote) or a purchasing RFQ (you ask
msgid "A scoped secret sent on the carbon-key request header that authenticates programmatic calls to Carbon, carrying its own permissions and rate limit rather than a user session's."
msgstr "A scoped secret sent on the carbon-key request header that authenticates programmatic calls to Carbon, carrying its own permissions and rate limit rather than a user session's."
-msgid "A seasonal theme is on for everyone today. You can pick yours again once it ends."
-msgstr "A seasonal theme is on for everyone today. You can pick yours again once it ends."
-
msgid "A separate schedule for tax reporting when tax rules require a method different from book depreciation."
msgstr "A separate schedule for tax reporting when tax rules require a method different from book depreciation."
@@ -4823,9 +4820,6 @@ msgstr "Carrier"
msgid "Carrier Account"
msgstr "Carrier Account"
-msgid "Carve"
-msgstr "Carve"
-
msgid "Cash & Banking"
msgstr "Cash & Banking"
@@ -12376,9 +12370,6 @@ msgstr "Its design may change before the change notice is released."
msgid "Its revenue goes back to what each line has left to recognize."
msgstr "Its revenue goes back to what each line has left to recognize."
-msgid "Jack-o'-lantern"
-msgstr "Jack-o'-lantern"
-
msgid "Job"
msgstr "Job"
@@ -12908,9 +12899,6 @@ msgstr "LIFO"
msgid "Light"
msgstr "Light"
-msgid "Light up"
-msgstr "Light up"
-
msgid "Light, dark, or follow your system setting."
msgstr "Light, dark, or follow your system setting."
@@ -18065,12 +18053,6 @@ msgstr "PV of Payments"
msgid "PV of Residual"
msgstr "PV of Residual"
-msgid "QC"
-msgstr "QC"
-
-msgid "QC passed"
-msgstr "QC passed"
-
msgid "QR Code to complete the current operation for this kanban"
msgstr "QR Code to complete the current operation for this kanban"
@@ -26256,9 +26238,6 @@ msgstr "Warn when the person inspecting an inbound item is the same person who r
msgid "Warning"
msgstr "Warning"
-msgid "Wash"
-msgstr "Wash"
-
msgid "Watch"
msgstr "Watch"
diff --git a/packages/locale/locales/en/mes.po b/packages/locale/locales/en/mes.po
index 0ca0efe48d..bccae4b286 100644
--- a/packages/locale/locales/en/mes.po
+++ b/packages/locale/locales/en/mes.po
@@ -110,9 +110,6 @@ msgstr "🚨 Heads up: on {0} your account will be moved to erp.try.carbon.ms"
msgid "A previous completion did not finish. Retrying resumes the remaining steps — quantities are not double-counted."
msgstr "A previous completion did not finish. Retrying resumes the remaining steps — quantities are not double-counted."
-msgid "A seasonal theme is on for everyone today. You can pick yours again once it ends."
-msgstr "A seasonal theme is on for everyone today. You can pick yours again once it ends."
-
msgid "About"
msgstr "About"
@@ -343,9 +340,6 @@ msgstr "Carbon Logo"
msgid "Cards"
msgstr "Cards"
-msgid "Carve"
-msgstr "Carve"
-
msgid "Change"
msgstr "Change"
@@ -927,9 +921,6 @@ msgstr "Item Master"
msgid "Items"
msgstr "Items"
-msgid "Jack-o'-lantern"
-msgstr "Jack-o'-lantern"
-
msgid "Job"
msgstr "Job"
@@ -984,9 +975,6 @@ msgstr "Let's build something"
msgid "Light"
msgstr "Light"
-msgid "Light up"
-msgstr "Light up"
-
msgid "Light, dark, or follow your system setting."
msgstr "Light, dark, or follow your system setting."
@@ -1563,12 +1551,6 @@ msgstr "Progress"
msgid "Purchasing"
msgstr "Purchasing"
-msgid "QC"
-msgstr "QC"
-
-msgid "QC passed"
-msgstr "QC passed"
-
msgid "Quality"
msgstr "Quality"
@@ -1631,9 +1613,6 @@ msgstr "Reject"
msgid "Reject Lot"
msgstr "Reject Lot"
-msgid "Rejected"
-msgstr "Rejected"
-
msgid "Released"
msgstr "Released"
@@ -2275,9 +2254,6 @@ msgstr "View maintenance dispatch"
msgid "View or open"
msgstr "View or open"
-msgid "Wash"
-msgstr "Wash"
-
msgid "We've emailed you a sign-in link and a 6-digit code. Follow the link, or enter the code here."
msgstr "We've emailed you a sign-in link and a 6-digit code. Follow the link, or enter the code here."
diff --git a/packages/locale/locales/es/erp.po b/packages/locale/locales/es/erp.po
index 1c80bb4ecf..86042e1b24 100644
--- a/packages/locale/locales/es/erp.po
+++ b/packages/locale/locales/es/erp.po
@@ -1504,9 +1504,6 @@ msgstr "Un RFQ de venta (un cliente te pide que cotices) o un RFQ de compra (tu
msgid "A scoped secret sent on the carbon-key request header that authenticates programmatic calls to Carbon, carrying its own permissions and rate limit rather than a user session's."
msgstr "Un secreto con alcance enviado en el encabezado de solicitud carbon-key que autentica llamadas programáticas a Carbon, llevando sus propios permisos y límite de velocidad en lugar de la sesión de un usuario."
-msgid "A seasonal theme is on for everyone today. You can pick yours again once it ends."
-msgstr "Hoy hay un tema de temporada para todos. Podrás volver a elegir el tuyo cuando termine."
-
msgid "A separate schedule for tax reporting when tax rules require a method different from book depreciation."
msgstr "Un cronograma separado para la presentación de impuestos cuando las reglas fiscales requieren un método diferente a la depreciación de libros."
@@ -4823,9 +4820,6 @@ msgstr "Transportista"
msgid "Carrier Account"
msgstr "Cuenta de Transportista"
-msgid "Carve"
-msgstr "Tallar"
-
msgid "Cash & Banking"
msgstr "Efectivo y Banca"
@@ -12376,9 +12370,6 @@ msgstr "Su diseño puede cambiar antes de que se libere el aviso de cambio."
msgid "Its revenue goes back to what each line has left to recognize."
msgstr "Sus ingresos por ventas vuelven a lo que cada línea tiene pendiente de reconocer."
-msgid "Jack-o'-lantern"
-msgstr "Calabaza de Halloween"
-
msgid "Job"
msgstr "Trabajo"
@@ -12908,9 +12899,6 @@ msgstr "LIFO"
msgid "Light"
msgstr "Claro"
-msgid "Light up"
-msgstr "Encender"
-
msgid "Light, dark, or follow your system setting."
msgstr "Claro, oscuro o seguir la configuración del sistema."
@@ -18065,12 +18053,6 @@ msgstr "VP de Pagos"
msgid "PV of Residual"
msgstr "VP de Residual"
-msgid "QC"
-msgstr "CC"
-
-msgid "QC passed"
-msgstr "CC aprobado"
-
msgid "QR Code to complete the current operation for this kanban"
msgstr "QR Code para completar la operación actual para este kanban"
@@ -26256,9 +26238,6 @@ msgstr "Advertir cuando la persona que inspecciona un artículo entrante es la m
msgid "Warning"
msgstr "Advertencia"
-msgid "Wash"
-msgstr "Lavar"
-
msgid "Watch"
msgstr "Ver"
diff --git a/packages/locale/locales/es/mes.po b/packages/locale/locales/es/mes.po
index 1aad5df50e..d08ba23d21 100644
--- a/packages/locale/locales/es/mes.po
+++ b/packages/locale/locales/es/mes.po
@@ -110,9 +110,6 @@ msgstr "🚨 Atención: el {0} su cuenta se trasladará a erp.try.carbon.ms"
msgid "A previous completion did not finish. Retrying resumes the remaining steps — quantities are not double-counted."
msgstr "Una finalización anterior no se completó. Reintentar reanuda los pasos restantes — las cantidades no se duplican."
-msgid "A seasonal theme is on for everyone today. You can pick yours again once it ends."
-msgstr "Hoy hay un tema de temporada para todos. Podrás volver a elegir el tuyo cuando termine."
-
msgid "About"
msgstr "Acerca de"
@@ -343,9 +340,6 @@ msgstr "Logotipo de Carbon"
msgid "Cards"
msgstr "Tarjetas"
-msgid "Carve"
-msgstr "Tallar"
-
msgid "Change"
msgstr "Cambiar"
@@ -927,9 +921,6 @@ msgstr "Maestro de artículos"
msgid "Items"
msgstr "Artículos"
-msgid "Jack-o'-lantern"
-msgstr "Calabaza de Halloween"
-
msgid "Job"
msgstr "Trabajo"
@@ -984,9 +975,6 @@ msgstr "Construyamos algo"
msgid "Light"
msgstr "Claro"
-msgid "Light up"
-msgstr "Encender"
-
msgid "Light, dark, or follow your system setting."
msgstr "Claro, oscuro, o seguir la configuración del sistema."
@@ -1563,12 +1551,6 @@ msgstr "Progreso"
msgid "Purchasing"
msgstr "Compras"
-msgid "QC"
-msgstr "CC"
-
-msgid "QC passed"
-msgstr "CC aprobado"
-
msgid "Quality"
msgstr "Calidad"
@@ -1631,9 +1613,6 @@ msgstr "Rechazar"
msgid "Reject Lot"
msgstr "Rechazar lote"
-msgid "Rejected"
-msgstr "Rechazado"
-
msgid "Released"
msgstr "Liberado"
@@ -2275,9 +2254,6 @@ msgstr "Ver orden de mantenimiento"
msgid "View or open"
msgstr "Ver o abrir"
-msgid "Wash"
-msgstr "Lavar"
-
msgid "We've emailed you a sign-in link and a 6-digit code. Follow the link, or enter the code here."
msgstr ""
diff --git a/packages/locale/locales/fr/erp.po b/packages/locale/locales/fr/erp.po
index ca6c7fe3fa..14e52784bb 100644
--- a/packages/locale/locales/fr/erp.po
+++ b/packages/locale/locales/fr/erp.po
@@ -1504,9 +1504,6 @@ msgstr "Un RFQ de vente (un client vous demande de citer) ou un RFQ d'achat (vou
msgid "A scoped secret sent on the carbon-key request header that authenticates programmatic calls to Carbon, carrying its own permissions and rate limit rather than a user session's."
msgstr "Un secret limité en portée envoyé sur l'en-tête de requête carbon-key qui authentifie les appels programmatiques à Carbon, possédant ses propres autorisations et limite de débit plutôt que ceux d'une session utilisateur."
-msgid "A seasonal theme is on for everyone today. You can pick yours again once it ends."
-msgstr "Un thème de saison s'applique à tous aujourd'hui. Vous pourrez choisir à nouveau le vôtre lorsqu'il prendra fin."
-
msgid "A separate schedule for tax reporting when tax rules require a method different from book depreciation."
msgstr "Un calendrier d'amortissement distinct pour la déclaration fiscale quand les règles fiscales exigent une méthode différente de l'amortissement comptable."
@@ -4823,9 +4820,6 @@ msgstr "Transporteur"
msgid "Carrier Account"
msgstr "Compte de transporteur"
-msgid "Carve"
-msgstr "Sculpter"
-
msgid "Cash & Banking"
msgstr "Trésorerie et Banque"
@@ -12376,9 +12370,6 @@ msgstr "Sa conception peut changer avant la publication de l'avis de modificatio
msgid "Its revenue goes back to what each line has left to recognize."
msgstr "Ses revenus reviennent à ce que chaque ligne a à reconnaître."
-msgid "Jack-o'-lantern"
-msgstr "Citrouille d'Halloween"
-
msgid "Job"
msgstr "Tâche"
@@ -12908,9 +12899,6 @@ msgstr "LIFO"
msgid "Light"
msgstr "Clair"
-msgid "Light up"
-msgstr "Allumer"
-
msgid "Light, dark, or follow your system setting."
msgstr "Clair, sombre, ou suivre le paramètre de votre système."
@@ -18065,12 +18053,6 @@ msgstr "VA des paiements"
msgid "PV of Residual"
msgstr "VA de la valeur résiduelle"
-msgid "QC"
-msgstr "CQ"
-
-msgid "QC passed"
-msgstr "CQ validé"
-
msgid "QR Code to complete the current operation for this kanban"
msgstr "QR Code pour terminer l'opération en cours pour ce kanban"
@@ -26256,9 +26238,6 @@ msgstr "Avertir lorsque la personne inspectant un article entrant est la même p
msgid "Warning"
msgstr "Avertissement"
-msgid "Wash"
-msgstr "Laver"
-
msgid "Watch"
msgstr "Regarder"
diff --git a/packages/locale/locales/fr/mes.po b/packages/locale/locales/fr/mes.po
index 43341b3d58..467627e0a5 100644
--- a/packages/locale/locales/fr/mes.po
+++ b/packages/locale/locales/fr/mes.po
@@ -110,9 +110,6 @@ msgstr "🚨 Attention : le {0}, votre compte sera transféré vers erp.try.carb
msgid "A previous completion did not finish. Retrying resumes the remaining steps — quantities are not double-counted."
msgstr "Un traitement précédent ne s'est pas terminé. Recommencer reprend les étapes restantes — les quantités ne sont pas comptabilisées en double."
-msgid "A seasonal theme is on for everyone today. You can pick yours again once it ends."
-msgstr "Un thème de saison s'applique à tous aujourd'hui. Vous pourrez choisir à nouveau le vôtre lorsqu'il prendra fin."
-
msgid "About"
msgstr "À propos"
@@ -343,9 +340,6 @@ msgstr "Logo Carbon"
msgid "Cards"
msgstr "Cartes"
-msgid "Carve"
-msgstr "Sculpter"
-
msgid "Change"
msgstr "Modifier"
@@ -927,9 +921,6 @@ msgstr "Fiche article"
msgid "Items"
msgstr "Articles"
-msgid "Jack-o'-lantern"
-msgstr "Citrouille d'Halloween"
-
msgid "Job"
msgstr "Ordre de fabrication"
@@ -984,9 +975,6 @@ msgstr "Construisons quelque chose"
msgid "Light"
msgstr "Clair"
-msgid "Light up"
-msgstr "Allumer"
-
msgid "Light, dark, or follow your system setting."
msgstr "Clair, sombre, ou suivre les paramètres système."
@@ -1563,12 +1551,6 @@ msgstr "Progression"
msgid "Purchasing"
msgstr "Achats"
-msgid "QC"
-msgstr "CQ"
-
-msgid "QC passed"
-msgstr "CQ validé"
-
msgid "Quality"
msgstr "Qualité"
@@ -1631,9 +1613,6 @@ msgstr "Rejeter"
msgid "Reject Lot"
msgstr "Rejeter lot"
-msgid "Rejected"
-msgstr "Rejeté"
-
msgid "Released"
msgstr "Lancé"
@@ -2275,9 +2254,6 @@ msgstr "Voir l'intervention de maintenance"
msgid "View or open"
msgstr "Afficher ou ouvrir"
-msgid "Wash"
-msgstr "Laver"
-
msgid "We've emailed you a sign-in link and a 6-digit code. Follow the link, or enter the code here."
msgstr ""
diff --git a/packages/locale/locales/hi/erp.po b/packages/locale/locales/hi/erp.po
index 0252e6eb45..a25259369c 100644
--- a/packages/locale/locales/hi/erp.po
+++ b/packages/locale/locales/hi/erp.po
@@ -1504,9 +1504,6 @@ msgstr "एक बिक्रय RFQ (एक ग्राहक आपको
msgid "A scoped secret sent on the carbon-key request header that authenticates programmatic calls to Carbon, carrying its own permissions and rate limit rather than a user session's."
msgstr "कार्बन-कुंजी अनुरोध हेडर पर भेजा गया एक स्कोप्ड गोपनीय जो कार्बन के लिए प्रोग्रामेटिक कॉल को प्रमाणित करता है, उपयोगकर्ता सत्र की बजाय अपनी स्वयं की अनुमतियां और दर सीमा ले जाता है।"
-msgid "A seasonal theme is on for everyone today. You can pick yours again once it ends."
-msgstr "आज सभी के लिए एक मौसमी थीम लागू है। इसके समाप्त होने पर आप फिर से अपनी थीम चुन सकते हैं।"
-
msgid "A separate schedule for tax reporting when tax rules require a method different from book depreciation."
msgstr "कर रिपोर्टिंग के लिए एक अलग अनुसूची जब कर नियम पुस्तक मूल्यह्रास से अलग विधि की आवश्यकता होती है।"
@@ -4823,9 +4820,6 @@ msgstr "वाहक"
msgid "Carrier Account"
msgstr "वाहक खाता"
-msgid "Carve"
-msgstr "नक्काशी"
-
msgid "Cash & Banking"
msgstr "नकद और बैंकिंग"
@@ -12376,9 +12370,6 @@ msgstr "इसकी डिजाइन परिवर्तन सूचना
msgid "Its revenue goes back to what each line has left to recognize."
msgstr "इसका राजस्व उस पर वापस जाता है जो प्रत्येक पंक्ति को मान्यता देने के लिए बाकी है।"
-msgid "Jack-o'-lantern"
-msgstr "जैक-ओ-लैंटर्न"
-
msgid "Job"
msgstr "Job"
@@ -12908,9 +12899,6 @@ msgstr "LIFO"
msgid "Light"
msgstr "हल्का"
-msgid "Light up"
-msgstr "जलाएँ"
-
msgid "Light, dark, or follow your system setting."
msgstr "हल्का, गहरा, या अपनी सिस्टम सेटिंग का पालन करें।"
@@ -18065,12 +18053,6 @@ msgstr "भुगतान का PV"
msgid "PV of Residual"
msgstr "अवशिष्ट का PV"
-msgid "QC"
-msgstr "QC"
-
-msgid "QC passed"
-msgstr "QC पास"
-
msgid "QR Code to complete the current operation for this kanban"
msgstr "इस कानबान के लिए वर्तमान ऑपरेशन पूर्ण करने के लिए QR कोड"
@@ -26256,9 +26238,6 @@ msgstr "चेतावनी दें जब आने वाली वस्
msgid "Warning"
msgstr "चेतावनी"
-msgid "Wash"
-msgstr "धुलाई"
-
msgid "Watch"
msgstr "देखें"
diff --git a/packages/locale/locales/hi/mes.po b/packages/locale/locales/hi/mes.po
index e7ffc43c31..fe019b8d65 100644
--- a/packages/locale/locales/hi/mes.po
+++ b/packages/locale/locales/hi/mes.po
@@ -110,9 +110,6 @@ msgstr "🚨 ध्यान दें: {0} को आपका खाता erp
msgid "A previous completion did not finish. Retrying resumes the remaining steps — quantities are not double-counted."
msgstr "एक पिछला समापन पूरा नहीं हुआ। पुनः प्रयास करने से शेष चरण जारी रहते हैं — मात्राएँ दोगुनी नहीं गिनी जाती हैं।"
-msgid "A seasonal theme is on for everyone today. You can pick yours again once it ends."
-msgstr "आज सभी के लिए एक मौसमी थीम लागू है। इसके समाप्त होने पर आप फिर से अपनी थीम चुन सकते हैं।"
-
msgid "About"
msgstr "के बारे में"
@@ -343,9 +340,6 @@ msgstr "कार्बन लोगो"
msgid "Cards"
msgstr "कार्ड"
-msgid "Carve"
-msgstr "नक्काशी"
-
msgid "Change"
msgstr "बदलें"
@@ -927,9 +921,6 @@ msgstr "आइटम मास्टर"
msgid "Items"
msgstr "आइटम"
-msgid "Jack-o'-lantern"
-msgstr "जैक-ओ-लैंटर्न"
-
msgid "Job"
msgstr "नौकरी"
@@ -984,9 +975,6 @@ msgstr "चलिए कुछ बनाते हैं"
msgid "Light"
msgstr "हल्का"
-msgid "Light up"
-msgstr "जलाएँ"
-
msgid "Light, dark, or follow your system setting."
msgstr "हल्का, गहरा, या अपनी सिस्टम सेटिंग का पालन करें।"
@@ -1563,12 +1551,6 @@ msgstr "प्रगति"
msgid "Purchasing"
msgstr "क्रय"
-msgid "QC"
-msgstr "QC"
-
-msgid "QC passed"
-msgstr "QC पास"
-
msgid "Quality"
msgstr "गुणवत्ता"
@@ -1631,9 +1613,6 @@ msgstr "अस्वीकार करें"
msgid "Reject Lot"
msgstr "लॉट अस्वीकार करें"
-msgid "Rejected"
-msgstr "अस्वीकृत"
-
msgid "Released"
msgstr "जारी"
@@ -2275,9 +2254,6 @@ msgstr "रखरखाव कार्य देखें"
msgid "View or open"
msgstr "देखें या खोलें"
-msgid "Wash"
-msgstr "धुलाई"
-
msgid "We've emailed you a sign-in link and a 6-digit code. Follow the link, or enter the code here."
msgstr ""
diff --git a/packages/locale/locales/it/erp.po b/packages/locale/locales/it/erp.po
index 50ad174c9b..3e8589b98d 100644
--- a/packages/locale/locales/it/erp.po
+++ b/packages/locale/locales/it/erp.po
@@ -1504,9 +1504,6 @@ msgstr "Un RFQ di vendita (un cliente ti chiede di quotare) o un RFQ di acquisto
msgid "A scoped secret sent on the carbon-key request header that authenticates programmatic calls to Carbon, carrying its own permissions and rate limit rather than a user session's."
msgstr "Un segreto con ambito inviato nell'intestazione della richiesta carbon-key che autentica le chiamate programmatiche a Carbon, portando le proprie autorizzazioni e limite di velocità invece della sessione utente."
-msgid "A seasonal theme is on for everyone today. You can pick yours again once it ends."
-msgstr "Oggi è attivo un tema stagionale per tutti. Al termine potrai scegliere di nuovo il tuo."
-
msgid "A separate schedule for tax reporting when tax rules require a method different from book depreciation."
msgstr "Un programma separato per la rendicontazione fiscale quando le norme fiscali richiedono un metodo diverso dall'ammortamento contabile."
@@ -4823,9 +4820,6 @@ msgstr "Vettore"
msgid "Carrier Account"
msgstr "Conto Vettore"
-msgid "Carve"
-msgstr "Intaglio"
-
msgid "Cash & Banking"
msgstr "Cassa e banche"
@@ -12376,9 +12370,6 @@ msgstr "Il suo design potrebbe cambiare prima che l'Avviso di modifica sia emess
msgid "Its revenue goes back to what each line has left to recognize."
msgstr "I suoi ricavi tornano a quello che rimane da riconoscere di ogni riga."
-msgid "Jack-o'-lantern"
-msgstr "Zucca di Halloween"
-
msgid "Job"
msgstr "Lavoro"
@@ -12908,9 +12899,6 @@ msgstr "LIFO"
msgid "Light"
msgstr "Chiaro"
-msgid "Light up"
-msgstr "Accensione"
-
msgid "Light, dark, or follow your system setting."
msgstr "Chiaro, scuro, o segui l'impostazione di sistema."
@@ -18065,12 +18053,6 @@ msgstr "VA dei pagamenti"
msgid "PV of Residual"
msgstr "VA residuale"
-msgid "QC"
-msgstr "CQ"
-
-msgid "QC passed"
-msgstr "CQ superato"
-
msgid "QR Code to complete the current operation for this kanban"
msgstr "QR Code per completare l'operazione corrente per questo kanban"
@@ -26256,9 +26238,6 @@ msgstr "Avvisa quando la persona che ispeziona un articolo in entrata è la stes
msgid "Warning"
msgstr "Avvertenza"
-msgid "Wash"
-msgstr "Lavaggio"
-
msgid "Watch"
msgstr "Guarda"
diff --git a/packages/locale/locales/it/mes.po b/packages/locale/locales/it/mes.po
index f01846b373..0d37839df9 100644
--- a/packages/locale/locales/it/mes.po
+++ b/packages/locale/locales/it/mes.po
@@ -110,9 +110,6 @@ msgstr "🚨 Attenzione: il {0} il tuo account verrà trasferito su erp.try.carb
msgid "A previous completion did not finish. Retrying resumes the remaining steps — quantities are not double-counted."
msgstr "Un completamento precedente non è terminato. Riprovare riprende i passaggi rimanenti — le quantità non vengono conteggiate due volte."
-msgid "A seasonal theme is on for everyone today. You can pick yours again once it ends."
-msgstr "Oggi è attivo un tema stagionale per tutti. Al termine potrai scegliere di nuovo il tuo."
-
msgid "About"
msgstr "Informazioni"
@@ -343,9 +340,6 @@ msgstr "Logo Carbon"
msgid "Cards"
msgstr "Schede"
-msgid "Carve"
-msgstr "Intaglio"
-
msgid "Change"
msgstr "Cambia"
@@ -927,9 +921,6 @@ msgstr "Anagrafica Articolo"
msgid "Items"
msgstr "Articoli"
-msgid "Jack-o'-lantern"
-msgstr "Zucca di Halloween"
-
msgid "Job"
msgstr "Commessa"
@@ -984,9 +975,6 @@ msgstr "Costruiamo qualcosa"
msgid "Light"
msgstr "Chiaro"
-msgid "Light up"
-msgstr "Accensione"
-
msgid "Light, dark, or follow your system setting."
msgstr "Chiaro, scuro, o segui le impostazioni di sistema."
@@ -1563,12 +1551,6 @@ msgstr "Avanzamento"
msgid "Purchasing"
msgstr "Acquisti"
-msgid "QC"
-msgstr "CQ"
-
-msgid "QC passed"
-msgstr "CQ superato"
-
msgid "Quality"
msgstr "Qualità"
@@ -1631,9 +1613,6 @@ msgstr "Rifiuta"
msgid "Reject Lot"
msgstr "Rifiuta Lotto"
-msgid "Rejected"
-msgstr "Rifiutato"
-
msgid "Released"
msgstr "Rilasciato"
@@ -2275,9 +2254,6 @@ msgstr "Visualizza intervento di manutenzione"
msgid "View or open"
msgstr "Visualizza o apri"
-msgid "Wash"
-msgstr "Lavaggio"
-
msgid "We've emailed you a sign-in link and a 6-digit code. Follow the link, or enter the code here."
msgstr ""
diff --git a/packages/locale/locales/ja/erp.po b/packages/locale/locales/ja/erp.po
index 5eefb381dd..624afddc44 100644
--- a/packages/locale/locales/ja/erp.po
+++ b/packages/locale/locales/ja/erp.po
@@ -1504,9 +1504,6 @@ msgstr "売上見積依頼(得意先が見積をお願いする)または購
msgid "A scoped secret sent on the carbon-key request header that authenticates programmatic calls to Carbon, carrying its own permissions and rate limit rather than a user session's."
msgstr "carbon-key リクエスト ヘッダーで送信されるスコープ付きシークレット。Carbon へのプログラマティック呼び出しを認証し、ユーザー セッションではなく独自の権限とレート制限を保有します。"
-msgid "A seasonal theme is on for everyone today. You can pick yours again once it ends."
-msgstr "本日は全員に季節限定のテーマが適用されています。終了後に、もう一度ご自分のテーマを選べます。"
-
msgid "A separate schedule for tax reporting when tax rules require a method different from book depreciation."
msgstr "税務報告のための別のスケジュール。税務ルールが帳簿減価償却とは異なる方法を要求する場合。"
@@ -4823,9 +4820,6 @@ msgstr "運送業者"
msgid "Carrier Account"
msgstr "運送業者アカウント"
-msgid "Carve"
-msgstr "彫刻"
-
msgid "Cash & Banking"
msgstr "現金と銀行"
@@ -12376,9 +12370,6 @@ msgstr "変更通知のリリース前に、そのデザインが変わる可能
msgid "Its revenue goes back to what each line has left to recognize."
msgstr "その売上高は各明細が計上待ちしている金額に戻ります。"
-msgid "Jack-o'-lantern"
-msgstr "ジャック・オー・ランタン"
-
msgid "Job"
msgstr "ジョブ"
@@ -12908,9 +12899,6 @@ msgstr "後入先出"
msgid "Light"
msgstr "ライト"
-msgid "Light up"
-msgstr "点灯"
-
msgid "Light, dark, or follow your system setting."
msgstr "ライト、ダーク、またはシステム設定に従う。"
@@ -18065,12 +18053,6 @@ msgstr "支払のPV"
msgid "PV of Residual"
msgstr "残存価値のPV"
-msgid "QC"
-msgstr "品質検査"
-
-msgid "QC passed"
-msgstr "検査合格"
-
msgid "QR Code to complete the current operation for this kanban"
msgstr "このかんばんの現在の工程を完了するためのQRコード"
@@ -26256,9 +26238,6 @@ msgstr "受け取った人と同じ人が受け入れ品を検査する場合に
msgid "Warning"
msgstr "警告"
-msgid "Wash"
-msgstr "洗浄"
-
msgid "Watch"
msgstr "見る"
diff --git a/packages/locale/locales/ja/mes.po b/packages/locale/locales/ja/mes.po
index 457b4d7a78..b45135a0e5 100644
--- a/packages/locale/locales/ja/mes.po
+++ b/packages/locale/locales/ja/mes.po
@@ -110,9 +110,6 @@ msgstr "🚨 お知らせ:{0}にアカウントが erp.try.carbon.ms に移行
msgid "A previous completion did not finish. Retrying resumes the remaining steps — quantities are not double-counted."
msgstr "前回の完了は終了しませんでした。再試行により残りのステップが再開されます。数量は二重計算されません。"
-msgid "A seasonal theme is on for everyone today. You can pick yours again once it ends."
-msgstr "本日は全員に季節限定のテーマが適用されています。終了後に、もう一度ご自分のテーマを選べます。"
-
msgid "About"
msgstr "バージョン情報"
@@ -343,9 +340,6 @@ msgstr "Carbonロゴ"
msgid "Cards"
msgstr "カード"
-msgid "Carve"
-msgstr "彫刻"
-
msgid "Change"
msgstr "変更"
@@ -927,9 +921,6 @@ msgstr "品目マスター"
msgid "Items"
msgstr "品目"
-msgid "Jack-o'-lantern"
-msgstr "ジャック・オー・ランタン"
-
msgid "Job"
msgstr "ジョブ"
@@ -984,9 +975,6 @@ msgstr "さあ、何かを作りましょう"
msgid "Light"
msgstr "ライト"
-msgid "Light up"
-msgstr "点灯"
-
msgid "Light, dark, or follow your system setting."
msgstr "ライト、ダーク、またはシステム設定に従う。"
@@ -1563,12 +1551,6 @@ msgstr "進捗"
msgid "Purchasing"
msgstr "購買"
-msgid "QC"
-msgstr "品質検査"
-
-msgid "QC passed"
-msgstr "検査合格"
-
msgid "Quality"
msgstr "品質"
@@ -1631,9 +1613,6 @@ msgstr "却下"
msgid "Reject Lot"
msgstr "ロットを却下"
-msgid "Rejected"
-msgstr "却下"
-
msgid "Released"
msgstr "リリース済"
@@ -2275,9 +2254,6 @@ msgstr "保全指示を表示"
msgid "View or open"
msgstr "表示または開く"
-msgid "Wash"
-msgstr "洗浄"
-
msgid "We've emailed you a sign-in link and a 6-digit code. Follow the link, or enter the code here."
msgstr ""
diff --git a/packages/locale/locales/ko/erp.po b/packages/locale/locales/ko/erp.po
index e2897c31ab..7cfbd8d2c0 100644
--- a/packages/locale/locales/ko/erp.po
+++ b/packages/locale/locales/ko/erp.po
@@ -1504,9 +1504,6 @@ msgstr "영업 견적 요청(고객이 견적을 요청) 또는 구매 견적
msgid "A scoped secret sent on the carbon-key request header that authenticates programmatic calls to Carbon, carrying its own permissions and rate limit rather than a user session's."
msgstr "carbon-key 요청 헤더에서 전송되는 범위 제한 암호로서, Carbon에 대한 프로그래밍 방식 호출을 인증하며 사용자 세션의 권한이 아닌 자체 권한 및 속도 제한을 전달합니다."
-msgid "A seasonal theme is on for everyone today. You can pick yours again once it ends."
-msgstr "오늘은 모든 사용자에게 시즌 테마가 적용됩니다. 시즌이 끝나면 다시 원하는 테마를 선택할 수 있습니다."
-
msgid "A separate schedule for tax reporting when tax rules require a method different from book depreciation."
msgstr "세금 규칙이 장부 감가상각과 다른 방법을 요구할 때 세금 보고를 위한 별도의 일정입니다."
@@ -4823,9 +4820,6 @@ msgstr "운송업체"
msgid "Carrier Account"
msgstr "운송업체 계정"
-msgid "Carve"
-msgstr "조각"
-
msgid "Cash & Banking"
msgstr "현금 및 은행"
@@ -12376,9 +12370,6 @@ msgstr "변경 통지가 발행되기 전에 설계가 변경될 수 있습니
msgid "Its revenue goes back to what each line has left to recognize."
msgstr "그 매출은 각 라인이 인식해야 할 남은 부분으로 돌아갑니다."
-msgid "Jack-o'-lantern"
-msgstr "잭오랜턴"
-
msgid "Job"
msgstr "작업"
@@ -12908,9 +12899,6 @@ msgstr "후입선출"
msgid "Light"
msgstr "라이트"
-msgid "Light up"
-msgstr "점등"
-
msgid "Light, dark, or follow your system setting."
msgstr "밝음, 어두움 또는 시스템 설정 따르기"
@@ -18065,12 +18053,6 @@ msgstr "지불의 현재가치"
msgid "PV of Residual"
msgstr "잔존가치의 현재가치"
-msgid "QC"
-msgstr "품질 검사"
-
-msgid "QC passed"
-msgstr "검사 통과"
-
msgid "QR Code to complete the current operation for this kanban"
msgstr "이 칸반의 현재 공정을 완료 처리하기 위한 QR 코드"
@@ -26256,9 +26238,6 @@ msgstr "입고 품목을 검사하는 사람이 해당 품목을 입고 처리
msgid "Warning"
msgstr "경고"
-msgid "Wash"
-msgstr "세척"
-
msgid "Watch"
msgstr "시청"
diff --git a/packages/locale/locales/ko/mes.po b/packages/locale/locales/ko/mes.po
index cf57870f44..f783bb9f31 100644
--- a/packages/locale/locales/ko/mes.po
+++ b/packages/locale/locales/ko/mes.po
@@ -110,9 +110,6 @@ msgstr "🚨 안내: {0}에 계정이 erp.try.carbon.ms(으)로 이전됩니다"
msgid "A previous completion did not finish. Retrying resumes the remaining steps — quantities are not double-counted."
msgstr "이전 완료가 완료되지 않았습니다. 다시 시도하면 남은 단계가 재개되며 — 수량이 중복으로 계산되지 않습니다."
-msgid "A seasonal theme is on for everyone today. You can pick yours again once it ends."
-msgstr "오늘은 모든 사용자에게 시즌 테마가 적용됩니다. 시즌이 끝나면 다시 원하는 테마를 선택할 수 있습니다."
-
msgid "About"
msgstr "정보"
@@ -343,9 +340,6 @@ msgstr "Carbon 로고"
msgid "Cards"
msgstr "카드"
-msgid "Carve"
-msgstr "조각"
-
msgid "Change"
msgstr "변경"
@@ -927,9 +921,6 @@ msgstr "품목 마스터"
msgid "Items"
msgstr "품목"
-msgid "Jack-o'-lantern"
-msgstr "잭오랜턴"
-
msgid "Job"
msgstr "작업"
@@ -984,9 +975,6 @@ msgstr "무언가를 만들어봅시다"
msgid "Light"
msgstr "라이트"
-msgid "Light up"
-msgstr "점등"
-
msgid "Light, dark, or follow your system setting."
msgstr "밝음, 어두움 또는 시스템 설정 따르기"
@@ -1563,12 +1551,6 @@ msgstr "진행 상황"
msgid "Purchasing"
msgstr "구매"
-msgid "QC"
-msgstr "품질 검사"
-
-msgid "QC passed"
-msgstr "검사 통과"
-
msgid "Quality"
msgstr "품질"
@@ -1631,9 +1613,6 @@ msgstr "거부"
msgid "Reject Lot"
msgstr "로트 거부"
-msgid "Rejected"
-msgstr "반려됨"
-
msgid "Released"
msgstr "릴리스됨"
@@ -2275,9 +2254,6 @@ msgstr "유지보수 지시 보기"
msgid "View or open"
msgstr "보기 또는 열기"
-msgid "Wash"
-msgstr "세척"
-
msgid "We've emailed you a sign-in link and a 6-digit code. Follow the link, or enter the code here."
msgstr ""
diff --git a/packages/locale/locales/pl/erp.po b/packages/locale/locales/pl/erp.po
index bb824ef689..66769687b7 100644
--- a/packages/locale/locales/pl/erp.po
+++ b/packages/locale/locales/pl/erp.po
@@ -1504,9 +1504,6 @@ msgstr "Zapytanie ofertowe do sprzedaży (klient prosi o ofertę) lub zapytanie
msgid "A scoped secret sent on the carbon-key request header that authenticates programmatic calls to Carbon, carrying its own permissions and rate limit rather than a user session's."
msgstr "Tajny klucz wysyłany w nagłówku żądania carbon-key, który uwierzytelnia programowe wywołania do Carbon, niosąc własne uprawnienia i limit szybkości zamiast sesji użytkownika."
-msgid "A seasonal theme is on for everyone today. You can pick yours again once it ends."
-msgstr "Dziś dla wszystkich obowiązuje motyw sezonowy. Gdy się skończy, możesz znów wybrać własny."
-
msgid "A separate schedule for tax reporting when tax rules require a method different from book depreciation."
msgstr "Oddzielny harmonogram dla raportowania podatkowego, gdy zasady podatkowe wymagają innej metody niż amortyzacja bilansowa."
@@ -4823,9 +4820,6 @@ msgstr "Przewoźnik"
msgid "Carrier Account"
msgstr "Konto przewoźnika"
-msgid "Carve"
-msgstr "Rzeźbienie"
-
msgid "Cash & Banking"
msgstr "Gotówka i Bankowość"
@@ -12376,9 +12370,6 @@ msgstr "Jego projekt może się zmienić przed wydaniem zawiadomienia o zmianie.
msgid "Its revenue goes back to what each line has left to recognize."
msgstr "Przychody ze sprzedaży powracają do tego, co każda pozycja ma jeszcze do rozpoznania."
-msgid "Jack-o'-lantern"
-msgstr "Dyniowy lampion"
-
msgid "Job"
msgstr "Zadanie"
@@ -12908,9 +12899,6 @@ msgstr "LIFO"
msgid "Light"
msgstr "Jasne"
-msgid "Light up"
-msgstr "Zapalanie"
-
msgid "Light, dark, or follow your system setting."
msgstr "Jasny, ciemny lub zgodnie z ustawieniami systemu."
@@ -18065,12 +18053,6 @@ msgstr "WO płatności"
msgid "PV of Residual"
msgstr "WO wartości resztkowej"
-msgid "QC"
-msgstr "KJ"
-
-msgid "QC passed"
-msgstr "KJ zaliczona"
-
msgid "QR Code to complete the current operation for this kanban"
msgstr "QR Code do zakończenia bieżącej operacji dla tego kanban"
@@ -26256,9 +26238,6 @@ msgstr "Ostrzegaj, gdy osoba sprawdzająca przychodzący towar jest tą samą os
msgid "Warning"
msgstr "Ostrzeżenie"
-msgid "Wash"
-msgstr "Mycie"
-
msgid "Watch"
msgstr "Obejrzyj"
diff --git a/packages/locale/locales/pl/mes.po b/packages/locale/locales/pl/mes.po
index a6e999810b..7628d92f77 100644
--- a/packages/locale/locales/pl/mes.po
+++ b/packages/locale/locales/pl/mes.po
@@ -110,9 +110,6 @@ msgstr "🚨 Uwaga: {0} Twoje konto zostanie przeniesione na erp.try.carbon.ms"
msgid "A previous completion did not finish. Retrying resumes the remaining steps — quantities are not double-counted."
msgstr "Poprzednie zakończenie nie zostało ukończone. Ponowienie wznawia pozostałe kroki — ilości nie są liczone podwójnie."
-msgid "A seasonal theme is on for everyone today. You can pick yours again once it ends."
-msgstr "Dziś dla wszystkich obowiązuje motyw sezonowy. Gdy się skończy, możesz znów wybrać własny."
-
msgid "About"
msgstr "O programie"
@@ -343,9 +340,6 @@ msgstr "Logo Carbon"
msgid "Cards"
msgstr "Karty"
-msgid "Carve"
-msgstr "Rzeźbienie"
-
msgid "Change"
msgstr "Zmień"
@@ -927,9 +921,6 @@ msgstr "Kartoteka pozycji"
msgid "Items"
msgstr "Artykuły"
-msgid "Jack-o'-lantern"
-msgstr "Dyniowy lampion"
-
msgid "Job"
msgstr "Zlecenie"
@@ -984,9 +975,6 @@ msgstr "Zbudujmy coś"
msgid "Light"
msgstr "Jasny"
-msgid "Light up"
-msgstr "Zapalanie"
-
msgid "Light, dark, or follow your system setting."
msgstr "Jasno, ciemno, lub zgodnie z ustawieniami systemu."
@@ -1563,12 +1551,6 @@ msgstr "Postęp"
msgid "Purchasing"
msgstr "Zakupy"
-msgid "QC"
-msgstr "KJ"
-
-msgid "QC passed"
-msgstr "KJ zaliczona"
-
msgid "Quality"
msgstr "Jakość"
@@ -1631,9 +1613,6 @@ msgstr "Odrzuć"
msgid "Reject Lot"
msgstr "Odrzuć partię"
-msgid "Rejected"
-msgstr "Odrzucone"
-
msgid "Released"
msgstr "Zwolniono"
@@ -2275,9 +2254,6 @@ msgstr "Wyświetl zlecenie utrzymania ruchu"
msgid "View or open"
msgstr "Wyświetl lub otwórz"
-msgid "Wash"
-msgstr "Mycie"
-
msgid "We've emailed you a sign-in link and a 6-digit code. Follow the link, or enter the code here."
msgstr ""
diff --git a/packages/locale/locales/pt/erp.po b/packages/locale/locales/pt/erp.po
index 73b87dbafc..f6b4defe44 100644
--- a/packages/locale/locales/pt/erp.po
+++ b/packages/locale/locales/pt/erp.po
@@ -1504,9 +1504,6 @@ msgstr "Um RFQ de venda (um cliente pede para você fazer uma cotação) ou um R
msgid "A scoped secret sent on the carbon-key request header that authenticates programmatic calls to Carbon, carrying its own permissions and rate limit rather than a user session's."
msgstr "Um segredo com escopo enviado no cabeçalho de solicitação carbon-key que autentica chamadas programáticas ao Carbon, carregando suas próprias permissões e limite de taxa em vez de uma sessão do usuário."
-msgid "A seasonal theme is on for everyone today. You can pick yours again once it ends."
-msgstr "Hoje há um tema sazonal para todos. Você poderá escolher o seu novamente quando ele terminar."
-
msgid "A separate schedule for tax reporting when tax rules require a method different from book depreciation."
msgstr "Um cronograma separado para fins de declaração de impostos quando as regras fiscais exigem um método diferente da depreciação contábil."
@@ -4823,9 +4820,6 @@ msgstr "Transportadora"
msgid "Carrier Account"
msgstr "Conta da Transportadora"
-msgid "Carve"
-msgstr "Entalhe"
-
msgid "Cash & Banking"
msgstr "Caixa e Banco"
@@ -12376,9 +12370,6 @@ msgstr "Seu design pode mudar antes do aviso de alteração ser liberado."
msgid "Its revenue goes back to what each line has left to recognize."
msgstr "Sua receita volta para o que cada linha ainda precisa reconhecer."
-msgid "Jack-o'-lantern"
-msgstr "Abóbora de Halloween"
-
msgid "Job"
msgstr "Trabalho"
@@ -12908,9 +12899,6 @@ msgstr "LIFO"
msgid "Light"
msgstr "Claro"
-msgid "Light up"
-msgstr "Acender"
-
msgid "Light, dark, or follow your system setting."
msgstr "Claro, escuro ou seguir a configuração do sistema."
@@ -18065,12 +18053,6 @@ msgstr "VP de Pagamentos"
msgid "PV of Residual"
msgstr "VP de Residual"
-msgid "QC"
-msgstr "CQ"
-
-msgid "QC passed"
-msgstr "CQ aprovado"
-
msgid "QR Code to complete the current operation for this kanban"
msgstr "QR Code para concluir a operação atual para este kanban"
@@ -26256,9 +26238,6 @@ msgstr "Avisar quando a pessoa que inspeciona um item de entrada é a mesma pess
msgid "Warning"
msgstr "Aviso"
-msgid "Wash"
-msgstr "Lavagem"
-
msgid "Watch"
msgstr "Assistir"
diff --git a/packages/locale/locales/pt/mes.po b/packages/locale/locales/pt/mes.po
index d5a4e9bc9d..110d235391 100644
--- a/packages/locale/locales/pt/mes.po
+++ b/packages/locale/locales/pt/mes.po
@@ -110,9 +110,6 @@ msgstr "🚨 Atenção: em {0}, sua conta será transferida para erp.try.carbon.
msgid "A previous completion did not finish. Retrying resumes the remaining steps — quantities are not double-counted."
msgstr "Uma conclusão anterior não foi concluída. Tentar novamente retoma as etapas restantes — as quantidades não são contadas duas vezes."
-msgid "A seasonal theme is on for everyone today. You can pick yours again once it ends."
-msgstr "Hoje há um tema sazonal para todos. Você poderá escolher o seu novamente quando ele terminar."
-
msgid "About"
msgstr "Sobre"
@@ -343,9 +340,6 @@ msgstr "Logo Carbon"
msgid "Cards"
msgstr "Cartões"
-msgid "Carve"
-msgstr "Entalhe"
-
msgid "Change"
msgstr "Alterar"
@@ -927,9 +921,6 @@ msgstr "Cadastro de Item"
msgid "Items"
msgstr "Itens"
-msgid "Jack-o'-lantern"
-msgstr "Abóbora de Halloween"
-
msgid "Job"
msgstr "Ordem"
@@ -984,9 +975,6 @@ msgstr "Vamos construir algo"
msgid "Light"
msgstr "Claro"
-msgid "Light up"
-msgstr "Acender"
-
msgid "Light, dark, or follow your system setting."
msgstr "Claro, escuro ou seguir a configuração do sistema."
@@ -1563,12 +1551,6 @@ msgstr "Progresso"
msgid "Purchasing"
msgstr "Compras"
-msgid "QC"
-msgstr "CQ"
-
-msgid "QC passed"
-msgstr "CQ aprovado"
-
msgid "Quality"
msgstr "Qualidade"
@@ -1631,9 +1613,6 @@ msgstr "Rejeitar"
msgid "Reject Lot"
msgstr "Rejeitar Lote"
-msgid "Rejected"
-msgstr "Rejeitado"
-
msgid "Released"
msgstr "Liberado"
@@ -2275,9 +2254,6 @@ msgstr "Visualizar ordem de manutenção"
msgid "View or open"
msgstr "Visualizar ou abrir"
-msgid "Wash"
-msgstr "Lavagem"
-
msgid "We've emailed you a sign-in link and a 6-digit code. Follow the link, or enter the code here."
msgstr ""
diff --git a/packages/locale/locales/ru/erp.po b/packages/locale/locales/ru/erp.po
index 3251fc3133..024ab87d8c 100644
--- a/packages/locale/locales/ru/erp.po
+++ b/packages/locale/locales/ru/erp.po
@@ -1504,9 +1504,6 @@ msgstr "Запрос цен от продаж (покупатель просит
msgid "A scoped secret sent on the carbon-key request header that authenticates programmatic calls to Carbon, carrying its own permissions and rate limit rather than a user session's."
msgstr "Секретный ключ, отправляемый в заголовке запроса carbon-key, который аутентифицирует программные вызовы к Carbon, несущий свои собственные права доступа и лимит количества запросов вместо сессии пользователя."
-msgid "A seasonal theme is on for everyone today. You can pick yours again once it ends."
-msgstr "Сегодня у всех сезонная тема. Когда она закончится, вы снова сможете выбрать свою."
-
msgid "A separate schedule for tax reporting when tax rules require a method different from book depreciation."
msgstr "Отдельный график для налоговой отчетности, когда налоговые правила требуют метода, отличного от бухгалтерской амортизации."
@@ -4823,9 +4820,6 @@ msgstr "Перевозчик"
msgid "Carrier Account"
msgstr "Счет перевозчика"
-msgid "Carve"
-msgstr "Резьба"
-
msgid "Cash & Banking"
msgstr "Денежные средства и Банк"
@@ -12376,9 +12370,6 @@ msgstr "Его конструкция может измениться до вы
msgid "Its revenue goes back to what each line has left to recognize."
msgstr "Её выручка распределяется на оставшиеся к признанию суммы по каждой строке."
-msgid "Jack-o'-lantern"
-msgstr "Светильник Джека"
-
msgid "Job"
msgstr "Задание"
@@ -12908,9 +12899,6 @@ msgstr "ЛИФО"
msgid "Light"
msgstr "Светлая"
-msgid "Light up"
-msgstr "Зажечь"
-
msgid "Light, dark, or follow your system setting."
msgstr "Светлая, тёмная или следовать системным параметрам."
@@ -18065,12 +18053,6 @@ msgstr "ТС платежей"
msgid "PV of Residual"
msgstr "ТС остатка"
-msgid "QC"
-msgstr "ОТК"
-
-msgid "QC passed"
-msgstr "ОТК пройден"
-
msgid "QR Code to complete the current operation for this kanban"
msgstr "QR-код для завершения текущей операции для этого канбана"
@@ -26256,9 +26238,6 @@ msgstr "Предупреждать, когда лицо, проверяющее
msgid "Warning"
msgstr "Предупреждение"
-msgid "Wash"
-msgstr "Мойка"
-
msgid "Watch"
msgstr "Смотреть"
diff --git a/packages/locale/locales/ru/mes.po b/packages/locale/locales/ru/mes.po
index 9bc5238d35..cf58960d62 100644
--- a/packages/locale/locales/ru/mes.po
+++ b/packages/locale/locales/ru/mes.po
@@ -110,9 +110,6 @@ msgstr "🚨 Внимание: {0} ваша учётная запись буде
msgid "A previous completion did not finish. Retrying resumes the remaining steps — quantities are not double-counted."
msgstr "Предыдущее выполнение не завершилось. Повторное выполнение возобновляет оставшиеся шаги — количество не учитывается дважды."
-msgid "A seasonal theme is on for everyone today. You can pick yours again once it ends."
-msgstr "Сегодня у всех сезонная тема. Когда она закончится, вы снова сможете выбрать свою."
-
msgid "About"
msgstr "О системе"
@@ -343,9 +340,6 @@ msgstr "Логотип Carbon"
msgid "Cards"
msgstr "Карточки"
-msgid "Carve"
-msgstr "Резьба"
-
msgid "Change"
msgstr "Изменить"
@@ -927,9 +921,6 @@ msgstr "Карточка номенклатуры"
msgid "Items"
msgstr "Номенклатура"
-msgid "Jack-o'-lantern"
-msgstr "Светильник Джека"
-
msgid "Job"
msgstr "Задание"
@@ -984,9 +975,6 @@ msgstr "Давайте создадим что-то"
msgid "Light"
msgstr "Светлый"
-msgid "Light up"
-msgstr "Зажечь"
-
msgid "Light, dark, or follow your system setting."
msgstr "Светлая, тёмная или согласно параметрам системы."
@@ -1563,12 +1551,6 @@ msgstr "Прогресс"
msgid "Purchasing"
msgstr "Закупки"
-msgid "QC"
-msgstr "ОТК"
-
-msgid "QC passed"
-msgstr "ОТК пройден"
-
msgid "Quality"
msgstr "Качество"
@@ -1631,9 +1613,6 @@ msgstr "Отклонить"
msgid "Reject Lot"
msgstr "Отклонить партию"
-msgid "Rejected"
-msgstr "Отклонено"
-
msgid "Released"
msgstr "Запущено"
@@ -2275,9 +2254,6 @@ msgstr "Просмотреть заявку на техобслуживание"
msgid "View or open"
msgstr "Просмотр или открытие"
-msgid "Wash"
-msgstr "Мойка"
-
msgid "We've emailed you a sign-in link and a 6-digit code. Follow the link, or enter the code here."
msgstr ""
diff --git a/packages/locale/locales/tr/erp.po b/packages/locale/locales/tr/erp.po
index 1d2ceb0aaf..13e1208c6c 100644
--- a/packages/locale/locales/tr/erp.po
+++ b/packages/locale/locales/tr/erp.po
@@ -1504,9 +1504,6 @@ msgstr "Bir satış RFQ (müşteri sizi alıntı yapmak için ister) veya satın
msgid "A scoped secret sent on the carbon-key request header that authenticates programmatic calls to Carbon, carrying its own permissions and rate limit rather than a user session's."
msgstr "Carbon'a programlı çağrıları doğrulayan carbon-key istek başlığında gönderilen kapsamlı bir gizli anahtar; bir kullanıcı oturumunun yerine kendi izinleri ve hız sınırını taşır."
-msgid "A seasonal theme is on for everyone today. You can pick yours again once it ends."
-msgstr "Bugün herkes için mevsimlik bir tema açık. Sona erdiğinde kendi temanızı yeniden seçebilirsiniz."
-
msgid "A separate schedule for tax reporting when tax rules require a method different from book depreciation."
msgstr "Vergi kuralları defter amortismanından farklı bir yöntem gerektirdiğinde vergi raporlaması için ayrı bir zaman çizelgesi."
@@ -4823,9 +4820,6 @@ msgstr "Nakliyeci"
msgid "Carrier Account"
msgstr "Nakliyeci Hesabı"
-msgid "Carve"
-msgstr "Oyma"
-
msgid "Cash & Banking"
msgstr "Nakit ve Bankacılık"
@@ -12376,9 +12370,6 @@ msgstr "Tasarımı, değişiklik bildirisi yayınlanmadan önce değişebilir."
msgid "Its revenue goes back to what each line has left to recognize."
msgstr "Hasılat, her satırın tanıması gereken kalanına geri döner."
-msgid "Jack-o'-lantern"
-msgstr "Bal kabağı feneri"
-
msgid "Job"
msgstr "İş"
@@ -12908,9 +12899,6 @@ msgstr "LIFO"
msgid "Light"
msgstr "Aydınlık"
-msgid "Light up"
-msgstr "Yakma"
-
msgid "Light, dark, or follow your system setting."
msgstr "Açık, Koyu veya sistem ayarınız."
@@ -18065,12 +18053,6 @@ msgstr "Ödemelerin BDH"
msgid "PV of Residual"
msgstr "Kalıntıların BDH"
-msgid "QC"
-msgstr "KK"
-
-msgid "QC passed"
-msgstr "KK geçti"
-
msgid "QR Code to complete the current operation for this kanban"
msgstr "Bu kanban için geçerli operasyonu tamamlamak için QR Kodu"
@@ -26256,9 +26238,6 @@ msgstr "Gelen bir ürünü kontrol eden kişinin, onu alan kişiyle aynı olmas
msgid "Warning"
msgstr "Uyarı"
-msgid "Wash"
-msgstr "Yıkama"
-
msgid "Watch"
msgstr "İzle"
diff --git a/packages/locale/locales/tr/mes.po b/packages/locale/locales/tr/mes.po
index ee977bcfb6..480c76444d 100644
--- a/packages/locale/locales/tr/mes.po
+++ b/packages/locale/locales/tr/mes.po
@@ -110,9 +110,6 @@ msgstr "🚨 Dikkat: {0} tarihinde hesabınız erp.try.carbon.ms adresine taşı
msgid "A previous completion did not finish. Retrying resumes the remaining steps — quantities are not double-counted."
msgstr "Önceki bir tamamlanma işlemi bitmedi. Yeniden deneme kalan adımları devam ettirir — miktarlar çifte sayılmaz."
-msgid "A seasonal theme is on for everyone today. You can pick yours again once it ends."
-msgstr "Bugün herkes için mevsimlik bir tema açık. Sona erdiğinde kendi temanızı yeniden seçebilirsiniz."
-
msgid "About"
msgstr "Hakkında"
@@ -343,9 +340,6 @@ msgstr "Carbon Logosu"
msgid "Cards"
msgstr "Kartlar"
-msgid "Carve"
-msgstr "Oyma"
-
msgid "Change"
msgstr "Değiştir"
@@ -927,9 +921,6 @@ msgstr "Ürün Ana Veri"
msgid "Items"
msgstr "Stok kartları"
-msgid "Jack-o'-lantern"
-msgstr "Bal kabağı feneri"
-
msgid "Job"
msgstr "İş Emri"
@@ -984,9 +975,6 @@ msgstr "Bir şeyler inşa edelim"
msgid "Light"
msgstr "Açık"
-msgid "Light up"
-msgstr "Yakma"
-
msgid "Light, dark, or follow your system setting."
msgstr "Açık, koyu veya sistem ayarınızı takip edin."
@@ -1563,12 +1551,6 @@ msgstr "İlerleme"
msgid "Purchasing"
msgstr "Satın alma"
-msgid "QC"
-msgstr "KK"
-
-msgid "QC passed"
-msgstr "KK geçti"
-
msgid "Quality"
msgstr "Kalite"
@@ -1631,9 +1613,6 @@ msgstr "Reddet"
msgid "Reject Lot"
msgstr "Lotu Reddet"
-msgid "Rejected"
-msgstr "Reddedilmiş"
-
msgid "Released"
msgstr "Serbest bırakıldı"
@@ -2275,9 +2254,6 @@ msgstr "Bakım emrini Görüntüle"
msgid "View or open"
msgstr "Görüntüle veya aç"
-msgid "Wash"
-msgstr "Yıkama"
-
msgid "We've emailed you a sign-in link and a 6-digit code. Follow the link, or enter the code here."
msgstr ""
diff --git a/packages/locale/locales/zh/erp.po b/packages/locale/locales/zh/erp.po
index d9e8f7a5f8..d1fdac6841 100644
--- a/packages/locale/locales/zh/erp.po
+++ b/packages/locale/locales/zh/erp.po
@@ -1504,9 +1504,6 @@ msgstr "销售RFQ(客户要求您报价)或采购RFQ(您要求供应商)
msgid "A scoped secret sent on the carbon-key request header that authenticates programmatic calls to Carbon, carrying its own permissions and rate limit rather than a user session's."
msgstr "在 carbon-key 请求标头上发送的范围内秘密,用于验证对 Carbon 的编程调用,携带自己的权限和速率限制,而不是用户会话的。"
-msgid "A seasonal theme is on for everyone today. You can pick yours again once it ends."
-msgstr "今天所有人都在使用季节主题。主题结束后,你可以重新选择自己的主题。"
-
msgid "A separate schedule for tax reporting when tax rules require a method different from book depreciation."
msgstr "当税收规则要求与账面折旧不同的方法时,用于税收报告的单独税收折旧方案。"
@@ -4823,9 +4820,6 @@ msgstr "承运商"
msgid "Carrier Account"
msgstr "承运商账户"
-msgid "Carve"
-msgstr "雕刻"
-
msgid "Cash & Banking"
msgstr "现金和银行"
@@ -12376,9 +12370,6 @@ msgstr "在变更通知下达前,其设计可能会改变。"
msgid "Its revenue goes back to what each line has left to recognize."
msgstr "其收入返还到每一行剩余待确认的部分。"
-msgid "Jack-o'-lantern"
-msgstr "南瓜灯"
-
msgid "Job"
msgstr "工作"
@@ -12908,9 +12899,6 @@ msgstr "后进先出"
msgid "Light"
msgstr "浅色"
-msgid "Light up"
-msgstr "点亮"
-
msgid "Light, dark, or follow your system setting."
msgstr "浅色、深色或跟随系统设置"
@@ -18065,12 +18053,6 @@ msgstr "付款现值"
msgid "PV of Residual"
msgstr "残值现值"
-msgid "QC"
-msgstr "质检"
-
-msgid "QC passed"
-msgstr "质检通过"
-
msgid "QR Code to complete the current operation for this kanban"
msgstr "为此看板完成当前工序的QR代码"
@@ -26256,9 +26238,6 @@ msgstr "当检验入库物料的人与收货人相同时发出警告。"
msgid "Warning"
msgstr "警告"
-msgid "Wash"
-msgstr "清洗"
-
msgid "Watch"
msgstr "观看"
diff --git a/packages/locale/locales/zh/mes.po b/packages/locale/locales/zh/mes.po
index a2dc43c4ab..dfed46f4ed 100644
--- a/packages/locale/locales/zh/mes.po
+++ b/packages/locale/locales/zh/mes.po
@@ -110,9 +110,6 @@ msgstr "🚨 提醒:您的账户将于 {0} 迁移至 erp.try.carbon.ms"
msgid "A previous completion did not finish. Retrying resumes the remaining steps — quantities are not double-counted."
msgstr "之前的完成未完成。重试会恢复剩余步骤 — 数量不会重复计数。"
-msgid "A seasonal theme is on for everyone today. You can pick yours again once it ends."
-msgstr "今天所有人都在使用季节主题。主题结束后,你可以重新选择自己的主题。"
-
msgid "About"
msgstr "关于"
@@ -343,9 +340,6 @@ msgstr "Carbon 标志"
msgid "Cards"
msgstr "卡片"
-msgid "Carve"
-msgstr "雕刻"
-
msgid "Change"
msgstr "更改"
@@ -927,9 +921,6 @@ msgstr "物料主数据"
msgid "Items"
msgstr "物料"
-msgid "Jack-o'-lantern"
-msgstr "南瓜灯"
-
msgid "Job"
msgstr "工单"
@@ -984,9 +975,6 @@ msgstr "让我们开始构建"
msgid "Light"
msgstr "浅色"
-msgid "Light up"
-msgstr "点亮"
-
msgid "Light, dark, or follow your system setting."
msgstr "浅色、深色或跟随系统设置。"
@@ -1563,12 +1551,6 @@ msgstr "进度"
msgid "Purchasing"
msgstr "采购"
-msgid "QC"
-msgstr "质检"
-
-msgid "QC passed"
-msgstr "质检通过"
-
msgid "Quality"
msgstr "质量"
@@ -1631,9 +1613,6 @@ msgstr "拒绝"
msgid "Reject Lot"
msgstr "拒绝批次"
-msgid "Rejected"
-msgstr "已拒绝"
-
msgid "Released"
msgstr "已下达"
@@ -2275,9 +2254,6 @@ msgstr "查看维护工单"
msgid "View or open"
msgstr "查看或打开"
-msgid "Wash"
-msgstr "清洗"
-
msgid "We've emailed you a sign-in link and a 6-digit code. Follow the link, or enter the code here."
msgstr ""
diff --git a/packages/react/AGENTS.md b/packages/react/AGENTS.md
index d2d88a4d53..06bd010326 100644
--- a/packages/react/AGENTS.md
+++ b/packages/react/AGENTS.md
@@ -51,7 +51,7 @@ import { Button, Card, HStack, VStack, IconButton, cn } from "@carbon/react";
- **Error boundary**: `@carbon/react/ErrorBoundary` — `RouteErrorBoundary` (exported as `ErrorBoundary` from a module layout so a failed loader shows inside the app shell; it shows the status code and, for a 4xx, the message the server threw — `routeErrorCopy` — so throw a `Response` whose body says what was wrong. A 5xx or thrown `Error` gets generic copy) and `RootErrorBoundary` (drop-in root `ErrorBoundary` for RR v7 that maps 404 / 503 (the maintenance screen) / other HTTP / thrown `Error` to a styled screen) plus its parts (`ErrorScreen`, `GlitchHeading`, `StatusReadout`, `MagneticLink`, `NoiseOverlay`). Both read a request that got no response (`isNetworkError`: a `TypeError` with one of the browsers' fetch-failure messages) as a lost connection, not a fault, and `useNetworkRetry` revalidates when the browser is back online or the tab is shown again, which clears the error. Wrap it in the app's `Document` and pass `env` so `window.env` is set (the client crashes hydration otherwise). Copy is intentionally hardcoded English, not i18n.
- **Avatar**: `src` may be a URL or a generated-avatar value from `user.avatarUrl` (`dicebear:<style>:<seed>[:<rrggbb>]`; the styles and value helpers are in `@carbon/utils` `avatar.ts`). A generated value renders as a plain `<img>` of `generatedAvatarUrl(value)` (`utils/generatedAvatarImage.ts`, which `Avatar` imports instead of the renderer so no bundle that shows an avatar carries DiceBear) — `/file/avatar/:value?v=<GENERATED_AVATAR_RENDER_VERSION>` — so it is in the server-rendered HTML and needs no client JavaScript. Every app (ERP, MES, academy) serves that path with a one-line route re-exporting `generatedAvatarLoader` from `@carbon/react/GeneratedAvatar`: it draws the SVG on the server with DiceBear 10 and answers `Cache-Control: public, max-age=31536000, immutable`, so a refresh reads it from the browser cache. **Bump `GENERATED_AVATAR_RENDER_VERSION` whenever the same value would draw differently** (a DiceBear upgrade, a change to the rendering options), or browsers keep the old image. The avatar picker draws in the browser instead (`GeneratedAvatarPreview`, `useGeneratedAvatar`), because a color drag makes a new value per step; there the DiceBear core and each style's JSON load with `import()` (`STYLE_LOADERS`, typed `Record<GeneratedAvatarStyle, …>`), never with a `with: { type: "json" }` attribute (Vite passes it to the browser, which rejects the JSON Vite serves as JavaScript, and the picker stays grey); the server side instead bundles `@dicebear/styles` through `ssrNoExternal` in each app's `vite.config.ts`, because Node refuses a package's JSON without the attribute. `generatedAvatarClassName(style)` picks the image classes: line-art styles on white (`bg-white`) in both themes, color styles on `bg-muted`. A value's optional background goes to DiceBear as `backgroundColor`; on a dark one (`isDarkBackground`, WCAG contrast) the styles that draw lines straight onto the background (`INK_OPTIONS`) get white ink. The app `Avatar` wrappers turn a stored value into `src` with `avatarSrc` (`@carbon/utils`); a new user has no avatar (initials) until they choose one
- **Announcement**: `AnnouncementBar` is the one-line bar both shells render above their page area for the deployment's announcement. It remembers a dismissal in localStorage per user and announcement id, and while shown sets `--announcement-height` on `<html>`; the ERP's `--content-inset` includes it, and a page sized from `100dvh` outside that variable must subtract it
-- **Seasonal decorations**: `@carbon/react/Halloween` exports `HalloweenLayer` (mounted once in each app shell) and `HalloweenLoginArt` (the ERP sign-in panel's ASCII story, `src/Halloween/night-shift/`). Both render nothing unless the root loader's theme is `halloween`, and everything but that entry file loads in its own chunk. Keep everything seasonal inside that folder: the removal checklist is the header of `src/Halloween/HalloweenLayer.tsx`. Not seasonal and staying: `useSeasonalTheme` and `SeasonalThemeNotice` (`src/SeasonalTheme.tsx`), which disable the theme pickers and say why while any seasonal theme is on
+- **Seasonal decorations**: `@carbon/react/Halloween` exports `HalloweenLayer` (mounted once in each app shell). It renders nothing unless the root loader's theme is `halloween`, and everything but that entry file loads in its own chunk. Keep everything seasonal inside that folder: the removal checklist is the header of `src/Halloween/HalloweenLayer.tsx`.
- **Polish**: shadows over borders, `tabular-nums` for dynamic numbers, `active:scale-[0.98]` on pressables, `text-balance`/`text-pretty` for text wrapping
## Cross-References
diff --git a/packages/react/src/Halloween/HalloweenLayer.tsx b/packages/react/src/Halloween/HalloweenLayer.tsx
index 08a5331f24..9af1f404fe 100644
--- a/packages/react/src/Halloween/HalloweenLayer.tsx
+++ b/packages/react/src/Halloween/HalloweenLayer.tsx
@@ -2,38 +2,36 @@
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-import { lazy, Suspense, useEffect, useRef, useState } from "react";
+import { lazy, Suspense } from "react";
import { Optional } from "./Optional";
import { useHalloween } from "./season";
// Seasonal decoration, shared by the ERP and the MES (`@carbon/react/Halloween`).
-// Everything renders only on Halloween, when the theme is on for everyone
-// (`useHalloween`, season.ts); on any other day this returns nothing. The
-// day is `available` in packages/utils/src/halloween-theme.ts.
+// Everything renders only while the Halloween theme is on (`useHalloween`,
+// season.ts); for anyone else, and on any other day, this returns nothing.
+// The days are `available` in packages/utils/src/halloween-theme.ts.
//
// To remove Halloween, the theme and every decoration:
// 1. Delete this folder and the `./Halloween` export in
// packages/react/package.json.
-// 2. Delete the three mounts and their imports: `<HalloweenLayer />` in the
-// ERP's and the MES's routes/x+/_layout.tsx, `<HalloweenLoginArt />` in
-// the ERP's routes/_public+/_layout.tsx.
+// 2. Delete the two mounts and their imports: `<HalloweenLayer />` in the
+// ERP's and the MES's routes/x+/_layout.tsx.
// 3. Delete packages/utils/src/halloween-theme.ts, its export in
// packages/utils/src/index.ts and its entry in `seasonalThemes`
// (packages/utils/src/themes.ts). The theme carries everything else
// (its day, its mesh colors), so nothing reads it by name.
// 4. Delete the doc lines that name them: the Halloween paragraphs of
// .claude/rules/coding-conventions.md (Theme System), the "Seasonal
-// decorations" bullet of packages/react/AGENTS.md (keep its last
-// sentence) and `halloween-theme.ts` in packages/utils/AGENTS.md.
+// decorations" bullet of packages/react/AGENTS.md and
+// `halloween-theme.ts` in packages/utils/AGENTS.md.
// 5. Run `pnpm run lingui:extract` to drop its strings from the catalogs.
// Typecheck flags any mount or import left behind. The `data-user-menu`,
-// `data-date` and `data-app-card` attributes the styles hang off, and
-// `relative` on the sign-in logos, do nothing on their own and can stay.
+// `data-date` and `data-app-card` attributes the styles hang off do nothing
+// on their own and can stay.
// This file is all the shells import, so it stays small: everything else
// loads in its own chunk, and only while the theme is on.
const Decorations = lazy(() => import("./Decorations"));
-const NightShift = lazy(() => import("./night-shift/NightShift"));
export function HalloweenLayer() {
const on = useHalloween();
@@ -46,55 +44,3 @@ export function HalloweenLayer() {
</Optional>
);
}
-
-/**
- * The Night Shift, the ASCII story on the sign-in page's left panel. Fills
- * its positioned parent; the engine loads only while the theme is on.
- */
-export function HalloweenLoginArt() {
- const on = useHalloween();
- if (!on) return null;
- return <LoginArt />;
-}
-
-function LoginArt() {
- const ref = useRef<HTMLDivElement>(null);
- // The panel is hidden on narrow screens: the engine loads and runs only
- // while it is shown.
- const [shown, setShown] = useState(false);
-
- // The scene is night in either mode, so the panel it fills goes dark: its
- // logo and headline take their dark variants. Undone on unmount.
- useEffect(() => {
- const panel = ref.current?.parentElement;
- if (!panel) return;
- const darkened = !panel.classList.contains("dark");
- if (darkened) panel.classList.add("dark");
- const resized = new ResizeObserver(([entry]) => {
- setShown((entry?.contentRect.width ?? 0) > 0);
- });
- resized.observe(panel);
- return () => {
- resized.disconnect();
- if (darkened) panel.classList.remove("dark");
- };
- }, []);
-
- return (
- <div
- ref={ref}
- aria-hidden
- className="pointer-events-none absolute inset-0 overflow-hidden"
- >
- {shown && (
- <Optional>
- <Suspense fallback={null}>
- <NightShift />
- </Suspense>
- </Optional>
- )}
- {/* Keeps the panel's headline readable over the fog. */}
- <div className="absolute inset-x-0 bottom-0 z-10 h-64 bg-gradient-to-t from-black/75 via-black/40 to-transparent" />
- </div>
- );
-}
diff --git a/packages/react/src/Halloween/night-shift/NightShift.tsx b/packages/react/src/Halloween/night-shift/NightShift.tsx
deleted file mode 100644
index e092dc62d6..0000000000
--- a/packages/react/src/Halloween/night-shift/NightShift.tsx
+++ /dev/null
@@ -1,282 +0,0 @@
-// SPDX-License-Identifier: AGPL-3.0-only
-// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
-// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-
-// The Night Shift on a canvas: fills its positioned parent, runs at 24 fps,
-// pauses with the tab, and watches the sign-in form so the cast can react
-// (with reduced motion it draws one still frame and watches nothing).
-// The story resumes from the next shift on the next visit in the same
-// browser session, so the hill keeps the lanterns it has earned.
-
-import { useLingui } from "@lingui/react/macro";
-import { useEffect, useRef, useState } from "react";
-import { onToast } from "../toasts";
-import type { Buffers } from "./frame";
-import { makeBuffers, renderFrame } from "./frame";
-import type { Layout } from "./layout";
-import { makeLayout } from "./layout";
-import type { Metrics } from "./paint";
-import { paint } from "./paint";
-import type { Labels, Watcher } from "./scene";
-import { IDLE_WATCHER } from "./scene";
-import type { Moment, ShiftPlan } from "./story";
-import { actStart, momentAt, planShift } from "./story";
-
-const FONT_FAMILY =
- '"Geist Mono Variable", "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace';
-/** Glyph size grows with the panel, so the scene fills it at any width. */
-function fontFor(width: number) {
- const px = Math.max(12, Math.min(16, width / 52));
- return { px, line: Math.trunc(px * 1.17 + 0.5) };
-}
-const FPS = 24;
-const SESSION_KEY = "carbon:night-shift";
-
-type Saved = { seed: number; shift: number };
-
-function readSaved(): Saved {
- try {
- const raw = window.sessionStorage.getItem(SESSION_KEY);
- if (raw) {
- const value: unknown = JSON.parse(raw);
- if (
- value &&
- typeof value === "object" &&
- "seed" in value &&
- "shift" in value &&
- typeof value.seed === "number" &&
- typeof value.shift === "number"
- ) {
- return { seed: value.seed, shift: value.shift };
- }
- }
- } catch {
- // Storage can be off (private mode); the story just starts over.
- }
- const seed = window.crypto.getRandomValues(new Uint32Array(1))[0] ?? 1;
- return { seed, shift: 0 };
-}
-
-function writeSaved(saved: Saved) {
- try {
- window.sessionStorage.setItem(SESSION_KEY, JSON.stringify(saved));
- } catch {
- // Not saved: the next visit starts a new story.
- }
-}
-
-/** The one frame shown to someone who prefers reduced motion. */
-function stillMoment(shift: number): Moment {
- // Late in Shipping: the procession lit, the ghost out, the door open.
- return momentAt(actStart("shipping") + 14, shift);
-}
-
-function fade(sinceSeconds: number, lasts: number) {
- if (sinceSeconds < 0 || sinceSeconds > lasts) return 0;
- return 1 - sinceSeconds / lasts;
-}
-
-function readFocus(watcher: Watcher) {
- const active = document.activeElement;
- watcher.field = false;
- watcher.secret = false;
- watcher.peek = false;
- if (
- !(
- active instanceof HTMLInputElement ||
- active instanceof HTMLTextAreaElement
- )
- )
- return;
- const hidden =
- active instanceof HTMLInputElement && active.type === "password";
- const named =
- /\b(password|otp|code|pin)\b/i.test(active.name) ||
- active.autocomplete === "one-time-code";
- watcher.secret = hidden || named;
- watcher.peek =
- !hidden &&
- active instanceof HTMLInputElement &&
- active.type === "text" &&
- /password/i.test(active.name);
- watcher.field = !watcher.secret;
-}
-
-export default function NightShift() {
- const { t } = useLingui();
- const canvasRef = useRef<HTMLCanvasElement>(null);
- const words: Labels = {
- stations: [t`Wash`, t`Carve`, t`Light up`, t`QC`],
- item: t`Jack-o'-lantern`,
- inProgress: t`In Progress`,
- complete: t`Completed`,
- scrapped: t`Scrapped`,
- passed: t`QC passed`,
- rejected: t`Rejected`
- };
- // Read by every frame, so a language change shows on the next one.
- const labels = useRef(words);
- labels.current = words;
- // Frame callbacks and observers are out of the error boundary's reach, so a
- // draw that throws is rethrown here, during render.
- const [crash, setCrash] = useState<{ error: unknown } | null>(null);
- if (crash) throw crash.error;
-
- useEffect(() => {
- const canvas = canvasRef.current;
- const ctx = canvas?.getContext("2d");
- const host = canvas?.parentElement;
- if (!canvas || !ctx || !host) return;
-
- const still = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
- const saved = readSaved();
- writeSaved({ seed: saved.seed, shift: saved.shift + 1 });
- const plans = new Map<number, ShiftPlan>();
- const planFor = (index: number) => {
- let plan = plans.get(index);
- if (!plan) {
- plan = planShift(saved.seed, index);
- plans.set(index, plan);
- }
- return plan;
- };
-
- const watcher: Watcher = { ...IDLE_WATCHER };
- let layout: Layout | null = null;
- let buffers: Buffers | null = null;
- let metrics: Metrics | null = null;
- let clock = 0;
- let last = performance.now();
- let lastShift = saved.shift;
- let flareAt = Number.NEGATIVE_INFINITY;
- let alarmAt = Number.NEGATIVE_INFINITY;
- let disposed = false;
- let frameId = 0;
-
- const measure = () => {
- const { width, height } = host.getBoundingClientRect();
- if (width <= 0 || height <= 0) return;
- const ratio = Math.min(2, window.devicePixelRatio || 1);
- canvas.width = Math.trunc(width * ratio);
- canvas.height = Math.trunc(height * ratio);
- ctx.setTransform(ratio, 0, 0, ratio, 0, 0);
- const size = fontFor(width);
- const font = `${size.px}px ${FONT_FAMILY}`;
- ctx.font = font;
- const cellWidth = ctx.measureText("M".repeat(100)).width / 100;
- const cols = Math.trunc(width / cellWidth);
- const rows = Math.trunc(height / size.line);
- layout = makeLayout(cols, rows, size.line / cellWidth);
- buffers = makeBuffers(cols, rows);
- metrics = {
- cellWidth,
- cellHeight: size.line,
- offsetX: (width - cols * cellWidth) / 2,
- offsetY: (height - rows * size.line) / 2,
- font,
- width,
- height,
- horizonRow: layout.horizon
- };
- };
-
- const draw = () => {
- if (disposed || !layout || !buffers || !metrics) return;
- try {
- const moment = still
- ? stillMoment(saved.shift)
- : momentAt(clock, saved.shift);
- if (moment.shift !== lastShift) {
- lastShift = moment.shift;
- writeSaved({ seed: saved.seed, shift: moment.shift + 1 });
- }
- readFocus(watcher);
- watcher.flare = fade(clock - flareAt, 1.4);
- watcher.alarm = fade(clock - alarmAt, 2.4);
- const frame = renderFrame(
- buffers,
- layout,
- planFor(moment.shift),
- moment,
- clock,
- watcher,
- labels.current
- );
- paint(ctx, buffers.main, frame, metrics);
- } catch (error) {
- disposed = true;
- setCrash({ error });
- }
- };
-
- const tick = (now: number) => {
- if (disposed) return;
- const delta = now - last;
- if (delta >= 1000 / FPS - 2) {
- last = now;
- // A hidden tab gets no frames; pick the story up where it was.
- clock += Math.min(delta, 250) / 1000;
- draw();
- }
- frameId = window.requestAnimationFrame(tick);
- };
-
- const redraw = () => {
- measure();
- draw();
- };
- redraw();
- void document.fonts?.load(`14px ${FONT_FAMILY}`).then(() => {
- if (!disposed) redraw();
- });
- const resize = new ResizeObserver(redraw);
- resize.observe(host);
- // One still frame: nothing moves, so nothing needs to react.
- if (still) {
- return () => {
- disposed = true;
- resize.disconnect();
- };
- }
- frameId = window.requestAnimationFrame(tick);
-
- const onPointer = (event: PointerEvent) => {
- if (!metrics) return;
- const rect = canvas.getBoundingClientRect();
- watcher.pointer = {
- x: (event.clientX - rect.left - metrics.offsetX) / metrics.cellWidth,
- y: (event.clientY - rect.top - metrics.offsetY) / metrics.cellHeight
- };
- };
- const onLeave = () => {
- watcher.pointer = null;
- };
- const onSubmit = () => {
- flareAt = clock;
- };
- const stopToasts = onToast("error", () => {
- alarmAt = clock;
- });
- window.addEventListener("pointermove", onPointer, { passive: true });
- document.documentElement.addEventListener("pointerleave", onLeave);
- document.addEventListener("submit", onSubmit, true);
-
- return () => {
- disposed = true;
- window.cancelAnimationFrame(frameId);
- resize.disconnect();
- stopToasts();
- window.removeEventListener("pointermove", onPointer);
- document.documentElement.removeEventListener("pointerleave", onLeave);
- document.removeEventListener("submit", onSubmit, true);
- };
- }, []);
-
- return (
- <canvas
- ref={canvasRef}
- aria-hidden
- className="absolute inset-0 h-full w-full"
- />
- );
-}
diff --git a/packages/react/src/Halloween/night-shift/exterior.ts b/packages/react/src/Halloween/night-shift/exterior.ts
deleted file mode 100644
index 2e313de049..0000000000
--- a/packages/react/src/Halloween/night-shift/exterior.ts
+++ /dev/null
@@ -1,58 +0,0 @@
-// SPDX-License-Identifier: AGPL-3.0-only
-// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
-// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-
-// The hill at night, back to front: the sky (sky.ts), the hill (hill.ts), the
-// plant (plant.ts) and the Great Lighting (great-lighting.ts). Every part is
-// drawn from the scene alone (the moment, the seconds and who is watching),
-// so any instant of the story can be rendered cold.
-
-import { drawGreatLighting } from "./great-lighting";
-import {
- drawDance,
- drawFence,
- drawGhost,
- drawGround,
- drawHills,
- drawPatch,
- drawPath,
- drawProcession,
- drawStones
-} from "./hill";
-import { drawBong, drawCraneAndHero, drawFactory } from "./plant";
-import type { Scene } from "./scene";
-import {
- dawnAt,
- drawBats,
- drawHorseman,
- drawLightning,
- drawMoon,
- drawRain,
- drawSkyVisitor,
- drawStars
-} from "./sky";
-
-export function drawExterior(scene: Scene) {
- const dawn = dawnAt(scene);
- drawStars(scene, dawn);
- drawMoon(scene, dawn);
- drawSkyVisitor(scene);
- drawBats(scene);
- drawHills(scene, dawn);
- drawHorseman(scene);
- drawGround(scene, dawn);
- drawPath(scene);
- drawStones(scene);
- drawFactory(scene, dawn);
- drawCraneAndHero(scene);
- drawFence(scene);
- drawPatch(scene);
- drawProcession(scene);
- drawGhost(scene);
- drawDance(scene);
- drawGreatLighting(scene);
- drawBong(scene);
- drawRain(scene);
- const flash = drawLightning(scene);
- return { dawn, flash };
-}
diff --git a/packages/react/src/Halloween/night-shift/faces.test.ts b/packages/react/src/Halloween/night-shift/faces.test.ts
deleted file mode 100644
index 21708e3c0a..0000000000
--- a/packages/react/src/Halloween/night-shift/faces.test.ts
+++ /dev/null
@@ -1,61 +0,0 @@
-// SPDX-License-Identifier: AGPL-3.0-only
-// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
-// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-
-// Every one of the 192 faces must fit inside the smallest pumpkin the Line
-// draws, or the blade would cut air; and every face has a one-line version.
-
-import { describe, expect, it } from "vitest";
-import { carvedCells, FACE_COUNT, HERO_MIN_RADIUS, miniFace } from "./faces";
-
-const ASPECT = 1.9;
-
-function allFaces() {
- const faces = [];
- for (let eyes = 0; eyes < 6; eyes++) {
- for (let nose = 0; nose < 4; nose++) {
- for (let mouth = 0; mouth < 8; mouth++) faces.push({ eyes, nose, mouth });
- }
- }
- return faces;
-}
-
-describe("faces", () => {
- it("has 192 of them", () => {
- expect(FACE_COUNT).toBe(192);
- expect(allFaces()).toHaveLength(FACE_COUNT);
- });
-
- it("fits every face inside the smallest hero pumpkin", () => {
- const rx = HERO_MIN_RADIUS * ASPECT * 1.18;
- const ry = HERO_MIN_RADIUS;
- for (const face of allFaces()) {
- const cells = carvedCells(face);
- expect(cells.length).toBeGreaterThan(0);
- for (const cell of cells) {
- // The pumpkin's centre can sit anywhere inside its cell.
- for (const offset of [0, 0.99]) {
- const nx = (cell.x + 0.5 - offset) / rx;
- const ny = (cell.y + 0.5 - offset) / ry;
- expect(nx * nx + ny * ny).toBeLessThanOrEqual(1);
- }
- }
- }
- });
-
- it("cuts the left eye first and the mouth last", () => {
- const cells = carvedCells({ eyes: 0, nose: 0, mouth: 0 });
- expect(cells[0]?.x).toBeLessThan(0);
- expect(cells.at(-1)?.y).toBeGreaterThan(0);
- });
-
- it("puts every face on one line, five characters wide", () => {
- for (const face of allFaces()) {
- const mini = miniFace(face);
- expect(mini).toHaveLength(5);
- expect(mini.startsWith("(")).toBe(true);
- expect(mini.endsWith(")")).toBe(true);
- }
- expect(miniFace({ eyes: 2, nose: 0, mouth: 0 })).toBe("(>w<)");
- });
-});
diff --git a/packages/react/src/Halloween/night-shift/faces.ts b/packages/react/src/Halloween/night-shift/faces.ts
deleted file mode 100644
index adde1e6d4f..0000000000
--- a/packages/react/src/Halloween/night-shift/faces.ts
+++ /dev/null
@@ -1,123 +0,0 @@
-// SPDX-License-Identifier: AGPL-3.0-only
-// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
-// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-
-// Jack-o'-lantern faces, built from parts: 6 eyes × 4 noses × 8 mouths, 192
-// faces. A part is a mask of the cells the blade cuts out (`#`), placed
-// relative to the pumpkin's centre. Every lantern also has a one-line
-// version, `(^w^)`, for the procession on the hill.
-
-import type { Random } from "../math";
-import { floorOf } from "../math";
-
-type Part = { mask: readonly string[]; mini: string };
-
-const EYES: readonly (Part & { miniRight?: string })[] = [
- { mask: [" # ", " ### ", "#####"], mini: "^" },
- { mask: [" ### ", "#####", " ### "], mini: "o" },
- { mask: ["# ", "### ", "#####"], mini: ">", miniRight: "<" },
- { mask: [" # ", " ### ", " # "], mini: "*" },
- { mask: [" ", "#####", " ### "], mini: "-" },
- { mask: [" ### ", "# #", " "], mini: "n" }
-];
-
-const NOSES: readonly Part[] = [
- { mask: [" # ", "###"], mini: "" },
- { mask: [" ", " # "], mini: "" },
- { mask: ["###", " # "], mini: "" },
- { mask: [], mini: "" }
-];
-
-const MOUTHS: readonly Part[] = [
- {
- mask: ["# #", " ############# ", " ######### "],
- mini: "w"
- },
- {
- mask: ["###############", "## ## ### ## ##", " ############# "],
- mini: "m"
- },
- {
- mask: [" ##### ", " ####### ", " ##### "],
- mini: "o"
- },
- { mask: ["## ## ## ##", " ## ### ## "], mini: "v" },
- {
- mask: ["# #", " ## ## ", " ######### "],
- mini: "u"
- },
- {
- mask: ["###############", "###############", " ############# "],
- mini: "D"
- },
- { mask: [" ", "###############"], mini: "_" },
- { mask: ["###############", " ### ##### ### ", " # # # "], mini: "W" }
-];
-
-export const FACE_COUNT = EYES.length * NOSES.length * MOUTHS.length;
-
-export type Face = { eyes: number; nose: number; mouth: number };
-
-export function drawFace(random: Random): Face {
- return {
- eyes: floorOf(random() * EYES.length),
- nose: floorOf(random() * NOSES.length),
- mouth: floorOf(random() * MOUTHS.length)
- };
-}
-
-export type Cell = { x: number; y: number };
-
-/** The smallest pumpkin, in rows, that holds every face (faces.test.ts). */
-export const HERO_MIN_RADIUS = 5.6;
-
-function maskCells(mask: readonly string[], left: number, top: number) {
- const cells: Cell[] = [];
- mask.forEach((line, row) => {
- for (let col = 0; col < line.length; col++) {
- if (line[col] === "#") cells.push({ x: left + col, y: top + row });
- }
- });
- return cells;
-}
-
-function mirrored(mask: readonly string[]) {
- return mask.map((line) => line.split("").reverse().join(""));
-}
-
-function width(mask: readonly string[]) {
- return mask.reduce((widest, line) => Math.max(widest, line.length), 0);
-}
-
-/**
- * The cells a face cuts out of a hero-sized pumpkin, relative to its centre,
- * in the order the blade cuts them: left eye, right eye, nose, mouth.
- */
-export function carvedCells(face: Face): Cell[] {
- const eyes = EYES[face.eyes] ?? EYES[0];
- const nose = NOSES[face.nose] ?? NOSES[0];
- const mouth = MOUTHS[face.mouth] ?? MOUTHS[0];
- if (!eyes || !nose || !mouth) return [];
- const eyeWidth = width(eyes.mask);
- const half = floorOf(eyeWidth / 2);
- const right = eyes.miniRight ? mirrored(eyes.mask) : eyes.mask;
- return [
- ...maskCells(eyes.mask, -5 - half, -4),
- ...maskCells(right, 5 - half, -4),
- ...maskCells(nose.mask, -floorOf(width(nose.mask) / 2), -1),
- ...maskCells(mouth.mask, -floorOf(width(mouth.mask) / 2), 1)
- ];
-}
-
-/** The face on one line, as a lantern in the procession shows it. */
-export function miniFace(face: Face): string {
- const eyes = EYES[face.eyes] ?? EYES[0];
- const mouth = MOUTHS[face.mouth] ?? MOUTHS[0];
- const left = eyes?.mini ?? "o";
- return `(${left}${mouth?.mini ?? "w"}${eyes?.miniRight ?? left})`;
-}
-
-/** A key for a carved cell, so a renderer can look cells up in a Set. */
-export function cellKey(x: number, y: number) {
- return (x + 64) * 256 + (y + 64);
-}
diff --git a/packages/react/src/Halloween/night-shift/frame.test.ts b/packages/react/src/Halloween/night-shift/frame.test.ts
deleted file mode 100644
index 99aafc9250..0000000000
--- a/packages/react/src/Halloween/night-shift/frame.test.ts
+++ /dev/null
@@ -1,208 +0,0 @@
-// SPDX-License-Identifier: AGPL-3.0-only
-// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
-// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-
-// Any instant of the story renders, on any panel size: every act, every
-// visitor, every rare event and the Great Lighting. Plus the few things
-// a reader of the frame should be able to count on.
-
-import { describe, expect, it } from "vitest";
-import { miniFace } from "./faces";
-import { makeBuffers, renderFrame } from "./frame";
-import type { Grid } from "./grid";
-import { makeLayout } from "./layout";
-import type { Labels } from "./scene";
-import { IDLE_WATCHER } from "./scene";
-import type { ShiftPlan } from "./story";
-import { actStart, LANTERNS_FOR_LIGHTING, momentAt, planShift } from "./story";
-
-const SIZES = [
- [70, 40],
- [100, 60],
- [135, 76]
-] as const;
-
-const LABELS: Labels = {
- stations: ["Wash", "Carve", "Light up", "QC"],
- item: "Jack-o'-lantern",
- inProgress: "In Progress",
- complete: "Completed",
- scrapped: "Scrapped",
- passed: "QC passed",
- rejected: "Rejected"
-};
-
-/** Every glyph, then every label's words. */
-function text(grid: Grid) {
- let out = "";
- for (let r = 0; r < grid.rows; r++) {
- for (let c = 0; c < grid.cols; c++)
- out += String.fromCharCode(grid.ch[r * grid.cols + c] ?? 32);
- out += "\n";
- }
- for (const label of grid.labels) out += `${label.text}\n`;
- return out;
-}
-
-function render(
- plan: ShiftPlan,
- seconds: number,
- cols = 100,
- rows = 60,
- watcher = IDLE_WATCHER,
- labels = LABELS
-) {
- const layout = makeLayout(cols, rows, 1.93);
- const buffers = makeBuffers(cols, rows);
- const moment = momentAt(seconds, plan.index);
- const frame = renderFrame(
- buffers,
- layout,
- plan,
- moment,
- seconds,
- watcher,
- labels
- );
- return { frame, grid: buffers.main, layout };
-}
-
-function withPlan(overrides: Partial<ShiftPlan>): ShiftPlan {
- return { ...planShift(7, 2), ...overrides };
-}
-
-describe("renderFrame", () => {
- it("draws every act, at every panel size, without leaving the grid blank", () => {
- for (const [cols, rows] of SIZES) {
- for (let s = 0; s < 90; s += 3) {
- const { grid, frame } = render(planShift(7, 2), s, cols, rows);
- const glyphs = grid.ch.reduce(
- (n, code) => n + (code === 32 ? 0 : 1),
- 0
- );
- expect(glyphs).toBeGreaterThan(cols * rows * 0.05);
- expect(frame.flash).toBeGreaterThanOrEqual(0);
- expect(frame.flash).toBeLessThanOrEqual(1);
- }
- }
- });
-
- it("draws every visitor, rare event and weather", () => {
- // Each varies on its own, so each is drawn where it shows: a visitor in
- // the witching hour, an event across the shift, weather on the hill.
- const witching = [actStart("witching") + 3, actStart("witching") + 8];
- const wholeShift = [3, 5, 20, 35, 45, 52, 70, 75, 85];
- const onTheHill = [3, 52, 70, 85];
- const cases: [Partial<ShiftPlan>, number[]][] = [
- ...(["witch", "horseman", "spider", "ship"] as const).map(
- (visitor): [Partial<ShiftPlan>, number[]] => [{ visitor }, witching]
- ),
- ...(["none", "reject", "boo", "dance"] as const).map(
- (event): [Partial<ShiftPlan>, number[]] => [{ event }, wholeShift]
- ),
- ...(["clear", "drizzle", "fog"] as const).map(
- (weather): [Partial<ShiftPlan>, number[]] => [{ weather }, onTheHill]
- )
- ];
- for (const [overrides, moments] of cases) {
- const plan = withPlan(overrides);
- for (const s of moments) expect(() => render(plan, s)).not.toThrow();
- }
- });
-
- it("shows the Line's work order, ticking to Complete after QC", () => {
- const plan = planShift(7, 2);
- const during = text(render(plan, actStart("line") + 10).grid);
- expect(during).toContain(plan.job);
- expect(during).toContain("In Progress");
- const after = text(render(plan, actStart("line") + 23).grid);
- expect(after).toContain("Complete");
- expect(after).toContain("QC PASSED");
- });
-
- it("keeps a long translation inside the ticket", () => {
- const plan = planShift(7, 2);
- const long = "x".repeat(60);
- const { grid } = render(plan, actStart("line") + 10, 70, 40, IDLE_WATCHER, {
- ...LABELS,
- item: long,
- inProgress: long,
- stations: [long, long, long, long]
- });
- const status = grid.labels.find((label) => label.text === long);
- expect(status).toBeDefined();
- for (const label of grid.labels) {
- expect(label.x).toBeGreaterThanOrEqual(0);
- expect(label.x + label.cells).toBeLessThanOrEqual(grid.cols);
- }
- // The ticket's labels never overlap one another.
- const row = (y: number) =>
- grid.labels.filter((label) => label.y === y).sort((a, b) => a.x - b.x);
- for (const y of new Set(grid.labels.map((label) => label.y))) {
- const labels = row(y);
- labels.slice(1).forEach((label, i) => {
- const before = labels[i];
- if (before)
- expect(label.x).toBeGreaterThanOrEqual(before.x + before.cells);
- });
- }
- });
-
- it("scraps a rejected pumpkin", () => {
- const plan = withPlan({ event: "reject" });
- const after = text(render(plan, actStart("line") + 22).grid);
- expect(after).toContain("Scrapped");
- expect(after).toContain("REJECTED");
- });
-
- it("stands the procession on the hill, the shipped lantern among them", () => {
- const plan = planShift(7, 2);
- const before = text(render(plan, actStart("harvest") + 2).grid);
- for (const face of plan.procession)
- expect(before).toContain(miniFace(face));
- const after = text(render(plan, actStart("witching") + 1).grid);
- expect(after).toContain(miniFace(plan.face));
- });
-
- it("turns every lantern away while a secret is typed", () => {
- const plan = planShift(7, 2);
- const watcher = { ...IDLE_WATCHER, secret: true };
- const frame = text(
- render(plan, actStart("harvest") + 2, 100, 60, watcher).grid
- );
- for (const face of plan.procession)
- expect(frame).not.toContain(miniFace(face));
- expect(frame).toContain("(:|:)");
- });
-
- it("lights thirteen stars for the Great Lighting", () => {
- let index = 0;
- while (!planShift(7, index).greatLighting) index++;
- const plan = planShift(7, index);
- const { frame } = render(plan, actStart("dawn") + 2);
- const stars = frame.lights.filter((light) => (light.halo ?? 0) > 0.2);
- expect(stars.length).toBeGreaterThanOrEqual(LANTERNS_FOR_LIGHTING);
- });
-
- it("brings the Line down over the hill from the top while the wipe runs", () => {
- const plan = planShift(7, 2);
- const line = actStart("line");
- const rowsAt = (seconds: number) =>
- text(render(plan, seconds).grid).split("\n").slice(0, 60);
- const settled = rowsAt(line + 2);
- // How many rows, from the top, already show the settled Line.
- const lineRows = (seconds: number) => {
- const rows = rowsAt(seconds);
- let n = 0;
- while (n < rows.length && rows[n] === settled[n]) n++;
- return n;
- };
- const early = lineRows(line + 0.4);
- const half = lineRows(line + 0.75);
- const late = lineRows(line + 1.1);
- expect(early).toBe(0);
- expect(half).toBeGreaterThan(0);
- expect(late).toBeGreaterThan(half);
- expect(late).toBeLessThan(60);
- });
-});
diff --git a/packages/react/src/Halloween/night-shift/frame.ts b/packages/react/src/Halloween/night-shift/frame.ts
deleted file mode 100644
index a700294d08..0000000000
--- a/packages/react/src/Halloween/night-shift/frame.ts
+++ /dev/null
@@ -1,295 +0,0 @@
-// SPDX-License-Identifier: AGPL-3.0-only
-// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
-// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-
-// One frame of the Night Shift: picks the scene for the moment (the hill or
-// the Line), wipes between them with a curtain of falling glyphs, rolls the
-// fog in, and lights every glyph near a lantern, a window or a candle.
-
-import { ease, hash01, lerp, segment } from "../math";
-import { drawExterior } from "./exterior";
-import type { Color } from "./grid";
-import { blue, Grid, green, hex, mix, NO_BG, red, rgb } from "./grid";
-import { drawInterior } from "./interior";
-import type { Layout } from "./layout";
-import { fbm2 } from "./noise";
-import { DAWN_HORIZON, DAWN_TOP, SKY_HORIZON, SKY_TOP } from "./palette";
-import type { Labels, Light, Scene, Watcher } from "./scene";
-import type { Moment, ShiftPlan } from "./story";
-
-export type Sky = { top: Color; horizon: Color };
-
-export type FrameOut = {
- sky: Sky;
- lights: Light[];
- /** A white flash over everything, 0 to 1 (lightning). */
- flash: number;
-};
-
-export type Buffers = { main: Grid; from: Grid; to: Grid; light: Float32Array };
-
-export function makeBuffers(cols: number, rows: number): Buffers {
- return {
- main: new Grid(cols, rows),
- from: new Grid(cols, rows),
- to: new Grid(cols, rows),
- light: new Float32Array(cols * rows * 3)
- };
-}
-
-const WIPE_SECONDS = 1.5;
-const FOG_RAMP = ".,-~~=";
-const FOG_DIM = hex("#352d4d");
-const FOG_BRIGHT = hex("#a79ecb");
-const WIPE_HEAD = hex("#ffe2b0");
-const WIPE_TAIL = hex("#ff8a2a");
-const WIPE_GLYPHS = "*+x%#@&?!/\\";
-
-const BASE_FOG = { clear: 0.62, drizzle: 0.74, fog: 0.95 } as const;
-
-/** How thick the fog is and how high it reaches, for this moment. */
-export function fogAt(plan: ShiftPlan, moment: Moment, layout: Layout) {
- const base = BASE_FOG[plan.weather];
- const low = layout.rows * 0.68;
- if (moment.act === "midnight") {
- const clear = ease(segment(moment.t, 0, 2.6));
- return { density: lerp(1.6, base, clear), top: lerp(0, low, clear) };
- }
- if (moment.act === "witching") {
- return {
- density: base + 0.25 * ease(moment.progress),
- top: low - 3 * ease(moment.progress)
- };
- }
- if (moment.act === "dawn") {
- const swallow = ease(segment(moment.t, 7, 11));
- return {
- density: lerp(base + 0.25, 1.6, swallow),
- top: lerp(low - 3, 0, swallow)
- };
- }
- return { density: base, top: low };
-}
-
-function rollFog(scene: Scene, density: number, top: number) {
- const { grid, layout, seconds } = scene;
- const start = Math.max(0, Math.trunc(top) - 6);
- for (let r = start; r < layout.rows; r++) {
- const rise = (r - top + 6) / 10;
- if (rise <= 0) continue;
- const height = rise >= 1 ? 1 : rise;
- for (let c = 0; c < layout.cols; c++) {
- const n = fbm2(
- c * 0.055 + seconds * 0.16,
- r * 0.2 - seconds * 0.03,
- 3,
- 31
- );
- const v = n * height * density;
- if (v < 0.3) continue;
- const k = Math.min(1, (v - 0.3) / 0.7);
- const i = r * layout.cols + c;
- const color = mix(FOG_DIM, FOG_BRIGHT, k);
- if (grid.ch[i] === 32 || k > 0.62) {
- grid.ch[i] = (
- FOG_RAMP[
- Math.min(FOG_RAMP.length - 1, Math.trunc(k * FOG_RAMP.length))
- ] ?? "~"
- ).charCodeAt(0);
- grid.fg[i] = color;
- } else {
- grid.fg[i] = mix(grid.fg[i] ?? 0, color, k * 0.6);
- }
- const bg = grid.bg[i] ?? NO_BG;
- if (bg !== NO_BG) grid.bg[i] = mix(bg, FOG_DIM, k * 0.45);
- }
- }
-}
-
-/** Lights every glyph near a light source: warm near lanterns, cool at lamps. */
-function applyLights(
- grid: Grid,
- layout: Layout,
- lights: Light[],
- buffer: Float32Array
-) {
- buffer.fill(0);
- const { cols, rows, aspect } = layout;
- for (const light of lights) {
- if (light.power <= 0) continue;
- const reachX = light.radius * aspect;
- const r0 = Math.max(0, Math.trunc(light.y - light.radius));
- const r1 = Math.min(rows - 1, Math.trunc(light.y + light.radius) + 1);
- const c0 = Math.max(0, Math.trunc(light.x - reachX));
- const c1 = Math.min(cols - 1, Math.trunc(light.x + reachX) + 1);
- const lr = (red(light.color) / 255) * light.power;
- const lg = (green(light.color) / 255) * light.power;
- const lb = (blue(light.color) / 255) * light.power;
- for (let r = r0; r <= r1; r++) {
- for (let c = c0; c <= c1; c++) {
- const d =
- Math.hypot((c + 0.5 - light.x) / aspect, r + 0.5 - light.y) /
- light.radius;
- if (d >= 1) continue;
- const f = (1 - d) * (1 - d);
- const i = (r * cols + c) * 3;
- buffer[i] = (buffer[i] ?? 0) + lr * f;
- buffer[i + 1] = (buffer[i + 1] ?? 0) + lg * f;
- buffer[i + 2] = (buffer[i + 2] ?? 0) + lb * f;
- }
- }
- }
- for (let i = 0; i < cols * rows; i++) {
- const lr = buffer[i * 3] ?? 0;
- const lg = buffer[i * 3 + 1] ?? 0;
- const lb = buffer[i * 3 + 2] ?? 0;
- if (lr + lg + lb < 0.01) continue;
- if (grid.ch[i] !== 32) {
- const fg = grid.fg[i] ?? 0;
- grid.fg[i] = rgb(
- red(fg) + lr * 230,
- green(fg) + lg * 230,
- blue(fg) + lb * 230
- );
- }
- const bg = grid.bg[i] ?? NO_BG;
- if (bg !== NO_BG)
- grid.bg[i] = rgb(
- red(bg) + lr * 40,
- green(bg) + lg * 40,
- blue(bg) + lb * 40
- );
- }
-}
-
-/** The curtain between scenes: falling glyphs, the new scene above them. */
-function wipe(
- target: Grid,
- from: Grid,
- to: Grid,
- progress: number,
- seconds: number
-) {
- const { cols, rows } = target;
- const spread = 0.45;
- const frontAt = (c: number) =>
- (progress * (1 + spread) - hash01(c * 53 + 7) * spread) * (rows + 4);
- const sourceAt = (c: number, r: number) => (r < frontAt(c) - 2 ? to : from);
- // A label goes with the cell it starts in.
- target.labels = [
- ...from.labels.filter((label) => sourceAt(label.x, label.y) === from),
- ...to.labels.filter((label) => sourceAt(label.x, label.y) === to)
- ];
- for (let c = 0; c < cols; c++) {
- const front = frontAt(c);
- for (let r = 0; r < rows; r++) {
- const i = r * cols + c;
- const source = sourceAt(c, r);
- target.ch[i] = source.ch[i] ?? 32;
- target.fg[i] = source.fg[i] ?? 0;
- target.bg[i] = source.bg[i] ?? NO_BG;
- const behind = front - r;
- if (behind >= 0 && behind < 3) {
- const glyph =
- WIPE_GLYPHS[
- Math.trunc(
- hash01(c * 7 + r * 3 + Math.trunc(seconds * 20)) *
- WIPE_GLYPHS.length
- )
- ] ?? "*";
- target.ch[i] = glyph.charCodeAt(0);
- target.fg[i] =
- behind < 1 ? WIPE_HEAD : mix(WIPE_TAIL, WIPE_HEAD, 1 - behind / 3);
- }
- }
- }
-}
-
-function sceneFor(grid: Grid, view: View, moment: Moment): Scene {
- return { grid, ...view, moment, lights: [] };
-}
-
-/** Everything a frame is drawn from but the moment. */
-type View = Omit<Scene, "grid" | "moment" | "lights">;
-
-export function renderFrame(
- buffers: Buffers,
- layout: Layout,
- plan: ShiftPlan,
- moment: Moment,
- seconds: number,
- watcher: Watcher,
- labels: Labels
-): FrameOut {
- const { main, from, to } = buffers;
- const view: View = { layout, plan, seconds, watcher, labels };
- main.clear();
- let lights: Light[] = [];
- let flash = 0;
- let dawn = 0;
- let exterior = true;
-
- const inWipe =
- (moment.act === "line" || moment.act === "shipping") &&
- moment.t < WIPE_SECONDS;
-
- if (inWipe) {
- const progress = moment.t / WIPE_SECONDS;
- from.clear();
- to.clear();
- const toLine = moment.act === "line";
- const before: Moment = toLine
- ? { ...moment, act: "harvest", t: 14, progress: 1 }
- : { ...moment, act: "line", t: 24, progress: 1 };
- const fromScene = sceneFor(from, view, before);
- const toScene = sceneFor(to, view, moment);
- if (toLine) {
- drawExterior(fromScene);
- drawInterior(toScene);
- const fog = fogAt(plan, before, layout);
- rollFog(fromScene, fog.density, fog.top);
- } else {
- drawInterior(fromScene);
- drawExterior(toScene);
- const fog = fogAt(plan, moment, layout);
- rollFog(toScene, fog.density, fog.top);
- }
- wipe(main, from, to, progress, seconds);
- lights = [
- ...fromScene.lights.map((light) => ({
- ...light,
- power: light.power * (1 - progress),
- halo: (light.halo ?? 0) * (1 - progress)
- })),
- ...toScene.lights.map((light) => ({
- ...light,
- power: light.power * progress,
- halo: (light.halo ?? 0) * progress
- }))
- ];
- exterior = !toLine;
- } else if (moment.act === "line") {
- const scene = sceneFor(main, view, moment);
- drawInterior(scene);
- lights = scene.lights;
- exterior = false;
- } else {
- const scene = sceneFor(main, view, moment);
- const out = drawExterior(scene);
- flash = out.flash;
- dawn = out.dawn;
- const fog = fogAt(plan, moment, layout);
- rollFog(scene, fog.density, fog.top);
- lights = scene.lights;
- }
-
- applyLights(main, layout, lights, buffers.light);
-
- const sky: Sky = exterior
- ? {
- top: mix(SKY_TOP, DAWN_TOP, dawn),
- horizon: mix(SKY_HORIZON, DAWN_HORIZON, dawn)
- }
- : { top: hex("#120c18"), horizon: hex("#120c18") };
- return { sky, lights, flash };
-}
diff --git a/packages/react/src/Halloween/night-shift/great-lighting.ts b/packages/react/src/Halloween/night-shift/great-lighting.ts
deleted file mode 100644
index ada579df00..0000000000
--- a/packages/react/src/Halloween/night-shift/great-lighting.ts
+++ /dev/null
@@ -1,116 +0,0 @@
-// SPDX-License-Identifier: AGPL-3.0-only
-// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
-// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-
-// The Great Lighting: thirteen lanterns rise and become the Carbon mark.
-
-import { ease, lerp, segment } from "../math";
-import { mix, scale } from "./grid";
-import { lanternSlot, pointAlong } from "./layout";
-import { flicker, noise2 } from "./noise";
-import { LANTERN_LIGHT, STAR_GOLD } from "./palette";
-import { drawLantern } from "./pumpkin";
-import type { Scene } from "./scene";
-import { lightingTime } from "./sky";
-import { MARK_EDGES, MARK_STARS } from "./sprites";
-import { LANTERNS_FOR_LIGHTING } from "./story";
-
-function constellationPoint(scene: Scene, index: number) {
- const { cols, rows, aspect, factory } = scene.layout;
- const star = MARK_STARS[index] ?? MARK_STARS[0] ?? { x: 212, y: 240 };
- // Right of the chimney's smoke, as large as fits: the moon has set.
- const left = factory.chimney + 4;
- const right = cols - 3;
- const sy = Math.min((rows * 0.3) / 480, (right - left) / 2 / (212 * aspect));
- return {
- x: (left + right) / 2 + (star.x - 212) * sy * aspect,
- y: rows * 0.26 + (star.y - 240) * sy
- };
-}
-
-/** Thirteen lanterns rise and become the Carbon mark, then the stars. */
-export function drawGreatLighting(scene: Scene) {
- const { grid, layout, plan, moment, seconds, lights } = scene;
- if (!plan.greatLighting) return;
- if (moment.act !== "witching" && moment.act !== "dawn") return;
- const T = lightingTime(scene);
- const lanterns = [...plan.procession, plan.face];
- const fade = 1 - ease(segment(T, 20, 24.5));
- const positions = lanterns.map((face, i) => {
- const slot = pointAlong(
- layout.path,
- lanternSlot(i, LANTERNS_FOR_LIGHTING),
- layout.aspect
- );
- const lift = ease(segment(T, 0.3 + i * 0.25, 3.8 + i * 0.25));
- const risen = {
- x: slot.x + Math.sin(seconds * 1.3 + i) * 2 * lift,
- y: slot.y - 0.6 - lift * 7
- };
- const glide = ease(segment(T, 5, 9));
- const target = constellationPoint(scene, i);
- return {
- face,
- x: lerp(risen.x, target.x, glide),
- y:
- lerp(risen.y, target.y, glide) +
- Math.sin(seconds * 2 + i) * 0.15 * (1 - glide),
- star: glide
- };
- });
-
- MARK_EDGES.forEach(([a, b], k) => {
- const from = positions[a];
- const to = positions[b];
- if (!from || !to) return;
- const shown = segment(T, 9 + k * 0.22, 9.6 + k * 0.22) * fade;
- if (shown <= 0) return;
- const steps = Math.trunc(
- Math.hypot((to.x - from.x) / layout.aspect, to.y - from.y) * 1.6
- );
- const dx = (to.x - from.x) / layout.aspect;
- const dy = to.y - from.y;
- const edge =
- Math.abs(dx) > 2 * Math.abs(dy)
- ? "-"
- : Math.abs(dy) > 2 * Math.abs(dx)
- ? "|"
- : dx * dy > 0
- ? "\\"
- : "/";
- for (let s = 1; s < steps; s++) {
- if (s / steps > shown) break;
- const x = lerp(from.x, to.x, s / steps);
- const y = lerp(from.y, to.y, s / steps);
- if (grid.isBlank(x, y))
- grid.put(x, y, edge, scale(STAR_GOLD, 0.7 * fade));
- }
- });
-
- positions.forEach((p, i) => {
- const lit = flicker(seconds + i, i);
- if (p.star < 0.5) {
- drawLantern(grid, p.x, p.y, p.face, { lit });
- } else {
- const twinkle = 0.7 + 0.3 * noise2(seconds * 3 + i, i, 8);
- const char = fade > 0.66 ? "*" : fade > 0.33 ? "+" : ".";
- grid.put(
- p.x,
- p.y,
- char,
- scale(
- mix(LANTERN_LIGHT, STAR_GOLD, p.star),
- twinkle * (0.4 + 0.6 * fade)
- )
- );
- }
- lights.push({
- x: p.x,
- y: p.y,
- radius: 2.6,
- color: mix(LANTERN_LIGHT, STAR_GOLD, p.star),
- power: 0.5 * lit * fade,
- halo: (0.18 + 0.12 * p.star) * fade
- });
- });
-}
diff --git a/packages/react/src/Halloween/night-shift/grid.ts b/packages/react/src/Halloween/night-shift/grid.ts
deleted file mode 100644
index d5a5c0a860..0000000000
--- a/packages/react/src/Halloween/night-shift/grid.ts
+++ /dev/null
@@ -1,213 +0,0 @@
-// SPDX-License-Identifier: AGPL-3.0-only
-// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
-// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-
-// The character grid every frame is drawn into before it is painted: one
-// glyph, one text colour and an optional cell background per cell. Colours
-// are packed 0xRRGGBB numbers in typed arrays, so a cell allocates nothing.
-
-import { floorOf } from "../math";
-
-export type Color = number;
-
-/** No background: the canvas behind the cell shows through. */
-export const NO_BG = -1;
-
-/** A sprite cell that hides whatever is behind it without drawing a glyph. */
-export const OPAQUE = "$";
-
-function clamp255(value: number) {
- if (value <= 0) return 0;
- if (value >= 255) return 255;
- return value | 0;
-}
-
-export function rgb(r: number, g: number, b: number): Color {
- return (clamp255(r) << 16) | (clamp255(g) << 8) | clamp255(b);
-}
-
-export function hex(value: string): Color {
- return Number.parseInt(value.replace("#", ""), 16);
-}
-
-export function red(color: Color) {
- return (color >> 16) & 255;
-}
-
-export function green(color: Color) {
- return (color >> 8) & 255;
-}
-
-export function blue(color: Color) {
- return color & 255;
-}
-
-/** `a` at t = 0, `b` at t = 1. */
-export function mix(a: Color, b: Color, t: number): Color {
- const k = t <= 0 ? 0 : t >= 1 ? 1 : t;
- return rgb(
- red(a) + (red(b) - red(a)) * k,
- green(a) + (green(b) - green(a)) * k,
- blue(a) + (blue(b) - blue(a)) * k
- );
-}
-
-export function scale(color: Color, k: number): Color {
- return rgb(red(color) * k, green(color) * k, blue(color) * k);
-}
-
-export function css(color: Color) {
- return `#${color.toString(16).padStart(6, "0")}`;
-}
-
-/**
- * Words in the user's language (a station name, a ticket's status). The grid
- * draws one character per cell, which a translation cannot keep to: a
- * combining mark, or a CJK glyph twice a cell wide. So a label reserves its
- * cells and the painter draws the whole string over them, cut short to fit.
- */
-export type Label = {
- x: number;
- y: number;
- cells: number;
- text: string;
- color: Color;
- align: "left" | "center";
-};
-
-// East Asian wide and fullwidth ranges: about two cells each.
-const WIDE =
- /[\u1100-\u115f\u2e80-\ua4cf\uac00-\ud7a3\uf900-\ufaff\ufe30-\ufe4f\uff00-\uff60\uffe0-\uffe6]/;
-
-/** Roughly how many cells a string takes in the panel's monospace font. */
-export function cellsFor(text: string) {
- let cells = 0;
- for (const char of text) cells += WIDE.test(char) ? 2 : 1;
- return cells;
-}
-
-export class Grid {
- readonly cols: number;
- readonly rows: number;
- readonly ch: Uint16Array;
- readonly fg: Uint32Array;
- readonly bg: Int32Array;
- labels: Label[] = [];
-
- constructor(cols: number, rows: number) {
- this.cols = cols;
- this.rows = rows;
- this.ch = new Uint16Array(cols * rows);
- this.fg = new Uint32Array(cols * rows);
- this.bg = new Int32Array(cols * rows);
- this.clear();
- }
-
- clear() {
- this.ch.fill(32);
- this.fg.fill(0);
- this.bg.fill(NO_BG);
- this.labels = [];
- }
-
- /** The cell index under a point, or -1 off the grid. */
- index(x: number, y: number) {
- const c = floorOf(x);
- const r = floorOf(y);
- if (c < 0 || r < 0 || c >= this.cols || r >= this.rows) return -1;
- return r * this.cols + c;
- }
-
- put(x: number, y: number, char: string, color: Color) {
- const i = this.index(x, y);
- if (i < 0) return;
- this.ch[i] = char.charCodeAt(0);
- this.fg[i] = color;
- }
-
- /** Clears the glyph so nothing behind shows, optionally filling the cell. */
- blank(x: number, y: number, background: Color = NO_BG) {
- const i = this.index(x, y);
- if (i < 0) return;
- this.ch[i] = 32;
- if (background !== NO_BG) this.bg[i] = background;
- }
-
- fill(x: number, y: number, background: Color) {
- const i = this.index(x, y);
- if (i < 0) return;
- this.bg[i] = background;
- }
-
- charAt(x: number, y: number) {
- const i = this.index(x, y);
- return i < 0 ? " " : String.fromCharCode(this.ch[i] ?? 32);
- }
-
- isBlank(x: number, y: number) {
- const i = this.index(x, y);
- return i < 0 || this.ch[i] === 32;
- }
-
- /**
- * A label in at most `cells` cells from (x, y), centred on them or from
- * their left. Returns how many cells it took.
- */
- label(
- x: number,
- y: number,
- text: string,
- color: Color,
- maxCells: number,
- align: Label["align"] = "left",
- background: Color = NO_BG
- ) {
- const cells = Math.max(0, Math.min(maxCells, cellsFor(text)));
- if (cells === 0) return 0;
- for (let k = 0; k < cells; k++) this.blank(x + k, y, background);
- this.labels.push({ x, y, cells, text, color, align });
- return cells;
- }
-
- /** Writes a string left to right; spaces leave what is behind. */
- text(x: number, y: number, value: string, color: Color) {
- for (let k = 0; k < value.length; k++) {
- const char = value[k] ?? " ";
- if (char !== " ") this.put(x + k, y, char, color);
- }
- }
-
- /**
- * Draws ASCII art with its top-left at (x, y). Spaces are transparent,
- * `$` hides what is behind. `color` may vary per glyph; returning null
- * skips that glyph.
- */
- sprite(
- x: number,
- y: number,
- lines: readonly string[],
- color: Color | ((char: string, col: number, row: number) => Color | null),
- background: Color = NO_BG
- ) {
- for (let row = 0; row < lines.length; row++) {
- const line = lines[row] ?? "";
- for (let col = 0; col < line.length; col++) {
- const char = line[col] ?? " ";
- if (char === " ") continue;
- if (char === OPAQUE) {
- this.blank(x + col, y + row, background);
- continue;
- }
- const tint = typeof color === "number" ? color : color(char, col, row);
- if (tint === null) continue;
- this.put(x + col, y + row, char, tint);
- if (background !== NO_BG) this.fill(x + col, y + row, background);
- }
- }
- }
-}
-
-/** Width of the widest line: a sprite's footprint in cells. */
-export function spriteWidth(lines: readonly string[]) {
- return lines.reduce((widest, line) => Math.max(widest, line.length), 0);
-}
diff --git a/packages/react/src/Halloween/night-shift/hill.ts b/packages/react/src/Halloween/night-shift/hill.ts
deleted file mode 100644
index d65b4f3284..0000000000
--- a/packages/react/src/Halloween/night-shift/hill.ts
+++ /dev/null
@@ -1,364 +0,0 @@
-// SPDX-License-Identifier: AGPL-3.0-only
-// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
-// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-
-// The hill: its ridges and ground, the path, the graveyard, the pumpkin
-// patch, the fence with its cat and crow, the lantern procession, the ghost
-// and the foreman's dance.
-
-import { ease, fraction, hash01, nearest, segment } from "../math";
-import type { Face } from "./faces";
-import { hex, mix, scale, spriteWidth } from "./grid";
-import { lanternSlot, pointAlong } from "./layout";
-import { flicker, noise2 } from "./noise";
-import {
- ALARM,
- BONE,
- CAT_BG,
- CAT_EYES,
- CAT_LINE,
- CAW,
- CROW_EYE,
- CROW_LINE,
- DAWN_EDGE,
- FENCE,
- GHOST_BG,
- GHOST_GLOW,
- GRASS,
- GRASS_LIT,
- GROUND_BG,
- HILL_BG,
- LANTERN_LIGHT,
- LEAF,
- PATH,
- PUMPKIN_MARK,
- PUMPKIN_SHELL,
- RIM_EDGE,
- RIP,
- STONE,
- STONE_BG,
- STONE_RIM,
- TEXTURE,
- VINE
-} from "./palette";
-import { drawLantern } from "./pumpkin";
-import type { Scene } from "./scene";
-import { CAT, CROW, GHOST, SKELETON, STONES } from "./sprites";
-import { LANTERNS_FOR_LIGHTING } from "./story";
-
-export function drawHills(scene: Scene, dawn: number) {
- const { grid, layout } = scene;
- const edge = mix(RIM_EDGE, DAWN_EDGE, dawn);
- for (let c = 0; c < layout.cols; c++) {
- const top = layout.ridge[c] ?? layout.horizon;
- const r0 = Math.trunc(top);
- for (let r = r0 + 1; r <= layout.horizon + 1; r++) {
- grid.blank(c, r);
- grid.fill(c, r, mix(HILL_BG, hex("#2a2236"), dawn * 0.5));
- if (hash01(c * 131 + r * 71) < 0.045) grid.put(c, r, ".", hex("#2b1f3e"));
- }
- const slope = (layout.ridge[c + 1] ?? top) - (layout.ridge[c - 1] ?? top);
- const char = slope < -0.45 ? "/" : slope > 0.45 ? "\\" : "_";
- grid.put(c, r0, char, edge);
- }
-}
-
-export function drawGround(scene: Scene, dawn: number) {
- const { grid, layout, seconds } = scene;
- for (let c = 0; c < layout.cols; c++) {
- const top = layout.ground[c] ?? layout.horizon;
- const r0 = Math.trunc(top);
- for (let r = r0 + 1; r < layout.rows; r++) {
- grid.fill(c, r, GROUND_BG);
- grid.blank(c, r);
- const h = hash01(c * 977 + r * 131);
- if (h < 0.07)
- grid.put(c, r, h < 0.025 ? "," : h < 0.05 ? "." : "`", TEXTURE);
- }
- const tall = hash01(c * 17 + 3) < 0.4;
- const sway = noise2(c * 0.25 + seconds * 0.6, 1.3, 2);
- const blade = tall
- ? sway < 0.4
- ? "/"
- : sway > 0.6
- ? "\\"
- : "|"
- : hash01(c) < 0.5
- ? ","
- : "'";
- grid.put(
- c,
- r0,
- blade,
- mix(GRASS, mix(GRASS_LIT, DAWN_EDGE, dawn * 0.4), hash01(c * 3))
- );
- }
-}
-
-export function drawPath(scene: Scene) {
- const { grid, layout } = scene;
- const steps = 110;
- for (let k = 0; k <= steps; k++) {
- if (hash01(k * 29) > 0.7) continue;
- const p = pointAlong(layout.path, k / steps, layout.aspect);
- grid.put(p.x, p.y + 0.4, k % 3 === 0 ? "," : ".", PATH);
- }
-}
-
-export function drawStones(scene: Scene) {
- const { grid, layout } = scene;
- for (const stone of layout.stones) {
- const art = STONES[stone.kind];
- const width = spriteWidth(art);
- const left = stone.x - Math.trunc(width / 2);
- const top = stone.base - art.length + 1;
- grid.sprite(
- left,
- top,
- art,
- (char, col, row) =>
- char === "R" || char === "I" || char === "P"
- ? RIP
- : row === 0 || col >= width - 2
- ? STONE_RIM
- : STONE,
- STONE_BG
- );
- }
-}
-
-export function drawPatch(scene: Scene) {
- const { grid, layout, moment } = scene;
- const { patch } = layout;
- const grown =
- moment.act === "midnight"
- ? 0.15
- : moment.act === "harvest"
- ? ease(segment(moment.t, 0, 5))
- : 1;
- const end = patch.left + (patch.right - patch.left) * grown;
- for (let x = patch.left; x <= end; x++) {
- const wave = Math.sin(x * 0.42);
- const y = patch.y + 1 + nearest(wave * 0.8);
- const slope = Math.cos(x * 0.42);
- const char = slope > 0.5 ? "\\" : slope < -0.5 ? "/" : "~";
- grid.put(x, y, char, VINE);
- if (hash01(x * 41) < 0.22)
- grid.put(x, y - 1, hash01(x) < 0.5 ? "&" : "%", LEAF);
- if (hash01(x * 7 + 1) < 0.12) grid.put(x, y + 1, "@", scale(VINE, 0.8));
- }
- const spots = 6;
- for (let k = 0; k < spots; k++) {
- const x =
- patch.left + 2 + ((k + 0.5) * (patch.right - patch.left - 4)) / spots;
- if (Math.abs(x - layout.hero.x) < 7) continue;
- if (x > end) continue;
- const y = patch.y + (k % 2) - 0.2;
- const art = k % 3 === 0 ? "(@)" : k % 3 === 1 ? "(o)" : "(O)";
- grid.text(x - 1, y, art, PUMPKIN_SHELL);
- grid.put(x, y, art[1] ?? "@", PUMPKIN_MARK);
- grid.put(x, y - 1, "'", VINE);
- }
-}
-
-export function drawFence(scene: Scene) {
- const { grid, layout, seconds, watcher } = scene;
- const { fence } = layout;
- for (let c = fence.left; c <= fence.right; c++) {
- const post = (c - fence.left) % 3 === 0;
- if (post) grid.put(c, fence.top, "^", FENCE);
- grid.put(c, fence.top + 1, post ? "|" : "-", FENCE);
- if (post) grid.put(c, fence.top + 2, "|", scale(FENCE, 0.8));
- }
-
- const { cat } = layout;
- let look: keyof typeof CAT.eyes = "ahead";
- if (watcher.secret) look = "left";
- else if (watcher.field) look = "right";
- else if (watcher.pointer) {
- const dx = watcher.pointer.x - cat.x;
- look = dx < -5 ? "left" : dx > 5 ? "right" : "ahead";
- } else {
- const idle = noise2(seconds * 0.18, 9, 4);
- look = idle < 0.36 ? "left" : idle > 0.64 ? "right" : "ahead";
- }
- if (fraction(seconds / 4.7) < 0.035) look = "blink";
- const art = [CAT.ears, CAT.eyes[look], ...CAT.body];
- grid.sprite(
- cat.x - 3,
- cat.y,
- art,
- (char) => (char === "o" ? CAT_EYES : CAT_LINE),
- CAT_BG
- );
- if (look !== "blink") {
- scene.lights.push({
- x: cat.x,
- y: cat.y + 1.5,
- radius: 1.4,
- color: CAT_EYES,
- power: 0.2,
- halo: 0.06
- });
- }
-
- const { crow } = layout;
- grid.sprite(
- crow.x,
- crow.y,
- CROW,
- (char) =>
- char === "o" ? CROW_EYE : char === ">" ? hex("#c9a227") : CROW_LINE,
- CAT_BG
- );
- if (watcher.alarm > 0)
- grid.text(
- crow.x + 4,
- crow.y - 1,
- "caw.",
- mix(CROW_LINE, CAW, watcher.alarm)
- );
-}
-
-function lanternLight(
- scene: Scene,
- x: number,
- y: number,
- lit: number,
- away: boolean
-) {
- const flare = scene.watcher.flare;
- scene.lights.push({
- x,
- y,
- radius: 2.8 + flare * 2,
- color:
- scene.watcher.alarm > 0
- ? mix(LANTERN_LIGHT, ALARM, scene.watcher.alarm)
- : LANTERN_LIGHT,
- power: 0.55 * lit * (away ? 0.45 : 1) * (1 + flare * 1.6),
- halo: 0.2 * lit * (away ? 0.5 : 1) * (1 + flare * 1.6)
- });
-}
-
-function lanternTint(scene: Scene, lit: number) {
- const { alarm } = scene.watcher;
- if (alarm <= 0) return undefined;
- const on = fraction(scene.seconds * 7) < 0.6;
- return mix(hex("#ffd36a"), ALARM, on ? alarm : alarm * 0.4 * lit);
-}
-
-/** The lanterns on the hill, the newest still hopping down from the door. */
-export function drawProcession(scene: Scene) {
- const { grid, layout, plan, moment, seconds, watcher } = scene;
- if (
- plan.greatLighting &&
- (moment.act === "witching" || moment.act === "dawn")
- )
- return;
- const shipped =
- (moment.act === "witching" || moment.act === "dawn") &&
- plan.event !== "reject";
- const lanterns: Face[] = shipped
- ? [...plan.procession, plan.face]
- : plan.procession;
- const peek = lanterns.length - 1;
- lanterns.forEach((face, i) => {
- const s = lanternSlot(i, LANTERNS_FOR_LIGHTING);
- const p = pointAlong(layout.path, s, layout.aspect);
- const bob = noise2(seconds * 1.1 + i * 3.1, i, 6) > 0.64 ? -1 : 0;
- const lit = flicker(seconds + i * 1.7, i);
- const away = watcher.secret && !(watcher.peek && i === peek);
- drawLantern(grid, p.x, p.y - 0.6 + bob, face, {
- lit,
- away,
- tint: lanternTint(scene, lit)
- });
- lanternLight(scene, p.x, p.y - 0.6 + bob, lit, away);
- });
-
- if (moment.act !== "shipping") return;
- const t = moment.t;
- if (plan.event === "reject") {
- const s = segment(t, 2, 8.5) * 1.15;
- if (t > 2 && s <= 1) {
- const p = pointAlong(layout.path, s, layout.aspect);
- const roll =
- ["(@)", "(o)", "(@)", "(O)"][Math.trunc(seconds * 10) % 4] ?? "(@)";
- grid.text(p.x - 1, p.y - 0.6, roll, PUMPKIN_MARK);
- }
- const chase = segment(t, 2.7, 9.8) * 1.15;
- if (t > 2.7 && chase <= 1) {
- const p = pointAlong(layout.path, chase, layout.aspect);
- const frame =
- Math.trunc(seconds * 8) % 2 === 0 ? SKELETON.runA : SKELETON.runB;
- grid.sprite(p.x - 3, p.y - 4.6, frame, BONE);
- }
- return;
- }
- if (t < 2.5) return;
- const u = segment(t, 2.5, 11.5);
- const slot = lanternSlot(plan.procession.length, LANTERNS_FOR_LIGHTING);
- const p = pointAlong(layout.path, slot * u, layout.aspect);
- const hop = u < 1 ? Math.sin(fraction((t - 2.5) / 0.5) * Math.PI) * 1.2 : 0;
- const lit = flicker(seconds, 99);
- const away = watcher.secret && !watcher.peek;
- drawLantern(grid, p.x, p.y - 0.6 - hop, plan.face, {
- lit,
- away,
- tint: lanternTint(scene, lit)
- });
- lanternLight(scene, p.x, p.y - 0.6 - hop, lit, away);
-}
-
-export function drawGhost(scene: Scene) {
- const { grid, layout, moment, seconds, watcher, lights } = scene;
- let alpha = 0;
- if (moment.act === "shipping") alpha = ease(segment(moment.t, 1.5, 4));
- else if (moment.act === "witching") alpha = 1;
- else if (moment.act === "dawn") alpha = 1 - ease(segment(moment.t, 6, 9));
- if (alpha <= 0) return;
- const first = layout.stones[0];
- const last = layout.stones[layout.stones.length - 1];
- const mid = first && last ? (first.x + last.x) / 2 : layout.cols * 0.45;
- const base = first?.base ?? layout.horizon + 2;
- const x = mid + Math.sin(seconds * 0.23) * layout.cols * 0.07;
- const y = base - 6.5 + Math.sin(seconds * 1.2) * 0.7;
- const body = watcher.secret
- ? watcher.peek
- ? GHOST.peek
- : GHOST.shut
- : GHOST.open;
- const hem = GHOST.hem[Math.trunc(seconds * 2.5) % 2] ?? GHOST.hem[0] ?? "";
- const color = mix(GROUND_BG, GHOST_GLOW, alpha * 0.9);
- grid.sprite(x - 4, y, [...body, hem], color, mix(GROUND_BG, GHOST_BG, alpha));
- lights.push({
- x,
- y: y + 2,
- radius: 3.4,
- color: hex("#b8b0ff"),
- power: 0.18 * alpha,
- halo: 0.1 * alpha
- });
-}
-
-export function drawDance(scene: Scene) {
- const { grid, layout, moment, plan, seconds } = scene;
- if (plan.event !== "dance" || moment.act !== "witching" || plan.greatLighting)
- return;
- const f = layout.factory;
- const x = f.door + 3;
- const y = f.base - 4;
- const step = Math.trunc(seconds / 0.4) % 2 === 0;
- grid.sprite(x, y, step ? SKELETON.danceA : SKELETON.danceB, BONE);
- grid.text(x + (step ? 7 : 6), y + (step ? 0 : 2), "c[_]", hex("#c8a27a"));
- for (let k = 0; k < 3; k++) {
- const age = fraction(seconds * 0.5 + k / 3);
- grid.put(
- x + 3 + Math.sin(age * 6 + k) * 2,
- y - 1 - age * 5,
- k % 2 ? "♪" : "♫",
- scale(BONE, 1 - age)
- );
- }
-}
diff --git a/packages/react/src/Halloween/night-shift/interior.ts b/packages/react/src/Halloween/night-shift/interior.ts
deleted file mode 100644
index 346f82d4a9..0000000000
--- a/packages/react/src/Halloween/night-shift/interior.ts
+++ /dev/null
@@ -1,407 +0,0 @@
-// SPDX-License-Identifier: AGPL-3.0-only
-// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
-// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-
-// The Line: inside the plant, the pumpkin rides a conveyor through four
-// stations (wash, carve, light, QC) while a work order in the corner ticks
-// along, the way a Carbon job does. Once the candle catches, the whole floor
-// turns from cold purple to warm orange.
-
-import { clamp01, ease, fraction, hash01, lerp, segment } from "../math";
-import { carvedCells, cellKey, HERO_MIN_RADIUS } from "./faces";
-import type { Color } from "./grid";
-import { cellsFor, hex, mix, scale } from "./grid";
-import { flicker, noise2 } from "./noise";
-import { drawPumpkin } from "./pumpkin";
-import type { Scene } from "./scene";
-import { CANDLE, LAMP, NOZZLE, SKELETON } from "./sprites";
-
-const WALL_COLD = hex("#120c18");
-const WALL_WARM = hex("#1f120b");
-const BRICK = hex("#1e1628");
-const FLOOR = hex("#0b070e");
-const FLOOR_LINE = hex("#3a2f4a");
-const BELT = hex("#6a6380");
-const ROLLER = hex("#9a93b0");
-const LEG = hex("#3e3852");
-const SIGN = hex("#8a80a8");
-const SIGN_BG = hex("#1b1424");
-const LAMP_COLD = hex("#b8c4ff");
-const LAMP_WARM = hex("#ffd9a0");
-const WATER = hex("#6aa8ff");
-const BUBBLE = hex("#a8d4ff");
-const CHIP = hex("#f2b26e");
-const STEEL = hex("#7d7694");
-const BLADE = hex("#e6e3f2");
-const WAX = hex("#ece2c6");
-const FLAME = hex("#ffd36a");
-const BONE = hex("#ece4cf");
-const PASS = hex("#6ee7a0");
-const FAIL = hex("#ff5a5a");
-const TICKET_LINE = hex("#5d5378");
-const TICKET_TEXT = hex("#d9d1ee");
-const TICKET_JOB = hex("#ffb347");
-const TICKET_BG = hex("#140f1c");
-const AMBER = hex("#f5b544");
-const PENDING = hex("#5a5270");
-const PUMPKIN_GLOW = hex("#ff8a2a");
-
-/** Where the pumpkin is along the line, seconds into the act. */
-function travel(t: number, stops: number[], start: number, exit: number) {
- const [wash = 0, carve = 0, light = 0, qc = 0] = stops;
- if (t < 1.5) return start;
- if (t < 3.5) return lerp(start, wash, ease(segment(t, 1.5, 3.5)));
- if (t < 6.5) return wash;
- if (t < 8) return lerp(wash, carve, ease(segment(t, 6.5, 8)));
- if (t < 14.5) return carve;
- if (t < 16) return lerp(carve, light, ease(segment(t, 14.5, 16)));
- if (t < 19.5) return light;
- if (t < 20.5) return lerp(light, qc, ease(segment(t, 19.5, 20.5)));
- if (t < 22.5) return qc;
- return lerp(qc, exit, ease(segment(t, 22.5, 24)));
-}
-
-/** Which stations are done, seconds into the act; QC needs the stamp. */
-function stationsDone(t: number) {
- return [t >= 6.5, t >= 14.5, t >= 19.5, t >= 21.3];
-}
-
-/** How warm the floor is: 0 until the candle catches, then 1. */
-export function warmthAt(t: number) {
- return ease(segment(t, 17.4, 18.6));
-}
-
-/** A bracketed plate, `[ WORD ]`, centred on x, the word cut to fit. */
-function plate(
- scene: Scene,
- centre: number,
- y: number,
- word: string,
- color: Color,
- background: Color,
- maxCells: number
-) {
- const cells = Math.max(1, Math.min(cellsFor(word), maxCells));
- const left = Math.trunc(centre - (cells + 4) / 2);
- // `$` keeps the wall out from behind the plate.
- scene.grid.sprite(left, y, [`[$${"$".repeat(cells)}$]`], color, background);
- scene.grid.label(left + 2, y, word, color, cells, "center", background);
-}
-
-function drawTicket(
- scene: Scene,
- done: boolean[],
- rejected: boolean,
- active: number
-) {
- const { grid, layout, plan, labels } = scene;
- const width = Math.min(layout.cols - 4, 48);
- const left = Math.trunc((layout.cols - width) / 2);
- const top = Math.max(7, Math.trunc(layout.rows * 0.12));
- const inner = width - 2;
- const border = `+${"-".repeat(inner)}+`;
- for (let r = top; r <= top + 3; r++) {
- for (let c = left; c <= left + width - 1; c++) grid.blank(c, r, TICKET_BG);
- }
- grid.text(left, top, border, TICKET_LINE);
- grid.text(left, top + 3, border, TICKET_LINE);
- grid.put(left, top + 1, "|", TICKET_LINE);
- grid.put(left, top + 2, "|", TICKET_LINE);
- grid.put(left + width - 1, top + 1, "|", TICKET_LINE);
- grid.put(left + width - 1, top + 2, "|", TICKET_LINE);
-
- grid.text(left + 2, top + 1, plan.job, TICKET_JOB);
- const finished = done.every(Boolean);
- const scrapped = rejected && done[3];
- const status = scrapped
- ? labels.scrapped
- : finished
- ? labels.complete
- : labels.inProgress;
- const statusColor = scrapped ? FAIL : finished ? PASS : AMBER;
- // The status keeps up to a third of the ticket; the item takes the rest.
- const statusCells = Math.min(cellsFor(status), Math.trunc(inner / 3));
- const statusLeft = left + width - 3 - statusCells - 2;
- grid.put(statusLeft, top + 1, "●", statusColor);
- grid.label(statusLeft + 2, top + 1, status, statusColor, statusCells);
- const itemLeft = left + 3 + plan.job.length;
- grid.put(itemLeft, top + 1, "·", TICKET_TEXT);
- grid.label(
- itemLeft + 2,
- top + 1,
- labels.item,
- TICKET_TEXT,
- statusLeft - 1 - (itemLeft + 2)
- );
-
- // Four equal slots: a mark, a space, the station's name.
- const slot = Math.trunc((inner - 2) / 4);
- let x = left + 2;
- labels.stations.forEach((name, k) => {
- const isDone = done[k] ?? false;
- const failed = rejected && k === 3 && isDone;
- const mark = failed ? "✗" : isDone ? "✓" : k === active ? "●" : "○";
- const color = failed
- ? FAIL
- : isDone
- ? PASS
- : k === active
- ? AMBER
- : PENDING;
- grid.put(x, top + 2, mark, color);
- grid.label(
- x + 2,
- top + 2,
- name,
- isDone || k === active ? TICKET_TEXT : PENDING,
- slot - 3
- );
- x += slot;
- });
-}
-
-export function drawInterior(scene: Scene) {
- const { grid, layout, plan, moment, seconds, lights, labels } = scene;
- const { cols, rows, aspect } = layout;
- const t = moment.act === "line" ? moment.t : 24;
- const warmth = warmthAt(t);
- const rejected = plan.event === "reject";
-
- // Laid out from the belt up: the pumpkin on it, the station signs just
- // above the pumpkin, the lamps above the signs. So a short panel only
- // loses wall, never a sign behind the pumpkin.
- const beltY = Math.trunc(rows * 0.68);
- const floorY = beltY + Math.max(4, Math.trunc(rows * 0.09));
- const radius = Math.min(6.2, Math.max(HERO_MIN_RADIUS, rows * 0.09));
- const signY = Math.trunc(beltY - radius * 2 - 0.2) - 2;
- const lampY = signY - 4;
- const wall = mix(WALL_COLD, WALL_WARM, warmth);
- for (let r = 0; r < rows; r++) {
- for (let c = 0; c < cols; c++) {
- if (r < floorY) {
- grid.fill(c, r, wall);
- // Running bond: a mortar course every third row, the joints of
- // each course offset by half a brick. Barely above the wall until
- // a lamp lights it.
- const course = Math.trunc(r / 3);
- const joint = (c + (course % 2) * 5) % 10 === 0;
- if (r % 3 === 2) grid.put(c, r, "_", BRICK);
- else if (joint) grid.put(c, r, "|", BRICK);
- } else {
- grid.fill(c, r, FLOOR);
- if (r === floorY) grid.put(c, r, "_", FLOOR_LINE);
- else if (hash01(c * 31 + r * 7) < 0.05)
- grid.put(c, r, ".", scale(FLOOR_LINE, 0.7));
- }
- }
- }
-
- const stops = [0.17, 0.37, 0.57, 0.76].map((k) => cols * k);
- const halfWidth = radius * aspect * 1.18;
- const start = -halfWidth - 4;
- const exit = cols + halfWidth + 6;
- let x = travel(t, stops, start, exit);
- let y = beltY - radius - 0.2;
- let spin = Math.sin(seconds * 0.5) * 0.12;
- if (rejected && t > 22.5) {
- const fall = segment(t, 22.6, 24);
- y += fall * fall * rows * 0.5;
- spin += fall * 9;
- }
-
- stops.forEach((stop, k) => {
- for (let r = 0; r < lampY; r++) grid.put(stop, r, "|", scale(STEEL, 0.6));
- grid.sprite(stop - 1, lampY, LAMP, STEEL);
- const buzz = k === 2 && noise2(seconds * 3, 1, 7) > 0.8 ? 0.4 : 1;
- const color = mix(LAMP_COLD, LAMP_WARM, warmth);
- grid.put(stop, lampY + 2, "o", scale(color, buzz));
- lights.push({
- x: stop,
- y: lampY + 3,
- radius: 11,
- color,
- power: 0.28 * buzz,
- halo: 0.16 * buzz
- });
- });
-
- const beltShift = Math.trunc(x);
- for (let c = 1; c < cols - 1; c++) {
- const pattern = "=o==";
- const char = pattern[(((c - beltShift) % 4) + 4) % 4] ?? "=";
- grid.put(c, beltY, char, char === "o" ? ROLLER : BELT);
- grid.put(c, beltY + 1, "-", scale(BELT, 0.6));
- if (c % 10 === 3)
- for (let r = beltY + 2; r < floorY; r++) grid.put(c, r, "|", LEG);
- }
-
- const [wash = 0, carve = 0, light = 0, qc = 0] = stops;
- const top = y - radius;
-
- if (t >= 3.2 && t < 6.9) {
- for (let r = 0; r < top - 7; r++)
- grid.text(wash - 1, r, "||", scale(STEEL, 0.6));
- grid.sprite(wash - 1, top - 7, NOZZLE, STEEL);
- for (let k = 0; k < 6; k++) {
- const age = fraction(seconds * 1.8 + k / 6);
- grid.put(
- wash + (k % 2 ? 0 : -0.6),
- top - 4 + age * 4,
- age < 0.5 ? "'" : "|",
- WATER
- );
- }
- for (let k = 0; k < 16; k++) {
- const phase = fraction(seconds * 0.45 + k / 16);
- const bx = wash + (hash01(k * 5) - 0.5) * halfWidth * 2.4;
- const by = beltY - 1 - phase * radius * 2.6;
- const char = phase < 0.3 ? "." : phase < 0.65 ? "o" : "O";
- if (
- grid.isBlank(bx, by) ||
- grid.charAt(bx, by) === "_" ||
- grid.charAt(bx, by) === "|"
- ) {
- grid.put(bx, by, char, scale(BUBBLE, 1 - phase * 0.7));
- }
- }
- }
-
- const cells = carvedCells(plan.face);
- const carving = clamp01(segment(t, 8.6, 14));
- const revealed = t < 8.6 ? 0 : Math.trunc(cells.length * carving);
- const carved = new Set<number>();
- for (let k = 0; k < revealed; k++) {
- const cell = cells[k];
- if (cell) carved.add(cellKey(cell.x, cell.y));
- }
- const ignition = ease(segment(t, 17.4, 18.2));
- const glow =
- ignition * flicker(seconds, 21) * (1 + 0.4 * (1 - segment(t, 18.2, 19)));
-
- if (x > -halfWidth - 2 && x < cols + halfWidth + 2 && y < rows + radius) {
- drawPumpkin(grid, {
- x,
- y,
- radius,
- aspect,
- spin,
- carved,
- glow: clamp01(glow),
- seconds,
- fill: 0.32
- });
- if (ignition > 0) {
- lights.push({
- x,
- y,
- radius: 10,
- color: PUMPKIN_GLOW,
- power: 0.12 * ignition,
- halo: 0.34 * ignition
- });
- }
- }
-
- const armUp = t < 8.3 || t > 14.2;
- if (!armUp) {
- const last = cells[Math.max(0, revealed - 1)];
- const bladeX = carve + (last?.x ?? 0);
- const bladeY = Math.trunc(y) + (last?.y ?? -3) - 1;
- // A laser cutter: the arm stops above the pumpkin and the beam's
- // spark sits on the cell being cut.
- const armTop = Math.trunc(rows * 0.12);
- const head = Math.trunc(y - radius) - 1;
- for (let r = armTop; r < head; r++)
- grid.put(bladeX, r, r === head - 2 ? "o" : "|", STEEL);
- grid.put(bladeX, head, "V", BLADE);
- const sparks = ["*", "+", "x"];
- grid.put(
- bladeX,
- bladeY,
- sparks[Math.trunc(seconds * 14) % 3] ?? "*",
- BLADE
- );
- scene.lights.push({
- x: bladeX,
- y: bladeY,
- radius: 2.5,
- color: BLADE,
- power: 0.4,
- halo: 0.18
- });
- for (let k = 0; k < 10; k++) {
- const age = fraction(seconds * 2.2 + k / 10) * 0.9;
- const vx = (hash01(k * 9 + 1) - 0.5) * 16;
- grid.put(
- bladeX + vx * age,
- bladeY - 3 * age + 7 * age * age,
- k % 3 === 0 ? "," : k % 3 === 1 ? "'" : ".",
- scale(CHIP, 1 - age)
- );
- }
- } else {
- const armTop = Math.trunc(rows * 0.12);
- for (let r = armTop; r < armTop + 4; r++)
- grid.put(carve + 9, r, "|", scale(STEEL, 0.7));
- grid.put(carve + 9, armTop + 4, "v", scale(BLADE, 0.6));
- }
-
- if (t >= 15.6 && t < 17.5) {
- const cy = lerp(-3, top - 2.2, ease(segment(t, 15.6, 17.4)));
- for (let r = 0; r < cy; r++) grid.put(light, r, "|", scale(STEEL, 0.6));
- grid.sprite(light - 1, cy, CANDLE, (char) => (char === "^" ? FLAME : WAX));
- grid.put(light, cy, Math.trunc(seconds * 12) % 2 ? "^" : "'", FLAME);
- lights.push({
- x: light,
- y: cy,
- radius: 3.5,
- color: FLAME,
- power: 0.6,
- halo: 0.22
- });
- }
-
- const inspector = { x: Math.min(qc + halfWidth + 1, cols - 8), y: beltY - 5 };
- let pose = SKELETON.stand;
- if (t >= 20.5 && t < 21.2) pose = SKELETON.stampUp;
- else if (t >= 21.2 && t < 21.6) pose = SKELETON.stampDown;
- if (rejected && t > 22.8) {
- const run = segment(t, 22.8, 24);
- inspector.x = lerp(inspector.x, cols + 4, run);
- pose = Math.trunc(seconds * 8) % 2 === 0 ? SKELETON.runA : SKELETON.runB;
- }
- grid.sprite(inspector.x, inspector.y, pose, BONE);
-
- if (t >= 21.3) {
- const pop = 1 - ease(segment(t, 21.3, 21.6)) * 0.4;
- const color: Color = rejected ? FAIL : PASS;
- plate(
- scene,
- qc,
- beltY - radius * 2 - 3.5,
- (rejected ? labels.rejected : labels.passed).toLocaleUpperCase(),
- scale(color, pop + 0.4),
- TICKET_BG,
- Math.trunc(cols * 0.3)
- );
- }
-
- // Signs last, so the wash pipe and the carving arm pass behind them.
- stops.forEach((stop, k) => {
- plate(
- scene,
- stop,
- signY,
- (labels.stations[k] ?? "").toLocaleUpperCase(),
- SIGN,
- SIGN_BG,
- Math.trunc(cols * 0.19) - 4
- );
- });
-
- const done = stationsDone(t);
- const active = done.indexOf(false);
- drawTicket(scene, done, rejected, active);
-
- return { warmth };
-}
diff --git a/packages/react/src/Halloween/night-shift/layout.ts b/packages/react/src/Halloween/night-shift/layout.ts
deleted file mode 100644
index 2750c93b4d..0000000000
--- a/packages/react/src/Halloween/night-shift/layout.ts
+++ /dev/null
@@ -1,188 +0,0 @@
-// SPDX-License-Identifier: AGPL-3.0-only
-// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
-// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-
-// Where everything stands on the hill, in cells, for a grid of a given size.
-// Recomputed only when the panel resizes. The upper left stays clear for the
-// Carbon logo and the lower band is fog, behind the panel's headline.
-
-import { floorOf, seeded } from "../math";
-import { fbm2, noise2 } from "./noise";
-import { hashSeed } from "./random";
-
-export type Point = { x: number; y: number };
-
-export type StoneKind = "rip" | "small" | "cross" | "round";
-
-export type Layout = {
- cols: number;
- rows: number;
- /** Cell height over cell width: how many columns make one row of distance. */
- aspect: number;
- /** Top row of the far hills, per column. */
- ridge: Float32Array;
- /** Top row of the near ground, per column. */
- ground: Float32Array;
- horizon: number;
- moon: { x: number; y: number; r: number };
- factory: {
- left: number;
- right: number;
- roof: number;
- base: number;
- tower: number;
- towerTop: number;
- chimney: number;
- chimneyTop: number;
- door: number;
- mast: number;
- jib: number;
- };
- /** The lantern path, from the factory door into the fog. */
- path: Point[];
- stones: { x: number; base: number; kind: StoneKind }[];
- fence: { left: number; right: number; top: number };
- cat: Point;
- crow: Point;
- patch: { left: number; right: number; y: number };
- hero: Point;
- stars: { x: number; y: number; seed: number }[];
-};
-
-export function makeLayout(cols: number, rows: number, aspect: number): Layout {
- const horizon = floorOf(rows * 0.585);
- const factoryLeft = Math.max(2, floorOf(cols * 0.05));
- const factoryRight = factoryLeft + Math.max(24, floorOf(cols * 0.25));
- const roof = horizon - Math.max(7, floorOf(rows * 0.1));
-
- const ridge = new Float32Array(cols);
- const ground = new Float32Array(cols);
- for (let c = 0; c < cols; c++) {
- ridge[c] = rows * 0.505 + rows * 0.13 * (fbm2(c * 0.03, 2.3, 4, 7) - 0.5);
- const flat = c >= factoryLeft - 2 && c <= factoryRight + 2;
- ground[c] = flat
- ? horizon
- : horizon +
- 1.6 * (noise2(c * 0.06, 0.7, 11) - 0.5) +
- (c > cols * 0.6 ? 1 : 0);
- }
-
- const moonR = Math.max(4.5, rows * 0.095);
- const moon = {
- x: cols * 0.7,
- y: Math.max(moonR + 3, rows * 0.24),
- r: moonR
- };
-
- const door = factoryLeft + floorOf((factoryRight - factoryLeft) * 0.55);
- const path: Point[] = [
- { x: door + 1, y: horizon + 0.5 },
- { x: cols * 0.34, y: rows * 0.628 },
- { x: cols * 0.46, y: rows * 0.668 },
- { x: cols * 0.58, y: rows * 0.652 },
- { x: cols * 0.7, y: rows * 0.684 },
- { x: cols * 0.83, y: rows * 0.668 },
- { x: cols * 0.99, y: rows * 0.694 }
- ];
-
- const kinds: StoneKind[] = ["rip", "cross", "small", "round", "rip"];
- const stones = kinds.map((kind, i) => ({
- kind,
- x: floorOf(cols * (0.355 + i * 0.05)),
- base: floorOf(rows * 0.622 + (i % 2) * 1.2)
- }));
-
- const fence = {
- left: floorOf(cols * 0.62),
- right: floorOf(cols * 0.88),
- top: floorOf(rows * 0.6)
- };
-
- const random = seeded(hashSeed(cols, rows));
- const stars: Layout["stars"] = [];
- const count = floorOf(cols * rows * 0.014);
- for (let i = 0; i < count * 3 && stars.length < count; i++) {
- const x = random() * cols;
- const y = random() * rows * 0.5;
- const dx = (x - moon.x) / aspect;
- const dy = y - moon.y;
- const inMoon = Math.hypot(dx, dy) < moon.r + 2;
- const column = ridge[floorOf(x)] ?? rows;
- if (inMoon || y > column - 2) continue;
- stars.push({ x, y, seed: floorOf(random() * 1e6) });
- }
-
- return {
- cols,
- rows,
- aspect,
- ridge,
- ground,
- horizon,
- moon,
- factory: {
- left: factoryLeft,
- right: factoryRight,
- roof,
- base: horizon,
- tower: factoryLeft + 6,
- towerTop: roof - 11,
- chimney: factoryRight - 5,
- chimneyTop: roof - 8,
- door,
- mast: factoryRight - 1,
- jib: roof - 6
- },
- path,
- stones,
- fence,
- cat: { x: floorOf(cols * 0.7), y: fence.top - 4 },
- crow: { x: fence.right - 4, y: fence.top - 3 },
- patch: {
- left: floorOf(cols * 0.56),
- right: floorOf(cols * 0.96),
- y: floorOf(rows * 0.745)
- },
- hero: { x: cols * 0.77, y: rows * 0.745 },
- stars
- };
-}
-
-function segmentLengths(path: Point[], aspect: number) {
- const lengths: number[] = [];
- for (let i = 1; i < path.length; i++) {
- const a = path[i - 1];
- const b = path[i];
- if (!a || !b) continue;
- lengths.push(Math.hypot((b.x - a.x) / aspect, b.y - a.y));
- }
- return lengths;
-}
-
-/** The point a fraction `s` (0 to 1) of the way along a path. */
-export function pointAlong(path: Point[], s: number, aspect: number): Point {
- const lengths = segmentLengths(path, aspect);
- const total = lengths.reduce((sum, length) => sum + length, 0);
- let rest = Math.max(0, Math.min(1, s)) * total;
- for (let i = 0; i < lengths.length; i++) {
- const length = lengths[i] ?? 0;
- const a = path[i];
- const b = path[i + 1];
- if (!a || !b) break;
- if (rest <= length || i === lengths.length - 1) {
- const k = length === 0 ? 0 : Math.min(1, rest / length);
- return { x: a.x + (b.x - a.x) * k, y: a.y + (b.y - a.y) * k };
- }
- rest -= length;
- }
- return path[0] ?? { x: 0, y: 0 };
-}
-
-/**
- * Where lantern `index` of `count` stands: the oldest furthest along the
- * path, into the fog; the newest nearest the factory door.
- */
-export function lanternSlot(index: number, capacity: number) {
- const spacing = 0.86 / capacity;
- return 0.97 - index * spacing;
-}
diff --git a/packages/react/src/Halloween/night-shift/noise.ts b/packages/react/src/Halloween/night-shift/noise.ts
deleted file mode 100644
index 6bbbccd9fb..0000000000
--- a/packages/react/src/Halloween/night-shift/noise.ts
+++ /dev/null
@@ -1,53 +0,0 @@
-// SPDX-License-Identifier: AGPL-3.0-only
-// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
-// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-
-// Smooth value noise for fog, moon craters, ridges and candle flicker.
-
-import { ease, floorOf } from "../math";
-
-function lattice(x: number, y: number, seed: number) {
- let h =
- Math.imul(x, 374761393) +
- Math.imul(y, 668265263) +
- Math.imul(seed, 1442695041);
- h = Math.imul(h ^ (h >>> 13), 1274126177);
- return ((h ^ (h >>> 16)) >>> 0) / 4294967296;
-}
-
-/** Value noise in [0, 1], continuous in x and y. */
-export function noise2(x: number, y: number, seed = 0) {
- const x0 = floorOf(x);
- const y0 = floorOf(y);
- const fx = ease(x - x0);
- const fy = ease(y - y0);
- const a = lattice(x0, y0, seed);
- const b = lattice(x0 + 1, y0, seed);
- const c = lattice(x0, y0 + 1, seed);
- const d = lattice(x0 + 1, y0 + 1, seed);
- const top = a + (b - a) * fx;
- const bottom = c + (d - c) * fx;
- return top + (bottom - top) * fy;
-}
-
-/** Fractal noise: `octaves` layers of `noise2`, each finer and fainter. */
-export function fbm2(x: number, y: number, octaves = 3, seed = 0) {
- let sum = 0;
- let amplitude = 0.5;
- let frequency = 1;
- let norm = 0;
- for (let i = 0; i < octaves; i++) {
- sum += amplitude * noise2(x * frequency, y * frequency, seed + i * 17);
- norm += amplitude;
- amplitude *= 0.5;
- frequency *= 2.03;
- }
- return sum / norm;
-}
-
-/** A candle's flicker over time, in [0, 1]; mostly bright, now and then a dip. */
-export function flicker(seconds: number, seed = 0) {
- const slow = noise2(seconds * 1.7, 0.5, seed);
- const fast = noise2(seconds * 9.3, 3.5, seed + 5);
- return Math.min(1, 0.55 + 0.35 * slow + 0.2 * fast);
-}
diff --git a/packages/react/src/Halloween/night-shift/paint.ts b/packages/react/src/Halloween/night-shift/paint.ts
deleted file mode 100644
index 5e837b789d..0000000000
--- a/packages/react/src/Halloween/night-shift/paint.ts
+++ /dev/null
@@ -1,181 +0,0 @@
-// SPDX-License-Identifier: AGPL-3.0-only
-// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
-// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-
-// Paints a frame onto a canvas: the sky, the cell backgrounds, the soft
-// halos of every light, then the glyphs. Glyphs of one colour that sit side
-// by side go out as one fillText, so a frame costs a few hundred calls, not
-// one per cell. Non-ASCII glyphs (✓ ● ♪) are drawn alone and centred, since
-// a fallback font need not share the monospace advance.
-
-import type { FrameOut } from "./frame";
-import type { Grid, Label } from "./grid";
-import { blue, css, green, NO_BG, red } from "./grid";
-
-export type Metrics = {
- /** Cell size in CSS pixels. */
- cellWidth: number;
- cellHeight: number;
- /** Where the grid starts, to centre it in the canvas. */
- offsetX: number;
- offsetY: number;
- font: string;
- width: number;
- height: number;
- horizonRow: number;
-};
-
-const styles = new Map<number, string>();
-
-function style(color: number) {
- let value = styles.get(color);
- if (!value) {
- value = css(color);
- styles.set(color, value);
- }
- return value;
-}
-
-function rgba(color: number, alpha: number) {
- return `rgba(${red(color)},${green(color)},${blue(color)},${alpha})`;
-}
-
-/** Drops the lowest bits so neighbouring glyphs share a colour and a run. */
-function quantize(color: number) {
- return color & 0xf8f8f8;
-}
-
-// Graphemes, so a cut never splits a letter from its marks.
-const graphemes = new Intl.Segmenter(undefined, { granularity: "grapheme" });
-
-/** A label's whole string over its cells, cut with an ellipsis to fit. */
-function drawLabel(ctx: CanvasRenderingContext2D, label: Label, m: Metrics) {
- const room = label.cells * m.cellWidth;
- let text = label.text;
- if (ctx.measureText(text).width > room) {
- const parts = Array.from(graphemes.segment(text), (part) => part.segment);
- while (parts.length > 0 && ctx.measureText(`${text}…`).width > room) {
- parts.pop();
- text = parts.join("");
- }
- text = `${text}…`;
- }
- const left = m.offsetX + label.x * m.cellWidth;
- ctx.fillStyle = style(quantize(label.color));
- ctx.textAlign = label.align;
- ctx.fillText(
- text,
- label.align === "center" ? left + room / 2 : left,
- m.offsetY + label.y * m.cellHeight + m.cellHeight / 2
- );
-}
-
-export function paint(
- ctx: CanvasRenderingContext2D,
- grid: Grid,
- frame: FrameOut,
- m: Metrics
-) {
- const { cellWidth: cw, cellHeight: ch, offsetX: ox, offsetY: oy } = m;
-
- const sky = ctx.createLinearGradient(0, 0, 0, oy + m.horizonRow * ch);
- sky.addColorStop(0, style(frame.sky.top));
- sky.addColorStop(1, style(frame.sky.horizon));
- ctx.globalCompositeOperation = "source-over";
- ctx.fillStyle = sky;
- ctx.fillRect(0, 0, m.width, m.height);
-
- for (let r = 0; r < grid.rows; r++) {
- let runStart = -1;
- let runColor = NO_BG;
- const flush = (end: number) => {
- if (runStart < 0 || runColor === NO_BG) return;
- ctx.fillStyle = style(runColor);
- ctx.fillRect(
- ox + runStart * cw,
- oy + r * ch,
- (end - runStart) * cw + 0.6,
- ch + 0.6
- );
- };
- for (let c = 0; c < grid.cols; c++) {
- const bg = grid.bg[r * grid.cols + c] ?? NO_BG;
- const color = bg === NO_BG ? NO_BG : quantize(bg);
- if (color !== runColor) {
- flush(c);
- runStart = c;
- runColor = color;
- }
- }
- flush(grid.cols);
- }
-
- ctx.globalCompositeOperation = "lighter";
- for (const light of frame.lights) {
- const halo = light.halo ?? 0;
- if (halo <= 0.005) continue;
- const x = ox + light.x * cw;
- const y = oy + light.y * ch;
- const radius = light.radius * ch * 1.7;
- const gradient = ctx.createRadialGradient(x, y, 0, x, y, radius);
- gradient.addColorStop(0, rgba(light.color, Math.min(0.6, halo)));
- gradient.addColorStop(0.4, rgba(light.color, Math.min(0.6, halo) * 0.35));
- gradient.addColorStop(1, rgba(light.color, 0));
- ctx.fillStyle = gradient;
- ctx.fillRect(x - radius, y - radius, radius * 2, radius * 2);
- }
- ctx.globalCompositeOperation = "source-over";
-
- ctx.font = m.font;
- ctx.textBaseline = "middle";
- for (let r = 0; r < grid.rows; r++) {
- const y = oy + r * ch + ch / 2;
- let run = "";
- let runStart = 0;
- let runColor = -1;
- let pendingSpaces = 0;
- const flush = () => {
- if (run.length > 0) {
- ctx.textAlign = "left";
- ctx.fillStyle = style(runColor);
- ctx.fillText(run, ox + runStart * cw, y);
- }
- run = "";
- runColor = -1;
- pendingSpaces = 0;
- };
- for (let c = 0; c < grid.cols; c++) {
- const i = r * grid.cols + c;
- const code = grid.ch[i] ?? 32;
- if (code === 32) {
- if (run.length > 0) pendingSpaces++;
- continue;
- }
- const color = quantize(grid.fg[i] ?? 0);
- if (code > 126) {
- flush();
- ctx.textAlign = "center";
- ctx.fillStyle = style(color);
- ctx.fillText(String.fromCharCode(code), ox + c * cw + cw / 2, y);
- continue;
- }
- if (run.length > 0 && color === runColor && pendingSpaces < 6) {
- run += " ".repeat(pendingSpaces) + String.fromCharCode(code);
- pendingSpaces = 0;
- continue;
- }
- flush();
- run = String.fromCharCode(code);
- runStart = c;
- runColor = color;
- }
- flush();
- }
-
- for (const label of grid.labels) drawLabel(ctx, label, m);
-
- if (frame.flash > 0) {
- ctx.fillStyle = `rgba(232,228,255,${frame.flash * 0.45})`;
- ctx.fillRect(0, 0, m.width, m.height);
- }
-}
diff --git a/packages/react/src/Halloween/night-shift/palette.ts b/packages/react/src/Halloween/night-shift/palette.ts
deleted file mode 100644
index 68c709e527..0000000000
--- a/packages/react/src/Halloween/night-shift/palette.ts
+++ /dev/null
@@ -1,71 +0,0 @@
-// SPDX-License-Identifier: AGPL-3.0-only
-// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
-// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-
-// The Night Shift's colours, shared by every part of the scene.
-
-import { GROUND, HILL, NIGHT, SILHOUETTE } from "../scene-palette";
-import { hex } from "./grid";
-
-export const SKY_TOP = hex(NIGHT);
-export const SKY_HORIZON = hex("#1d1233");
-export const DAWN_TOP = hex("#191628");
-export const DAWN_HORIZON = hex("#5d4a68");
-export const SILHOUETTE_BG = hex(SILHOUETTE);
-export const GROUND_BG = hex(GROUND);
-export const HILL_BG = hex(HILL);
-export const RIM_EDGE = hex("#5b4a8a");
-export const DAWN_EDGE = hex("#8a7a96");
-export const STAR_DIM = hex("#3a3460");
-export const STAR_BRIGHT = hex("#ece6ff");
-export const MOON_DARK = hex("#3a3352");
-export const MOON_LIT = hex("#f4ecd6");
-export const EARTHSHINE = hex("#211b33");
-export const BAT_DARK = hex("#0b0711");
-export const BAT_RIM = hex("#5d4d86");
-export const GRASS = hex("#2e2440");
-export const GRASS_LIT = hex("#4d3d6a");
-export const TEXTURE = hex("#241a33");
-export const PATH = hex("#4a3a5c");
-export const STONE = hex("#6f6890");
-export const STONE_RIM = hex("#a49cc8");
-export const STONE_BG = hex("#17111f");
-export const RIP = hex("#3d3656");
-export const FACTORY_TEXTURE = hex("#1a1226");
-export const ROOF = hex("#4b3b70");
-export const WINDOW_OFF = hex("#2a2140");
-export const WINDOW_DIM = hex("#7a3a10");
-export const WINDOW_LIT = hex("#ffb347");
-export const DOOR_WOOD = hex("#1d120e");
-export const DOOR_OPEN = hex("#8a4a12");
-export const CHIMNEY = hex("#3d2f52");
-export const SMOKE = hex("#6a6088");
-export const CLOCK_RIM = hex("#a89a6a");
-export const CLOCK_FACE = hex("#3a2f18");
-export const CLOCK_HAND = hex("#fff1c4");
-export const STEEL = hex("#5f5874");
-export const CABLE = hex("#8a83a0");
-export const VINE = hex("#33502a");
-export const LEAF = hex("#4c7034");
-export const PUMPKIN_SHELL = hex("#9a420c");
-export const PUMPKIN_MARK = hex("#cf6a1c");
-export const FENCE = hex("#4f3d4e");
-export const CAT_LINE = hex("#3e3058");
-export const CAT_BG = hex("#07040b");
-export const CAT_EYES = hex("#d4ff5a");
-export const CROW_LINE = hex("#3a304e");
-export const CROW_EYE = hex("#ffcc33");
-export const CAW = hex("#efe8ff");
-export const LANTERN_LIGHT = hex("#ff8a2a");
-export const ALARM = hex("#ff2d2d");
-export const GHOST_GLOW = hex("#ddd8f6");
-export const GHOST_BG = hex("#272238");
-export const BONE = hex("#ece4cf");
-export const VISITOR_RIM = hex("#4f4074");
-export const SHIP_GLOW = hex("#8fd6b8");
-export const SPIDER_EYES = hex("#ff3b3b");
-export const HEAD_GLOW = hex("#ffb347");
-export const RAIN = hex("#5d5585");
-export const BOLT = hex("#f3eeff");
-export const RING = hex("#d9c98e");
-export const STAR_GOLD = hex("#ffe6a8");
diff --git a/packages/react/src/Halloween/night-shift/plant.ts b/packages/react/src/Halloween/night-shift/plant.ts
deleted file mode 100644
index aba071c7cd..0000000000
--- a/packages/react/src/Halloween/night-shift/plant.ts
+++ /dev/null
@@ -1,279 +0,0 @@
-// SPDX-License-Identifier: AGPL-3.0-only
-// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
-// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-
-// The plant: the factory with its clock tower, the crane on its roof and
-// the hero pumpkin it lifts, and the clock's bong at midnight.
-
-import {
- clamp01,
- ease,
- fraction,
- hash01,
- lerp,
- nearest,
- segment
-} from "../math";
-import { hex, mix, NO_BG, scale } from "./grid";
-import { flicker } from "./noise";
-import {
- CABLE,
- CHIMNEY,
- CLOCK_FACE,
- CLOCK_HAND,
- CLOCK_RIM,
- DOOR_OPEN,
- DOOR_WOOD,
- FACTORY_TEXTURE,
- RING,
- ROOF,
- SILHOUETTE_BG,
- SMOKE,
- STEEL,
- WINDOW_DIM,
- WINDOW_LIT,
- WINDOW_OFF
-} from "./palette";
-import { drawPumpkin } from "./pumpkin";
-import type { Scene } from "./scene";
-import { CLOCK } from "./sprites";
-import { ACTS, actStart } from "./story";
-
-const RUN_START = ACTS[0].seconds;
-
-/** The tower clock: 12 at midnight, about half past five at dawn, then back. */
-export function clockHours(scene: Scene) {
- const { moment } = scene;
- const runEnd = actStart("dawn") + 6;
- const run = (s: number) =>
- 5.6 * clamp01((s - RUN_START) / (runEnd - RUN_START));
- if (moment.act !== "dawn") return run(moment.shiftT);
- if (moment.t < 6) return run(moment.shiftT);
- return run(runEnd) * (1 - ease(segment(moment.t, 6, 8.5)));
-}
-
-function handChar(angle: number) {
- const a = ((angle % Math.PI) + Math.PI) % Math.PI;
- if (a < Math.PI / 8 || a > (7 * Math.PI) / 8) return "|";
- if (a < (3 * Math.PI) / 8) return "/";
- if (a < (5 * Math.PI) / 8) return "-";
- return "\\";
-}
-
-function strikeGlow(scene: Scene) {
- if (scene.moment.act !== "midnight") return 0;
- let glow = 0;
- for (let k = 0; k < 12; k++) {
- const age = scene.moment.t - (0.6 + k * 0.55);
- if (age >= 0 && age < 0.5) glow = Math.max(glow, 1 - age / 0.5);
- }
- return glow;
-}
-
-export function drawFactory(scene: Scene, dawn: number) {
- const { grid, layout, seconds, lights, moment, plan } = scene;
- const f = layout.factory;
- for (let r = f.roof; r < f.base + 1; r++) {
- for (let c = f.left; c <= f.right; c++) {
- grid.fill(c, r, SILHOUETTE_BG);
- grid.blank(c, r);
- if (hash01(c * 61 + r * 17) < 0.04) grid.put(c, r, ".", FACTORY_TEXTURE);
- }
- }
- for (let c = f.left; c + 2 <= f.right; c += 3) {
- grid.sprite(c, f.roof - 2, [" /|", "/$|"], ROOF, SILHOUETTE_BG);
- }
- for (const row of [f.roof + 2, f.roof + 5]) {
- if (row > f.base - 3) continue;
- for (let x = f.left + 2; x + 1 < f.right - 1; x += 4) {
- if (Math.abs(x - f.door) < 3) continue;
- const h = hash01(x * 13 + row * 7);
- if (h > 0.28) {
- const b = (0.6 + 0.4 * flicker(seconds + h * 10, x)) * (1 - dawn * 0.7);
- grid.text(x, row, "[]", mix(WINDOW_DIM, WINDOW_LIT, b));
- lights.push({
- x: x + 1,
- y: row + 0.5,
- radius: 2.2,
- color: WINDOW_LIT,
- power: 0.32 * b,
- halo: 0.05 * b
- });
- } else {
- grid.text(x, row, "[]", WINDOW_OFF);
- }
- }
- }
- const open =
- moment.act === "shipping" &&
- moment.t > 1.5 &&
- moment.t < (plan.event === "reject" ? 10 : 12.5);
- grid.sprite(
- f.door - 1,
- f.base - 3,
- [" _ ", "|$|", "|$|"],
- ROOF,
- open ? DOOR_OPEN : DOOR_WOOD
- );
- if (open) {
- lights.push({
- x: f.door,
- y: f.base - 1.5,
- radius: 4.5,
- color: WINDOW_LIT,
- power: 0.75,
- halo: 0.22
- });
- }
-
- for (let r = f.chimneyTop + 1; r < f.roof; r++) {
- grid.sprite(f.chimney - 1, r, ["|$|"], CHIMNEY, SILHOUETTE_BG);
- }
- grid.text(f.chimney - 1, f.chimneyTop, "===", ROOF);
- for (let k = 0; k < 16; k++) {
- const age = fraction(seconds * 0.11 + k / 16);
- const x =
- f.chimney + age * age * 18 + Math.sin(seconds * 0.7 + k) * age * 2;
- const y = f.chimneyTop - 1 - age * 12;
- const char =
- age < 0.18
- ? "o"
- : age < 0.5
- ? k % 2
- ? "("
- : ")"
- : age < 0.8
- ? "~"
- : ".";
- if (grid.isBlank(x, y)) grid.put(x, y, char, scale(SMOKE, 1 - age * 0.75));
- }
-
- grid.put(f.tower, f.towerTop - 1, "+", ROOF);
- grid.put(f.tower, f.towerTop, "^", ROOF);
- for (let k = 1; k <= 4; k++) {
- const y = f.towerTop + k;
- grid.put(f.tower - k - 1, y, "/", ROOF);
- grid.put(f.tower + k + 1, y, "\\", ROOF);
- for (let c = f.tower - k; c <= f.tower + k; c++) {
- grid.fill(c, y, SILHOUETTE_BG);
- grid.blank(c, y);
- }
- }
- for (let y = f.towerTop + 5; y < f.roof; y++) {
- grid.put(f.tower - 5, y, "|", ROOF);
- grid.put(f.tower + 5, y, "|", ROOF);
- for (let c = f.tower - 4; c <= f.tower + 4; c++) {
- grid.fill(c, y, SILHOUETTE_BG);
- grid.blank(c, y);
- }
- }
- const strike = strikeGlow(scene);
- const face = mix(CLOCK_FACE, hex("#7a6430"), strike * 0.6);
- grid.sprite(f.tower - 3, f.towerTop + 5, CLOCK, CLOCK_RIM, face);
- const center = { x: f.tower, y: f.towerTop + 7 };
- const hours = clockHours(scene);
- const minute = fraction(hours) * Math.PI * 2;
- const hour = (hours / 12) * Math.PI * 2;
- for (const k of [1, 2]) {
- grid.put(
- center.x + nearest(Math.sin(minute) * k),
- center.y + nearest(-Math.cos(minute) * k * 0.5),
- handChar(minute),
- CLOCK_HAND
- );
- }
- const hx = center.x + nearest(Math.sin(hour) * 1.2);
- const hy = center.y + nearest(-Math.cos(hour) * 0.6);
- if (hx !== center.x || hy !== center.y)
- grid.put(hx, hy, handChar(hour), scale(CLOCK_HAND, 0.85));
- grid.put(center.x, center.y, "o", CLOCK_HAND);
- lights.push({
- x: center.x,
- y: center.y,
- radius: 3 + strike * 5,
- color: hex("#ffd98a"),
- power: 0.25 + strike * 0.8,
- halo: 0.1 + strike * 0.3
- });
-}
-
-/** The crane on the roof, and the hero pumpkin while it hangs from it. */
-export function drawCraneAndHero(scene: Scene) {
- const { grid, layout, moment, seconds } = scene;
- const f = layout.factory;
- const stub = 4;
- const reach = Math.max(stub, Math.trunc(layout.hero.x - f.mast));
- const heroRadius =
- moment.act === "midnight"
- ? 1.05
- : 1.05 +
- 1.15 * ease(segment(moment.t, 2.5, 6.5)) +
- 0.05 * Math.sin(seconds * 3);
- const heroTop = layout.hero.y - heroRadius;
- const t = moment.act === "harvest" ? moment.t : -1;
-
- let length = stub;
- let hookY = f.jib + 2;
- let carried = false;
- if (t >= 0) {
- if (t < 8) length = lerp(stub, reach, ease(segment(t, 6, 8)));
- else if (t < 11.5) length = reach;
- else length = lerp(reach, stub, ease(segment(t, 11.5, 13.2)));
- if (t >= 8 && t < 9.5)
- hookY = lerp(f.jib + 2, heroTop - 1, ease(segment(t, 8, 9.5)));
- else if (t >= 9.5 && t < 10) hookY = heroTop - 1;
- else if (t >= 10 && t < 13.2)
- hookY = lerp(heroTop - 1, f.jib + 3, ease(segment(t, 10, 11.5)));
- else if (t >= 13.2)
- hookY = lerp(f.jib + 3, f.roof + 2, ease(segment(t, 13.2, 14)));
- carried = t >= 10;
- }
- const L = Math.trunc(length);
- for (let y = f.jib; y < f.roof; y++) grid.put(f.mast, y, "H", STEEL);
- for (let k = 1; k <= L; k++) {
- grid.put(f.mast + k, f.jib, k === L ? ">" : "=", STEEL);
- if (k < L)
- grid.put(f.mast + k, f.jib + 1, k % 2 ? "\\" : "/", scale(STEEL, 0.7));
- }
- const hookX = f.mast + L - 1;
- for (let y = f.jib + 1; y < hookY; y++) grid.put(hookX, y, "|", CABLE);
- grid.put(hookX, hookY, "J", CABLE);
-
- // Lowered through the roof hatch at the end of the harvest: gone inside.
- const sunk = t >= 13.2 && hookY + 1 > f.roof - 1;
- const showHero =
- moment.act === "midnight" || (moment.act === "harvest" && !sunk);
- if (!showHero) return;
- const center = carried
- ? { x: hookX + 0.5, y: hookY + 1 + heroRadius }
- : { x: layout.hero.x, y: layout.hero.y };
- drawPumpkin(grid, {
- x: center.x,
- y: center.y,
- radius: heroRadius,
- aspect: layout.aspect,
- spin: seconds * 0.4,
- seconds
- });
-}
-
-export function drawBong(scene: Scene) {
- const { grid, layout, moment } = scene;
- if (moment.act !== "midnight") return;
- const origin = { x: layout.factory.tower, y: layout.factory.towerTop + 7 };
- for (let k = 0; k < 12; k++) {
- const age = moment.t - (0.6 + k * 0.55);
- if (age < 0 || age > 1.8) continue;
- const radius = age * 15;
- const strength = 1 - age / 1.8;
- const samples = Math.max(12, Math.trunc(radius * layout.aspect * 6));
- for (let s = 0; s < samples; s++) {
- const a = (s / samples) * Math.PI * 2;
- const x = origin.x + Math.cos(a) * radius * layout.aspect;
- const y = origin.y + Math.sin(a) * radius;
- if (!grid.isBlank(x, y) || grid.bg[grid.index(x, y)] !== NO_BG) continue;
- const char = strength > 0.66 ? "*" : strength > 0.33 ? ":" : ".";
- grid.put(x, y, char, scale(RING, strength * 0.8));
- }
- }
-}
diff --git a/packages/react/src/Halloween/night-shift/pumpkin.ts b/packages/react/src/Halloween/night-shift/pumpkin.ts
deleted file mode 100644
index 9a2b38ce24..0000000000
--- a/packages/react/src/Halloween/night-shift/pumpkin.ts
+++ /dev/null
@@ -1,141 +0,0 @@
-// SPDX-License-Identifier: AGPL-3.0-only
-// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
-// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-
-// Pumpkins, shaded as solids: each cell inside the outline gets a surface
-// normal, the moon lights it from the upper right, and the ribs darken it in
-// grooves that turn as the pumpkin turns. Carved cells show the candle
-// inside, flickering.
-
-import type { Face } from "./faces";
-import { cellKey, miniFace } from "./faces";
-import type { Color, Grid } from "./grid";
-import { hex, mix, scale } from "./grid";
-import { noise2 } from "./noise";
-
-const RIND_RAMP = ".:-=+*#%@";
-const GLOW_RAMP = "+*%#@";
-
-const RIND_DARK = hex("#2a0e04");
-const RIND_LIT = hex("#ff8c22");
-const RIM = hex("#9b8cd0");
-const GLOW_DIM = hex("#c2410c");
-const GLOW_HOT = hex("#fff4cc");
-const HOLE = hex("#0b0405");
-const STEM = hex("#6b7a2e");
-
-// The moon, up and to the right, a little towards the viewer.
-const LIGHT = { x: 0.55, y: -0.55, z: 0.63 };
-
-export type PumpkinLook = {
- x: number;
- y: number;
- /** Half the height in rows; the width follows from the cell aspect. */
- radius: number;
- aspect: number;
- /** Turns the ribs, in radians. */
- spin?: number;
- /** Carved cells, keyed with `cellKey`, relative to the centre. */
- carved?: ReadonlySet<number>;
- /** How brightly the candle inside burns, 0 to 1. */
- glow?: number;
- seconds: number;
- /** Overall light, so a pumpkin in deep fog or shadow can sit back. */
- ambient?: number;
- /** Light that reaches the side away from the moon, 0 to 1. */
- fill?: number;
-};
-
-/** Draws a pumpkin and returns the cells its carved face covers. */
-export function drawPumpkin(grid: Grid, look: PumpkinLook) {
- const { x, y, radius, aspect, seconds } = look;
- const rx = radius * aspect * 1.18;
- const ry = radius;
- const spin = look.spin ?? 0;
- const glow = look.glow ?? 0;
- const ambient = look.ambient ?? 1;
- const fill = look.fill ?? 0.12;
- const top = Math.trunc(y - ry) - 1;
- const bottom = Math.trunc(y + ry) + 1;
- const left = Math.trunc(x - rx) - 1;
- const right = Math.trunc(x + rx) + 1;
- for (let row = top; row <= bottom; row++) {
- for (let col = left; col <= right; col++) {
- const nx = (col + 0.5 - x) / rx;
- const ny = (row + 0.5 - y) / ry;
- const d2 = nx * nx + ny * ny;
- if (d2 > 1) continue;
- const nz = Math.sqrt(1 - d2);
- const dx = col - Math.trunc(x);
- const dy = row - Math.trunc(y);
- if (look.carved?.has(cellKey(dx, dy))) {
- if (glow > 0) {
- const heat =
- glow * (0.72 + 0.28 * noise2(seconds * 8 + dx * 0.4, dy * 0.6, 3));
- const char =
- GLOW_RAMP[
- Math.min(
- GLOW_RAMP.length - 1,
- Math.trunc(heat * GLOW_RAMP.length)
- )
- ] ?? "@";
- grid.put(col, row, char, mix(GLOW_DIM, GLOW_HOT, heat));
- grid.fill(col, row, mix(HOLE, hex("#5a1a00"), heat));
- } else {
- grid.blank(col, row, HOLE);
- }
- continue;
- }
- const lambert = Math.max(0, nx * LIGHT.x + ny * LIGHT.y + nz * LIGHT.z);
- const longitude = Math.atan2(nx, nz);
- const rib = 0.5 + 0.5 * Math.cos((longitude + spin) * 6);
- const groove = 0.62 + 0.38 * Math.sqrt(rib);
- // A lit lantern's rind sits back so its carved face reads.
- const brightness = Math.min(
- 1,
- (fill + (1 - fill) * lambert) * groove * ambient * (1 - 0.45 * glow)
- );
- const char =
- RIND_RAMP[
- Math.min(
- RIND_RAMP.length - 1,
- Math.trunc(brightness * RIND_RAMP.length)
- )
- ] ?? ".";
- let color = mix(RIND_DARK, RIND_LIT, brightness);
- if (d2 > 0.7 && nx > 0.15 && ny < 0.1) color = mix(color, RIM, 0.35);
- grid.put(col, row, char, color);
- grid.fill(col, row, scale(RIND_DARK, 0.6));
- }
- }
- grid.put(x, y - ry - 0.6, ")", STEM);
- grid.put(x + 1, y - ry - 0.6, "~", scale(STEM, 0.8));
-}
-
-const LANTERN_RIND = hex("#b4500f");
-const LANTERN_FACE = hex("#ffd36a");
-
-/** A lantern in the procession: `(^w^)`, or its back while it looks away. */
-export function drawLantern(
- grid: Grid,
- x: number,
- y: number,
- face: Face,
- options: { lit: number; away?: boolean; tint?: Color }
-) {
- const text = options.away ? "(:|:)" : miniFace(face);
- const left = x - 2;
- const lit = options.lit;
- const faceColor = options.tint ?? mix(GLOW_DIM, LANTERN_FACE, lit);
- for (let k = 0; k < text.length; k++) {
- const char = text[k] ?? " ";
- const isShell = k === 0 || k === text.length - 1 || options.away;
- grid.put(
- left + k,
- y,
- char,
- isShell ? mix(scale(LANTERN_RIND, 0.6), LANTERN_RIND, lit) : faceColor
- );
- }
- grid.put(x, y - 1, "'", STEM);
-}
diff --git a/packages/react/src/Halloween/night-shift/random.ts b/packages/react/src/Halloween/night-shift/random.ts
deleted file mode 100644
index e8d09c0826..0000000000
--- a/packages/react/src/Halloween/night-shift/random.ts
+++ /dev/null
@@ -1,36 +0,0 @@
-// SPDX-License-Identifier: AGPL-3.0-only
-// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
-// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-
-// Seeded randomness for the Night Shift. Every shift is drawn from its own
-// seed, so a shift looks the same however often it is rendered, and the
-// story can be replayed (and tested) from the seed alone.
-
-import type { Random } from "../math";
-
-/** Folds numbers into one 32-bit seed (FNV-1a over their bits). */
-export function hashSeed(...parts: number[]): number {
- let hash = 2166136261;
- for (const part of parts) {
- hash ^= part >>> 0;
- hash = Math.imul(hash, 16777619);
- hash ^= hash >>> 13;
- }
- return hash >>> 0;
-}
-
-/** Picks by weight: `[["a", 3], ["b", 1]]` gives "a" three times in four. */
-export function pickWeighted<T>(
- random: Random,
- weighted: readonly (readonly [T, number])[]
-): T {
- const total = weighted.reduce((sum, [, weight]) => sum + weight, 0);
- let roll = random() * total;
- for (const [item, weight] of weighted) {
- roll -= weight;
- if (roll < 0) return item;
- }
- const last = weighted.at(-1);
- if (!last) throw new Error("pickWeighted: empty list");
- return last[0];
-}
diff --git a/packages/react/src/Halloween/night-shift/scene.ts b/packages/react/src/Halloween/night-shift/scene.ts
deleted file mode 100644
index 9eb2b28c82..0000000000
--- a/packages/react/src/Halloween/night-shift/scene.ts
+++ /dev/null
@@ -1,75 +0,0 @@
-// SPDX-License-Identifier: AGPL-3.0-only
-// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
-// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-
-// What every scene of the Night Shift draws with: the grid, the hill's
-// layout, the shift's plan, where the story is, and what the person at the
-// login form is doing.
-
-import type { Color, Grid } from "./grid";
-import type { Layout, Point } from "./layout";
-import type { Moment, ShiftPlan } from "./story";
-
-/** A light: tints the glyphs around it and, with `halo`, glows on the canvas. */
-export type Light = {
- x: number;
- y: number;
- /** Reach, in rows. */
- radius: number;
- color: Color;
- /** How strongly it tints glyphs, 0 to about 1. */
- power: number;
- /** Opacity of the soft halo painted under the glyphs. */
- halo?: number;
-};
-
-/** The login form, as the scene reacts to it. */
-export type Watcher = {
- /** The pointer, in cells, while it is over the page. */
- pointer: Point | null;
- /** A field has focus: the cat looks at the form. */
- field: boolean;
- /** A secret field (password, one-time code) has focus: nobody looks. */
- secret: boolean;
- /** The secret is shown in clear: one lantern peeks. */
- peek: boolean;
- /** 1 just after a submit, fading to 0: every lantern flares. */
- flare: number;
- /** 1 just after an error, fading to 0: the lanterns flicker red. */
- alarm: number;
-};
-
-export const IDLE_WATCHER: Watcher = {
- pointer: null,
- field: false,
- secret: false,
- peek: false,
- flare: 0,
- alarm: 0
-};
-
-/**
- * The words the scene shows, in the user's language: the factory's four
- * stations, the job on the line's ticket, its status and the QC stamp.
- */
-export type Labels = {
- stations: readonly [string, string, string, string];
- item: string;
- inProgress: string;
- complete: string;
- scrapped: string;
- passed: string;
- rejected: string;
-};
-
-export type Scene = {
- grid: Grid;
- labels: Labels;
- layout: Layout;
- plan: ShiftPlan;
- moment: Moment;
- /** Seconds since the story started: drives flicker and drift. */
- seconds: number;
- watcher: Watcher;
- lights: Light[];
-};
diff --git a/packages/react/src/Halloween/night-shift/sky.ts b/packages/react/src/Halloween/night-shift/sky.ts
deleted file mode 100644
index 7069b9825d..0000000000
--- a/packages/react/src/Halloween/night-shift/sky.ts
+++ /dev/null
@@ -1,341 +0,0 @@
-// SPDX-License-Identifier: AGPL-3.0-only
-// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
-// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-
-// The sky over the hill: stars, the moon, bats, the witching hour's
-// visitors, rain and lightning. Also when the dawn and the Great Lighting
-// are, and what sits in front of the moon, which the hill and plant read.
-
-import { clamp01, ease, fraction, hash01, lerp, segment } from "../math";
-import type { Color } from "./grid";
-import { hex, mix, scale } from "./grid";
-import { fbm2, noise2 } from "./noise";
-import {
- BAT_DARK,
- BAT_RIM,
- BOLT,
- CABLE,
- DAWN_EDGE,
- EARTHSHINE,
- HEAD_GLOW,
- MOON_DARK,
- MOON_LIT,
- RAIN,
- SHIP_GLOW,
- SPIDER_EYES,
- STAR_BRIGHT,
- STAR_DIM,
- VISITOR_RIM
-} from "./palette";
-import type { Scene } from "./scene";
-import { BAT, BOO, HORSEMAN, SHIP, SPIDER, WITCH } from "./sprites";
-
-/** How far into the dawn: the sky pales, then the clock spins back. */
-export function dawnAt(scene: Scene) {
- return scene.moment.act === "dawn" ? ease(segment(scene.moment.t, 0, 6)) : 0;
-}
-
-/** Seconds into the Great Lighting (the witching hour, then the dawn). */
-export function lightingTime(scene: Scene) {
- const { moment } = scene;
- if (moment.act === "witching") return moment.t;
- if (moment.act === "dawn") return 14 + moment.t;
- return -1;
-}
-
-/**
- * Where the moon is. On the shift of the Great Lighting it sets behind the
- * hills as the lanterns rise, and leaves them the sky.
- */
-function moonAt(scene: Scene) {
- const { moon, horizon } = scene.layout;
- if (!scene.plan.greatLighting) return moon;
- const T = lightingTime(scene);
- if (T < 0) return moon;
- const set = ease(segment(T, 0.5, 7));
- return { ...moon, y: lerp(moon.y, horizon + moon.r + 2, set) };
-}
-
-export function overMoon(scene: Scene, x: number, y: number) {
- const { aspect } = scene.layout;
- const moon = moonAt(scene);
- const dx = (x + 0.5 - moon.x) / (moon.r * aspect);
- const dy = (y + 0.5 - moon.y) / moon.r;
- return dx * dx + dy * dy <= 1;
-}
-
-/** A silhouette's glyph colour: black against the moon, rim-lit elsewhere. */
-export function silhouette(scene: Scene, dark: Color, rim: Color) {
- return (x: number, y: number) => (overMoon(scene, x, y) ? dark : rim);
-}
-
-export function drawStars(scene: Scene, dawn: number) {
- const { grid, layout, seconds } = scene;
- for (const star of layout.stars) {
- const v = noise2(seconds * 0.7 + star.seed * 0.013, star.seed % 97);
- const shine = (0.3 + 0.7 * v) * (1 - dawn);
- if (shine < 0.14) continue;
- const char = v > 0.8 ? "*" : v > 0.64 ? "+" : v > 0.4 ? "." : "'";
- grid.put(star.x, star.y, char, mix(STAR_DIM, STAR_BRIGHT, shine));
- }
-}
-
-const MOON_RAMP = " .:-=+*#%@";
-
-export function drawMoon(scene: Scene, dawn: number) {
- const { grid, layout, plan, lights } = scene;
- const { aspect } = layout;
- const moon = moonAt(scene);
- const angle = plan.moonPhase * Math.PI * 2;
- const lx = Math.sin(angle);
- const lz = Math.cos(angle);
- const rx = moon.r * aspect;
- for (
- let row = Math.trunc(moon.y - moon.r) - 1;
- row <= moon.y + moon.r + 1;
- row++
- ) {
- for (let col = Math.trunc(moon.x - rx) - 1; col <= moon.x + rx + 1; col++) {
- const nx = (col + 0.5 - moon.x) / rx;
- const ny = (row + 0.5 - moon.y) / moon.r;
- const d2 = nx * nx + ny * ny;
- if (d2 > 1) continue;
- const nz = Math.sqrt(1 - d2);
- const facing = nx * lx + nz * lz;
- const lit = clamp01((facing + 0.06) / 0.2);
- const maria = clamp01(
- (fbm2(nx * 2.4 + 3, ny * 2.4 + 1, 3, 5) - 0.5) / 0.16
- );
- const crater = noise2(nx * 9 + 1, ny * 9 + 4, 9) > 0.78 ? 0.75 : 1;
- const brightness = lit * (0.7 + 0.3 * nz) * (1 - 0.35 * maria) * crater;
- if (brightness < 0.07) {
- if ((col + row) % 2 === 0) grid.put(col, row, ".", EARTHSHINE);
- continue;
- }
- const index = Math.min(
- MOON_RAMP.length - 1,
- Math.trunc(brightness * MOON_RAMP.length)
- );
- grid.put(
- col,
- row,
- MOON_RAMP[index] ?? "@",
- mix(MOON_DARK, mix(MOON_LIT, DAWN_EDGE, dawn * 0.5), brightness)
- );
- }
- }
- const illumination = (1 + lz) / 2;
- lights.push({
- x: moon.x,
- y: moon.y,
- radius: moon.r * 3,
- color: hex("#b9b0e0"),
- power: 0,
- halo: (0.08 + 0.14 * illumination) * (1 - dawn * 0.6)
- });
-}
-
-function batTargets(scene: Scene) {
- const { cols, rows } = scene.layout;
- const targets: { x: number; y: number }[] = [];
- const spacingX = 2;
- const spacingY = 1;
- const letterWidth = spacingX * 5 + 4;
- const left = cols * 0.4 - (letterWidth * BOO.length) / 2;
- BOO.forEach((letter, k) => {
- letter.forEach((line, row) => {
- for (let col = 0; col < line.length; col++) {
- if (line[col] !== "#") continue;
- targets.push({
- x: left + k * letterWidth + col * spacingX,
- y: rows * 0.13 + row * spacingY
- });
- }
- });
- });
- return targets;
-}
-
-export function drawBats(scene: Scene) {
- const { grid, layout, plan, moment, seconds } = scene;
- const t = moment.shiftT;
- if (t > 16) return;
- const boo = plan.event === "boo";
- const targets = boo ? batTargets(scene) : [];
- const count = boo ? targets.length : 12;
- const belfry = { x: layout.factory.tower, y: layout.factory.towerTop + 2 };
- const shade = silhouette(scene, BAT_DARK, BAT_RIM);
- for (let i = 0; i < count; i++) {
- const start = 1 + i * (boo ? 0.06 : 0.13);
- const u = (t - start) / (boo ? 11 : 8.5);
- if (u < 0 || u > 1) continue;
- const r1 = hash01(i * 7 + plan.index * 131);
- const r2 = hash01(i * 13 + 5);
- const control = {
- x: layout.moon.x + (r1 - 0.5) * layout.moon.r * layout.aspect * 2.6,
- y: layout.moon.y + (r2 - 0.5) * layout.moon.r * 2.2
- };
- const exit = {
- x: layout.cols + 6 + r1 * 10,
- y: layout.rows * (0.02 + hash01(i * 31 + 2) * 0.16)
- };
- const a = (1 - u) * (1 - u);
- const b = 2 * (1 - u) * u;
- const c = u * u;
- let x = a * belfry.x + b * control.x + c * exit.x;
- let y =
- a * belfry.y +
- b * control.y +
- c * exit.y +
- Math.sin(seconds * 9 + i) * 0.5;
- const target = targets[i];
- let folded = false;
- if (target) {
- const w = ease(segment(t, 3.4, 4.8)) * (1 - ease(segment(t, 7.4, 8.4)));
- x = lerp(x, target.x, w);
- y = lerp(y, target.y, w);
- // In formation each bat hangs as one glyph, so the letters read.
- folded = w > 0.85;
- }
- if (folded) {
- grid.put(x, y, "v", shade(x, y));
- continue;
- }
- const frame =
- BAT[Math.trunc(seconds * 11 + i * 0.37) % BAT.length] ?? "-v-";
- for (let k = 0; k < frame.length; k++) {
- grid.put(x - 1 + k, y, frame[k] ?? " ", shade(x - 1 + k, y));
- }
- }
-}
-
-export function drawSkyVisitor(scene: Scene) {
- const { grid, layout, plan, moment, seconds, lights } = scene;
- if (moment.act !== "witching" || plan.greatLighting) return;
- const t = moment.t;
- const { moon, cols } = layout;
- const shade = silhouette(scene, BAT_DARK, VISITOR_RIM);
- if (plan.visitor === "witch") {
- const u = segment(t, 2, 12);
- if (u <= 0 || u >= 1) return;
- const x = lerp(cols + 4, -22, u);
- const y = moon.y - 3 + Math.sin(t * 1.3) * 1.4;
- const cape = WITCH.cape[Math.trunc(seconds * 5) % 2] ?? "";
- const art = [...WITCH.body.slice(0, 4), cape, WITCH.broom];
- grid.sprite(x, y, art, (_char, col, row) => shade(x + col, y + row));
- return;
- }
- if (plan.visitor === "ship") {
- const u = segment(t, 1.5, 13);
- if (u <= 0 || u >= 1) return;
- const x = lerp(-30, cols + 2, u);
- const y = moon.y - 2 + Math.sin(t * 0.9) * 0.6;
- grid.sprite(x, y, SHIP, (_char, col, row) =>
- overMoon(scene, x + col, y + row) ? hex("#163a30") : SHIP_GLOW
- );
- lights.push({
- x: x + 13,
- y: y + 3,
- radius: 6,
- color: SHIP_GLOW,
- power: 0.15,
- halo: 0.12
- });
- return;
- }
- if (plan.visitor === "spider") {
- const down = ease(segment(t, 1.5, 5));
- const up = ease(segment(t, 10, 13));
- const drop = down * (1 - up);
- if (drop <= 0) return;
- const x = moon.x - 6;
- const y = lerp(-6, moon.y - 1, drop) + Math.sin(seconds * 1.6) * 0.4 * drop;
- for (let r = 0; r < y; r++) grid.put(x + 6, r, "|", scale(CABLE, 0.7));
- grid.sprite(x, y, SPIDER, (char, col, row) =>
- char === "o" ? SPIDER_EYES : shade(x + col, y + row)
- );
- lights.push({
- x: x + 6,
- y: y + 1,
- radius: 1.6,
- color: SPIDER_EYES,
- power: 0.3,
- halo: 0.08
- });
- }
-}
-
-export function drawHorseman(scene: Scene) {
- const { grid, layout, plan, moment, seconds, lights } = scene;
- if (
- moment.act !== "witching" ||
- plan.greatLighting ||
- plan.visitor !== "horseman"
- )
- return;
- const u = segment(moment.t, 2, 11);
- if (u <= 0 || u >= 1) return;
- const x = lerp(-22, layout.cols + 2, u);
- const column = Math.trunc(x + 10);
- const ground =
- layout.ridge[Math.max(0, Math.min(layout.cols - 1, column))] ??
- layout.horizon;
- const gallop = Math.trunc(seconds * 8) % 2;
- const y = ground - 4.6 - (gallop ? 0.4 : 0);
- const legs = HORSEMAN.legs[gallop] ?? "";
- grid.sprite(x, y, [...HORSEMAN.body, legs], (char) =>
- char === "@" || char === "(" || char === ")" ? HEAD_GLOW : VISITOR_RIM
- );
- lights.push({
- x: x + 12,
- y,
- radius: 2.5,
- color: HEAD_GLOW,
- power: 0.5,
- halo: 0.2
- });
-}
-
-export function drawRain(scene: Scene) {
- const { grid, layout, plan, moment, seconds } = scene;
- if (plan.weather !== "drizzle") return;
- const heavy = moment.act === "witching" ? 1.7 : 1;
- const count = Math.trunc(layout.cols * 0.45 * heavy);
- for (let k = 0; k < count; k++) {
- const speed = 22 + hash01(k * 3) * 10;
- const y =
- fraction((seconds * speed) / (layout.rows + 6) + hash01(k * 11)) *
- (layout.rows + 6) -
- 3;
- const x = hash01(k * 17) * (layout.cols + 10) - 5 + y * 0.3;
- grid.put(x, y, k % 3 === 0 ? "," : "'", RAIN);
- }
-}
-
-/** Lightning in the witching hour: draws the bolt, returns the flash. */
-export function drawLightning(scene: Scene) {
- const { grid, layout, plan, moment } = scene;
- if (moment.act !== "witching" || plan.greatLighting) return 0;
- let flash = 0;
- const strikes = [
- 3.2 + hash01(plan.index * 3) * 1.5,
- 8.7 + hash01(plan.index * 5) * 1.8
- ];
- strikes.forEach((at, k) => {
- const age = moment.t - at;
- if (age < 0 || age > 0.6) return;
- flash = Math.max(
- flash,
- age < 0.08 ? 1 : age < 0.18 ? 0.35 : age < 0.26 ? 0.7 : 0
- );
- let x = layout.cols * (0.15 + hash01(plan.index * 7 + k) * 0.75);
- const bright = scale(BOLT, 1 - age / 0.6);
- for (let y = 0; y < (layout.ridge[Math.trunc(x)] ?? layout.horizon); y++) {
- const step = hash01(plan.index * 97 + k * 31 + y) * 3;
- const dx = step < 1 ? -1 : step < 2 ? 0 : 1;
- grid.put(x, y, dx < 0 ? "/" : dx > 0 ? "\\" : "|", bright);
- x += dx;
- }
- });
- return flash;
-}
diff --git a/packages/react/src/Halloween/night-shift/sprites.ts b/packages/react/src/Halloween/night-shift/sprites.ts
deleted file mode 100644
index 75a339e143..0000000000
--- a/packages/react/src/Halloween/night-shift/sprites.ts
+++ /dev/null
@@ -1,144 +0,0 @@
-// SPDX-License-Identifier: AGPL-3.0-only
-// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
-// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-
-// The cast, in ASCII. Spaces are transparent; `$` hides what is behind
-// without drawing a glyph, so a ghost in front of a gravestone covers it.
-// String.raw keeps the backslashes as drawn.
-
-const r = String.raw;
-
-export const GHOST = {
- open: [r` .---. `, r` /$o$o$\ `, r` |$$O$$| `, r` |$$$$$| `],
- shut: [r` .---. `, r` /$=$=$\ `, r` |$$~$$| `, r` |$$$$$| `],
- peek: [r` .---. `, r` /$o$=$\ `, r` |$$o$$| `, r` |$$$$$| `],
- hem: [r` '^v^v^' `, r` 'v^v^v' `]
-};
-
-export const SKELETON = {
- stand: [r` .-. `, r` (o.o) `, r` |=| `, r` /|=|\ `, r` / \ `],
- stampUp: [r` .-. _`, r` (o.o)|`, r` |=|/ `, r` /|=| `, r` / \ `],
- stampDown: [r` .-. `, r` (o.o) `, r` |=|__`, r` /|=| #`, r` / \ `],
- runA: [r` .-. `, r` (o.o) `, r` |=|\ `, r` /|=| `, r` / > `],
- runB: [r` .-. `, r` (o.o) `, r` /|=| `, r` |=|\ `, r` |\ `],
- danceA: [r`\ .-. /`, r` (o.o) `, r` |=| `, r` |=| `, r` / \ `],
- danceB: [r` .-. `, r` (^.^) `, r` /|=|\ `, r` |=| `, r` | \_`]
-};
-
-export const CAT = {
- ears: r` /\_/\ `,
- eyes: {
- left: r`(o o ) `,
- ahead: r`( o o ) `,
- right: r`( o o) `,
- blink: r`( - - ) `
- },
- body: [r` = ^ = `, r`/$$$$$\ `, r`(_)_(_)~`]
-};
-
-export const CROW = [r` _ `, r` (o> `, r`/)_) `, r` '' `];
-
-export const STONES = {
- rip: [r` .-. `, r`|RIP|`, r`|$$$|`],
- small: [r` __ `, r`|$$|`],
- cross: [r` | `, r`-+-`, r` | `],
- round: [r` .--. `, r`/$$$$\ `, r`|$$$$|`]
-};
-
-export const BAT = [r`\v/`, r`-v-`, r`/v\ `];
-
-export const WITCH = {
- body: [
- r` /\ `,
- r` / \ `,
- r` _/____\_ `,
- r` (o ) `,
- r` /|$$|\ `
- ],
- cape: [r` /|$$|\~ `, r` /|$$|\~~ `],
- broom: r` ===|==|===}}}} `
-};
-
-export const HORSEMAN = {
- body: [
- r` (@) `,
- r` _/| `,
- r` __,--'$$|__ `,
- r` /$$_____$$$_\_ `
- ],
- legs: [r` / / \ \/ \/ `, r` \ \ / /\ /\ `]
-};
-
-export const SPIDER = [
- r` \ || / `,
- r` \ \(oo)/ / `,
- r` -=($$)=- `,
- r` / /(__)\ \ `,
- r` / \ `
-];
-
-export const SHIP = [
- r` | | | `,
- r` )_) )_) )_) `,
- r` )___))___))___)\ `,
- r` )____)____)_____)\\ `,
- r` _____|____|____|____\\\__`,
- r` \$$$$$$$$$$$$$$$$$$$/ `
-];
-
-export const CANDLE = [r` ^ `, r`|$|`, r`|_|`];
-
-export const LAMP = [r` | `, r`/~\ `];
-
-export const NOZZLE = [r`||`, r`||`, r`\/`];
-
-export const CLOCK = [
- r` .---. `,
- r`/$$$$$\ `,
- r`|$$$$$|`,
- r`\$$$$$/`,
- r` '---' `
-];
-
-/** Dot-matrix letters for the bats' "BOO", one '#' per bat: 52 bats. */
-export const BOO = [
- ["####.", "#...#", "#...#", "####.", "#...#", "#...#", "####."],
- [".###.", "#...#", "#...#", "#...#", "#...#", "#...#", ".###."],
- [".###.", "#...#", "#...#", "#...#", "#...#", "#...#", ".###."]
-];
-
-/**
- * The Carbon mark as thirteen stars, on the logo's own 424 × 480 canvas:
- * the hexagon, then the inner shape. `MARK_EDGES` joins them.
- */
-export const MARK_STARS = [
- { x: 212, y: 0 },
- { x: 424, y: 120 },
- { x: 424, y: 360 },
- { x: 212, y: 480 },
- { x: 0, y: 360 },
- { x: 0, y: 120 },
- { x: 212, y: 110 },
- { x: 112, y: 177 },
- { x: 204, y: 240 },
- { x: 204, y: 350 },
- { x: 320, y: 300 },
- { x: 320, y: 240 },
- { x: 320, y: 180 }
-];
-
-export const MARK_EDGES: readonly (readonly [number, number])[] = [
- [0, 1],
- [1, 2],
- [2, 3],
- [3, 4],
- [4, 5],
- [5, 0],
- [6, 7],
- [7, 8],
- [8, 9],
- [9, 10],
- [10, 11],
- [11, 12],
- [12, 6]
-];
diff --git a/packages/react/src/Halloween/night-shift/story.test.ts b/packages/react/src/Halloween/night-shift/story.test.ts
deleted file mode 100644
index 3047d11f0a..0000000000
--- a/packages/react/src/Halloween/night-shift/story.test.ts
+++ /dev/null
@@ -1,111 +0,0 @@
-// SPDX-License-Identifier: AGPL-3.0-only
-// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
-// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-
-// The story's rules: one shift is ninety seconds of six acts, a shift is
-// the same however often it is drawn, the hill keeps every lantern it ships
-// (but a rejected one), and a full hill rises and starts over.
-
-import { describe, expect, it } from "vitest";
-import {
- ACTS,
- actStart,
- LANTERNS_FOR_LIGHTING,
- momentAt,
- planShift,
- processionAfter,
- SHIFT_SECONDS
-} from "./story";
-
-describe("momentAt", () => {
- it("plays the six acts in order, ninety seconds a shift", () => {
- expect(SHIFT_SECONDS).toBe(90);
- expect(ACTS.map((act) => act.id)).toEqual([
- "midnight",
- "harvest",
- "line",
- "shipping",
- "witching",
- "dawn"
- ]);
- for (const act of ACTS) {
- const moment = momentAt(actStart(act.id) + 0.5);
- expect(moment.act).toBe(act.id);
- expect(moment.t).toBeCloseTo(0.5);
- }
- });
-
- it("starts the next shift at midnight, counting from the first", () => {
- const moment = momentAt(SHIFT_SECONDS * 2 + 1, 5);
- expect(moment.shift).toBe(7);
- expect(moment.act).toBe("midnight");
- expect(moment.shiftT).toBeCloseTo(1);
- });
-});
-
-describe("planShift", () => {
- it("is the same shift however often it is drawn", () => {
- expect(planShift(42, 6)).toEqual(planShift(42, 6));
- });
-
- it("differs from shift to shift", () => {
- const faces = new Set(
- Array.from({ length: 12 }, (_, i) =>
- JSON.stringify(planShift(42, i).face)
- )
- );
- expect(faces.size).toBeGreaterThan(6);
- });
-
- it("walks the moon through its phases, one step of eight per shift", () => {
- expect(planShift(1, 0).moonPhase).toBe(0);
- expect(planShift(1, 4).moonPhase).toBe(0.5);
- expect(planShift(1, 8).moonPhase).toBe(0);
- });
-
- it("keeps every lantern it ships, until thirteen rise and the hill is empty", () => {
- for (const seed of [1, 2, 3, 7, 99]) {
- let lightings = 0;
- for (let i = 0; i < 40; i++) {
- const plan = planShift(seed, i);
- const next = planShift(seed, i + 1);
- expect(next.procession).toEqual(processionAfter(plan));
- expect(plan.procession.length).toBeLessThan(LANTERNS_FOR_LIGHTING);
- if (plan.event === "reject") {
- expect(next.procession).toHaveLength(plan.procession.length);
- } else if (plan.greatLighting) {
- lightings++;
- expect(plan.procession.length + 1).toBe(LANTERNS_FOR_LIGHTING);
- expect(next.procession).toHaveLength(0);
- } else {
- expect(next.procession).toEqual([...plan.procession, plan.face]);
- }
- }
- expect(lightings).toBeGreaterThan(0);
- }
- });
-
- it("numbers the work order by shift", () => {
- expect(planShift(1, 0).job).toBe("JOB-1031");
- expect(planShift(1, 3).job).toBe("JOB-1034");
- });
-
- it("brings every rare event and every visitor sooner or later", () => {
- const events = new Set<string>();
- const visitors = new Set<string>();
- for (let seed = 1; seed < 60; seed++) {
- for (let i = 0; i < 6; i++) {
- const plan = planShift(seed, i);
- events.add(plan.event);
- visitors.add(plan.visitor);
- }
- }
- expect([...events].sort()).toEqual(["boo", "dance", "none", "reject"]);
- expect([...visitors].sort()).toEqual([
- "horseman",
- "ship",
- "spider",
- "witch"
- ]);
- });
-});
diff --git a/packages/react/src/Halloween/night-shift/story.ts b/packages/react/src/Halloween/night-shift/story.ts
deleted file mode 100644
index 499ecb2a26..0000000000
--- a/packages/react/src/Halloween/night-shift/story.ts
+++ /dev/null
@@ -1,155 +0,0 @@
-// SPDX-License-Identifier: AGPL-3.0-only
-// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
-// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-
-// The Night Shift: a haunted plant on a hill works one shift, midnight to a
-// dawn that never comes, making one jack-o'-lantern. Every shift is seeded,
-// so it differs from the last (face, weather, visitor, moon phase, now and
-// then a rare event), and the lanterns it ships stay on the hill. When the
-// hill holds thirteen, they all rise and become the Carbon mark in the sky.
-
-import { seeded } from "../math";
-import type { Face } from "./faces";
-import { drawFace } from "./faces";
-import { hashSeed, pickWeighted } from "./random";
-
-export const ACTS = [
- { id: "midnight", seconds: 9 },
- { id: "harvest", seconds: 14 },
- { id: "line", seconds: 24 },
- { id: "shipping", seconds: 18 },
- { id: "witching", seconds: 14 },
- { id: "dawn", seconds: 11 }
-] as const;
-
-export type ActId = (typeof ACTS)[number]["id"];
-
-export const SHIFT_SECONDS = ACTS.reduce((sum, act) => sum + act.seconds, 0);
-
-/** Where the story is: which shift, which act, how far into it. */
-export type Moment = {
- shift: number;
- act: ActId;
- /** Seconds into the act. */
- t: number;
- /** 0 to 1 through the act. */
- progress: number;
- /** Seconds into the shift. */
- shiftT: number;
-};
-
-export function actStart(id: ActId) {
- let start = 0;
- for (const act of ACTS) {
- if (act.id === id) return start;
- start += act.seconds;
- }
- return start;
-}
-
-export function momentAt(seconds: number, firstShift = 0): Moment {
- const elapsed = Math.max(0, seconds);
- const shifts = Math.trunc(elapsed / SHIFT_SECONDS);
- const shiftT = elapsed - shifts * SHIFT_SECONDS;
- let start = 0;
- for (const act of ACTS) {
- if (shiftT < start + act.seconds) {
- const t = shiftT - start;
- return {
- shift: firstShift + shifts,
- act: act.id,
- t,
- progress: t / act.seconds,
- shiftT
- };
- }
- start += act.seconds;
- }
- const last = ACTS[ACTS.length - 1];
- return {
- shift: firstShift + shifts,
- act: last?.id ?? "dawn",
- t: last?.seconds ?? 0,
- progress: 1,
- shiftT
- };
-}
-
-export type Weather = "clear" | "drizzle" | "fog";
-export type Visitor = "witch" | "horseman" | "spider" | "ship";
-export type RareEvent = "none" | "reject" | "boo" | "dance";
-
-export const LANTERNS_FOR_LIGHTING = 13;
-const OPENING_LANTERNS = 4;
-
-export type ShiftPlan = {
- index: number;
- /** The work order on the line's ticket, e.g. "JOB-1031". */
- job: string;
- face: Face;
- weather: Weather;
- visitor: Visitor;
- event: RareEvent;
- /** 0 full, 0.5 new, back to full at 1; one step of eight per shift. */
- moonPhase: number;
- /** The lanterns already on the hill when the shift starts, oldest first. */
- procession: Face[];
- /** This shift's lantern fills the hill: they rise instead of a visitor. */
- greatLighting: boolean;
-};
-
-function drawShift(seed: number, index: number, procession: Face[]): ShiftPlan {
- const random = seeded(hashSeed(seed, index));
- const face = drawFace(random);
- const weather = pickWeighted<Weather>(random, [
- ["clear", 9],
- ["drizzle", 5],
- ["fog", 6]
- ]);
- const visitor = pickWeighted<Visitor>(random, [
- ["witch", 1],
- ["horseman", 1],
- ["spider", 1],
- ["ship", 1]
- ]);
- const event = pickWeighted<RareEvent>(random, [
- ["none", 17],
- ["reject", 1],
- ["boo", 1],
- ["dance", 1]
- ]);
- const greatLighting =
- event !== "reject" && procession.length + 1 >= LANTERNS_FOR_LIGHTING;
- return {
- index,
- job: `JOB-${1031 + index}`,
- face,
- weather,
- visitor,
- event,
- moonPhase: (((index % 8) + 8) % 8) / 8,
- procession,
- greatLighting
- };
-}
-
-/** The lanterns on the hill once a shift is over. */
-export function processionAfter(plan: ShiftPlan): Face[] {
- if (plan.event === "reject") return plan.procession;
- if (plan.greatLighting) return [];
- return [...plan.procession, plan.face];
-}
-
-function openingProcession(seed: number) {
- const random = seeded(hashSeed(seed, 0x0bad5eed));
- return Array.from({ length: OPENING_LANTERNS }, () => drawFace(random));
-}
-
-/** Plays the story from the first shift to `index` and returns that shift. */
-export function planShift(seed: number, index: number): ShiftPlan {
- let procession = openingProcession(seed);
- for (let k = 0; k < index; k++) {
- procession = processionAfter(drawShift(seed, k, procession));
- }
- return drawShift(seed, index, procession);
-}
diff --git a/packages/react/src/Halloween/season.ts b/packages/react/src/Halloween/season.ts
index 3a41778006..9af565f3de 100644
--- a/packages/react/src/Halloween/season.ts
+++ b/packages/react/src/Halloween/season.ts
@@ -6,12 +6,12 @@ import { halloweenTheme } from "@carbon/utils";
import useHydrated from "../hooks/useHydrated";
import { useRouteData } from "../hooks/useRouteData";
-// The one check every Halloween decoration sits behind, the sign-in page's
-// Night Shift included: the root loader's theme is Halloween. That is the
-// case for everyone on Halloween (`available` on `halloweenTheme`, applied by
-// `resolveTheme`) and for no one on any other day, so everything switches on
-// and off by itself, and the rest of the year nothing is rendered, styled or
-// listened to.
+// The one check every Halloween decoration sits behind: the root loader's
+// theme is Halloween. That is the case inside the app in season (`available`
+// on `halloweenTheme`, applied by `themeForRequest`) for everyone who has not
+// picked another theme, and for no one on any other day, so everything
+// switches on and off by itself, and the rest of the year nothing is
+// rendered, styled or listened to.
/**
* Whether the Halloween decorations are on. False on the server: they
diff --git a/packages/react/src/SeasonalTheme.tsx b/packages/react/src/SeasonalTheme.tsx
deleted file mode 100644
index b9f3bccca9..0000000000
--- a/packages/react/src/SeasonalTheme.tsx
+++ /dev/null
@@ -1,32 +0,0 @@
-// SPDX-License-Identifier: AGPL-3.0-only
-// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
-// including ports, remain AGPLv3; serving them over a network requires releasing their source.
-
-import { isSeasonalTheme } from "@carbon/utils";
-import { Trans } from "@lingui/react/macro";
-import { useRouteData } from "./hooks/useRouteData";
-import { cn } from "./utils/cn";
-
-/**
- * Whether a seasonal theme is on (the root loader rendered one). The theme
- * pickers are disabled while it is: a pick would not show until the season
- * ends.
- */
-export function useSeasonalTheme() {
- const root = useRouteData<{ theme?: string }>("/");
- return isSeasonalTheme(root?.theme);
-}
-
-/** Why a theme picker is disabled; nothing outside a season. */
-export function SeasonalThemeNotice({ className }: { className?: string }) {
- const seasonal = useSeasonalTheme();
- if (!seasonal) return null;
- return (
- <p className={cn("text-xs text-muted-foreground text-pretty", className)}>
- <Trans>
- A seasonal theme is on for everyone today. You can pick yours again once
- it ends.
- </Trans>
- </p>
- );
-}
diff --git a/packages/react/src/hooks/index.ts b/packages/react/src/hooks/index.ts
index 0d2d6052f4..cdca31a058 100644
--- a/packages/react/src/hooks/index.ts
+++ b/packages/react/src/hooks/index.ts
@@ -30,6 +30,7 @@ import { useRouteData } from "./useRouteData";
import type { Shortcut, ShortcutDefinition } from "./useShortcutKeys";
import { useShortcutKeyMap, useShortcutKeys } from "./useShortcutKeys";
import { useShortcutSequence } from "./useShortcutSequence";
+import { useThemePreview } from "./useThemePreview";
import useThrottle from "./useThrottle";
import { useUrlParams } from "./useUrlParams";
@@ -61,6 +62,7 @@ export {
useShortcutKeyMap,
useShortcutKeys,
useShortcutSequence,
+ useThemePreview,
useThrottle,
useUrlParams
};
diff --git a/packages/react/src/hooks/useThemePreview.ts b/packages/react/src/hooks/useThemePreview.ts
new file mode 100644
index 0000000000..9e3a5c5a8b
--- /dev/null
+++ b/packages/react/src/hooks/useThemePreview.ts
@@ -0,0 +1,35 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
+// including ports, remain AGPLv3; serving them over a network requires releasing their source.
+
+import { useCallback, useEffect, useRef } from "react";
+
+/**
+ * Paints a theme's variables onto `<body>` at once, ahead of the root loader.
+ * The preview outranks the theme the root document puts on `<html>`, so it is
+ * removed once `settled` (the save landed and the root revalidated) and on
+ * unmount; left behind, it would cover the theme another page renders.
+ */
+export function useThemePreview(settled: boolean) {
+ const previewed = useRef(new Set<string>());
+
+ const clear = useCallback(() => {
+ for (const key of previewed.current) {
+ document.body.style.removeProperty(`--${key}`);
+ }
+ previewed.current.clear();
+ }, []);
+
+ useEffect(() => {
+ if (settled) clear();
+ }, [settled, clear]);
+
+ useEffect(() => clear, [clear]);
+
+ return useCallback((variables: Record<string, string>) => {
+ for (const [key, value] of Object.entries(variables)) {
+ document.body.style.setProperty(`--${key}`, value);
+ previewed.current.add(key);
+ }
+ }, []);
+}
diff --git a/packages/react/src/index.tsx b/packages/react/src/index.tsx
index 1c1fe4b464..64a4bb10a5 100644
--- a/packages/react/src/index.tsx
+++ b/packages/react/src/index.tsx
@@ -313,7 +313,6 @@ import {
ResizablePanelGroup
} from "./Resizable";
import { ScrollArea, ScrollBar } from "./ScrollArea";
-import { SeasonalThemeNotice, useSeasonalTheme } from "./SeasonalTheme";
import {
Select,
SelectContent,
@@ -696,7 +695,6 @@ export {
reactNodeToString,
ScrollArea,
ScrollBar,
- SeasonalThemeNotice,
Select,
SelectContent,
SelectGroup,
@@ -780,7 +778,6 @@ export {
useModalDrawerType,
useOperatingSystem,
usePickOrderOptions,
- useSeasonalTheme,
useShortcutKeyMap,
useSidebar,
useViewport,
diff --git a/packages/utils/AGENTS.md b/packages/utils/AGENTS.md
index 0065799608..ef3ba9b32d 100644
--- a/packages/utils/AGENTS.md
+++ b/packages/utils/AGENTS.md
@@ -64,7 +64,7 @@ pnpm --filter @carbon/utils typecheck
| `planning-sizing` | `computePlanningOrders` — reorder-quantity sizing for the four reordering policies (`ComputePlanningOrdersInput` — `{ reorderingPolicy, periods, projections, todayDate, params: PlanningSizingParams }` — in, `PlanningOrderSuggestion[]` out). Pure and clock-free (`todayDate` is injected). Also `orderSizingRules(policyName, params)` — how ONE order of a policy is sized (per-order quantity, daily vs spread, maximum, minimum, multiples) — shared by MRP's change actions and the planning pages: `splitIntoOrders` (a week's summed action back into its orders; `lotSizeBatches` is the batch case) and `reducedOrderQuantity` (a Decrease's floor and multiples). Shared by the MRP engine and the item planning tab's `ItemReorderPolicy`, so both size an order the same way; `planning-sizing.test.ts` pins it against hand-computed results of the SQL `calculate_quantity_to_order` |
| `precision` | The whole numeric-precision API (re-exported from `@carbon/database/precision`): `SCALE`, `EPSILON`, `RoundingMode`, `round`, `distributeRoundingResidual`, `scrapAllowance`, `applyRate`, `deriveRate`, `isBalanced`, `assertBalanced` |
| `format` | The ONLY place display/input digit counts are chosen: `moneyFormatOptions` (settlement — the currency's decimals are floor AND ceiling), `rateFormatOptions` (per-unit RATE — those decimals are only the floor, ceiling is `SCALE`), the `PERCENT_FORMAT` / `PERCENT_POINTS_FORMAT` / `SCALE_FORMAT` constants, `cldrCurrencyDecimals`, their `format*` helpers, and `INPUT_FORMAT` / `INPUT_STEP` for editable fields. Call sites pick a KIND, never a digit count |
-| `themes` | The everyday `themes` (every picker lists them, and only them) and `seasonalThemes` (each in its own file, e.g. `halloween-theme.ts`, typed `SeasonalTheme`: an `available` window). Every theme carries its `mesh` colors. In season a seasonal theme replaces every theme for everyone; no one can pick it. `resolveTheme` (what to render for a stored name), `storedTheme` (the user's own pick, whatever is in season, falling back to `DEFAULT_THEME_NAME`), `themeByName` (any theme by name, for rendering a name already resolved), `isSeasonalTheme`, `isInSeason`. A seasonal theme declares everything about itself, so removing it touches no caller |
+| `themes` | The everyday `themes` (every picker lists them all year) and `seasonalThemes` (each in its own file, e.g. `halloween-theme.ts`, typed `SeasonalTheme`: an `available` window). Every theme carries its `mesh` colors. In season a seasonal theme replaces every theme for everyone until they pick another. `resolveTheme(name, { date, seasonalOff })` (what to render for a stored name; `seasonalOff` is the seasonal theme the browser picked away from), `pickableThemes` (what a picker lists: the in-season seasonal theme first, then `themes`), `seasonalThemeNow`, `themeForRequest` (the theme to render for a request's cookies and page: seasonal only where `isAppPath` holds, `/x`, so public pages keep the brand), `themeCookieWrites` (the cookies a pick writes, as data; each app's `setTheme` serializes them with its cookie domain), `THEME_COOKIE` / `SEASONAL_OFF_COOKIE`, `storedTheme` (the stored everyday theme, falling back to `DEFAULT_THEME_NAME`), `themeByName` (any theme by name, for rendering a name already resolved), `isSeasonalTheme`, `isInSeason`. A seasonal theme declares everything about itself, so removing it touches no caller |
| `string` | Slugify, truncate, camelCase/titleCase conversions |
| `items` | Item lookups and `getReadableIdWithRevision` (`readableId.revision`) |
| `revalidate` | `shouldRevalidate` predicates: `isSearchParamOnlyNavigation` (the root loader only; layouts do not skip their loaders, see `coding-conventions.md` → Routes) |
diff --git a/packages/utils/src/halloween-theme.ts b/packages/utils/src/halloween-theme.ts
index 959657582f..709f4b8f5a 100644
--- a/packages/utils/src/halloween-theme.ts
+++ b/packages/utils/src/halloween-theme.ts
@@ -4,17 +4,18 @@
import type { SeasonalTheme } from "./themes";
-// Seasonal theme: on October 31 it replaces every theme, for everyone, and
-// the sign-in page's Night Shift and the app decorations come with it
-// (packages/react/src/Halloween/). Nobody can pick it. To change the day or
-// widen it to a few, edit `available`; nothing else is needed. The removal
-// checklist is at the top of packages/react/src/Halloween/HalloweenLayer.tsx.
+// Seasonal theme: from October 27 to 31 it replaces every theme inside the
+// signed-in app, for everyone who has not picked another one since, and the
+// app decorations come with it (packages/react/src/Halloween/). Sign-in,
+// shared links and onboarding keep the brand theme. To change the days, edit
+// `available`; nothing else is needed. The removal checklist is
+// at the top of packages/react/src/Halloween/HalloweenLayer.tsx.
export const halloweenTheme = {
name: "halloween",
label: "Halloween",
available: {
- from: { month: 10, day: 31 },
+ from: { month: 10, day: 27 },
to: { month: 10, day: 31 }
},
mesh: {
diff --git a/packages/utils/src/themes.test.ts b/packages/utils/src/themes.test.ts
index f3c4bcd5a2..d3632487d9 100644
--- a/packages/utils/src/themes.test.ts
+++ b/packages/utils/src/themes.test.ts
@@ -11,12 +11,15 @@ import {
DEFAULT_THEME_NAME,
isInSeason,
isSeasonalTheme,
+ pickableThemes,
resolveTheme,
type SeasonalTheme,
seasonalThemes,
storedTheme,
type ThemeWindow,
themeByName,
+ themeCookieWrites,
+ themeForRequest,
themes
} from "./themes";
import { themeColorValidator } from "./types";
@@ -145,18 +148,22 @@ describe("resolveTheme on an ordinary day", () => {
});
it("returns the stored theme", () => {
- expect(resolveTheme("violet", ordinaryDay).name).toBe("violet");
+ expect(resolveTheme("violet", { date: ordinaryDay }).name).toBe("violet");
expect(storedTheme("violet").name).toBe("violet");
expect(themeByName("violet").name).toBe("violet");
expect(isSeasonalTheme("violet")).toBe(false);
});
it("falls back to the default for a removed or missing theme", () => {
- expect(resolveTheme("pumpkin-spice", ordinaryDay).name).toBe(
+ expect(resolveTheme("pumpkin-spice", { date: ordinaryDay }).name).toBe(
+ DEFAULT_THEME_NAME
+ );
+ expect(resolveTheme(undefined, { date: ordinaryDay }).name).toBe(
+ DEFAULT_THEME_NAME
+ );
+ expect(resolveTheme(null, { date: ordinaryDay }).name).toBe(
DEFAULT_THEME_NAME
);
- expect(resolveTheme(undefined, ordinaryDay).name).toBe(DEFAULT_THEME_NAME);
- expect(resolveTheme(null, ordinaryDay).name).toBe(DEFAULT_THEME_NAME);
});
});
@@ -167,23 +174,75 @@ for (const theme of seasonal) {
const dayAfter = lastDay.add({ days: 1 });
describe(`seasonal theme "${theme.name}"`, () => {
- it("is in no picker", () => {
- expect(themes.map((t) => t.name)).not.toContain(theme.name);
+ afterEach(() => {
+ vi.useRealTimers();
+ });
+
+ it("is listed first in the pickers only while in season", () => {
+ expect(pickableThemes(firstDay).map((t) => t.name)).toEqual([
+ theme.name,
+ ...themes.map((t) => t.name)
+ ]);
+ expect(pickableThemes(dayAfter)).toEqual(themes);
expect(themeColorValidator.safeParse({ theme: theme.name }).success).toBe(
- false
+ true
);
});
- it("replaces every theme for everyone while in season", () => {
+ it("replaces every theme while in season, unless the browser switched it off", () => {
for (const day of [firstDay, lastDay]) {
- expect(resolveTheme("violet", day).name).toBe(theme.name);
- expect(resolveTheme(undefined, day).name).toBe(theme.name);
+ expect(resolveTheme("violet", { date: day }).name).toBe(theme.name);
+ expect(resolveTheme(undefined, { date: day }).name).toBe(theme.name);
+ expect(
+ resolveTheme("violet", { date: day, seasonalOff: theme.name }).name
+ ).toBe("violet");
}
});
+ it("shows only inside the signed-in app", () => {
+ vi.useFakeTimers();
+ vi.setSystemTime(`${firstDay.toString()}T12:00:00Z`);
+ const picked = "theme=violet";
+ const switchedOff = `theme=violet; seasonal-theme-off=${theme.name}`;
+ expect(themeForRequest(picked, "/x").name).toBe(theme.name);
+ expect(themeForRequest(picked, "/x/sales").name).toBe(theme.name);
+ expect(themeForRequest(picked, "/login").name).toBe("violet");
+ expect(themeForRequest(picked, "/share/quote/1").name).toBe("violet");
+ expect(themeForRequest(picked, "/xylophone").name).toBe("violet");
+ expect(themeForRequest(null, "/login").name).toBe(DEFAULT_THEME_NAME);
+ expect(themeForRequest(switchedOff, "/x").name).toBe("violet");
+ });
+
+ it("is switched off by an everyday pick made inside the app", () => {
+ expect(
+ themeCookieWrites("violet", { inApp: true, date: firstDay })
+ ).toEqual([
+ { name: "theme", value: "violet", maxAge: 31536000 },
+ { name: "seasonal-theme-off", value: theme.name, maxAge: 2592000 }
+ ]);
+ });
+
+ it("stays on after a pick made outside the app or out of season", () => {
+ const storesOnly = [{ name: "theme", value: "violet", maxAge: 31536000 }];
+ expect(
+ themeCookieWrites("violet", { inApp: false, date: firstDay })
+ ).toEqual(storesOnly);
+ expect(
+ themeCookieWrites("violet", { inApp: true, date: dayAfter })
+ ).toEqual(storesOnly);
+ });
+
+ it("turns back on when picked, keeping the stored theme", () => {
+ expect(
+ themeCookieWrites(theme.name, { inApp: true, date: firstDay })
+ ).toEqual([{ name: "seasonal-theme-off", value: "", maxAge: 0 }]);
+ });
+
it("hands everyone back their own theme after its season", () => {
- expect(resolveTheme("violet", dayAfter).name).toBe("violet");
- expect(resolveTheme(theme.name, dayAfter).name).toBe(DEFAULT_THEME_NAME);
+ expect(resolveTheme("violet", { date: dayAfter }).name).toBe("violet");
+ expect(resolveTheme(theme.name, { date: dayAfter }).name).toBe(
+ DEFAULT_THEME_NAME
+ );
});
it("is never a stored pick, but renders by name", () => {
diff --git a/packages/utils/src/themes.ts b/packages/utils/src/themes.ts
index dbc9c13c1d..87ba9c16c9 100644
--- a/packages/utils/src/themes.ts
+++ b/packages/utils/src/themes.ts
@@ -4,10 +4,11 @@
import type { CalendarDate } from "@internationalized/date";
import { today } from "@internationalized/date";
+import * as cookie from "cookie";
import template from "lodash.template";
import { halloweenTheme } from "./halloween-theme";
-/** The everyday themes: what every theme picker offers, and all it offers. */
+/** The everyday themes: what every theme picker offers all year. */
export const themes = [
{
name: "zinc",
@@ -541,11 +542,11 @@ export type MeshColors = {
};
/**
- * A theme that takes over for a few days a year: while in season every
- * browser renders it, whatever theme was picked, and when the season ends
- * everyone is back on their own. No picker ever lists one. Everything about
- * it lives on the theme, so removing one is deleting its file and its
- * `seasonalThemes` entry.
+ * A theme that takes over the signed-in app for a few days a year: while in
+ * season it renders for everyone until they pick another theme, and when the
+ * season ends everyone is back on their own. Pickers list it only while it is in
+ * season. Everything about it lives on the theme, so removing one is deleting
+ * its file and its `seasonalThemes` entry.
*/
export type SeasonalTheme = {
name: string;
@@ -605,29 +606,101 @@ export function isInSeason(
}
/** The seasonal theme on now, if any. */
-function seasonalThemeNow(date?: CalendarDate): Theme | undefined {
+export function seasonalThemeNow(date?: CalendarDate): Theme | undefined {
return seasonalThemes.find((theme) => isInSeason(theme, date));
}
/**
- * The everyday theme a stored name picks, whatever is in season: what a
- * picker shows as chosen and saves. An unknown name (a theme since removed,
- * or a seasonal one) falls back to the default, so removing a theme never
- * breaks a browser that still holds its cookie.
+ * The everyday theme a stored name picks, whatever is in season. An unknown
+ * name (a theme since removed, or a seasonal one) falls back to the default,
+ * so removing a theme never breaks a browser that still holds its cookie.
*/
export function storedTheme(name: string | null | undefined): Theme {
return themes.find((candidate) => candidate.name === name) ?? defaultTheme;
}
/**
- * The theme to render for a stored name: a seasonal theme in season, for
- * everyone; otherwise the stored everyday theme (`storedTheme`).
+ * The theme to render for a stored name: a seasonal theme in season, unless
+ * this browser switched it off (`seasonalOff`, the name of the seasonal theme
+ * it picked away from); otherwise the stored everyday theme (`storedTheme`).
*/
export function resolveTheme(
name: string | null | undefined,
- date?: CalendarDate
+ {
+ date,
+ seasonalOff
+ }: { date?: CalendarDate; seasonalOff?: string | null } = {}
+): Theme {
+ const seasonal = seasonalThemeNow(date);
+ return seasonal && seasonal.name !== seasonalOff
+ ? seasonal
+ : storedTheme(name);
+}
+
+/** The everyday theme a browser picked. */
+export const THEME_COOKIE = "theme";
+
+/** The seasonal theme a browser picked away from while it was in season. */
+export const SEASONAL_OFF_COOKIE = "seasonal-theme-off";
+
+const THEME_MAX_AGE = 60 * 60 * 24 * 365;
+// Long enough to outlast a season, short enough to be gone by the next one.
+const SEASONAL_OFF_MAX_AGE = 60 * 60 * 24 * 30;
+
+/**
+ * Whether a page is inside the signed-in app (`/x`), the only place a
+ * seasonal theme shows: sign-in, shared links and onboarding keep the brand.
+ */
+export function isAppPath(pathname: string) {
+ return pathname === "/x" || pathname.startsWith("/x/");
+}
+
+export function themeForRequest(
+ cookieHeader: string | null,
+ pathname: string
): Theme {
- return seasonalThemeNow(date) ?? storedTheme(name);
+ const cookies = cookieHeader ? cookie.parse(cookieHeader) : {};
+ if (!isAppPath(pathname)) return storedTheme(cookies[THEME_COOKIE]);
+ return resolveTheme(cookies[THEME_COOKIE], {
+ seasonalOff: cookies[SEASONAL_OFF_COOKIE]
+ });
+}
+
+/** A cookie a theme pick writes; `maxAge: 0` deletes it. */
+export type ThemeCookieWrite = { name: string; value: string; maxAge: number };
+
+/**
+ * The cookies a theme pick writes. A seasonal theme turns itself back on and
+ * keeps the stored theme. An everyday theme is stored and, when picked inside
+ * the app while a seasonal theme is on, switches that one off for this
+ * browser; a pick made elsewhere (onboarding) never saw it, so leaves it on.
+ */
+export function themeCookieWrites(
+ theme: string,
+ { inApp, date }: { inApp: boolean; date?: CalendarDate }
+): ThemeCookieWrite[] {
+ if (isSeasonalTheme(theme)) {
+ return [{ name: SEASONAL_OFF_COOKIE, value: "", maxAge: 0 }];
+ }
+ const writes = [{ name: THEME_COOKIE, value: theme, maxAge: THEME_MAX_AGE }];
+ const seasonal = inApp ? seasonalThemeNow(date) : undefined;
+ if (seasonal) {
+ writes.push({
+ name: SEASONAL_OFF_COOKIE,
+ value: seasonal.name,
+ maxAge: SEASONAL_OFF_MAX_AGE
+ });
+ }
+ return writes;
+}
+
+/**
+ * The themes a picker lists: the seasonal theme first while it is in season,
+ * then every everyday theme.
+ */
+export function pickableThemes(date?: CalendarDate): readonly Theme[] {
+ const seasonal = seasonalThemeNow(date);
+ return seasonal ? [seasonal, ...themes] : themes;
}
/**
@@ -640,9 +713,8 @@ export function themeByName(name: string | null | undefined): Theme {
}
/**
- * Whether a name is a seasonal theme. While the root loader's theme is one,
- * the pickers are disabled: whatever they saved would not show until the
- * season ends.
+ * Whether a name is a seasonal theme. Picking one saves no everyday theme: it
+ * only turns the seasonal theme back on for this browser.
*/
export function isSeasonalTheme(name: string | null | undefined) {
// Typed, so it still compiles once the list is empty.
diff --git a/packages/utils/src/types.ts b/packages/utils/src/types.ts
index 8dd6fe6781..eade7cd7b3 100644
--- a/packages/utils/src/types.ts
+++ b/packages/utils/src/types.ts
@@ -3,7 +3,7 @@
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { z } from "zod";
-import { themes } from "./themes";
+import { isSeasonalTheme, themes } from "./themes";
export enum Edition {
Cloud = "cloud",
@@ -21,11 +21,17 @@ export const modeValidator = z.object({
mode: z.enum(["light", "dark", "system"])
});
-/** A theme color by name — one of `themes`. Stored per browser, like the mode. */
+/**
+ * A theme color by name — one of `themes`, or a seasonal theme (picking one
+ * turns it back on). Stored per browser, like the mode.
+ */
export const themeColorValidator = z.object({
- theme: z.string().refine((name) => themes.some((t) => t.name === name), {
- message: "Invalid theme"
- })
+ theme: z
+ .string()
+ .refine(
+ (name) => themes.some((t) => t.name === name) || isSeasonalTheme(name),
+ { message: "Invalid theme" }
+ )
});
export enum Plan {