Skip to content

pantoken / packages/core/src / runTokenPlugins

פונקציה: runTokenPlugins()

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

בטא

להריץ את ה-hook tokens של כל תוסף לפי הסדר. כל hook מקבל את הרשימה הנוכחית ומחזיר את ההחלפה המלאה; התוצאה ממוינת ומוסרת כפילויות לפי השם.

פרמטרים

tokens

Token[]

theme

Theme

plugins

לקריאה בלבד PantokenPlugin[]

מחזיר

Token[]

דוגמה

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