Repository navigation
feat: add defineThemeTokens typed token contract - #1211
Closed
jonkwheeler wants to merge 2 commits into
Closed
jonkwheeler wants to merge 2 commits into
jonkwheeler wants to merge 2 commits into
Conversation
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>
Closed
4 of 5 tasks
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). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Slice O2 of the typed-native-styling decomposition (tracked in #1204). Re-cut from #1195 — pure addition, no dependencies.
Adds
octane/theme-tokensexportingdefineThemeTokens: declare a theme-token contract once in a plain.tsmodule and let TypeScript check token names and value types natively — the typed entry point the later styling slices build on.var(--name, fallback)reference, plusvars(bare--namenames),raw(declared values), andcss(the:rootsheet plus per-variant selector/media blocks).prefix/selectorcontrol emission;raw/vars/cssare reserved output fields (type-levelnevergate for TS callers, dev warning for JS callers);prefix: ''is treated as unprefixed, matching the compiler-side contract extractor../theme-tokenssubpath export and theverify-distcontract 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(regenerateddocs/packages.md)Provenance
agent-authored)Re-cut mechanically from the validated diff in #1195; no redesign.
Need help on this PR? Tag
@codesmith-botwith 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-tokensentry point exportingdefineThemeTokens, 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, plusraw,vars(bare custom-property names), and generatedcss(:root/ custom selector, optionalprefix, and per-variant selector or@mediablocks).raw,vars, andcssare reserved token group names (typed rejection + dev warnings for JS).Packaging updates register the subpath in
package.json, extendverify-distexport contract, add a patch changeset, and bump the generatedoctaneexport count indocs/packages.md. Coverage lives intheme-tokens.test.ts(runtime emission + ats.Programcontract gate).Reviewed by Cursor Bugbot for commit f3ba7ab. Bugbot is set up for automated code reviews on this repo. Configure here.