pierre-themes.ts
This file
Path
apps/web/src/server/pierre-themes.ts
46 lines · 1.2 KiB · TypeScript
Last changed by
Merge build/comments-web-rest into mainoscabrielbefore adoption0eb1248
History of this fileTake it
Merge build/comments-web-rest into mainoscabrielbefore adoption0eb1248
lines 1–2why, one step back1// `@pierre/theming/themes` for the Worker: its collections map every theme to a dynamic import, about 1.7 MB,2// and the server draws in the token theme alone, so these collections hold nothing.Merge perf/ssr-highlight into mainoscabrielbefore adoption5881ff2
lines 3–46why, one step back3import { Effect } from "effect";4import { normalizeTheme } from "shiki/core";5import type {6 ThemeRegistrationAny,7 ThemeRegistrationResolved,8} from "shiki/core";910interface Descriptor {11 readonly name: string;12 readonly load: () => Promise<ThemeRegistrationResolved>;13}1415const empty = {16 getTheme: (_name: string): Descriptor | undefined => undefined,17 getThemes: (): readonly Descriptor[] => [],18};1920export const pierreThemes = empty;2122export const shikiThemes = empty;2324export const themes = empty;2526const unwrap = (27 loaded: ThemeRegistrationAny | { default: ThemeRegistrationAny }28) => ("default" in loaded ? loaded.default : loaded);2930export const createTheme = ({31 load,32 name,33}: {34 readonly name: string;35 readonly load: () => Promise<36 ThemeRegistrationAny | { default: ThemeRegistrationAny }37 >;38}): Descriptor => ({39 load: () =>40 Effect.runPromise(41 Effect.promise(load).pipe(42 Effect.map((loaded) => normalizeTheme(unwrap(loaded)))43 )44 ),45 name,46});