Skip to content

pantoken / packages/core/src / runTokenPlugins

ฟังก์ชัน: runTokenPlugins()

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

เบต้า

เรียกใช้งานฮุค tokens ของแต่ละปลั๊กอินตามลำดับ แต่ละฮุคจะรับรายการปัจจุบันและคืนค่าการแทนที่ทั้งหมด ผลลัพธ์จะถูกลบรายการที่ซ้ำกันตามชื่อ

พารามิเตอร์

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