Skip to content

pantoken / packages/core/src / runTokenPlugins

Hàm: runTokenPlugins()

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

Beta

Chạy hook tokens của từng plugin theo thứ tự. Mỗi hook nhận danh sách hiện tại và trả về phần thay thế đầy đủ; kết quả được loại bỏ trùng lặp theo tên.

Tham số

tokens

Token[]

theme

Theme

plugins

chỉ đọc PantokenPlugin[]

Trả về

Token[]

Ví dụ

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