Skip to content

pantoken / packages/plugin-kit/src / resolveTokens

Funzione: resolveTokens()

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

Beta

Risolvi il valore di ogni token rispetto all'insieme (vedi makeResolver), usando il nome come chiave.

Parametri

base

readonly Token[]

options?

ResolveOptions

Restituisce

Map<string, string>

Esempio

Risolvi un'intera IR in una mappa nome → valore

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"