Skip to content

pantoken / packages/core/src / runTokenPlugins

Función: runTokenPlugins()

runTokenPlugins(tokens, theme, plugins): Token[]

Beta

Ejecuta en orden el hook tokens de cada plugin. Cada hook recibe la lista actual y devuelve la sustitución completa; el resultado se desduplica por nombre.

Parámetros

tokens

Token[]

theme

Theme

plugins

solo lectura PantokenPlugin[]

Devuelve

Token[]

Ejemplo

ts
import { runTokenPlugins, type PantokenPlugin } from "@pantoken/core";
import type { Token } from "@pantoken/model";

const base: Token[] = [
  { name: "--instui-x", syntax: "<color>", inherits: true, value: "#fff" },
];
const addBrand: PantokenPlugin = {
  name: "brand",
  tokens: ({ tokens }) => [
    ...tokens,
    defineToken({ name: "--instui-brand", value: "#0374B5" }),
  ],
};

runTokenPlugins(base, "rebrand", [addBrand]); // → base + the --instui-brand token