| 1234567891011121314151617181920212223242526272829303132333435363738 |
- import { Mask } from "../store/mask";
- import { CN_MASKS } from "./cn";
- import { type BuiltinMask } from "./typing";
- export { type BuiltinMask } from "./typing";
- export const BUILTIN_MASK_ID = 100000;
- export const BUILTIN_MASK_STORE = {
- buildinId: BUILTIN_MASK_ID,
- masks: {} as Record<string, BuiltinMask>,
- get(id?: string) {
- if (!id) return undefined;
- return this.masks[id] as Mask | undefined;
- },
- add(m: BuiltinMask) {
- const mask = { ...m, id: this.buildinId++, builtin: true };
- this.masks[mask.id] = mask;
- return mask;
- },
- };
- export const BUILTIN_MASKS: BuiltinMask[] = CN_MASKS.map(mask => BUILTIN_MASK_STORE.add(mask));
- // if (typeof window != "undefined") {
- // // run in browser skip in next server
- // fetch("/masks.json")
- // .then((res) => res.json())
- // .catch((error) => {
- // console.error("[Fetch] failed to fetch masks", error);
- // return { cn: [] };
- // })
- // .then((masks) => {
- // const { cn = [] } = masks;
- // return cn.map((m) => {
- // BUILTIN_MASKS.push(BUILTIN_MASK_STORE.add(m));
- // });
- // });
- // }
|