Skip to content

pantoken-root / packages/core/src / resolveReferences

函数: resolveReferences() ​

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

Beta

将每个 token 解析为具体的单模式值:展开 var(...) 链并将 light-dark() 折叠为所选的 mode。

参数 ​

tokens ​

只读 Token[]

IR。

mode? ​

Mode = "light"

保留 light-dark() 的哪一侧(默认 "light")。

返回值 ​

Map<string, string>

从 token 名称到具体值的映射。

示例 ​

将已构建的 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