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