Skip to content

pantoken / packages/plugin-kit/src / resolveTokens

Συνάρτηση: resolveTokens()

resolveTokens(base, options?): Map<string, string>

Βήτα

Επίλυσε την τιμή κάθε token σε σχέση με το σύνολο (βλ. makeResolver), με κλειδί το όνομα.

Παράμετροι

base

readonly Token[]

options?

ResolveOptions

Επιστρέφει

Map<string, string>

Παράδειγμα

Επίλυση ολόκληρου IR σε χάρτη όνομα → τιμή

ts
import { resolveTokens } from "@pantoken/utils";
import type { Token } from "@pantoken/model";

const ir: Token[] = [
  { name: "--instui-leaf", syntax: "<color>", inherits: true, value: "#0374B5" },
  { name: "--instui-brand", syntax: "*", inherits: true, value: "var(--instui-leaf)" },
  { name: "--instui-bg", syntax: "*", inherits: true, value: "light-dark(#fff, #000)" },
];

const byName = resolveTokens(ir, { mode: "dark" });
byName.get("--instui-brand"); // → "#0374B5"
byName.get("--instui-bg");    // → "#000"