index.ts 711 B

1234567891011121314151617181920212223242526
  1. import { Mask } from "../store/mask";
  2. import { CN_MASKS } from "./cn";
  3. import { EN_MASKS } from "./en";
  4. import { type BuiltinMask } from "./typing";
  5. export { type BuiltinMask } from "./typing";
  6. export const BUILTIN_MASK_ID = 100000;
  7. export const BUILTIN_MASK_STORE = {
  8. buildinId: BUILTIN_MASK_ID,
  9. masks: {} as Record<string, BuiltinMask>,
  10. get(id?: string) {
  11. if (!id) return undefined;
  12. return this.masks[id] as Mask | undefined;
  13. },
  14. add(m: BuiltinMask) {
  15. const mask = { ...m, id: this.buildinId++, builtin: true };
  16. this.masks[mask.id] = mask;
  17. return mask;
  18. },
  19. };
  20. export const BUILTIN_MASKS: BuiltinMask[] = [...CN_MASKS, ...EN_MASKS].map(
  21. (m) => BUILTIN_MASK_STORE.add(m),
  22. );