{"versions":{"0.0.1":{"name":"@pierre/theming","version":"0.0.1","license":"apache-2.0","type":"module","sideEffects":false,"typesVersions":{"*":{"*":["dist/*"],"color":["dist/color.d.ts"],"react":["dist/react.d.ts"],"themes":["dist/themes.d.ts"]}},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./color":{"types":"./dist/color.d.ts","import":"./dist/color.js"},"./react":{"types":"./dist/react.d.ts","import":"./dist/react.js"},"./themes":{"types":"./dist/themes.d.ts","import":"./dist/themes.js"}},"publishConfig":{"access":"public"},"scripts":{"build":"tsdown --clean && bun scripts/assert-core-clean.ts","dev":"echo 'Watching for changes…' && tsdown --watch --log-level error","test":"bun test","tsc":"tsgo --noEmit --pretty","prepublishOnly":"bun run build"},"dependencies":{},"devDependencies":{"@pierre/theme":"1.0.3","@shikijs/themes":"4.0.2","@types/react":"19.2.7","@types/react-dom":"19.2.3","react":"19.2.3","react-dom":"19.2.3","shiki":"4.0.2","tsdown":"0.15.11","typescript":"5.9.2"},"peerDependencies":{"@pierre/theme":"^1.0.0","@shikijs/themes":"^3.0.0 || ^4.0.0","react":"^18.3.1 || ^19.0.0","react-dom":"^18.3.1 || ^19.0.0","shiki":"^3.0.0 || ^4.0.0"},"peerDependenciesMeta":{"react":{"optional":true},"react-dom":{"optional":true},"shiki":{"optional":true},"@pierre/theme":{"optional":true},"@shikijs/themes":{"optional":true}},"_id":"@pierre/theming@0.0.1","_integrity":"sha512-1thlEtJbqdyLzc1ZS2KQa1q7FzDGHT4dTEdKHoyQjOMeWWOmbVG5/ndEfOKfAb5Fzkz8cNJrOjFLiZoDH/A03A==","_nodeVersion":"24.3.0","_npmVersion":"10.8.3","shasum":"f0c4bd07d730e9de15f6fb7d770f4faab7bb21ca","dist":{"integrity":"sha512-1thlEtJbqdyLzc1ZS2KQa1q7FzDGHT4dTEdKHoyQjOMeWWOmbVG5/ndEfOKfAb5Fzkz8cNJrOjFLiZoDH/A03A==","shasum":"f0c4bd07d730e9de15f6fb7d770f4faab7bb21ca","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/@pierre/theming/-/theming-0.0.1.tgz","fileCount":59,"unpackedSize":182505,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIGCEuATrj6/sXetoJhaBIr0mbDcFCN/fE3xNWfoOgBR8AiEA+QURbalzGDwoRe6wcGeX6MXAk3s+2Zj4dS8gqbSNEbU="}],"size":45524},"_npmUser":{"name":"anonymous","email":"alexsexton@gmail.com"},"directories":{},"maintainers":[{"name":"anonymous","email":"jacobthornton@gmail.com"},{"name":"anonymous","email":"imownbey@gmail.com"},{"name":"anonymous","email":"markdotto@gmail.com"},{"name":"anonymous","email":"alexsexton@gmail.com"},{"name":"anonymous","email":"amadeusdemarzi@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/theming_0.0.1_1781110120885_0.18935221644977673"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2026-06-10T16:48:41.035Z","publish_time":1781110121035,"_source_registry_name":"default","contributors":[]},"0.0.2":{"name":"@pierre/theming","version":"0.0.2","license":"apache-2.0","type":"module","sideEffects":false,"typesVersions":{"*":{"*":["dist/*"],"color":["dist/color.d.ts"],"react":["dist/react.d.ts"],"themes":["dist/themes.d.ts"]}},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./color":{"types":"./dist/color.d.ts","import":"./dist/color.js"},"./react":{"types":"./dist/react.d.ts","import":"./dist/react.js"},"./themes":{"types":"./dist/themes.d.ts","import":"./dist/themes.js"}},"publishConfig":{"access":"public"},"dependencies":{},"devDependencies":{"@shikijs/themes":"4.2.0","@types/react":"19.2.7","@types/react-dom":"19.2.3","react":"19.2.7","react-dom":"19.2.7","shiki":"4.2.0","tsdown":"0.22.3","typescript":"6.0.3","@pierre/theme":"1.1.0"},"peerDependencies":{"@pierre/theme":"^1.1.0","@shikijs/themes":"^3.0.0 || ^4.0.0","react":"^18.3.1 || ^19.0.0","react-dom":"^18.3.1 || ^19.0.0","shiki":"^3.0.0 || ^4.0.0"},"peerDependenciesMeta":{"react":{"optional":true},"react-dom":{"optional":true},"shiki":{"optional":true},"@pierre/theme":{"optional":true},"@shikijs/themes":{"optional":true}},"scripts":{},"_nodeVersion":"26.0.0","_id":"@pierre/theming@0.0.2","dist":{"integrity":"sha512-QM1M4stXfnzfaE8I8YbjXSApV8c+2dBsXJj8eYg9WTpBR/cTmCZIcfGnN4p13iRrYu2Br/R/OJfEL7uR8Qjctw==","shasum":"fefe5a2cfc26ca0d26c71962032e1902741d4616","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/@pierre/theming/-/theming-0.0.2.tgz","fileCount":59,"unpackedSize":171570,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCkh9cqvGX5e56y0SBK21itnjhK49oiZ6GpcYvOnyfQiAIhAOhGv/PriEOGCRsW7q29pcaNsoEgiUCyNAnVNRcC3RS7"}],"size":47135},"_npmUser":{"name":"anonymous","email":"amadeusdemarzi@gmail.com"},"directories":{},"maintainers":[{"name":"anonymous","email":"jacobthornton@gmail.com"},{"name":"anonymous","email":"imownbey@gmail.com"},{"name":"anonymous","email":"markdotto@gmail.com"},{"name":"anonymous","email":"nicolas@pierre.co"},{"name":"anonymous","email":"alexsexton@gmail.com"},{"name":"anonymous","email":"amadeusdemarzi@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/theming_0.0.2_1782432992514_0.9260092675013805"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2026-06-26T00:16:32.678Z","publish_time":1782432992678,"_source_registry_name":"default","contributors":[]},"1.0.0":{"name":"@pierre/theming","version":"1.0.0","license":"apache-2.0","type":"module","sideEffects":false,"typesVersions":{"*":{"*":["dist/*"],"color":["dist/color.d.ts"],"react":["dist/react.d.ts"],"themes":["dist/themes.d.ts"]}},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./color":{"types":"./dist/color.d.ts","import":"./dist/color.js"},"./react":{"types":"./dist/react.d.ts","import":"./dist/react.js"},"./themes":{"types":"./dist/themes.d.ts","import":"./dist/themes.js"}},"publishConfig":{"access":"public"},"dependencies":{},"devDependencies":{"@shikijs/themes":"4.2.0","@types/react":"19.2.7","@types/react-dom":"19.2.3","react":"19.2.7","react-dom":"19.2.7","shiki":"4.2.0","tsdown":"0.22.3","typescript":"6.0.3","@pierre/theme":"2.0.0"},"peerDependencies":{"@pierre/theme":"^1.1.0","@shikijs/themes":"^3.0.0 || ^4.0.0","react":"^18.3.1 || ^19.0.0","react-dom":"^18.3.1 || ^19.0.0","shiki":"^3.0.0 || ^4.0.0"},"peerDependenciesMeta":{"react":{"optional":true},"react-dom":{"optional":true},"shiki":{"optional":true},"@pierre/theme":{"optional":true},"@shikijs/themes":{"optional":true}},"scripts":{},"_nodeVersion":"26.0.0","_id":"@pierre/theming@1.0.0","dist":{"integrity":"sha512-WsdrnhKfjeyXGDikZmN9pkpeZ5S/cl6EE72feiSc0tlynT1tMYqXqouhuv/foK+PY9OEnebOAVRQn3+rAstR8g==","shasum":"520e0f857c1b762e975f5b7a15f74a3e8320b825","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/@pierre/theming/-/theming-1.0.0.tgz","fileCount":60,"unpackedSize":182469,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIDo7cupWnWgmkhPKSdMgWh72jRTsDj2SMKJOlsJQ3osZAiEAxXpwVAijeo4YZdDrBrhKbrNY8Zxr4kwzM2VktzJl3lw="}],"size":50971},"_npmUser":{"name":"anonymous","email":"amadeusdemarzi@gmail.com"},"directories":{},"maintainers":[{"name":"anonymous","email":"jacobthornton@gmail.com"},{"name":"anonymous","email":"imownbey@gmail.com"},{"name":"anonymous","email":"markdotto@gmail.com"},{"name":"anonymous","email":"nicolas@pierre.co"},{"name":"anonymous","email":"alexsexton@gmail.com"},{"name":"anonymous","email":"amadeusdemarzi@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/theming_1.0.0_1784930575202_0.5361744865099372"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2026-07-24T22:02:55.347Z","publish_time":1784930575347,"_source_registry_name":"default","contributors":[]},"1.0.1":{"_id":"@pierre/theming@1.0.1","dist":{"shasum":"79601332d7985b5f37ceebe20399a15ededa6809","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/@pierre/theming/-/theming-1.0.1.tgz","fileCount":60,"integrity":"sha512-WCI5Qd7iprDpISL9fBYOLe8RV53+b7mFNA3bPzl60/2CKCSrsKN8zEcep6Y3BAzvARlmca50zGjDodqPGiTUKA==","signatures":[{"sig":"MEUCIQDMNIWR4hF9398PKYKbg3hFHjhiu09nwdSgiUHhNZt69QIgH9zcyZyETckJ2U0TBmaX7Vxu0LvkniuYnkGImhFa1C4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDdnNTD6VuZY8J4e05lSF3N0PJGNFr8EkKsdzNHqz2AcwIgQplKtKiddlKpxTkx+ezTeQWhnTuRi8r2SdPGupOjiik="}],"unpackedSize":182654,"size":51053},"name":"@pierre/theming","type":"module","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./color":{"types":"./dist/color.d.ts","import":"./dist/color.js"},"./react":{"types":"./dist/react.d.ts","import":"./dist/react.js"},"./themes":{"types":"./dist/themes.d.ts","import":"./dist/themes.js"}},"license":"apache-2.0","scripts":{},"version":"1.0.1","_npmUser":{"name":"anonymous","email":"amadeusdemarzi@gmail.com"},"directories":{},"maintainers":[{"name":"anonymous","email":"jacobthornton@gmail.com"},{"name":"anonymous","email":"imownbey@gmail.com"},{"name":"anonymous","email":"markdotto@gmail.com"},{"name":"anonymous","email":"nicolas@pierre.co"},{"name":"anonymous","email":"alexsexton@gmail.com"},{"name":"anonymous","email":"amadeusdemarzi@gmail.com"}],"sideEffects":false,"_nodeVersion":"26.0.0","dependencies":{},"publishConfig":{"access":"public"},"typesVersions":{"*":{"*":["dist/*"],"color":["dist/color.d.ts"],"react":["dist/react.d.ts"],"themes":["dist/themes.d.ts"]}},"_hasShrinkwrap":false,"devDependencies":{"react":"19.2.7","shiki":"4.4.1","tsdown":"0.22.3","react-dom":"19.2.7","typescript":"6.0.3","@types/react":"19.2.7","@pierre/theme":"2.0.0","@shikijs/themes":"4.4.1","@types/react-dom":"19.2.3"},"peerDependencies":{"react":"^18.3.1 || ^19.0.0","shiki":"^3.0.0 || ^4.0.0","react-dom":"^18.3.1 || ^19.0.0","@pierre/theme":"^1.1.0 || ^2.0.0","@shikijs/themes":"^3.0.0 || ^4.0.0"},"peerDependenciesMeta":{"react":{"optional":true},"shiki":{"optional":true},"react-dom":{"optional":true},"@pierre/theme":{"optional":true},"@shikijs/themes":{"optional":true}},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/theming_1.0.1_1785977427354_0.5251450378233913"},"_cnpmcore_publish_time":"2026-08-06T00:50:27.436Z","publish_time":1785977427436,"_source_registry_name":"default","contributors":[]},"1.0.2":{"_id":"@pierre/theming@1.0.2","dist":{"shasum":"2b295f2d637f9dd75e43fbacbb6cdb7105fc57a1","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/@pierre/theming/-/theming-1.0.2.tgz","fileCount":60,"integrity":"sha512-RmXLLqtx31UGcR8kZyO5hGAQ1EXz6loT1Cu0BFAGsbnBboIxp2BlomkLfWyvdT4WZXnBGyu25onL1gKpFQuSUw==","signatures":[{"sig":"MEUCIQDRu3bOnru8A7S9aS5TNF3q3VRjJxekVP1+LXZIpmk/ZwIgSWXxkOxbtngJPjc+SI2Qklvvfu2d/RJKR5wYbQyrLJ8=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIBpLMBWOF577adefc4aGeeovOtDli0o+TYN1s5EHlAU/AiB4br2zhu3r2nOOdigGCHk5TDG630JvJDjkPThJ0xOibg=="}],"unpackedSize":182403,"size":50968},"name":"@pierre/theming","type":"module","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./color":{"types":"./dist/color.d.ts","import":"./dist/color.js"},"./react":{"types":"./dist/react.d.ts","import":"./dist/react.js"},"./themes":{"types":"./dist/themes.d.ts","import":"./dist/themes.js"}},"license":"apache-2.0","scripts":{},"version":"1.0.2","_npmUser":{"name":"anonymous","email":"amadeusdemarzi@gmail.com"},"directories":{},"maintainers":[{"name":"anonymous","email":"jacobthornton@gmail.com"},{"name":"anonymous","email":"imownbey@gmail.com"},{"name":"anonymous","email":"markdotto@gmail.com"},{"name":"anonymous","email":"nicolas@pierre.co"},{"name":"anonymous","email":"i@jex.me"},{"name":"anonymous","email":"alexsexton@gmail.com"},{"name":"anonymous","email":"amadeusdemarzi@gmail.com"}],"sideEffects":false,"_nodeVersion":"24.11.0","dependencies":{},"publishConfig":{"access":"public"},"typesVersions":{"*":{"*":["dist/*"],"color":["dist/color.d.ts"],"react":["dist/react.d.ts"],"themes":["dist/themes.d.ts"]}},"_hasShrinkwrap":false,"devDependencies":{"react":"19.2.7","shiki":"4.4.1","tsdown":"0.22.14","react-dom":"19.2.7","typescript":"7.0.2","@types/react":"19.2.7","@pierre/theme":"2.0.0","@shikijs/themes":"4.4.1","@types/react-dom":"19.2.3"},"peerDependencies":{"react":"^18.3.1 || ^19.0.0","shiki":"^3.0.0 || ^4.0.0","react-dom":"^18.3.1 || ^19.0.0","@pierre/theme":"^1.1.0 || ^2.0.0","@shikijs/themes":"^3.0.0 || ^4.0.0"},"peerDependenciesMeta":{"react":{"optional":true},"shiki":{"optional":true},"react-dom":{"optional":true},"@pierre/theme":{"optional":true},"@shikijs/themes":{"optional":true}},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/theming_1.0.2_1792605567386_0.2153990950372453"},"_cnpmcore_publish_time":"2026-10-21T17:59:27.491Z","publish_time":1792605567491,"_source_registry_name":"default","contributors":[]}},"dist-tags":{"latest":"1.0.2"},"name":"@pierre/theming","time":{"created":"2026-06-11T10:26:52.379Z","modified":"2026-10-21T17:59:44.122Z","0.0.1":"2026-06-10T16:48:41.035Z","0.0.2":"2026-06-26T00:16:32.678Z","1.0.0":"2026-07-24T22:02:55.347Z","1.0.1":"2026-08-06T00:50:27.436Z","1.0.2":"2026-10-21T17:59:27.491Z"},"readme":"# @pierre/theming\n\nThe theming toolkit for Pierre's open-source UI packages. It provides catalog\nprimitives, the loader/cache for resolving theme JSON, a normalizer plus color\ntransforms that resolve and derive accessible UI colors from a resolved shiki\ntheme, and a framework-agnostic controller for the selected color mode and\ntheme. `@pierre/diffs`, `@pierre/trees`, and the apps built on top of them all\ndraw their colors from this one package, so a single theme resolves to the same\nsurfaces everywhere.\n\nIt understands the [Shiki](https://shiki.style/) / VS Code theme format, so\nthemes shipped by Shiki, custom VS Code themes, and Pierre's first-party themes\nall resolve to the same shape.\n\n## Theme model\n\nTheme-kit uses a few names for related but different things:\n\n- **theme name**: the stable string apps pass around, such as `pierre-dark` or\n  `github-light`. It is the id used by catalogs, resolvers, controllers,\n  storage, and theme pickers. Treat it like a database key: small, serializable,\n  and safe to persist.\n- **theme descriptor**: the catalog entry for one name. It contains the name,\n  optional metadata (`displayName`, `collection`, `colorScheme`), and a lazy\n  `load()` function. Descriptors let an app list available themes without\n  loading theme JSON yet.\n- **resolved theme object**: the actual theme returned by a descriptor loader or\n  resolver. This is the Shiki / VS Code-like object that has `colors`, `fg`,\n  `bg`, `type`, and `name` after normalization.\n\nRecommendation for apps: keep the theme name in state and storage, use\ndescriptors for menus and metadata, and use the resolved theme object only when\nyou need to color UI or hand a theme to Shiki.\n\n### Shiki theme shape\n\nA Shiki / VS Code theme has two important color areas:\n\n- `tokenColors` / `settings` describe syntax highlighting rules: comments,\n  strings, keywords, functions, and other code tokens.\n- `colors` is a map of workbench-style UI keys, such as `editor.background`,\n  `editor.foreground`, `sideBar.background`, `list.hoverBackground`,\n  `focusBorder`, and `gitDecoration.addedResourceForeground`.\n\n`normalizeThemeColors` and the color transforms read the workbench-like `colors`\nkeys plus the normalized top-level `fg`, `bg`, and `type`. They do not inspect\nsyntax-token rules. Use the raw resolved Shiki theme when rendering highlighted\ncode; use `normalizeThemeColors` (and the transforms) when coloring app UI\naround that code.\n\n## Entry points\n\ntheming ships one implementation through four public entry points.\n\n| Import                   | Peer dep                                    | Purpose                                                            |\n| ------------------------ | ------------------------------------------- | ------------------------------------------------------------------ |\n| `@pierre/theming`        | —                                           | Catalog/resolver/controller primitives and types                   |\n| `@pierre/theming/color`  | —                                           | `normalizeThemeColors` plus the `colorUtils` color transforms      |\n| `@pierre/theming/react`  | `react`                                     | hooks over a controller                                            |\n| `@pierre/theming/themes` | `@pierre/theme`, `@shikijs/themes`, `shiki` | Bundled Pierre/Shiki collections and Shiki / VS Code normalization |\n\n## Install\n\n```bash\npnpm add @pierre/theming\n```\n\nAdd the optional peers only for the entries you use, e.g., `react` for `/react`,\nand `@pierre/theme`, `@shikijs/themes`, and `shiki` for `/themes`.\n\n## Agent skill\n\nInstall the agent skill for this package with the\n[Skills CLI](https://skills.sh/docs/cli):\n\n```bash\nnpx skills add pierrecomputer/pierre --skill theming\n```\n\n## Collections and catalogs\n\nThe core entry exports two closely-related composition primitives:\n\n- A `ThemeCollection` is an ordered set of theme descriptors and lazy loaders.\n  The `/themes` entry exports `themes`, the bundled Pierre-then-Shiki\n  collection, plus `pierreThemes` and `shikiThemes` source collections when an\n  app wants one source or wants to compose its own order.\n- A `ThemeCatalog` is the app-level collection, plus `defaultLightThemeName` and\n  `defaultDarkThemeName`.\n\nListing a name never loads, imports, or evaluates that theme. Each descriptor\nonly carries a loader function, so it is safe to render a full theme picker on a\npage that never resolves a theme.\n\n```ts\nimport { createThemeCatalog } from '@pierre/theming';\nimport { themes } from '@pierre/theming/themes';\n\nconst catalog = createThemeCatalog({\n  themes,\n  defaultLightThemeName: 'pierre-light',\n  defaultDarkThemeName: 'pierre-dark',\n});\n\ncatalog.getThemeNames(); // ['pierre-light', 'pierre-light-soft', …]\ncatalog.getThemeNames({ colorScheme: 'light' }); // ['pierre-light', …]\ncatalog.getThemeNames({ colorScheme: 'dark' }); // ['pierre-dark', …]\ncatalog.getThemes({ collection: 'pierre' }); // Pierre descriptors only\ncatalog.defaultLightThemeName; // 'pierre-light'\ncatalog.defaultDarkThemeName; // 'pierre-dark'\n\nconst opinionatedCatalog = createThemeCatalog({\n  themes: themes.pick(['github-light', 'solarized-dark']),\n  defaultLightThemeName: 'github-light',\n  defaultDarkThemeName: 'solarized-dark',\n});\n```\n\nApps that want a local default different from theming's canonical Pierre pair\nshould set it on their catalog, then let the controller read those defaults:\n\n```ts\nconst diffshubCatalog = createThemeCatalog({\n  themes,\n  defaultLightThemeName: 'pierre-light-soft',\n  defaultDarkThemeName: 'pierre-dark-soft',\n});\n\nconst controller = createThemeController({\n  catalog: diffshubCatalog,\n  defaultMode: 'system',\n});\n```\n\nCollections can be passed anywhere descriptors can be passed, so larger\ncollections are just wrappers around smaller collections:\n\n```ts\nimport { createThemeCollection } from '@pierre/theming';\nimport { pierreThemes, shikiThemes, createTheme } from '@pierre/theming/themes';\n\nconst appThemes = createThemeCollection({\n  themes: [\n    pierreThemes.pick(['pierre-light', 'pierre-dark']),\n    shikiThemes.pick(['github-light', 'solarized-dark']),\n    createTheme({\n      name: 'acme-dark',\n      collection: 'acme',\n      colorScheme: 'dark',\n      load: () => import('./acme-dark.json'),\n    }),\n  ],\n});\n```\n\nCollections are immutable snapshots: their descriptor lists do not change after\nconstruction, and helpers such as `pick()` and `orderBy()` return new\ncollections. Order is part of that contract:\n\n- `themes` is bundled in a stable default order: all Pierre themes first, then\n  Shiki themes.\n- `getThemeNames(options)` and `getThemes(options)` preserve the current\n  collection order after filtering by `colorScheme` and/or `collection`.\n- `pick([...])` returns the requested themes in the caller-provided order.\n- `orderBy(compare)` returns a reordered collection without loading any theme.\n\n```ts\n// Reverse alphabetical selector order.\nconst reverseAlphabetical = themes.orderBy((a, b) =>\n  b.name.localeCompare(a.name)\n);\n\n// Pierre first, then all non-Pierre themes alphabetically by display label/name.\nconst collectionRank = (collection: string | undefined) =>\n  collection === 'pierre' ? 0 : 1;\nconst pierreFirst = themes.orderBy((a, b) => {\n  const rank = collectionRank(a.collection) - collectionRank(b.collection);\n  if (rank !== 0) return rank;\n  const aLabel = a.displayName ?? a.name;\n  const bLabel = b.displayName ?? b.name;\n  return aLabel.localeCompare(bLabel);\n});\n```\n\nPass plain descriptors for custom loaders that already return a usable\n`ThemeLike`. Use `createTheme()` from `/themes` when the loader returns a raw VS\nCode/Shiki theme that should be normalized before consumers use it:\n\n```ts\nimport { createTheme } from '@pierre/theming/themes';\n\nconst acmeDark = createTheme({\n  name: 'acme-dark',\n  colorScheme: 'dark',\n  collection: 'acme',\n  displayName: 'Acme Dark',\n  load: () => import('./acme-dark.json'),\n});\n```\n\nDescriptor names should match the resolved theme object's machine name. The\noptional `collection` field identifies the source collection for filtering and\nordering; the convention is lowercase names such as `pierre`, `shiki`, or an\napp/package slug.\n\nNormalization intentionally lives behind the public `/themes` helper, not in\n`createThemeCollection()`. Collections are dependency-light registries for\nnames, metadata, and loaders; they can hold already-resolved `ThemeLike`\nobjects, app-specific generated themes, or raw VS Code/Shiki themes. Raw VS\nCode/Shiki themes should use `createTheme()`. The bundled Pierre and Shiki\ncollections use that same helper. If an app pre-normalizes themes at build time,\nit can use plain descriptors and does not need `createTheme()`.\n\n## Resolving themes\n\nA `ThemeResolver` is a registry of named loaders plus a cache. You register a\nloader for a name; the resolver runs it at most once, dedupes concurrent calls,\nand serves the resolved theme synchronously thereafter. The resolver itself\nknows nothing about Shiki or theme JSON — it just caches whatever a loader\nreturns.\n\n```ts\nimport { createThemeResolver } from '@pierre/theming';\n\n// An isolated instance with its own registry and cache.\nconst resolver = createThemeResolver();\n```\n\nA loader is a zero-argument async factory that returns a theme object or a\n`{ default }` ES-module namespace (the shape a dynamic `import()` of a JSON or\n`.mjs` theme produces — the resolver unwraps `default`):\n\n```ts\nresolver.registerTheme('my-theme', () => import('./my-theme.json'));\n\n// Async cold path — runs the loader, caches the result, dedupes concurrent calls.\nconst theme = await resolver.resolveTheme('my-theme');\n\n// Sync warm path — returns the cached theme or undefined if not resolved yet.\nconst cached = resolver.getResolvedTheme('my-theme');\n\n// \"Get hot, resolve cold\" — the cached theme synchronously, or a Promise.\nconst value = resolver.getResolvedOrResolveTheme('my-theme');\n```\n\nOther methods worth knowing:\n\n- `registerThemeIfAbsent(name, loader)` — register only when the name is free;\n  returns whether it was added. `registerTheme` throws `DuplicateThemeError`.\n- `resolveThemes(names)` / `getResolvedThemes(names)` — batch variants\n  (`getResolvedThemes` throws `UnresolvedThemeError` for the first cold name).\n- `seedResolvedTheme(name, theme)` / `seedResolvedThemes(entries)` — drop a\n  fully-resolved theme straight into the cache without a loader, for\n  environments (e.g. a worker handed pre-resolved themes by the main thread)\n  that can't run one.\n- `hasRegisteredTheme` / `hasResolvedTheme` / `hasResolvedThemes` — registry and\n  cache introspection.\n- `clearResolvedThemes()` — clear the cache and in-flight loads while keeping\n  the registered loaders.\n\n`resolveTheme` rejects with `UnregisteredThemeError` when no loader exists for\nthe name.\n\n### Registering theme loaders\n\nCollections register themselves into a resolver with the per-name lazy imports.\nMany themes can be registered without generating a large initial bundle to load.\n\n```ts\nimport { createTheme, themes } from '@pierre/theming/themes';\n\n// Register exactly the themes an opinionated app exposes.\nthemes.pick(['github-light', 'solarized-dark']).registerInto(resolver);\n\n// Or register the full bundled Pierre-then-Shiki collection.\nthemes.registerInto(resolver);\n\n// Custom VS Code/Shiki themes use the same descriptor model.\nconst acmeDark = createTheme({\n  name: 'my-vscode-theme',\n  colorScheme: 'dark',\n  load: () => import('./theme.json'),\n});\n\nresolver.registerTheme(acmeDark.name, acmeDark.load);\n```\n\nUse `collection.registerInto(resolver)` when you want idempotent registration:\nit calls `registerThemeIfAbsent`, so existing resolver entries win. Use\n`resolver.registerTheme(descriptor.name, descriptor.load)` when duplicate names\nshould be an error.\n\nRegistering a whole app catalog against a resolver is also a single call. Most\napps can let `createThemeController({ catalog })` do this automatically; use\nmanual registration when lower-level code owns the resolver directly.\n\n```ts\nimport { createThemeCatalog, createThemeResolver } from '@pierre/theming';\nimport { themes } from '@pierre/theming/themes';\n\nconst catalog = createThemeCatalog({\n  themes,\n  defaultLightThemeName: 'pierre-light',\n  defaultDarkThemeName: 'pierre-dark',\n});\n\nconst resolver = createThemeResolver();\ncatalog.registerInto(resolver);\n```\n\n## Reading theme colors\n\nOnce you have a resolved theme object, the `@pierre/theming/color` entry gives\nyou two things for working with its colors: `normalizeThemeColors` to read the\ncolors a theme actually defines, and a `colorUtils` bag of color transforms to\nderive new colors from them. They live in their own entry so apps that only need\nthe catalog/controller don't pay for the color math.\n\nBoth exist because a raw Shiki theme is not a UI component API. Each theme may\nuse different workbench keys, omit optional keys, or ship a value that works in\nthe editor but not in a tree, popover, or app shell. Rather than make every\nconsumer rediscover the same fallback chains and repairs, theming centralizes\nthem in `normalizeThemeColors` and ships the contrast/color math as standalone\ntransforms.\n\n`normalizeThemeColors` and the transforms accept a `ThemeLike` — a structural\nsubset of a Shiki / VS Code theme, so resolved themes from this package,\n`@pierre/diffs`, or Shiki all fit:\n\n```ts\ninterface ThemeLike {\n  bg?: string;\n  colors?: Record<string, string>;\n  fg?: string;\n  name?: string;\n  type?: 'dark' | 'light';\n}\n```\n\n### `normalizeThemeColors`\n\n`normalizeThemeColors(theme: ThemeLike): ThemeLike` is the front door for\nreading the colors a theme defines. It takes a Shiki-normalized theme (fg, bg,\nand type already present) and returns a **same-shape** theme — the same\ntop-level fields and the same `colors` map vocabulary (the VS Code / Shiki\nworkbench keys, nothing renamed) — with the `colors` map resolved.\n\nWhat it **fills** (mechanical fallback, no opinion):\n\n- surfaces: `editor.background` / `editor.foreground`, `sideBar.background` /\n  `sideBar.foreground`, `input.background`, `sideBarSectionHeader.foreground`,\n  and `list.activeSelectionForeground`.\n- git status: `gitDecoration.{added,modified,deleted}ResourceForeground` via the\n  `gitDecoration → terminal.ansi* → editorGutter.*` chain.\n- the focus ring: `list.focusOutline`, set to the first non-transparent of\n  `list.focusOutline` then `focusBorder`.\n\nWhat it **repairs** (universal correctness): it drops `list.hoverBackground`\nwhen it equals the sidebar surface or would erase the row text.\n\nWhat it deliberately **leaves alone** (consumer opinion): the selection lookup\n(`list.activeSelectionBackground` / `list.focusBackground` /\n`editor.selectionBackground`) passes through raw, so each consumer applies its\nown choice.\n\nThe result is pure, frozen, WeakMap-memoized per input theme, and idempotent. It\nruns lazily at read time by default.\n\n```ts\nimport { normalizeThemeColors } from '@pierre/theming/color';\n\nconst { colors } = normalizeThemeColors(theme);\n// colors['sideBar.background'], colors['gitDecoration.addedResourceForeground'],\n// colors['list.focusOutline'], …\n```\n\n### Color transforms\n\n`colorUtils` bundles the pure color transforms — functions with no theme\nknowledge that take colors and answer questions about them or mix new ones.\nBundling them in one object keeps the entry's export surface small. Use them to\nderive **new** colors from a theme's colors. Its methods:\n\n- `relativeLuminance`, `contrastRatio` — WCAG luminance and contrast math.\n- `isDarkSurface`, `surfacesMatch`, `isFullyTransparent` — surface predicates.\n- `compositeOverBg` — flatten a translucent color over a background.\n- `hoverWouldEraseText` — whether a hover color would erase row text.\n- `pickReadableForeground` — the most legible foreground for a surface.\n- `deriveMutedFg` — a muted foreground derived from fg and surface.\n\n```ts\nimport { colorUtils, normalizeThemeColors } from '@pierre/theming/color';\n\nconst { colors } = normalizeThemeColors(theme);\nconst surface = colors['sideBar.background'];\nconst fg = colorUtils.pickReadableForeground(surface, [\n  colors['sideBar.foreground'],\n]);\nconst mutedFg = colorUtils.deriveMutedFg(fg, surface);\n```\n\n### `normalizeTheme` (Shiki) vs `normalizeThemeColors` (theming)\n\nThese are two different normalizers; do not wire them up backwards.\n\n- Shiki's `normalizeTheme` (from `shiki/core`, applied at load by `createTheme`)\n  normalizes the **whole** theme, including syntax token colors and the base\n  `fg` / `bg` / `type`.\n- theming's `normalizeThemeColors` only resolves the workbench `colors` map and\n  **assumes** a theme that has already been Shiki-normalized.\n\nSo `normalizeTheme` runs first, at load; `normalizeThemeColors` runs after, on\nthe already-normalized theme.\n\n### Assembled token sets are consumer-owned\n\ntheming ships no assembled token object. The opinionated, presentation-ready\ntoken sets live with their consumers:\n\n- `@pierre/trees`' `themeToTreeStyles()` builds its tree CSS variables on\n  `normalizeThemeColors`.\n- Apps build their own app-chrome tokens from `normalizeThemeColors` plus the\n  transforms — for example diffshub's `deriveChromeTokens`.\n\nEach consumer maps the resolved/derived colors onto its own variable names, so\nthe mapping lives in one place per consumer and the color resolution lives here,\nshared.\n\n### Read-time vs pre-warm at load\n\nNormalization runs lazily at read time and is memoized, so the default needs no\nwiring: the first read of a theme normalizes it, and every later read returns\nthe same frozen object.\n\nBecause `normalizeThemeColors` is pure and idempotent, an app that wants a\npre-densified canonical object at load can call `normalizeThemeColors` inside\nits loader and `seedResolvedTheme` the result. That captures the load-time\nbenefit for anyone who wants it without mandating a chokepoint that would break\nthe resolver's contract or miss runtime-registered themes. The default is\nlazy/read-time; pre-warming is a one-line opt-in.\n\n## The theme controller\n\nThe controller is the stateful layer: it owns the selected light and dark theme\nnames, the color mode (`'light' | 'dark' | 'system'`), the theme resolved for\nthe active mode, and persistence. It has no React dependency, so a vanilla app\ncan drive it directly; the `/react` hooks are thin wrappers over it.\n\nIt is **SSR-safe**: every browser access (`localStorage`, `matchMedia`) is\nguarded, so it constructs and runs on the server (persistence and the\nprefers-color-scheme listener no-op) and hydrates on the client.\n\n```ts\nimport { createThemeCatalog } from '@pierre/theming';\nimport { createThemeController } from '@pierre/theming';\nimport { themes } from '@pierre/theming/themes';\n\nconst catalog = createThemeCatalog({\n  themes,\n  defaultLightThemeName: 'pierre-light',\n  defaultDarkThemeName: 'pierre-dark',\n});\n\nconst controller = createThemeController({\n  catalog,\n  defaultMode: 'system',\n  storageKey: 'theme', // built-in localStorage persistence (one JSON entry)\n});\n\ncontroller.getState();\n// {\n//   mode: 'system',\n//   lightThemeName: 'pierre-light',\n//   darkThemeName: 'pierre-dark',\n//   resolvedTheme: ThemeLike | undefined,  // the active theme, once resolved\n//   resolvedColorScheme: 'light' | 'dark', // 'system' collapsed to a concrete scheme\n// }\n\ncontroller.resolver; // the resolver this controller created and registered into\n\ncontroller.setColorMode('dark');\ncontroller.setThemeNameForScheme('light', 'catppuccin-latte');\n\nconst unsubscribe = controller.subscribe(() => render(controller.getState()));\ncontroller.destroy(); // detach the prefers-color-scheme listener\n```\n\n`resolvedColorScheme` is the concrete `'light' | 'dark'` after resolving\n`'system'` against the OS preference — drive your `data-theme` / `class`\napplication off it directly rather than re-deriving it. While in `'system'` mode\nthe controller listens for OS theme flips and re-resolves automatically. Only\nthe active theme is resolved by default; pass `preloadInactive: true` to resolve\nthe inactive one too so a mode flip is instant.\n\n### Resolver ownership\n\n`createThemeController({ catalog })` creates an isolated resolver, registers the\ncatalog into it, and exposes it as `controller.resolver`. That is the\nrecommended path for most apps: the controller/provider becomes the single owner\nof theme selection and resolution.\n\nPass `resolver` explicitly when several controllers, vanilla widgets, workers,\nor tests intentionally need to share one registry/cache:\n\n```ts\nimport { createThemeResolver } from '@pierre/theming';\n\nconst resolver = createThemeResolver();\nconst controller = createThemeController({ catalog, resolver });\n\ncontroller.resolver === resolver; // true\n```\n\nUse multiple resolvers only for deliberate isolation: embedded widgets,\ntenant-specific registries, SSR request isolation, tests, or side-by-side\npreviews where the same theme name should resolve to different objects.\nOtherwise, share one resolver to avoid a split-cache bug where one part of an\napp registers a loader that another part cannot see.\n\n### Persistence\n\nBy default, pass a `storageKey` to get built-in `localStorage` persistence under\none JSON entry. Omit it to disable persistence. For a custom layout — for\nexample mapping the selection onto pre-existing keys, or a non-`localStorage`\nstore — pass a `persistence` adapter, which takes precedence over `storageKey`:\n\n```ts\nimport type { ThemePersistence } from '@pierre/theming';\n\nconst persistence: ThemePersistence = {\n  load() {\n    /* return a { mode, lightThemeName, darkThemeName } selection, or null */\n  },\n  save(selection) {\n    /* persist it; guard your own browser access to stay SSR-safe */\n  },\n};\n\ncreateThemeController({ catalog, persistence });\n```\n\nOnly the selection (`mode` + the two theme names) is ever persisted — the\nresolved theme object is always re-derived from the resolver on load.\n\n## React bindings\n\nThe `/react` entry is a `useSyncExternalStore` selector over a controller\ninstance — no state of its own, no tearing, SSR-friendly. Create the controller\nonce (a module singleton is fine) and pass it in. `useThemeController` returns\nthe full controller state, including `resolvedTheme`.\n\n```tsx\nimport { useThemeController } from '@pierre/theming/react';\n\nfunction ThemeToolbar() {\n  const { mode, resolvedColorScheme } = useThemeController(controller);\n\n  return (\n    <button\n      onClick={() =>\n        controller.setColorMode(mode === 'dark' ? 'light' : 'dark')\n      }\n    >\n      {resolvedColorScheme}\n    </button>\n  );\n}\n```\n\n## Putting it together\n\nA typical app wires the pieces in this order:\n\n1. **Create one catalog** from the theme collections the app exposes. Use\n   `themes.pick([...])` when the app only offers a small opinionated set.\n2. **Create one controller** as a module singleton with that catalog and your\n   persistence. Use `controller.resolver` anywhere lower-level code needs the\n   same registry/cache.\n3. **Subscribe** (via the `/react` hooks or `controller.subscribe`) and apply\n   `resolvedColorScheme` to the document (`data-theme`, `class`,\n   `style.colorScheme`).\n4. **Theme your chrome** by building your own chrome tokens from\n   `normalizeThemeColors(resolvedTheme)` plus the color transforms (as diffshub\n   does) and mapping them onto your CSS variables, and **theme nested file\n   trees** by handing the resolved theme to `@pierre/trees`'\n   `themeToTreeStyles()` (which sits on `normalizeThemeColors`).\n\nTheme-kit currently stops at these engine-level primitives. Higher-level\ncomponent-wrapper prop contracts, such as a single `theme` prop shared across\ndiff, tree, and chrome components, are still app-local while that API settles.","users":{}}