Skip to content

feat: add defineThemeTokens typed token contract - #1211

Closed
jonkwheeler wants to merge 2 commits into
octanejs:mainfrom
jonkwheeler:feat/theme-token-contracts
Closed

jonkwheeler wants to merge 2 commits into
octanejs:mainfrom
jonkwheeler:feat/theme-token-contracts

Conversation

@jonkwheeler

@jonkwheeler jonkwheeler commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Slice O2 of the typed-native-styling decomposition (tracked in #1204). Re-cut from #1195 — pure addition, no dependencies.

Adds octane/theme-tokens exporting defineThemeTokens: declare a theme-token contract once in a plain .ts module and let TypeScript check token names and value types natively — the typed entry point the later styling slices build on.

  • Returned object keeps the declared shape; every leaf is a var(--name, fallback) reference, plus vars (bare --name names), raw (declared values), and css (the :root sheet plus per-variant selector/media blocks).
  • Variants are excess-key-checked against the contract; prefix/selector control emission; raw/vars/css are reserved output fields (type-level never gate for TS callers, dev warning for JS callers); prefix: '' is treated as unprefixed, matching the compiler-side contract extractor.
  • Registers the ./theme-tokens subpath export and the verify-dist contract entry.

Test plan

  • packages/octane/tests/theme-tokens.test.ts (10 tests, octane + octane-prod projects, incl. ts.Program typecheck-gate pins)
  • pnpm typecheck:files, pnpm format:files, pnpm sync (regenerated docs/packages.md)
  • CI

Provenance

  • An agent produced this diff (agent-authored)

Re-cut mechanically from the validated diff in #1195; no redesign.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Note

Low Risk
Additive public API and tests only; no changes to runtime, compiler, or existing export behavior beyond the new subpath.

Overview
Adds a new octane/theme-tokens entry point exporting defineThemeTokens, so apps can declare a nested theme-token contract in plain TypeScript and get native typechecking on token names, leaf types, and variant overrides.

The helper returns the same tree with each leaf as a var(--name, fallback) string, plus raw, vars (bare custom-property names), and generated css (:root / custom selector, optional prefix, and per-variant selector or @media blocks). raw, vars, and css are reserved token group names (typed rejection + dev warnings for JS).

Packaging updates register the subpath in package.json, extend verify-dist export contract, add a patch changeset, and bump the generated octane export count in docs/packages.md. Coverage lives in theme-tokens.test.ts (runtime emission + a ts.Program contract gate).

Reviewed by Cursor Bugbot for commit f3ba7ab. Bugbot is set up for automated code reviews on this repo. Configure here.

jonkwheeler and others added 2 commits September 21, 2026 09:25
Adds `octane/theme-tokens` exporting `defineThemeTokens`: declare a theme-token
contract once in a plain `.ts` module and let TypeScript check token names and
value types natively. The returned object keeps the declared shape with every
leaf a `var(--name, fallback)` reference, plus `vars` (bare names), `raw` (the
declared values), and `css` (the :root sheet plus per-variant blocks). Registers
the `./theme-tokens` subpath export and the verify-dist contract entry.

Re-cut from feat/typed-native-styling (slice O2, tracked in octanejs#1204).

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent feat PR: new feature or capability labels Sep 21, 2026
@jonkwheeler

Copy link
Copy Markdown
Contributor Author

Closing this slice draft for now: the typed-styling work is moving to an RFC first so the approach can be discussed with maintainers before asking for slice review. The branch and this re-cut remain intact; slices may be reopened or re-cut once the RFC settles the direction. Still tracked in the decomposition index (#1204).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-authored Diff or issue body substantially produced by an AI agent feat PR: new feature or capability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant