Skip to content

pantoken / packages/core/src / resolveReferences

関数: resolveReferences()

resolveReferences(tokens, mode?): Map<string, string>

ベータ

すべてのトークンを具体的で単一モードの値に解決する: var(...) のチェーンを展開し、 light-dark() を選択した mode に折り畳む。

パラメーター

tokens

読み取り専用 Token[]

IR(中間表現)。

mode?

Mode = "light"

light-dark() のどちらの側を保持するか(デフォルトは "light")。

戻り値

Map<string, string>

トークン名を具体的な値に対応付けたマップ。

ビルドされたIRを具体的なダークモードの値に解決する

ts
import { buildTokens } from "@pantoken/core/build";
import { resolveReferences } from "@pantoken/core";

const resolved = resolveReferences(buildTokens(), "dark");
resolved.get("--instui-color-background-base"); // → a concrete "#…" value