Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
feat(shell): Mid-Autumn easter egg on first launch, replayable from Settings (#1029)
TioitWang5870f4efc1ca
diff --git a/apps/desktop/src/assets/mid-autumn-cake.webp b/apps/desktop/src/assets/mid-autumn-cake.webpnew file mode 100644index 000000000..88872f2a5Binary files /dev/null and b/apps/desktop/src/assets/mid-autumn-cake.webp differdiff --git a/apps/desktop/src/assets/mid-autumn-moon.webp b/apps/desktop/src/assets/mid-autumn-moon.webpnew file mode 100644index 000000000..e0b8399b7Binary files /dev/null and b/apps/desktop/src/assets/mid-autumn-moon.webp differdiff --git a/apps/desktop/src/features/app/AppShell.tsx b/apps/desktop/src/features/app/AppShell.tsxindex 20ec725df..9b86f7af6 100644--- a/apps/desktop/src/features/app/AppShell.tsx+++ b/apps/desktop/src/features/app/AppShell.tsx@@ -19,6 +19,7 @@ import { WorkPanel } from "../../components/workpanel/WorkPanel";import { useCopyTex } from "../../hooks/use-copy-tex";import { api } from "../../lib/api";import { PortalVisibilityProvider } from "../../lib/portal-visibility";+import { MidAutumnEggHost } from "../mid-autumn-egg/MidAutumnEggHost";import { CollapsedTitlebarActions, RoutePending } from "./chrome";import { useAppShellRuntime } from "./useAppShellRuntime";@@ -304,6 +305,7 @@ export function AppShell() {) : null}<SearchDialog open={searchOpen} onClose={() => setSearchOpen(false)} /><ToastHost />+ <MidAutumnEggHost ready={ready} showSplash={showSplash} /><ExtensionPromptHost />{page === "settings" ? <UpdateBanner /> : null}</>diff --git a/apps/desktop/src/features/mid-autumn-egg/MidAutumnEggHost.tsx b/apps/desktop/src/features/mid-autumn-egg/MidAutumnEggHost.tsxnew file mode 100644index 000000000..aebd28faf--- /dev/null+++ b/apps/desktop/src/features/mid-autumn-egg/MidAutumnEggHost.tsx@@ -0,0 +1,37 @@+import { useEffect, type ReactElement } from "react";+import {+ hasSeenMidAutumnEgg,+ markMidAutumnEggSeen,+} from "../../lib/mid-autumn-egg-preferences";+import { useMidAutumnEggStore } from "../../stores/mid-autumn-egg-store";+import { MidAutumnEggOverlay } from "./MidAutumnEggOverlay";++/**+ * Launch gate for the Mid-Autumn easter egg.+ *+ * The egg must never compete with the existing boot surface: it only opens once+ * the shell is ready AND the startup splash has finished, and only once per+ * profile. The seen flag is written before the overlay opens, so a crash during+ * playback cannot replay it on every later launch. Later launches, remounts and+ * manual replays from Settings never take this branch.+ */+export function MidAutumnEggHost({+ ready,+ showSplash,+}: {+ ready: boolean;+ showSplash: boolean;+}): ReactElement {+ const open = useMidAutumnEggStore((state) => state.open);+ const showMidAutumnEgg = useMidAutumnEggStore((state) => state.show);+ const hideMidAutumnEgg = useMidAutumnEggStore((state) => state.hide);++ useEffect(() => {+ if (!ready || showSplash) return;+ if (hasSeenMidAutumnEgg()) return;+ markMidAutumnEggSeen();+ showMidAutumnEgg();+ }, [ready, showSplash, showMidAutumnEgg]);++ return <MidAutumnEggOverlay open={open} onClose={hideMidAutumnEgg} />;+}diff --git a/apps/desktop/src/features/mid-autumn-egg/MidAutumnEggOverlay.tsx b/apps/desktop/src/features/mid-autumn-egg/MidAutumnEggOverlay.tsxnew file mode 100644index 000000000..a8277d489--- /dev/null+++ b/apps/desktop/src/features/mid-autumn-egg/MidAutumnEggOverlay.tsx@@ -0,0 +1,108 @@+import { useEffect, useRef, type ReactNode } from "react";+import { useTranslation } from "react-i18next";+import { IconClose } from "../../components/icons";+import { portalOverlay } from "../../components/ui";+// Renderer-sized copies of the two Mid-Autumn textures (same import style as+// components/BrandLogo.tsx).+import moonImageUrl from "../../assets/mid-autumn-moon.webp";+import cakeImageUrl from "../../assets/mid-autumn-cake.webp";+import { createMidAutumnEggScene, type MidAutumnEggScene } from "./scene";+import "./mid-autumn-egg.css";++/**+ * Full-screen Mid-Autumn easter egg.+ *+ * The overlay renders one canvas; the scene owns everything that is drawn+ * inside it, including the decoration layer (veil, caption, sparks) it creates+ * next to the canvas. Closing (button or Escape) destroys the scene, so the+ * animation loop and its timers never outlive the overlay.+ */+export function MidAutumnEggOverlay({+ open,+ onClose,+}: {+ open: boolean;+ onClose: () => void;+}): ReactNode {+ const { t } = useTranslation();+ const dialogRef = useRef<HTMLDivElement | null>(null);+ const canvasRef = useRef<HTMLCanvasElement | null>(null);+ const closeRef = useRef<HTMLButtonElement | null>(null);++ useEffect(() => {+ if (!open) return;+ const canvas = canvasRef.current;+ if (!canvas) return;+ const scene: MidAutumnEggScene = createMidAutumnEggScene({+ canvas,+ moonImageUrl,+ cakeImageUrl,+ // A failed texture is not fatal, but it must not vanish without a trace.+ onError: (error) => console.error("Mid-Autumn easter egg scene error", error),+ });+ scene.start();+ return () => scene.destroy();+ }, [open]);++ useEffect(() => {+ if (!open) return;+ const previouslyFocused = document.activeElement as HTMLElement | null;+ const previousOverflow = document.body.style.overflow;+ document.body.style.overflow = "hidden";+ closeRef.current?.focus();++ const onKeyDown = (event: KeyboardEvent) => {+ if (event.key === "Escape") {+ event.preventDefault();+ onClose();+ return;+ }+ if (event.key !== "Tab") return;++ const focusable = dialogRef.current?.querySelectorAll<HTMLElement>(+ 'button:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])',+ );+ if (!focusable?.length) return;+ const first = focusable[0];+ const last = focusable[focusable.length - 1];+ if (event.shiftKey && document.activeElement === first) {+ event.preventDefault();+ last.focus();+ } else if (!event.shiftKey && document.activeElement === last) {+ event.preventDefault();+ first.focus();+ }+ };++ window.addEventListener("keydown", onKeyDown);+ return () => {+ window.removeEventListener("keydown", onKeyDown);+ document.body.style.overflow = previousOverflow;+ previouslyFocused?.focus();+ };+ }, [open, onClose]);++ if (!open) return null;++ return portalOverlay(+ <div+ ref={dialogRef}+ className="overlay mid-autumn-egg-overlay"+ role="dialog"+ aria-modal="true"+ aria-label={t("settings.midAutumnEgg")}+ >+ <canvas ref={canvasRef} className="mid-autumn-egg-canvas" />+ <button+ ref={closeRef}+ type="button"+ className="mid-autumn-egg-close"+ onClick={onClose}+ aria-label={t("settings.closeEasterEgg")}+ >+ <IconClose size={16} />+ <span>{t("settings.closeEasterEgg")}</span>+ </button>+ </div>,+ );+}diff --git a/apps/desktop/src/features/mid-autumn-egg/mid-autumn-egg.css b/apps/desktop/src/features/mid-autumn-egg/mid-autumn-egg.cssnew file mode 100644index 000000000..d2488c822--- /dev/null+++ b/apps/desktop/src/features/mid-autumn-egg/mid-autumn-egg.css@@ -0,0 +1,156 @@+/* Mid-Autumn easter egg overlay.+ *+ * The scene draws everything on a single canvas and owns the decoration layer+ * (`.mid-autumn-egg-decor` with veil, caption and sparks) it appends next to the+ * canvas. Caption and spark copy is Chinese on purpose: it is artwork content,+ * not UI chrome.+ *+ * The overlay itself is opaque, so the application behind it never leaks into+ * the night sky; the first canvas frame paints the same night colour.+ */++.overlay.mid-autumn-egg-overlay {+ /* Full-screen takeover: above every other dialog inside the overlay root. */+ z-index: 100;+ padding: 0;+ overflow: hidden;+ isolation: isolate;+ background: var(--ds-bg-under);+ font-family:+ Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,+ "SF Pro Display", "PingFang SC", sans-serif;+}++.mid-autumn-egg-canvas {+ position: absolute;+ inset: 0;+ width: 100%;+ height: 100%;+ display: block;+}++/* Decoration layer: never steals pointer events from the close button. */+.mid-autumn-egg-decor {+ position: absolute;+ inset: 0;+ z-index: 1;+ overflow: hidden;+ pointer-events: none;+}++.mid-autumn-egg-veil {+ position: absolute;+ inset: 0;+ opacity: 0;+ background:+ radial-gradient(520px 300px at 78% 18%, rgba(255, 218, 148, 0.065), transparent 70%),+ linear-gradient(180deg, rgba(4, 6, 10, 0.06), rgba(4, 6, 10, 0.12));+ animation: mid-autumn-egg-veil-in 1100ms ease-out 120ms forwards;+}++@keyframes mid-autumn-egg-veil-in {+ to {+ opacity: 1;+ }+}++.mid-autumn-egg-caption {+ position: absolute;+ right: clamp(28px, 6vw, 92px);+ top: clamp(220px, 30vh, 330px);+ opacity: 0;+ transform: translateY(6px);+ text-align: right;+ color: rgba(255, 255, 255, 0.92);+ text-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);+}++.mid-autumn-egg-caption.show {+ animation: mid-autumn-egg-caption-in 900ms cubic-bezier(0.22, 0.8, 0.24, 1) forwards;+}++.mid-autumn-egg-caption-title {+ font-size: var(--text-lg-plus);+ font-weight: var(--font-weight-semibold);+ letter-spacing: var(--tracking-wide);+}++.mid-autumn-egg-caption-sub {+ margin-top: 7px;+ font-size: var(--text-sm);+ color: rgba(255, 255, 255, 0.48);+ letter-spacing: var(--tracking-wide);+}++@keyframes mid-autumn-egg-caption-in {+ to {+ opacity: 0.96;+ transform: translateY(0);+ }+}++.mid-autumn-egg-spark {+ position: absolute;+ width: 3px;+ height: 3px;+ border-radius: var(--radius-round);+ background: rgba(255, 237, 188, 0.95);+ box-shadow: 0 0 10px rgba(255, 221, 150, 0.55);+ opacity: 0;+}++.mid-autumn-egg-spark.play {+ animation: mid-autumn-egg-sparkle 1.5s ease-out forwards;+}++@keyframes mid-autumn-egg-sparkle {+ 0% {+ opacity: 0;+ transform: translate(0, 0) scale(0.3);+ }+ 18% {+ opacity: 0.95;+ }+ 100% {+ opacity: 0;+ transform: translate(var(--mid-autumn-egg-spark-dx), var(--mid-autumn-egg-spark-dy)) scale(1.15);+ }+}++/* Always-visible close affordance: high contrast, >= 32x32 hit area, focus ring. */+.mid-autumn-egg-close {+ position: absolute;+ top: 16px;+ right: 16px;+ z-index: 2;+ display: inline-flex;+ align-items: center;+ gap: 6px;+ min-width: 32px;+ min-height: 32px;+ padding: 6px 12px;+ border: 1px solid rgba(255, 255, 255, 0.3);+ border-radius: var(--radius-full);+ background: rgba(12, 16, 28, 0.72);+ color: rgba(255, 255, 255, 0.94);+ font: inherit;+ font-size: var(--text-sm-plus);+ letter-spacing: var(--tracking-wide);+ cursor: pointer;+ backdrop-filter: blur(16px);+ transition:+ background 0.2s ease,+ border-color 0.2s ease,+ color 0.2s ease;+}++.mid-autumn-egg-close:hover {+ background: rgba(32, 40, 62, 0.92);+ border-color: rgba(255, 255, 255, 0.5);+ color: #fff;+}++.mid-autumn-egg-close:focus-visible {+ outline: 2px solid var(--ds-focus);+ outline-offset: 2px;+}diff --git a/apps/desktop/src/features/mid-autumn-egg/poem-schedule.ts b/apps/desktop/src/features/mid-autumn-egg/poem-schedule.tsnew file mode 100644index 000000000..42d671bf2--- /dev/null+++ b/apps/desktop/src/features/mid-autumn-egg/poem-schedule.ts@@ -0,0 +1,180 @@+/**+ * Vertical poem layer: the pair data, the seeded schedule and the per-item+ * geometry.+ *+ * Several pairs float on screen at once. Each "lane" picks its own random gap,+ * random lifetime and random pair, so appearance time, position and font size+ * are all irregular. The schedule is precomputed once and then loops.+ */+import {+ DEFAULT_MID_AUTUMN_EGG_CONFIG,+ POEM_CHAR_STAGGER,+ POEM_COLUMN_STAGGER,+ POEM_CYCLE_TAIL_SECONDS,+ POEM_DRIFT_MIN,+ POEM_DRIFT_RANGE,+ POEM_EDGE_PADDING,+ POEM_FONT_MAX,+ POEM_FONT_MIN,+ POEM_FONT_RATIO,+ POEM_FONT_SCALE_MIN,+ POEM_FONT_SCALE_RANGE,+ POEM_GAP_BASE_SECONDS,+ POEM_GAP_RANDOM_SECONDS,+ POEM_HALF_HEIGHT_PAD_RATIO,+ POEM_HALF_WIDTH_RATIO,+ POEM_HORIZON_SECONDS,+ POEM_LIFE_BASE_SECONDS,+ POEM_LIFE_RANDOM_SECONDS,+ POEM_LINE_HEIGHT_RATIO,+ POEM_PHASE_RANGE,+ POEM_SCHEDULE_GUARD,+ POEM_SEED,+ POEM_SWAY_MIN,+ POEM_SWAY_RANGE,+ POEM_SWAY_SPEED_MIN,+ POEM_SWAY_SPEED_RANGE,+ POEM_VERTICAL_MARGIN,+ POEM_WOBBLE_MIN,+ POEM_WOBBLE_RANGE,+ clamp,+} from "./timeline";++export type PoemPair = readonly [string, string];++/** One scheduled appearance of a pair, with all of its layout parameters. */+export type PoemScheduleItem = {+ /** Seconds, relative to the start of the poem cycle. */+ start: number;+ /** Seconds, relative to the start of the poem cycle. */+ end: number;+ /** Index into `PoemSchedule.columns`. */+ pair: number;+ fontSize: number;+ lineHeight: number;+ centerX: number;+ centerY: number;+ /** Vertical drift over the whole lifetime (negative = floats upwards). */+ drift: number;+ swayAmplitude: number;+ swaySpeed: number;+ wobble: number;+ phase: number;+};++/** Precomputed poem layer: the glyph columns plus the appearance schedule. */+export type PoemSchedule = {+ /** `columns[pair][column]` is a list of code points; column 0 is the right (leading) line. */+ columns: string[][][];+ items: PoemScheduleItem[];+ /** Length of the precomputed table; the animation loops it. */+ cycle: number;+};++/**+ * Deterministic linear congruential generator, so the layout of the poem layer+ * is reproducible for a given viewport instead of being resampled every frame.+ */+export function createSeededRandom(seed: number): () => number {+ let state = seed >>> 0;+ return () => {+ state = (state * 1664525 + 1013904223) >>> 0;+ return state / 4294967296;+ };+}++export function createPoemSchedule(options: {+ width: number;+ height: number;+ /** How many pairs may be on screen at the same time (at least 1). */+ maxPairs: number;+ pairs?: readonly PoemPair[];+}): PoemSchedule {+ const { width, height, maxPairs } = options;+ const pairs = options.pairs ?? DEFAULT_MID_AUTUMN_EGG_CONFIG.poemPairs;+ const baseFontSize = clamp(+ Math.min(width, height) * POEM_FONT_RATIO,+ POEM_FONT_MIN,+ POEM_FONT_MAX,+ );+ const random = createSeededRandom(POEM_SEED);+ const laneCount = Math.max(1, Math.trunc(maxPairs));++ const columns = pairs.map(([leading, answering]) => [+ Array.from(leading),+ Array.from(answering),+ ]);+ const longestLines = pairs.map(([leading, answering]) =>+ Math.max(Array.from(leading).length, Array.from(answering).length),+ );++ const items: PoemScheduleItem[] = [];+ const laneEnds: number[] = [];+ const laneLastPairs: number[] = [];+ for (let lane = 0; lane < laneCount; lane++) {+ laneEnds.push(0);+ laneLastPairs.push(-1);+ }++ let guard = 0;+ while (guard++ < POEM_SCHEDULE_GUARD) {+ // Always extend the lane that finished first, so the lanes interleave.+ let slot = 0;+ for (let lane = 1; lane < laneCount; lane++) {+ if (laneEnds[lane] < laneEnds[slot]) slot = lane;+ }++ const start =+ laneEnds[slot] + POEM_GAP_BASE_SECONDS + random() * POEM_GAP_RANDOM_SECONDS;+ if (start > POEM_HORIZON_SECONDS) break;+ const life = POEM_LIFE_BASE_SECONDS + random() * POEM_LIFE_RANDOM_SECONDS;++ // The famous pair opens the animation; afterwards a lane never repeats its+ // own previous pair back to back.+ let pair = items.length === 0 ? pairs.length - 1 : Math.floor(random() * pairs.length);+ if (pair === laneLastPairs[slot]) pair = (pair + 1) % pairs.length;+ laneLastPairs[slot] = pair;+ laneEnds[slot] = start + life;++ const fontSize = baseFontSize * (POEM_FONT_SCALE_MIN + random() * POEM_FONT_SCALE_RANGE);+ const lineHeight = fontSize * POEM_LINE_HEIGHT_RATIO;+ const halfHeight =+ ((longestLines[pair] - 1) / 2) * lineHeight ++ fontSize * POEM_HALF_HEIGHT_PAD_RATIO;+ const halfWidth = fontSize * POEM_HALF_WIDTH_RATIO;+ const minY = halfHeight + POEM_VERTICAL_MARGIN;+ const maxY = height - halfHeight - POEM_VERTICAL_MARGIN;+ const minX = halfWidth + POEM_EDGE_PADDING;+ const maxX = width - halfWidth - POEM_EDGE_PADDING;++ items.push({+ start,+ end: start + life,+ pair,+ fontSize,+ lineHeight,+ // No fixed anchor: the pair may appear anywhere the text still fits.+ centerX: minX + random() * Math.max(1, maxX - minX),+ centerY: minY + random() * Math.max(1, maxY - minY),+ drift: -(POEM_DRIFT_MIN + random() * POEM_DRIFT_RANGE),+ swayAmplitude: POEM_SWAY_MIN + random() * POEM_SWAY_RANGE,+ swaySpeed: POEM_SWAY_SPEED_MIN + random() * POEM_SWAY_SPEED_RANGE,+ wobble: POEM_WOBBLE_MIN + random() * POEM_WOBBLE_RANGE,+ phase: random() * POEM_PHASE_RANGE,+ });+ }+ items.sort((left, right) => left.start - right.start);++ return {+ columns,+ items,+ cycle: items.length+ ? items[items.length - 1].end + POEM_CYCLE_TAIL_SECONDS+ : 1,+ };+}++/** Per-glyph phase offset used when drawing a pair. */+export function glyphPhase(item: PoemScheduleItem, column: number, index: number): number {+ return item.phase + column * POEM_COLUMN_STAGGER + index * POEM_CHAR_STAGGER;+}diff --git a/apps/desktop/src/features/mid-autumn-egg/scene.ts b/apps/desktop/src/features/mid-autumn-egg/scene.tsnew file mode 100644index 000000000..4c4b2097d--- /dev/null+++ b/apps/desktop/src/features/mid-autumn-egg/scene.ts@@ -0,0 +1,1024 @@+/**+ * Mid-Autumn easter egg engine.+ *+ * Owns the canvas, the timeline loop, the resize re-layout, the sparkle bursts+ * and the caption. The sky, stars, horizon glow, rising moon, mooncake rain and+ * column piling, the pixel-sampled text assembly and the vertical poem layer are+ * a faithful port of the verified standalone animation.+ *+ * The scene also creates and owns the small DOM decoration layer (veil, caption,+ * sparks) inside the canvas' parent, and tears it down in `destroy()`.+ */+import {+ CAKE_BOUNCE_DAMPING,+ CAKE_COLUMN_GROWTH,+ CAKE_COLUMN_GROWTH_RANDOM,+ CAKE_COLUMN_SPREAD,+ CAKE_COLUMN_WIDTH_RATIO,+ CAKE_CONTACT_RATIO,+ CAKE_FILL,+ CAKE_RADIUS_MAX,+ CAKE_RADIUS_MIN,+ CAKE_RADIUS_RATIO,+ CAKE_SPAWN_ABOVE_RANGE,+ CAKE_SPAWN_PAD_RATIO,+ CAKE_SPAWN_VX,+ CAKE_SPAWN_VY_MIN,+ CAKE_SPAWN_VY_RANGE,+ CAKE_SPIN_RANGE,+ CAKE_SPRITE_LIFT_RATIO,+ CAKE_SPRITE_PADDING_RATIO,+ CAKE_SPRITE_SUPERSAMPLE,+ CAPTION_SUBTITLE,+ CAPTION_TITLE,+ DEFAULT_MID_AUTUMN_EGG_CONFIG,+ GRAVITY_K,+ GRAVITY_MIN,+ GROUND_INSET_MIN,+ GROUND_INSET_RATIO,+ MAX_FAST_FORWARD_STEPS,+ MAX_FRAME_STEP_SECONDS,+ MOON_BREATH_AMPLITUDE,+ MOON_BREATH_SPEED,+ MOON_FILL,+ MOON_GLOW_INNER_RATIO,+ MOON_GLOW_OUTER_RATIO,+ MOON_PATH_END_MIN_RATIO,+ MOON_PATH_START_OFFSET,+ MOON_RADIUS_MAX,+ MOON_RADIUS_MIN,+ MOON_RADIUS_RATIO,+ MOON_SPARK_COUNT,+ MOON_TRAIL_MAX,+ ORIENTATION_DEBOUNCE_MS,+ POEM_ALPHA_BASE,+ POEM_ALPHA_RANGE,+ POEM_BREATHE_SPEED,+ POEM_CHAR_WOBBLE_AMPLITUDE,+ POEM_CHAR_WOBBLE_SPEED,+ POEM_COLUMN_GAP_RATIO,+ POEM_FADE_IN_FRACTION,+ POEM_FADE_OUT_FRACTION,+ POEM_GLOW_ALPHA_SCALE,+ POEM_GLOW_BLUR,+ POEM_MIN_ENVELOPE,+ RAIN_SPAWN_GUARD,+ RESIZE_DEBOUNCE_MS,+ SERIF_FONT_STACK,+ SIMULATION_STEP_SECONDS,+ SPARK_DELAY_RANGE_MS,+ SPARK_DISTANCE_MIN,+ SPARK_DISTANCE_RANGE,+ SPARK_LIFETIME_MS,+ STAR_ALPHA_MIN,+ STAR_ALPHA_RANGE,+ STAR_BAND_RATIO,+ STAR_COUNT_MAX,+ STAR_COUNT_MIN,+ STAR_DENSITY,+ STAR_RADIUS_MIN,+ STAR_RADIUS_RANGE,+ STAR_SPEED_MIN,+ STAR_SPEED_RANGE,+ STATIC_FRAME_TAIL_SECONDS,+ TEXT_ARC_LIFT,+ TEXT_ARC_LIFT_RANDOM,+ TEXT_CONTROL_SPREAD,+ TEXT_DELAY_RANDOM,+ TEXT_RECT_ASPECT,+ TEXT_RECT_CENTER_Y_RATIO,+ TEXT_RECT_MAX_HEIGHT_RATIO,+ TEXT_RECT_MAX_WIDTH,+ TEXT_RECT_WIDTH_RATIO,+ TEXT_SPARK_COUNT,+ TEXT_STACK_JITTER_RATIO,+ TRAIL_GLOW_INNER_BASE,+ TRAIL_GLOW_INNER_LIFE,+ TRAIL_LIFETIME,+ TRAIL_RADIUS_BASE,+ TRAIL_RADIUS_LIFE,+ clamp,+ createMidAutumnEggPhases,+ cubicPoint,+ easeInOutCubic,+ easeInOutQuad,+ rand,+ type MidAutumnEggConfig,+ type MidAutumnEggPhases,+ type Vec2,+} from "./timeline";+import { glyphPhase, createPoemSchedule, type PoemSchedule } from "./poem-schedule";+import { sampleTextPoints, type TextSamplePoint } from "./text-sampling";++export type MidAutumnEggSceneOptions = {+ canvas: HTMLCanvasElement;+ moonImageUrl: string;+ cakeImageUrl: string;+ /** When set, freeze the timeline at this many seconds and render one frame instead of animating (used by QA screenshots). */+ seekSeconds?: number;+ /** Called for a non-fatal failure (e.g. an asset failed to decode) instead of silently swallowing it. */+ onError?: (error: unknown) => void;+};++export type MidAutumnEggScene = { start(): void; destroy(): void };++type CakeLifecycle = "falling" | "landed" | "placed";++type Cake = {+ x: number;+ y: number;+ vx: number;+ vy: number;+ rot: number;+ rot0: number;+ spin: number;+ state: CakeLifecycle;+ targetX: number;+ targetY: number;+ originX: number;+ originY: number;+ controlX: number;+ controlY: number;+ delay: number;+};++type Star = {+ x: number;+ y: number;+ r: number;+ alpha: number;+ phase: number;+ speed: number;+};++type TrailSample = { x: number; y: number; bornAt: number };++type SparkHandle = { element: HTMLElement; timer: number };++type MoonPath = { start: Vec2; control1: Vec2; control2: Vec2; end: Vec2 };++type TextRect = { x: number; y: number; w: number; h: number };++export function createMidAutumnEggScene(+ options: MidAutumnEggSceneOptions,+): MidAutumnEggScene {+ const canvas = options.canvas;+ const maybeContext = canvas.getContext("2d");+ if (!maybeContext) {+ options.onError?.(new Error("Mid-Autumn easter egg: no 2D canvas context"));+ return { start: () => {}, destroy: () => {} };+ }+ const context: CanvasRenderingContext2D = maybeContext;++ const config: MidAutumnEggConfig = DEFAULT_MID_AUTUMN_EGG_CONFIG;+ const phases: MidAutumnEggPhases = createMidAutumnEggPhases(config);+ const reduceMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;+ const seekSeconds =+ typeof options.seekSeconds === "number" && Number.isFinite(options.seekSeconds)+ ? Math.max(0, options.seekSeconds)+ : null;++ /* ---- decoration layer owned by the scene (veil, caption, sparks) ---- */+ const container = canvas.parentElement ?? canvas.ownerDocument.body;+ const decor = document.createElement("div");+ decor.className = "mid-autumn-egg-decor";+ decor.setAttribute("aria-hidden", "true");+ const veil = document.createElement("div");+ veil.className = "mid-autumn-egg-veil";+ const caption = document.createElement("div");+ caption.className = "mid-autumn-egg-caption";+ const captionTitle = document.createElement("div");+ captionTitle.className = "mid-autumn-egg-caption-title";+ captionTitle.textContent = CAPTION_TITLE;+ const captionSubtitle = document.createElement("div");+ captionSubtitle.className = "mid-autumn-egg-caption-sub";+ captionSubtitle.textContent = CAPTION_SUBTITLE;+ caption.append(captionTitle, captionSubtitle);+ decor.append(veil, caption);+ container.appendChild(decor);++ /* ---- layout state, rebuilt by setup() ---- */+ let width = 0;+ let height = 0;+ let dpr = 1;+ let cakeRadius = 9;+ let groundY = 0;+ let columnWidth = 16;+ let columnCount = 0;+ let columnHeights = new Float32Array(0);+ let moonRadius = 60;+ let moonPath: MoonPath = createMoonPath(0, 0, 0);++ /* ---- scene state ---- */+ let stars: Star[] = [];+ let cakes: Cake[] = [];+ let trail: TrailSample[] = [];+ let poem: PoemSchedule | null = null;+ let moonImage: HTMLImageElement | null = null;+ let cakeImage: HTMLImageElement | null = null;+ let cakeSprite: HTMLCanvasElement | null = null;+ let cakeSpriteScale = 1;+ let textRect: TextRect | null = null;+ let sparks: SparkHandle[] = [];++ let elapsed = 0;+ let startTime = 0;+ let lastFrameTime = 0;+ let spawnAccumulator = 0;+ let skyProgress = 0;+ let textTargetsBuilt = false;+ let poemBuilt = false;+ let moonSparkDone = false;+ let textSparkDone = false;++ let frameId: number | null = null;+ let sparkFrames: number[] = [];+ let resizeTimer: number | null = null;+ let started = false;+ let destroyed = false;++ /* ------------------------------------------------------------------ *+ * Layout+ * ------------------------------------------------------------------ */++ function createMoonPath(viewWidth: number, viewHeight: number, radius: number): MoonPath {+ return {+ start: {+ x: -radius * MOON_PATH_START_OFFSET,+ y: viewHeight + radius * MOON_PATH_START_OFFSET,+ },+ control1: { x: viewWidth * 0.05, y: viewHeight * 0.7 },+ control2: { x: viewWidth * 0.33, y: viewHeight * 0.04 },+ end: {+ x: viewWidth * 0.78,+ y: Math.max(radius * MOON_PATH_END_MIN_RATIO, viewHeight * 0.16),+ },+ };+ }++ function setup(): void {+ dpr = Math.min(window.devicePixelRatio || 1, 2);+ width = window.innerWidth;+ height = window.innerHeight;++ canvas.width = Math.round(width * dpr);+ canvas.height = Math.round(height * dpr);+ canvas.style.width = `${width}px`;+ canvas.style.height = `${height}px`;+ context.setTransform(dpr, 0, 0, dpr, 0, 0);++ cakeRadius = clamp(+ Math.min(width, height) * CAKE_RADIUS_RATIO,+ CAKE_RADIUS_MIN,+ CAKE_RADIUS_MAX,+ );+ groundY = height - Math.max(GROUND_INSET_MIN, height * GROUND_INSET_RATIO);+ columnWidth = cakeRadius * CAKE_COLUMN_WIDTH_RATIO;+ columnCount = Math.ceil(width / columnWidth) + 2;+ columnHeights = new Float32Array(columnCount);++ moonRadius = clamp(+ Math.min(width, height) * MOON_RADIUS_RATIO,+ MOON_RADIUS_MIN,+ MOON_RADIUS_MAX,+ );+ moonPath = createMoonPath(width, height, moonRadius);++ buildStars();+ if (cakeImage) buildCakeSprite();+ reset();+ }++ function reset(): void {+ cakes = [];+ trail = [];+ poem = null;+ columnHeights.fill(0);+ spawnAccumulator = 0;+ elapsed = 0;+ startTime = 0;+ lastFrameTime = 0;+ skyProgress = 0;+ textTargetsBuilt = false;+ poemBuilt = false;+ moonSparkDone = false;+ textSparkDone = false;+ textRect = null;+ caption.classList.remove("show");+ clearSparks();+ }++ function columnIndexOf(x: number): number {+ return clamp(Math.floor(x / columnWidth), 0, columnCount - 1);+ }++ /* ------------------------------------------------------------------ *+ * Stars and horizon glow+ * ------------------------------------------------------------------ */++ function buildStars(): void {+ stars = [];+ const count = clamp(Math.round((width * height) / STAR_DENSITY), STAR_COUNT_MIN, STAR_COUNT_MAX);+ for (let index = 0; index < count; index++) {+ stars.push({+ x: Math.random() * width,+ y: Math.random() * height * STAR_BAND_RATIO,+ r: Math.random() * STAR_RADIUS_RANGE + STAR_RADIUS_MIN,+ alpha: STAR_ALPHA_MIN + Math.random() * STAR_ALPHA_RANGE,+ phase: Math.random() * Math.PI * 2,+ speed: STAR_SPEED_MIN + Math.random() * STAR_SPEED_RANGE,+ });+ }+ }++ function drawStars(skyAlpha: number): void {+ if (skyAlpha <= 0) return;+ for (const star of stars) {+ const twinkle = 0.5 + 0.5 * Math.sin(elapsed * star.speed + star.phase);+ context.globalAlpha = star.alpha * (0.3 + 0.7 * twinkle) * skyAlpha;+ context.fillStyle = "#dbe7ff";+ context.beginPath();+ context.arc(star.x, star.y, star.r, 0, Math.PI * 2);+ context.fill();+ }+ context.globalAlpha = 1;+ }++ function drawHorizon(skyAlpha: number): void {+ if (skyAlpha <= 0) return;+ context.globalAlpha = skyAlpha;++ const glow = context.createLinearGradient(0, height * 0.68, 0, height);+ glow.addColorStop(0, "rgba(255,190,110,0)");+ glow.addColorStop(0.6, "rgba(255,172,92,0.055)");+ glow.addColorStop(1, "rgba(255,152,70,0.14)");+ context.fillStyle = glow;+ context.fillRect(0, height * 0.68, width, height * 0.32);++ const pool = context.createRadialGradient(+ width * 0.5,+ height * 1.06,+ 0,+ width * 0.5,+ height * 1.06,+ width * 0.72,+ );+ pool.addColorStop(0, "rgba(255,186,104,0.11)");+ pool.addColorStop(0.5, "rgba(255,170,90,0.04)");+ pool.addColorStop(1, "rgba(255,170,90,0)");+ context.fillStyle = pool;+ context.fillRect(0, height * 0.55, width, height * 0.45);++ context.globalAlpha = 1;+ }++ /* ------------------------------------------------------------------ *+ * Mooncake sprite: the asset is scaled once into an offscreen canvas,+ * because 500+ cakes per frame would be too slow to scale every time.+ * ------------------------------------------------------------------ */++ function buildCakeSprite(): void {+ if (!cakeImage) return;+ const supersample = CAKE_SPRITE_SUPERSAMPLE;+ const body = (cakeRadius * 2) / CAKE_FILL * supersample;+ const size = Math.ceil(body * CAKE_SPRITE_PADDING_RATIO);++ const sprite = document.createElement("canvas");+ sprite.width = size;+ sprite.height = size;+ const spriteContext = sprite.getContext("2d");+ if (!spriteContext) {+ options.onError?.(new Error("Mid-Autumn easter egg: cake sprite context unavailable"));+ return;+ }+ spriteContext.imageSmoothingEnabled = true;+ spriteContext.imageSmoothingQuality = "high";++ const glow = spriteContext.createRadialGradient(+ size / 2,+ size / 2,+ body * 0.42,+ size / 2,+ size / 2,+ size * 0.5,+ );+ glow.addColorStop(0, "rgba(255,204,116,0.32)");+ glow.addColorStop(0.5, "rgba(255,178,88,0.10)");+ glow.addColorStop(1, "rgba(255,168,76,0)");+ spriteContext.fillStyle = glow;+ spriteContext.fillRect(0, 0, size, size);++ // The body sits slightly high to cancel the baked-in drop shadow.+ spriteContext.drawImage(+ cakeImage,+ (size - body) / 2,+ (size - body) / 2 - body * CAKE_SPRITE_LIFT_RATIO,+ body,+ body,+ );++ cakeSprite = sprite;+ cakeSpriteScale = 1 / supersample;+ }++ /* ------------------------------------------------------------------ *+ * Moon+ * ------------------------------------------------------------------ */++ function moonPosition(): Vec2 {+ const progress = clamp(elapsed / phases.rise, 0, 1);+ return cubicPoint(+ moonPath.start,+ moonPath.control1,+ moonPath.control2,+ moonPath.end,+ easeInOutQuad(progress),+ );+ }++ function drawMoon(): void {+ if (!moonImage) return;+ const position = moonPosition();+ // Breathing once the moon has arrived.+ const radius =+ moonRadius * (1 + Math.sin(elapsed * MOON_BREATH_SPEED) * MOON_BREATH_AMPLITUDE);++ const glow = context.createRadialGradient(+ position.x,+ position.y,+ radius * MOON_GLOW_INNER_RATIO,+ position.x,+ position.y,+ radius * MOON_GLOW_OUTER_RATIO,+ );+ glow.addColorStop(0, "rgba(255,238,175,0.28)");+ glow.addColorStop(0.32, "rgba(255,220,140,0.10)");+ glow.addColorStop(0.66, "rgba(255,205,120,0.03)");+ glow.addColorStop(1, "rgba(255,200,110,0)");+ context.fillStyle = glow;+ context.beginPath();+ context.arc(position.x, position.y, radius * MOON_GLOW_OUTER_RATIO, 0, Math.PI * 2);+ context.fill();++ const diameter = (radius * 2) / MOON_FILL;+ context.drawImage(+ moonImage,+ position.x - diameter / 2,+ position.y - diameter / 2,+ diameter,+ diameter,+ );+ }++ function drawTrail(): void {+ if (!trail.length) return;+ for (let index = trail.length - 1; index >= 0; index--) {+ const sample = trail[index];+ const age = elapsed - sample.bornAt;+ if (age > TRAIL_LIFETIME || age < 0) {+ trail.splice(index, 1);+ continue;+ }+ const life = 1 - age / TRAIL_LIFETIME;+ const glow = context.createRadialGradient(+ sample.x,+ sample.y,+ 0,+ sample.x,+ sample.y,+ TRAIL_GLOW_INNER_BASE + life * TRAIL_GLOW_INNER_LIFE,+ );+ glow.addColorStop(0, `rgba(255,238,192,${(0.15 * life).toFixed(4)})`);+ glow.addColorStop(0.28, `rgba(255,211,133,${(0.09 * life).toFixed(4)})`);+ glow.addColorStop(1, "rgba(255,190,92,0)");+ context.fillStyle = glow;+ context.beginPath();+ context.arc(sample.x, sample.y, TRAIL_RADIUS_BASE + life * TRAIL_RADIUS_LIFE, 0, Math.PI * 2);+ context.fill();+ }+ }++ /* ------------------------------------------------------------------ *+ * Mooncake rain+ * ------------------------------------------------------------------ */++ function spawnCake(): void {+ const pad = cakeRadius * CAKE_SPAWN_PAD_RATIO;+ cakes.push({+ x: pad + Math.random() * Math.max(1, width - pad * 2),+ y: -cakeRadius * 2 - Math.random() * CAKE_SPAWN_ABOVE_RANGE,+ vx: rand(-CAKE_SPAWN_VX, CAKE_SPAWN_VX),+ vy: rand(CAKE_SPAWN_VY_MIN, CAKE_SPAWN_VY_MIN + CAKE_SPAWN_VY_RANGE),+ rot: Math.random() * Math.PI * 2,+ rot0: 0,+ spin: rand(-CAKE_SPIN_RANGE, CAKE_SPIN_RANGE),+ state: "falling",+ targetX: 0,+ targetY: 0,+ originX: 0,+ originY: 0,+ controlX: 0,+ controlY: 0,+ delay: 0,+ });+ }++ /**+ * Pair every mooncake with a sampled pixel of the target text.+ *+ * The sampler may return up to 15% more points than there are mooncakes; the+ * points are sorted by x and thinned evenly, so the whole line stays covered+ * instead of the surplus piling up on the right-hand glyph.+ */+ function buildTextTargets(): void {+ const count = cakes.length;+ if (!count) return;++ let rectWidth = Math.min(width * TEXT_RECT_WIDTH_RATIO, TEXT_RECT_MAX_WIDTH);+ let rectHeight = rectWidth / TEXT_RECT_ASPECT;+ const maxRectHeight = height * TEXT_RECT_MAX_HEIGHT_RATIO;+ if (rectHeight > maxRectHeight) {+ rectHeight = maxRectHeight;+ rectWidth = rectHeight * TEXT_RECT_ASPECT;+ }+ const rectX = (width - rectWidth) / 2;+ const rectY = height * TEXT_RECT_CENTER_Y_RATIO - rectHeight * 0.5;++ const raw = sampleTextPoints(config.text, count, rectWidth, rectHeight);+ if (!raw.length) return;+ textRect = { x: rectX, y: rectY, w: rectWidth, h: rectHeight };++ raw.sort((left, right) => left.x - right.x);+ const points: TextSamplePoint[] = [];+ if (raw.length > count) {+ const last = raw.length - 1;+ for (let index = 0; index < count; index++) {+ points.push(raw[Math.round((index * last) / Math.max(1, count - 1))]);+ }+ } else {+ for (const point of raw) points.push(point);+ }++ // Left cakes fly to the left points, which produces the sweeping stagger.+ const ordered = cakes.slice().sort((left, right) => left.x - right.x);+ const total = Math.max(1, points.length);++ for (let index = 0; index < ordered.length; index++) {+ const cake = ordered[index];+ const point = points[index % total];+ const stacked = index >= total;+ const jitter = cakeRadius * TEXT_STACK_JITTER_RATIO;+ cake.targetX = rectX + point.x + (stacked ? rand(-jitter, jitter) : 0);+ cake.targetY = rectY + point.y + (stacked ? rand(-jitter, jitter) : 0);+ cake.originX = cake.x;+ cake.originY = cake.y;+ cake.controlX = (cake.originX + cake.targetX) * 0.5 + rand(-TEXT_CONTROL_SPREAD, TEXT_CONTROL_SPREAD);+ cake.controlY =+ Math.min(cake.originY, cake.targetY) - TEXT_ARC_LIFT - Math.random() * TEXT_ARC_LIFT_RANDOM;+ cake.delay =+ (cake.originX / Math.max(1, width)) * phases.flyStagger + Math.random() * TEXT_DELAY_RANDOM;+ cake.rot0 = cake.rot;+ }+ }++ /* ------------------------------------------------------------------ *+ * Poem layer+ * ------------------------------------------------------------------ */++ function drawPoem(): void {+ if (!poem || !poem.items.length) return;++ const local = elapsed - phases.poemStart;+ if (local <= 0) return;++ const time = local % poem.cycle;+ const intro = clamp(local / phases.poemFade, 0, 1);++ context.save();+ context.textAlign = "center";+ context.textBaseline = "middle";++ for (const item of poem.items) {+ if (time < item.start || time >= item.end) continue;++ const progress = (time - item.start) / (item.end - item.start);+ const envelope =+ intro *+ easeInOutQuad(clamp(progress / POEM_FADE_IN_FRACTION, 0, 1)) *+ easeInOutQuad(clamp((1 - progress) / POEM_FADE_OUT_FRACTION, 0, 1));+ if (envelope <= POEM_MIN_ENVELOPE) continue;++ const lines = poem.columns[item.pair];+ const rise = progress * item.drift;+ const sway = Math.sin(elapsed * item.swaySpeed + item.phase) * item.swayAmplitude;++ context.font = `500 ${item.fontSize.toFixed(1)}px ${SERIF_FONT_STACK}`;++ for (let column = 0; column < 2; column++) {+ const glyphs = lines[column];+ // Right column carries the leading line, left column the answer.+ const columnX =+ item.centerX ++ (column === 0 ? item.fontSize * POEM_COLUMN_GAP_RATIO : -item.fontSize * POEM_COLUMN_GAP_RATIO) ++ sway;+ for (let index = 0; index < glyphs.length; index++) {+ const phase = glyphPhase(item, column, index);+ const y =+ item.centerY ++ (index - (glyphs.length - 1) / 2) * item.lineHeight ++ rise ++ Math.sin(elapsed * POEM_CHAR_WOBBLE_SPEED * item.wobble + phase) *+ POEM_CHAR_WOBBLE_AMPLITUDE;+ const breathe = 0.5 + 0.5 * Math.sin(elapsed * POEM_BREATHE_SPEED + phase * 0.8);+ const alpha = envelope * (POEM_ALPHA_BASE + POEM_ALPHA_RANGE * breathe);++ context.shadowColor = `rgba(255,226,160,${(alpha * POEM_GLOW_ALPHA_SCALE).toFixed(4)})`;+ context.shadowBlur = POEM_GLOW_BLUR;+ context.fillStyle = `rgba(255,238,196,${alpha.toFixed(4)})`;+ context.fillText(glyphs[index], columnX, y);+ }+ }+ }+ context.restore();+ }++ /* ------------------------------------------------------------------ *+ * Update+ * ------------------------------------------------------------------ */++ function update(dt: number): void {+ /* Phase 1: the moon */+ if (elapsed <= phases.rise) {+ const position = moonPosition();+ trail.push({ x: position.x, y: position.y, bornAt: elapsed });+ if (trail.length > MOON_TRAIL_MAX) trail.shift();+ } else if (!moonSparkDone) {+ moonSparkDone = true;+ burst(moonPath.end.x, moonPath.end.y, MOON_SPARK_COUNT);+ }++ /* Phase 2: the mooncake rain */+ if (elapsed >= phases.rainStart && elapsed < phases.rainStart + phases.spawnDuration) {+ spawnAccumulator += dt * phases.rainRate;+ let guard = 0;+ while (spawnAccumulator >= 1 && guard++ < RAIN_SPAWN_GUARD) {+ spawnAccumulator -= 1;+ spawnCake();+ }+ }++ const gravity = Math.max(GRAVITY_MIN, height * GRAVITY_K);+ for (const cake of cakes) {+ if (cake.state !== "falling") continue;++ cake.vy += gravity * dt;+ cake.x += cake.vx * dt;+ cake.y += cake.vy * dt;+ cake.rot += cake.spin * dt;++ if (cake.x < cakeRadius) {+ cake.x = cakeRadius;+ cake.vx = Math.abs(cake.vx) * CAKE_BOUNCE_DAMPING;+ }+ if (cake.x > width - cakeRadius) {+ cake.x = width - cakeRadius;+ cake.vx = -Math.abs(cake.vx) * CAKE_BOUNCE_DAMPING;+ }++ const column = columnIndexOf(cake.x);+ const floorY = groundY - columnHeights[column];++ if (cake.y + cakeRadius * CAKE_CONTACT_RATIO >= floorY) {+ cake.y = floorY - cakeRadius * CAKE_CONTACT_RATIO;+ cake.vy = 0;+ cake.state = "landed";+ cake.rot0 = cake.rot;++ // Column piling: the column grows and spreads slightly into its+ // neighbours, which keeps the pile from looking like a wall.+ columnHeights[column] +=+ cakeRadius * CAKE_COLUMN_GROWTH + Math.random() * cakeRadius * CAKE_COLUMN_GROWTH_RANDOM;+ if (column > 0) columnHeights[column - 1] += cakeRadius * CAKE_COLUMN_SPREAD;+ if (column < columnCount - 1) columnHeights[column + 1] += cakeRadius * CAKE_COLUMN_SPREAD;+ }+ }++ /* Phase 3: take off and assemble the text */+ if (elapsed >= phases.flyStart && !textTargetsBuilt) {+ for (const cake of cakes) {+ if (cake.state === "falling") {+ cake.state = "landed";+ cake.vy = 0;+ cake.rot0 = cake.rot;+ }+ }+ buildTextTargets();+ textTargetsBuilt = true;+ }++ if (textTargetsBuilt) {+ for (const cake of cakes) {+ if (cake.state !== "landed") continue;++ const local = elapsed - phases.flyStart - cake.delay;+ if (local <= 0) continue;++ const progress = Math.min(1, local / phases.flyDuration);+ const eased = easeInOutCubic(progress);+ const inverse = 1 - eased;++ cake.x = inverse * inverse * cake.originX + 2 * inverse * eased * cake.controlX + eased * eased * cake.targetX;+ cake.y = inverse * inverse * cake.originY + 2 * inverse * eased * cake.controlY + eased * eased * cake.targetY;+ cake.rot = cake.rot0 * (1 - eased);++ if (progress >= 1) {+ cake.state = "placed";+ cake.x = cake.targetX;+ cake.y = cake.targetY;+ cake.rot = 0;+ }+ }+ }++ if (!textSparkDone && elapsed >= phases.done) {+ textSparkDone = true;+ if (textRect) burst(textRect.x + textRect.w / 2, textRect.y + textRect.h / 2, TEXT_SPARK_COUNT);+ showCaption();+ }++ /* Phase 4: the background poem layer */+ if (elapsed >= phases.poemStart && !poemBuilt) {+ poem = createPoemSchedule({+ width,+ height,+ maxPairs: config.poemMax,+ pairs: config.poemPairs,+ });+ poemBuilt = true;+ }+ }++ /* ------------------------------------------------------------------ *+ * Render+ * ------------------------------------------------------------------ */++ function drawCakes(): void {+ if (!cakeSprite) return;+ const spriteWidth = cakeSprite.width * cakeSpriteScale;+ const spriteHeight = cakeSprite.height * cakeSpriteScale;++ for (const cake of cakes) {+ if (cake.y < -60) continue;+ context.save();+ context.translate(cake.x, cake.y);+ if (cake.rot) context.rotate(cake.rot);+ context.drawImage(cakeSprite, -spriteWidth / 2, -spriteHeight / 2, spriteWidth, spriteHeight);+ context.restore();+ }+ }++ function render(): void {+ const skyAlpha = config.skyAlpha * skyProgress;+ context.clearRect(0, 0, width, height);++ context.globalAlpha = skyAlpha;+ const sky = context.createLinearGradient(0, 0, 0, height);+ sky.addColorStop(0.0, "#02040f");+ sky.addColorStop(0.35, "#061024");+ sky.addColorStop(0.7, "#0a1730");+ sky.addColorStop(1.0, "#10203d");+ context.fillStyle = sky;+ context.fillRect(0, 0, width, height);+ context.globalAlpha = 1;++ drawStars(skyAlpha);+ drawHorizon(skyAlpha);++ // The poem layer stays at the very back so it never fights the text.+ if (poemBuilt) drawPoem();++ drawTrail();+ drawMoon();+ drawCakes();+ }++ /* ------------------------------------------------------------------ *+ * Sparks and caption+ * ------------------------------------------------------------------ */++ function burst(x: number, y: number, count: number): void {+ if (!config.sparkle) return;+ for (let index = 0; index < count; index++) {+ const spark = document.createElement("i");+ spark.className = "mid-autumn-egg-spark";+ const angle = Math.random() * Math.PI * 2;+ const distance = SPARK_DISTANCE_MIN + Math.random() * SPARK_DISTANCE_RANGE;+ spark.style.left = `${x}px`;+ spark.style.top = `${y}px`;+ spark.style.setProperty("--mid-autumn-egg-spark-dx", `${Math.cos(angle) * distance}px`);+ spark.style.setProperty("--mid-autumn-egg-spark-dy", `${Math.sin(angle) * distance}px`);+ spark.style.animationDelay = `${Math.random() * SPARK_DELAY_RANGE_MS}ms`;+ decor.appendChild(spark);++ const frame = window.requestAnimationFrame(() => {+ sparkFrames = sparkFrames.filter((id) => id !== frame);+ if (destroyed) return;+ spark.classList.add("play");+ });+ sparkFrames.push(frame);++ const timer = window.setTimeout(() => {+ spark.remove();+ sparks = sparks.filter((handle) => handle.element !== spark);+ }, SPARK_LIFETIME_MS);+ sparks.push({ element: spark, timer });+ }+ }++ function clearSparks(): void {+ for (const handle of sparks) {+ window.clearTimeout(handle.timer);+ handle.element.remove();+ }+ sparks = [];+ for (const frame of sparkFrames) window.cancelAnimationFrame(frame);+ sparkFrames = [];+ }++ function showCaption(): void {+ if (!config.caption) return;+ caption.classList.remove("show");+ void caption.offsetWidth; // Force a reflow so the animation can replay.+ caption.classList.add("show");+ }++ /* ------------------------------------------------------------------ *+ * Main loop, seek and static frame+ * ------------------------------------------------------------------ */++ function loop(now: number): void {+ if (destroyed) return;+ if (!lastFrameTime) lastFrameTime = now;+ let dt = (now - lastFrameTime) / 1000;+ lastFrameTime = now;+ if (dt > MAX_FRAME_STEP_SECONDS) dt = MAX_FRAME_STEP_SECONDS;+ if (dt < 0) dt = 0;++ if (!startTime) startTime = now;+ elapsed = (now - startTime) / 1000;+ skyProgress = clamp(elapsed / phases.skyIn, 0, 1);++ update(dt);+ render();++ frameId = window.requestAnimationFrame(loop);+ }++ /** Run the simulation forward in fixed steps; used by reduced motion and by QA seeks. */+ function fastForward(target: number): void {+ elapsed = 0;+ skyProgress = 1;+ const step = SIMULATION_STEP_SECONDS;+ let steps = 0;+ while (elapsed < target && steps++ < MAX_FAST_FORWARD_STEPS) {+ elapsed += step;+ update(step);+ }+ elapsed = target;+ }++ function renderStaticFrame(): void {+ fastForward(phases.done + STATIC_FRAME_TAIL_SECONDS);+ skyProgress = 1;+ render();+ }++ function renderSeekFrame(target: number): void {+ fastForward(target);+ skyProgress = clamp(target / phases.skyIn, 0, 1);+ render();+ if (target >= phases.done) showCaption();+ }++ /* ------------------------------------------------------------------ *+ * Resize+ * ------------------------------------------------------------------ */++ function onResize(): void {+ resizeTimer = null;+ setup();+ if (seekSeconds !== null) {+ renderSeekFrame(seekSeconds);+ return;+ }+ if (reduceMotion) {+ renderStaticFrame();+ showCaption();+ }+ }++ function scheduleRelayout(delay: number): void {+ if (destroyed) return;+ if (resizeTimer !== null) window.clearTimeout(resizeTimer);+ resizeTimer = window.setTimeout(onResize, delay);+ }++ function onWindowResize(): void {+ scheduleRelayout(RESIZE_DEBOUNCE_MS);+ }++ function onOrientationChange(): void {+ scheduleRelayout(ORIENTATION_DEBOUNCE_MS);+ }++ /* ------------------------------------------------------------------ *+ * Assets and lifecycle+ * ------------------------------------------------------------------ */++ function loadImage(url: string, onSettled: () => void): HTMLImageElement {+ const image = new Image();+ image.onload = onSettled;+ image.onerror = () => {+ // Non-fatal: the animation keeps running without that layer.+ options.onError?.(new Error(`Mid-Autumn easter egg: failed to load ${url}`));+ onSettled();+ };+ image.src = url;+ return image;+ }++ function loadImages(onReady: () => void): void {+ let settled = 0;+ const done = (): void => {+ if (++settled === 2) onReady();+ };+ moonImage = loadImage(options.moonImageUrl, done);+ cakeImage = loadImage(options.cakeImageUrl, done);+ }++ function releaseImages(): void {+ for (const image of [moonImage, cakeImage]) {+ if (!image) continue;+ image.onload = null;+ image.onerror = null;+ }+ moonImage = null;+ cakeImage = null;+ }++ function start(): void {+ if (started || destroyed) return;+ started = true;++ window.addEventListener("resize", onWindowResize);+ window.addEventListener("orientationchange", onOrientationChange);+ setup();++ loadImages(() => {+ if (destroyed) return;+ if (cakeImage) buildCakeSprite();+ reset();+ if (seekSeconds !== null) {+ renderSeekFrame(seekSeconds);+ return;+ }+ if (reduceMotion) {+ renderStaticFrame();+ showCaption();+ return;+ }+ frameId = window.requestAnimationFrame(loop);+ });+ }++ function destroy(): void {+ if (destroyed) return;+ destroyed = true;++ if (frameId !== null) {+ window.cancelAnimationFrame(frameId);+ frameId = null;+ }+ if (resizeTimer !== null) {+ window.clearTimeout(resizeTimer);+ resizeTimer = null;+ }+ window.removeEventListener("resize", onWindowResize);+ window.removeEventListener("orientationchange", onOrientationChange);++ clearSparks();+ releaseImages();+ caption.classList.remove("show");+ decor.remove();++ cakes = [];+ stars = [];+ trail = [];+ poem = null;+ columnHeights = new Float32Array(0);+ cakeSprite = null;+ textRect = null;+ }++ return { start, destroy };+}diff --git a/apps/desktop/src/features/mid-autumn-egg/text-sampling.ts b/apps/desktop/src/features/mid-autumn-egg/text-sampling.tsnew file mode 100644index 000000000..a60418702--- /dev/null+++ b/apps/desktop/src/features/mid-autumn-egg/text-sampling.ts@@ -0,0 +1,103 @@+/**+ * Pixel sampling of the target text.+ *+ * The offscreen canvas is drawn and read back purely for geometry: it produces+ * the points the mooncakes fly to. Nothing here touches the scene, the DOM of+ * the overlay or the animation clock.+ */+import { TEXT_FONT_STACK, rand } from "./timeline";++/** A sampled point of the target text, in the coordinate space of the offscreen canvas. */+export type TextSamplePoint = { x: number; y: number };++/** Alpha above which a pixel counts as part of a glyph. */+const ALPHA_THRESHOLD = 128;+/** Font size as a share of the offscreen canvas height. */+const FONT_SIZE_RATIO = 0.94;+/** Glyph width is kept inside this share of the canvas width. */+const WIDTH_FIT_RATIO = 0.96;+/** Random jitter per point, as a share of the sampling step. */+const JITTER_RATIO = 0.16;+const MIN_STEP = 3;+const MIN_STEP_REFINED = 2;+/** Accepted deviation of the point count from the requested target. */+const ACCEPT_MIN_RATIO = 0.85;+const ACCEPT_MAX_RATIO = 1.15;+const MAX_REFINE_PASSES = 5;++/**+ * Sample the filled pixels of `text` on a `width` x `height` offscreen canvas.+ *+ * The sampling step is refined until the point count is within ±15% of+ * `target`, so the number of points matches the number of mooncakes. Returns an+ * empty array when the 2D context is unavailable (canvas unsupported) or when+ * the text paints nothing; the caller then keeps the mooncakes on the ground.+ */+export function sampleTextPoints(+ text: string,+ target: number,+ width: number,+ height: number,+): TextSamplePoint[] {+ const canvasWidth = Math.max(2, Math.round(width));+ const canvasHeight = Math.max(2, Math.round(height));++ const canvas = document.createElement("canvas");+ canvas.width = canvasWidth;+ canvas.height = canvasHeight;+ const context = canvas.getContext("2d");+ if (!context) return [];++ let fontSize = canvasHeight * FONT_SIZE_RATIO;+ const applyFont = (): void => {+ context.font = `bold ${fontSize.toFixed(1)}px ${TEXT_FONT_STACK}`;+ };+ context.textAlign = "center";+ context.textBaseline = "middle";+ applyFont();+ const measured = context.measureText(text).width;+ if (measured > canvasWidth * WIDTH_FIT_RATIO) {+ fontSize *= (canvasWidth * WIDTH_FIT_RATIO) / measured;+ applyFont();+ }+ context.fillStyle = "#fff";+ context.fillText(text, canvasWidth / 2, canvasHeight / 2);++ const pixels = context.getImageData(0, 0, canvasWidth, canvasHeight).data;++ const collect = (step: number): TextSamplePoint[] => {+ const points: TextSamplePoint[] = [];+ const jitter = step * JITTER_RATIO;+ let row = 0;+ for (let y = step * 0.5; y < canvasHeight; y += step, row++) {+ const offset = (row % 2) * step * 0.5;+ for (let x = step * 0.5 + offset; x < canvasWidth; x += step) {+ const sampleX = x | 0;+ const sampleY = y | 0;+ if (sampleX < 0 || sampleX >= canvasWidth) continue;+ if (sampleY < 0 || sampleY >= canvasHeight) continue;+ if (pixels[(sampleY * canvasWidth + sampleX) * 4 + 3] > ALPHA_THRESHOLD) {+ points.push({ x: x + rand(-jitter, jitter), y: y + rand(-jitter, jitter) });+ }+ }+ }+ return points;+ };++ let step = Math.max(+ MIN_STEP,+ Math.sqrt((canvasWidth * canvasHeight) / Math.max(1, target)),+ );+ let points = collect(step);+ for (let pass = 0; pass < MAX_REFINE_PASSES; pass++) {+ if (!points.length) break;+ const ratio = points.length / target;+ if (ratio > ACCEPT_MAX_RATIO || ratio < ACCEPT_MIN_RATIO) {+ step = Math.max(MIN_STEP_REFINED, step * Math.sqrt(ratio));+ points = collect(step);+ } else {+ break;+ }+ }+ return points;+}diff --git a/apps/desktop/src/features/mid-autumn-egg/timeline.ts b/apps/desktop/src/features/mid-autumn-egg/timeline.tsnew file mode 100644index 000000000..3430d728e--- /dev/null+++ b/apps/desktop/src/features/mid-autumn-egg/timeline.ts@@ -0,0 +1,331 @@+/**+ * Timeline, easing helpers and tuning constants for the Mid-Autumn easter egg.+ *+ * This is a faithful port of the hand-verified standalone animation: the same+ * timeline, the same physics, the same shapes and the same poem scheduling.+ * Every magic number of that animation lives here with a name, so the scene+ * module stays readable and nothing drifts while the port is reviewed.+ */++/** Tunable knobs of the animation. The defaults are the verified baseline. */+export type MidAutumnEggConfig = {+ /** Baseline duration in seconds. Only the moon rise scales with it. */+ duration: number;+ /** Moon rise slowdown factor (1.5 = the moon rises 1.5x slower than the baseline). */+ moonSpeed: number;+ /** Sky opacity: below 1 the overlay canvas lets the application shine through. */+ skyAlpha: number;+ /** Total number of mooncakes; also the pixel density of the assembled text. */+ cakes: number;+ /** Text assembled out of mooncakes (on-screen artwork, intentionally Chinese). */+ text: string;+ /**+ * Vertical poem pairs. Within a pair the right column is the leading line and+ * the left column answers it (vertical text reads right to left).+ */+ poemPairs: readonly (readonly [string, string])[];+ /** How many poem pairs may float on screen at the same time. */+ poemMax: number;+ /** Spark bursts when the moon arrives and when the text is assembled. */+ sparkle: boolean;+ /** Closing caption in the top-right corner. */+ caption: boolean;+};++/** The configuration the standalone animation was verified with. */+export const DEFAULT_MID_AUTUMN_EGG_CONFIG: MidAutumnEggConfig = {+ duration: 5.0,+ moonSpeed: 1.5,+ skyAlpha: 0.9,+ cakes: 520,+ text: "中秋快乐",+ poemPairs: [+ ["明月几时有", "把酒问青天"],+ ["不知天上宫阙", "今夕是何年"],+ ["我欲乘风归去", "又恐琼楼玉宇"],+ ["高处不胜寒", "起舞弄清影"],+ ["何似在人间", "转朱阁低绮户"],+ ["照无眠", "不应有恨"],+ ["何事长向别时圆", "人有悲欢离合"],+ ["月有阴晴圆缺", "此事古难全"],+ // The most famous pair opens the animation.+ ["但愿人长久", "千里共婵娟"],+ ],+ poemMax: 4,+ sparkle: true,+ caption: true,+};++/** Absolute timeline of one run, in seconds. */+export type MidAutumnEggPhases = {+ /** Moon rise along the bezier curve. */+ rise: number;+ /** Short hold in the top-right corner after the rise. */+ hold: number;+ /** First fallen mooncake. */+ rainStart: number;+ /** Window during which mooncakes are spawned. */+ spawnDuration: number;+ /** End of the falling window. */+ rainEnd: number;+ /** Mooncakes take off to assemble the text. */+ flyStart: number;+ /** Left-to-right stagger of the take-off. */+ flyStagger: number;+ /** Flight time of a single mooncake. */+ flyDuration: number;+ /** The text is fully assembled. */+ done: number;+ /** Background poem pairs start fading in. */+ poemStart: number;+ /** Fade-in duration of the whole poem layer. */+ poemFade: number;+ /** Night sky fade-in. */+ skyIn: number;+ /** Mooncakes spawned per second during the spawn window. */+ rainRate: number;+};++/**+ * Derive the timeline from the config.+ *+ * The rise scales with `duration * 0.21 * moonSpeed`; every later phase is a+ * fixed offset from `rainStart`, so the mooncake rain keeps its own rhythm no+ * matter how slow the moon is.+ */+export function createMidAutumnEggPhases(+ config: MidAutumnEggConfig,+): MidAutumnEggPhases {+ const rise = config.duration * 0.21 * config.moonSpeed;+ const hold = 0.25;+ const rainStart = rise + hold;+ const spawnDuration = 1.2;+ const flyStart = rainStart + 2.2;+ const flyStagger = 0.5;+ const flyDuration = 0.8;+ return {+ rise,+ hold,+ rainStart,+ spawnDuration,+ rainEnd: rainStart + 1.75,+ flyStart,+ flyStagger,+ flyDuration,+ done: flyStart + flyStagger + flyDuration,+ poemStart: rainStart + 3.15,+ poemFade: 0.75,+ skyIn: 0.9,+ rainRate: config.cakes / spawnDuration,+ };+}++/* ------------------------------------------------------------------ *+ * Helpers+ * ------------------------------------------------------------------ */++export type Vec2 = { x: number; y: number };++export function clamp(value: number, min: number, max: number): number {+ return value < min ? min : value > max ? max : value;+}++export function rand(min: number, max: number): number {+ return min + Math.random() * (max - min);+}++export function easeInOutQuad(t: number): number {+ return t < 0.5 ? 2 * t * t : 1 - (-2 * t + 2) ** 2 / 2;+}++export function easeInOutCubic(t: number): number {+ return t < 0.5 ? 4 * t * t * t : 1 - (-2 * t + 2) ** 3 / 2;+}++/** Point on a cubic bezier curve at `t` in 0..1. */+export function cubicPoint(+ p0: Vec2,+ p1: Vec2,+ p2: Vec2,+ p3: Vec2,+ t: number,+): Vec2 {+ const mt = 1 - t;+ const a = mt * mt * mt;+ const b = 3 * mt * mt * t;+ const c = 3 * mt * t * t;+ const d = t * t * t;+ return {+ x: a * p0.x + b * p1.x + c * p2.x + d * p3.x,+ y: a * p0.y + b * p1.y + c * p2.y + d * p3.y,+ };+}++/* ------------------------------------------------------------------ *+ * Fonts and sprite geometry+ * ------------------------------------------------------------------ */++export const TEXT_FONT_STACK =+ '"PingFang SC","Hiragino Sans GB","Microsoft YaHei","Noto Sans SC",sans-serif';+export const SERIF_FONT_STACK =+ '"Songti SC","STSong","SimSun","Noto Serif SC",serif';++/** Share of the moon/cake sprite that is the solid body (the images carry a glow). */+export const MOON_FILL = 0.86;+export const CAKE_FILL = 0.87;+/** Supersampling factor of the cached mooncake sprite, plus its glow padding. */+export const CAKE_SPRITE_SUPERSAMPLE = 2;+export const CAKE_SPRITE_PADDING_RATIO = 1.36;+export const CAKE_SPRITE_LIFT_RATIO = 0.015;++/* ------------------------------------------------------------------ *+ * Layout ratios (resolution independent)+ * ------------------------------------------------------------------ */++export const CAKE_RADIUS_RATIO = 0.012;+export const CAKE_RADIUS_MIN = 5;+export const CAKE_RADIUS_MAX = 11;+export const GROUND_INSET_RATIO = 0.06;+export const GROUND_INSET_MIN = 26;+/** Stacking column width as a multiple of the mooncake radius. */+export const CAKE_COLUMN_WIDTH_RATIO = 1.6;+export const MOON_RADIUS_RATIO = 0.075;+export const MOON_RADIUS_MIN = 34;+export const MOON_RADIUS_MAX = 88;+export const MOON_PATH_START_OFFSET = 1.8;+export const MOON_PATH_END_MIN_RATIO = 1.9;+export const STAR_DENSITY = 9000;+export const STAR_COUNT_MIN = 80;+export const STAR_COUNT_MAX = 320;+export const STAR_BAND_RATIO = 0.88;+export const STAR_RADIUS_MIN = 0.35;+export const STAR_RADIUS_RANGE = 1.3;+export const STAR_ALPHA_MIN = 0.2;+export const STAR_ALPHA_RANGE = 0.65;+export const STAR_SPEED_MIN = 0.5;+export const STAR_SPEED_RANGE = 1.9;++/* ------------------------------------------------------------------ *+ * Physics and rain+ * ------------------------------------------------------------------ */++/** Gravity = screen height * this factor, so the fall time is resolution independent. */+export const GRAVITY_K = 3.2;+export const GRAVITY_MIN = 1500;+export const CAKE_SPAWN_PAD_RATIO = 2.2;+export const CAKE_SPAWN_ABOVE_RANGE = 80;+export const CAKE_SPAWN_VX = 27;+export const CAKE_SPAWN_VY_MIN = 50;+export const CAKE_SPAWN_VY_RANGE = 110;+export const CAKE_SPIN_RANGE = 2.5;+export const CAKE_BOUNCE_DAMPING = 0.5;+/** Contact offset of the cake centre above the floor and the pile top. */+export const CAKE_CONTACT_RATIO = 0.82;+export const CAKE_COLUMN_GROWTH = 1.5;+export const CAKE_COLUMN_GROWTH_RANDOM = 0.3;+export const CAKE_COLUMN_SPREAD = 0.12;+export const RAIN_SPAWN_GUARD = 24;++/* ------------------------------------------------------------------ *+ * Text assembly+ * ------------------------------------------------------------------ */++export const TEXT_RECT_MAX_WIDTH = 1100;+export const TEXT_RECT_WIDTH_RATIO = 0.88;+export const TEXT_RECT_ASPECT = 4.6;+export const TEXT_RECT_MAX_HEIGHT_RATIO = 0.38;+export const TEXT_RECT_CENTER_Y_RATIO = 0.47;+/** Stacked mooncakes (more cakes than sampled points) scatter by this much. */+export const TEXT_STACK_JITTER_RATIO = 0.6;+export const TEXT_CONTROL_SPREAD = 60;+export const TEXT_ARC_LIFT = 80;+export const TEXT_ARC_LIFT_RANDOM = 110;+export const TEXT_DELAY_RANDOM = 0.12;++/* ------------------------------------------------------------------ *+ * Moon+ * ------------------------------------------------------------------ */++export const MOON_BREATH_SPEED = 1.7;+export const MOON_BREATH_AMPLITUDE = 0.012;+export const MOON_GLOW_INNER_RATIO = 0.6;+export const MOON_GLOW_OUTER_RATIO = 3.2;+export const MOON_TRAIL_MAX = 70;+export const TRAIL_LIFETIME = 0.7;+export const TRAIL_GLOW_INNER_BASE = 14;+export const TRAIL_GLOW_INNER_LIFE = 18;+export const TRAIL_RADIUS_BASE = 18;+export const TRAIL_RADIUS_LIFE = 16;++/* ------------------------------------------------------------------ *+ * Sparks and caption+ * ------------------------------------------------------------------ */++export const MOON_SPARK_COUNT = 18;+export const TEXT_SPARK_COUNT = 22;+export const SPARK_DISTANCE_MIN = 18;+export const SPARK_DISTANCE_RANGE = 42;+export const SPARK_DELAY_RANGE_MS = 180;+export const SPARK_LIFETIME_MS = 1900;+/** Caption copy: artwork content, not UI chrome. */+export const CAPTION_TITLE = "月满 · 团圆";+export const CAPTION_SUBTITLE = "AIUO · PI-DESKTOP";++/* ------------------------------------------------------------------ *+ * Loop, resize and fast-forward+ * ------------------------------------------------------------------ */++export const MAX_FRAME_STEP_SECONDS = 0.05;+export const SIMULATION_STEP_SECONDS = 1 / 60;+/** Upper bound of fast-forward steps, so a hostile seek value cannot hang the renderer. */+export const MAX_FAST_FORWARD_STEPS = 60 * 600;+export const STATIC_FRAME_TAIL_SECONDS = 0.8;+export const RESIZE_DEBOUNCE_MS = 160;+export const ORIENTATION_DEBOUNCE_MS = 260;++/* ------------------------------------------------------------------ *+ * Poem layer tuning+ * ------------------------------------------------------------------ */++export const POEM_SEED = 20260924;+/** The schedule is precomputed for 30 minutes and then loops. */+export const POEM_HORIZON_SECONDS = 1800;+export const POEM_SCHEDULE_GUARD = 5000;+export const POEM_GAP_BASE_SECONDS = 0.6;+export const POEM_GAP_RANDOM_SECONDS = 3.2;+export const POEM_LIFE_BASE_SECONDS = 8;+export const POEM_LIFE_RANDOM_SECONDS = 6;+export const POEM_FONT_RATIO = 0.03;+export const POEM_FONT_MIN = 13;+export const POEM_FONT_MAX = 34;+export const POEM_FONT_SCALE_MIN = 0.72;+export const POEM_FONT_SCALE_RANGE = 0.62;+export const POEM_LINE_HEIGHT_RATIO = 1.12;+export const POEM_HALF_HEIGHT_PAD_RATIO = 0.62;+/** Horizontal half-extent of a two-column pair, in font sizes. */+export const POEM_HALF_WIDTH_RATIO = 1.35;+export const POEM_COLUMN_GAP_RATIO = 0.82;+export const POEM_EDGE_PADDING = 12;+export const POEM_VERTICAL_MARGIN = 14;+export const POEM_DRIFT_MIN = 20;+export const POEM_DRIFT_RANGE = 45;+export const POEM_SWAY_MIN = 4;+export const POEM_SWAY_RANGE = 9;+export const POEM_SWAY_SPEED_MIN = 0.16;+export const POEM_SWAY_SPEED_RANGE = 0.22;+export const POEM_WOBBLE_MIN = 0.55;+export const POEM_WOBBLE_RANGE = 0.4;+export const POEM_PHASE_RANGE = 6.283;+export const POEM_CYCLE_TAIL_SECONDS = 0.3;+export const POEM_FADE_IN_FRACTION = 0.16;+export const POEM_FADE_OUT_FRACTION = 0.28;+export const POEM_MIN_ENVELOPE = 0.002;+export const POEM_ALPHA_BASE = 0.042;+export const POEM_ALPHA_RANGE = 0.062;+export const POEM_GLOW_ALPHA_SCALE = 1.5;+export const POEM_GLOW_BLUR = 12;+export const POEM_COLUMN_STAGGER = 0.9;+export const POEM_CHAR_STAGGER = 0.5;+export const POEM_CHAR_WOBBLE_SPEED = 0.7;+export const POEM_CHAR_WOBBLE_AMPLITUDE = 3.4;+export const POEM_BREATHE_SPEED = 0.6;diff --git a/apps/desktop/src/features/settings/SettingsPage.tsx b/apps/desktop/src/features/settings/SettingsPage.tsxindex 95e3a474d..f9f7db675 100644--- a/apps/desktop/src/features/settings/SettingsPage.tsx+++ b/apps/desktop/src/features/settings/SettingsPage.tsx@@ -7,6 +7,7 @@ import type {ShortcutPlatform,} from "@pi-desktop/shared";import { useAppStore } from "../../stores/app-store";+import { useMidAutumnEggStore } from "../../stores/mid-autumn-egg-store";import { api } from "../../lib/api";import {isSettingsDestinationHidden,@@ -88,6 +89,7 @@ export function SettingsPage() {const settings = useAppStore((s) => s.settings);const version = useAppStore((s) => s.version);const refreshProviders = useAppStore((s) => s.refreshProviders);+ const showMidAutumnEgg = useMidAutumnEggStore((s) => s.show);const platform = (window.piDesktop?.platform ?? "darwin") as ShortcutPlatform;// Developer-only destinations (Cloud sync and Remote Hosts) exist only@@ -596,6 +598,17 @@ export function SettingsPage() {<UpdatesRow currentVersion={version?.version} /></SettingsCard>+ <SettingsCard title={t("settings.easterEggs")}>+ <SettingsRow+ title={t("settings.midAutumnEgg")}+ description={t("settings.midAutumnEggDesc")}+ >+ <Button variant="secondary" onClick={showMidAutumnEgg}>+ {t("settings.playMidAutumnEgg")}+ </Button>+ </SettingsRow>+ </SettingsCard>+{settings && (<DeveloperSection settings={settings} saveSettings={saveSettings} />)}diff --git a/apps/desktop/src/lib/mid-autumn-egg-preferences.ts b/apps/desktop/src/lib/mid-autumn-egg-preferences.tsnew file mode 100644index 000000000..7ece1c726--- /dev/null+++ b/apps/desktop/src/lib/mid-autumn-egg-preferences.ts@@ -0,0 +1,32 @@+const MID_AUTUMN_EGG_SEEN_STORAGE_KEY = "pi.desktop.midAutumnEggSeen";++function storage(): Storage | null {+ try {+ return typeof globalThis !== "undefined" && "localStorage" in globalThis+ ? globalThis.localStorage+ : null;+ } catch {+ return null;+ }+}++/** True once the launch easter egg has been shown so it never replays by itself. */+export function hasSeenMidAutumnEgg(): boolean {+ const store = storage();+ if (!store) return false;+ try {+ return store.getItem(MID_AUTUMN_EGG_SEEN_STORAGE_KEY) === "1";+ } catch {+ return false;+ }+}++export function markMidAutumnEggSeen(): void {+ const store = storage();+ if (!store) return;+ try {+ store.setItem(MID_AUTUMN_EGG_SEEN_STORAGE_KEY, "1");+ } catch {+ // A blocked or full localStorage must not prevent the app from running.+ }+}diff --git a/apps/desktop/src/stores/mid-autumn-egg-store.ts b/apps/desktop/src/stores/mid-autumn-egg-store.tsnew file mode 100644index 000000000..cb5f5a151--- /dev/null+++ b/apps/desktop/src/stores/mid-autumn-egg-store.ts@@ -0,0 +1,15 @@+import { create } from "zustand";++/**+ * Whether the full-screen Mid-Autumn overlay is showing. `show` is used both+ * for the once-only launch replay and for the manual replay in Settings.+ */+export const useMidAutumnEggStore = create<{+ open: boolean;+ show: () => void;+ hide: () => void;+}>((set) => ({+ open: false,+ show: () => set({ open: true }),+ hide: () => set({ open: false }),+}));diff --git a/apps/desktop/test/mid-autumn-egg.test.mjs b/apps/desktop/test/mid-autumn-egg.test.mjsnew file mode 100644index 000000000..f159f1566--- /dev/null+++ b/apps/desktop/test/mid-autumn-egg.test.mjs@@ -0,0 +1,239 @@+/**+ * Mid-Autumn easter egg contract.+ *+ * Two layers are covered:+ *+ * 1. The pure timeline / poem-schedule modules, which carry the timing that was+ * tuned by hand: the moon rises 1.5x slower than the baseline while the+ * mooncake rain, the assembly and the poem keep their own fixed rhythm, and+ * several poem pairs float on screen at unfixed positions.+ * 2. The renderer wiring: a once-only launch gate that waits for the existing+ * startup splash to finish, a settings row that replays it, and the assets+ * that ship with the feature.+ *+ * All user-visible copies go through i18n, so the catalogue keys are part of+ * the contract as well.+ */+import assert from "node:assert/strict";+import { existsSync, readFileSync, readdirSync } from "node:fs";+import test from "node:test";++import {+ DEFAULT_MID_AUTUMN_EGG_CONFIG,+ createMidAutumnEggPhases,+} from "../src/features/mid-autumn-egg/timeline.ts";++const featureDir = new URL("../src/features/mid-autumn-egg/", import.meta.url);+const read = (relative) => readFileSync(new URL(relative, import.meta.url), "utf8");++const overlaySource = read("../src/features/mid-autumn-egg/MidAutumnEggOverlay.tsx");+const hostSource = read("../src/features/mid-autumn-egg/MidAutumnEggHost.tsx");+const sceneSource = read("../src/features/mid-autumn-egg/scene.ts");+const preferencesSource = read("../src/lib/mid-autumn-egg-preferences.ts");+const storeSource = read("../src/stores/mid-autumn-egg-store.ts");+const settingsPageSource = read("../src/features/settings/SettingsPage.tsx");+const appShellSource = read("../src/features/app/AppShell.tsx");++/* ------------------------------------------------------------------ *+ * Timeline+ * ------------------------------------------------------------------ */++test("a slow moon does not change the mooncake rain rhythm", () => {+ const baseline = createMidAutumnEggPhases({+ ...DEFAULT_MID_AUTUMN_EGG_CONFIG,+ moonSpeed: 1,+ });+ const slowed = createMidAutumnEggPhases(DEFAULT_MID_AUTUMN_EGG_CONFIG);++ // The moon rise is the only phase that scales.+ assert.equal(slowed.rise, baseline.rise * DEFAULT_MID_AUTUMN_EGG_CONFIG.moonSpeed);+ assert.equal(slowed.rise.toFixed(3), "1.575");+ assert.equal(baseline.rise.toFixed(3), "1.050");++ assert.equal(slowed.spawnDuration, baseline.spawnDuration);+ assert.equal(slowed.flyStagger, baseline.flyStagger);+ const round = (value) => Number(value.toFixed(3));+ assert.equal(+ round(slowed.rainEnd - slowed.rainStart),+ round(baseline.rainEnd - baseline.rainStart),+ );+ assert.equal(slowed.flyDuration, baseline.flyDuration);+ assert.equal(slowed.poemFade, baseline.poemFade);+ assert.equal(+ Number((slowed.rainStart - baseline.rainStart).toFixed(3)),+ Number((slowed.rise - baseline.rise).toFixed(3)),+ );+});++test("the phases keep the hand-tuned absolute timeline", () => {+ const phases = createMidAutumnEggPhases(DEFAULT_MID_AUTUMN_EGG_CONFIG);++ assert.equal(phases.hold, 0.25);+ assert.equal(phases.rainStart.toFixed(3), "1.825");+ assert.equal(phases.spawnDuration.toFixed(3), "1.200");+ assert.equal(phases.rainEnd.toFixed(3), "3.575");+ assert.equal(phases.flyStart.toFixed(3), "4.025");+ assert.equal(phases.done.toFixed(3), "5.325");+ assert.equal(phases.poemStart.toFixed(3), "4.975");+ assert.equal(phases.skyIn, 0.9);++ // All 520 mooncakes are spawned inside the spawn window.+ assert.equal(phases.rainRate.toFixed(3), (DEFAULT_MID_AUTUMN_EGG_CONFIG.cakes / 1.2).toFixed(3));++ // The text is assembled after the rain has landed, and the poem follows it.+ assert.ok(phases.spawnDuration < phases.rainEnd - phases.rainStart);+ assert.ok(phases.flyStart > phases.rainEnd);+ assert.ok(phases.poemStart < phases.done);+});++test("the poem data ships as vertical pairs with a famous closing pair", () => {+ const pairs = DEFAULT_MID_AUTUMN_EGG_CONFIG.poemPairs;++ assert.ok(pairs.length >= 8);+ for (const [leading, answering] of pairs) {+ assert.ok(leading.length > 0 && answering.length > 0);+ // Vertical columns stay inside the reserved height on a small viewport.+ assert.ok(Math.max(leading.length, answering.length) <= 7);+ }+ assert.deepEqual(pairs.at(-1), ["但愿人长久", "千里共婵娟"]);+});++/* ------------------------------------------------------------------ *+ * Poem schedule+ *+ * The scheduler imports its layout constants through the repo's extensionless+ * specifier convention, which node:test cannot resolve by itself, so its+ * contract is pinned at the source level here. The runtime behaviour (several+ * pairs on screen at once, at unfixed positions, cycling in a random order) is+ * verified by the screenshot harness described in the pull request.+ * ------------------------------------------------------------------ */++const poemScheduleSource = read("../src/features/mid-autumn-egg/poem-schedule.ts");++test("the poem scheduler is seeded, lane-capped and cyclic", () => {+ // A fixed seed is what keeps the layout reproducible for a given viewport.+ assert.match(poemScheduleSource, /createSeededRandom\(POEM_SEED\)/);+ assert.match(poemScheduleSource, /1664525/);+ assert.match(poemScheduleSource, /1013904223/);++ // Concurrency is bounded by lanes, and the table loops instead of growing.+ assert.match(poemScheduleSource, /maxPairs/);+ assert.match(poemScheduleSource, /cycle/);++ // Every scheduled appearance owns its lifetime, placement and drift.+ for (const field of ["start", "end", "centerX", "centerY", "drift", "fontSize"]) {+ assert.match(poemScheduleSource, new RegExp(`\\b${field}\\b`));+ }++ // Placements come from the seeded stream, not from a fixed slot table.+ assert.match(poemScheduleSource, /random\(\)/);+ assert.match(poemScheduleSource, /pairs\.map/);+});++test("the schedule keeps every pair as two vertical columns", () => {+ assert.match(poemScheduleSource, /Array\.from\(leading\)/);+ assert.match(poemScheduleSource, /Array\.from\(answering\)/);+ assert.match(poemScheduleSource, /columns/);+});++/* ------------------------------------------------------------------ *+ * Assets+ * ------------------------------------------------------------------ */++test("the two artwork assets ship as webp", () => {+ const assets = new URL("../src/assets/", import.meta.url);++ for (const name of ["mid-autumn-moon.webp", "mid-autumn-cake.webp"]) {+ const file = new URL(name, assets);+ assert.ok(existsSync(file), `${name} must exist`);+ const bytes = readFileSync(file);+ assert.equal(bytes.subarray(0, 4).toString("ascii"), "RIFF");+ assert.equal(bytes.subarray(8, 12).toString("ascii"), "WEBP");+ assert.ok(bytes.length > 4096, `${name} looks like a real image`);+ }++ // The animation must not carry base64 artwork or an embedded html document.+ assert.equal(sceneSource.includes("data:image"), false);+ assert.equal(sceneSource.includes("srcdoc"), false);+ assert.equal(overlaySource.includes("iframe"), false);+ assert.equal(overlaySource.includes("data:image"), false);+ assert.equal(readdirSync(featureDir).some((name) => name.endsWith(".html")), false);+});++/* ------------------------------------------------------------------ *+ * Once-only launch gate+ * ------------------------------------------------------------------ */++test("the seen flag is a guarded renderer preference", () => {+ assert.match(preferencesSource, /pi\.desktop\.midAutumnEggSeen/);+ assert.match(preferencesSource, /export function hasSeenMidAutumnEgg\(\): boolean/);+ assert.match(preferencesSource, /export function markMidAutumnEggSeen\(\): void/);+ // Storage access must never throw into the app.+ assert.match(preferencesSource, /catch\s*\{/);+ assert.equal(/window\.localStorage/.test(preferencesSource), false);+});++test("the launch gate waits for the existing startup splash", () => {+ // The gate is explicit about both signals instead of racing the splash.+ assert.match(hostSource, /ready/);+ assert.match(hostSource, /showSplash/);+ assert.match(hostSource, /hasSeenMidAutumnEgg\(\)/);+ assert.match(hostSource, /markMidAutumnEggSeen\(\)/);+ // Marking before showing is what makes it a single automatic playback.+ assert.ok(+ hostSource.indexOf("markMidAutumnEggSeen()") < hostSource.indexOf("showMidAutumnEgg()"),+ "the flag must be written before the overlay opens",+ );+ // It must not touch or replace the boot/loading surface.+ assert.equal(/StartupSplash|setSplashPhase|splashPhase/.test(hostSource), false);+ assert.equal(hostSource.includes("any"), false);+ assert.match(appShellSource, /<MidAutumnEggHost[^>]*showSplash=\{showSplash\}/);+});++test("the overlay is dismissible from its top-right corner", () => {+ assert.match(overlaySource, /role="dialog"/);+ assert.match(overlaySource, /aria-modal/);+ assert.match(overlaySource, /settings\.closeEasterEgg/);+ assert.match(overlaySource, /Escape/);+ assert.match(overlaySource, /createMidAutumnEggScene\(/);+ assert.match(overlaySource, /\.destroy\(\)/);+ assert.match(overlaySource, /mid-autumn-moon\.webp/);+ assert.match(overlaySource, /mid-autumn-cake\.webp/);+ assert.equal(overlaySource.includes(": any"), false);+});++/* ------------------------------------------------------------------ *+ * Replay from settings+ * ------------------------------------------------------------------ */++test("settings exposes the egg and replays it through the store", () => {+ assert.match(storeSource, /useMidAutumnEggStore/);+ for (const field of ["open", "show", "hide"]) assert.match(storeSource, new RegExp(field));+ assert.match(settingsPageSource, /settings\.easterEggs/);+ assert.match(settingsPageSource, /settings\.midAutumnEgg/);+ assert.match(settingsPageSource, /settings\.playMidAutumnEgg/);+ assert.match(settingsPageSource, /useMidAutumnEggStore/);+});++test("every catalogue carries the easter egg strings", () => {+ const locales = readdirSync(new URL("../../../packages/i18n/src/locales/", import.meta.url), {+ withFileTypes: true,+ }).filter((entry) => entry.isDirectory());++ assert.ok(locales.length >= 8);+ for (const locale of locales) {+ const catalogue = readFileSync(+ new URL(`../../../packages/i18n/src/locales/${locale.name}/index.ts`, import.meta.url),+ "utf8",+ );+ for (const key of [+ "easterEggs",+ "midAutumnEgg",+ "midAutumnEggDesc",+ "playMidAutumnEgg",+ "closeEasterEgg",+ ]) {+ assert.match(catalogue, new RegExp(`\\b${key}\\b`), `${locale.name} is missing ${key}`);+ }+ }+});diff --git a/docs/spec/04-ux/06-settings-ia.md b/docs/spec/04-ux/06-settings-ia.mdindex 79e428eda..25dff4ec3 100644--- a/docs/spec/04-ux/06-settings-ia.md+++ b/docs/spec/04-ux/06-settings-ia.md@@ -735,6 +735,14 @@ system while preserving their different data ownership:- disabling developer mode closes an open console and disables or removesevery entry point; Settings search indexes the card, switch, and consoleaction+- **Easter eggs** card with one row that replays the Mid-Autumn egg: a+ full-screen Moon Festival canvas animation (moonrise, a mooncake rain, the+ mooncakes flying up to assemble 「中秋快乐」, and vertical poem lines drifting+ behind them). The same animation also plays by itself once, at most one time+ ever per profile, and only after the startup splash has finished — it must+ never cover the boot splash or appear while the app is still loading.+ Closing it (top-right close button or Escape) returns to the app; afterwards+ it is only reachable from this row- The Updates row always exposes a Release notes action. It opens a modalcontaining the complete shipped stable changelog in newest-first order,localized to the product language and marking the current and availablediff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.mdindex b7922b590..54fde409f 100644--- a/docs/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/spec/06-delivery/04-e2e-test-plan.md@@ -174,6 +174,22 @@General.- **Status:** Documented; run after integration into main.++### E2E-SHELL-mid-autumn-egg-first-open++- **Preconditions:** A profile whose renderer storage has never recorded the+ Mid-Autumn egg (`pi.desktop.midAutumnEggSeen` unset).+- **Steps:** Launch the app and watch the startup splash; after the shell is+ ready close the egg with its top-right close button, relaunch and confirm no+ automatic playback, then open Settings → Info and activate the Mid-Autumn+ egg row.+- **Expected:** The automatic egg appears only once the startup splash has+ finished; it never covers or delays the splash and never appears while the+ app is still loading. It fills the window, exposes an obvious top-right+ close button, and both that button and Escape dismiss it and restore focus+ to the app. Settings → Info shows the Easter eggs card, and its row replays+ the same animation on demand regardless of the seen flag.+- **Status:** Documented; run after integration into main.- Document every user-visible and protocol-visible behavior that MVP must verify.- Provide a scenario catalog that maps to acceptance criteria (A–H) and milestones (M1–M6).- Serve as the traceability backbone: scenario ID ↔ acceptance criterion ↔ spec.diff --git a/packages/i18n/src/locales/de/index.ts b/packages/i18n/src/locales/de/index.tsindex f9fed0ed5..abf0d3c9a 100644--- a/packages/i18n/src/locales/de/index.ts+++ b/packages/i18n/src/locales/de/index.ts@@ -1447,6 +1447,11 @@ sklm: {"feedback": "Ein Problem melden","feedbackDesc": "Öffnet GitHub mit Ihrer ausgefüllten Version.","openFeedback": "Öffnen Sie GitHub",+ "easterEggs": "Ostereier",+ "midAutumnEgg": "Mondfest-Osterei",+ "midAutumnEggDesc": "Eine bildschirmfüllende Mondfest-Animation, die beim Start der App einmal abgespielt wird; hier können Sie sie erneut abspielen.",+ "playMidAutumnEgg": "Abspielen",+ "closeEasterEgg": "Schließen","developer": "Entwickler","developerMode": "Entwicklermodus","developerModeDesc": "Aktivieren Sie Entwicklertools und F12.",diff --git a/packages/i18n/src/locales/en/index.ts b/packages/i18n/src/locales/en/index.tsindex 249749a58..4b1eb247a 100644--- a/packages/i18n/src/locales/en/index.ts+++ b/packages/i18n/src/locales/en/index.ts@@ -1466,6 +1466,11 @@ sklm: {feedback: "Report a problem",feedbackDesc: "Opens GitHub with your version filled in.",openFeedback: "Open GitHub",+ easterEggs: "Easter eggs",+ midAutumnEgg: "Mid-Autumn egg",+ midAutumnEggDesc: "A full-screen Moon Festival animation that plays once when the app opens; replay it here.",+ playMidAutumnEgg: "Play",+ closeEasterEgg: "Close",developer: "Developer",developerMode: "Developer mode",developerModeDesc: "Enable developer tools and F12.",diff --git a/packages/i18n/src/locales/es/index.ts b/packages/i18n/src/locales/es/index.tsindex ed3657f14..f53ed2679 100644--- a/packages/i18n/src/locales/es/index.ts+++ b/packages/i18n/src/locales/es/index.ts@@ -1447,6 +1447,11 @@ sklm: {"feedback": "Informar un problema","feedbackDesc": "Abre GitHub con su versión completa.","openFeedback": "Abrir GitHub",+ "easterEggs": "Huevos de Pascua",+ "midAutumnEgg": "Huevo del Festival del Medio Otoño",+ "midAutumnEggDesc": "Una animación a pantalla completa del Festival del Medio Otoño que se reproduce una vez al abrir la aplicación; puedes volver a reproducirla aquí.",+ "playMidAutumnEgg": "Reproducir",+ "closeEasterEgg": "Cerrar","developer": "Desarrollador","developerMode": "Modo desarrollador","developerModeDesc": "Habilitar herramientas de desarrollador y F12.",diff --git a/packages/i18n/src/locales/fr/index.ts b/packages/i18n/src/locales/fr/index.tsindex d02da9d12..da2425f90 100644--- a/packages/i18n/src/locales/fr/index.ts+++ b/packages/i18n/src/locales/fr/index.ts@@ -1447,6 +1447,11 @@ sklm: {"feedback": "Signaler un problème","feedbackDesc": "Ouvre GitHub avec votre version renseignée.","openFeedback": "Ouvrez GitHub",+ "easterEggs": "Œufs de Pâques",+ "midAutumnEgg": "Œuf de la Fête de la mi-automne",+ "midAutumnEggDesc": "Une animation en plein écran de la Fête de la mi-automne qui se joue une fois à l'ouverture de l'application ; vous pouvez la relancer ici.",+ "playMidAutumnEgg": "Lire",+ "closeEasterEgg": "Fermer","developer": "Développeur","developerMode": "Mode développeur","developerModeDesc": "Activez les outils de développement et F12.",diff --git a/packages/i18n/src/locales/ko/index.ts b/packages/i18n/src/locales/ko/index.tsindex c3c165e53..752e7d9a9 100644--- a/packages/i18n/src/locales/ko/index.ts+++ b/packages/i18n/src/locales/ko/index.ts@@ -1464,6 +1464,11 @@ sklm: {feedback: "문제 신고",feedbackDesc: "버전 정보가 입력된 GitHub 페이지를 엽니다.",openFeedback: "GitHub 열기",+ easterEggs: "이스터 에그",+ midAutumnEgg: "추석 이스터 에그",+ midAutumnEggDesc: "앱을 열 때 한 번 재생되는 전체 화면 추석 애니메이션이며, 여기서 다시 재생할 수 있습니다.",+ playMidAutumnEgg: "다시 재생",+ closeEasterEgg: "닫기",developer: "개발자",developerMode: "개발자 모드",developerModeDesc: "개발자 도구와 F12를 활성화합니다.",diff --git a/packages/i18n/src/locales/pt-BR/index.ts b/packages/i18n/src/locales/pt-BR/index.tsindex a62abcd8d..f6899b5fd 100644--- a/packages/i18n/src/locales/pt-BR/index.ts+++ b/packages/i18n/src/locales/pt-BR/index.ts@@ -1409,6 +1409,11 @@ export const ptBR = {feedback: "Relatar um problema",feedbackDesc: "Abra uma issue no GitHub com diagnósticos opcionais.",openFeedback: "Abrir GitHub",+ easterEggs: "Ovos de Páscoa",+ midAutumnEgg: "Ovo do Festival do Meio do Outono",+ midAutumnEggDesc: "Uma animação em tela cheia do Festival do Meio do Outono que é reproduzida uma vez ao abrir o aplicativo; você pode reproduzi-la novamente aqui.",+ playMidAutumnEgg: "Reproduzir",+ closeEasterEgg: "Fechar",developer: "Desenvolvedor",developerMode: "Modo de desenvolvedor",developerModeDesc: "Habilita logs adicionais, painéis de depuração e inspeção.",diff --git a/packages/i18n/src/locales/tr/index.ts b/packages/i18n/src/locales/tr/index.tsindex b8c903643..2f8f6a4bf 100644--- a/packages/i18n/src/locales/tr/index.ts+++ b/packages/i18n/src/locales/tr/index.ts@@ -1454,6 +1454,11 @@ sklm: {feedback: "Sorun bildir",feedbackDesc: "Sürümünüz doldurulmuş olarak GitHub’ı açar.",openFeedback: "GitHub’ı aç",+ easterEggs: "Sürprizler",+ midAutumnEgg: "Sonbahar Ortası sürprizi",+ midAutumnEggDesc: "Uygulama açıldığında bir kez oynatılan tam ekran Sonbahar Ortası (Ay Festivali) animasyonu; buradan yeniden oynatabilirsiniz.",+ playMidAutumnEgg: "Oynat",+ closeEasterEgg: "Kapat",developer: "Geliştirici",developerMode: "Geliştirici kipi",developerModeDesc: "Geliştirici araçlarını ve F12’yi aç.",diff --git a/packages/i18n/src/locales/zh-CN/index.ts b/packages/i18n/src/locales/zh-CN/index.tsindex 49494d567..d2dfff77f 100644--- a/packages/i18n/src/locales/zh-CN/index.ts+++ b/packages/i18n/src/locales/zh-CN/index.ts@@ -1434,6 +1434,11 @@ sklm: {feedback: "问题反馈",feedbackDesc: "在 GitHub 提交问题,并自动带上当前版本。",openFeedback: "打开 GitHub",+ easterEggs: "彩蛋",+ midAutumnEgg: "中秋彩蛋",+ midAutumnEggDesc: "应用启动时播放一次的全屏中秋动画,可在此再次播放。",+ playMidAutumnEgg: "再播一次",+ closeEasterEgg: "关闭",developer: "开发者",developerMode: "开发者模式",developerModeDesc: "启用开发者工具和 F12。",diff --git a/packages/i18n/src/locales/zh-TW/index.ts b/packages/i18n/src/locales/zh-TW/index.tsindex 493c113a7..a77c4e33f 100644--- a/packages/i18n/src/locales/zh-TW/index.ts+++ b/packages/i18n/src/locales/zh-TW/index.ts@@ -1434,6 +1434,11 @@ sklm: {feedback: "問題反饋",feedbackDesc: "在 GitHub 提交問題,並自動帶上當前版本。",openFeedback: "開啟 GitHub",+ easterEggs: "彩蛋",+ midAutumnEgg: "中秋彩蛋",+ midAutumnEggDesc: "應用程式啟動時播放一次的全螢幕中秋動畫,可在此再次播放。",+ playMidAutumnEgg: "再播一次",+ closeEasterEgg: "關閉",developer: "開發者",developerMode: "開發者模式",developerModeDesc: "啟用開發者工具和 F12。",