Skip to content

pantoken / packages/utils/src / unknownReferences

函式: unknownReferences()

unknownReferences(text, ir): string[]

Beta(測試)

漂移檢查:--instui-*text 中的名稱,這些名稱不是 IR 所定義的(已排序;為空表示沒有 漂移)。用於那些 參考 在其他地方定義的 tokens 的輸出 — 例如 docusaurus/vitepress 橋接,其 var(--instui-*) 目標必須全部為真實的 tokens。

參數

text

string

產生的輸出。

ir

唯讀 Token[]

來源 token 的 IR。

回傳

string[]

未知的 token 名稱。

範例

ts
import { unknownReferences } from "@pantoken/utils";
import type { Token } from "@pantoken/model";

const ir: Token[] = [
  { name: "--instui-leaf", syntax: "<color>", inherits: true, value: "#0374B5" },
];

unknownReferences("--x: var(--instui-leaf); --y: var(--instui-gone);", ir);
// → ["--instui-gone"]
unknownReferences("--x: var(--instui-leaf);", ir); // → []  (no drift)