mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-12-06 19:56:45 +10:30
94 lines
1.7 KiB
TypeScript
94 lines
1.7 KiB
TypeScript
import type {
|
|
BooleanSetting,
|
|
ButtonSetting,
|
|
ComponentSetting,
|
|
HotkeySetting,
|
|
NumberSetting,
|
|
SelectSetting,
|
|
StringSetting,
|
|
} from "./types";
|
|
|
|
export function numberSetting(
|
|
options: Omit<NumberSetting, "type">,
|
|
): NumberSetting {
|
|
return {
|
|
type: "number",
|
|
...options,
|
|
};
|
|
}
|
|
|
|
export function booleanSetting(
|
|
options: Omit<BooleanSetting, "type">,
|
|
): BooleanSetting {
|
|
return {
|
|
type: "boolean",
|
|
...options,
|
|
};
|
|
}
|
|
|
|
export function stringSetting(
|
|
options: Omit<StringSetting, "type">,
|
|
): StringSetting {
|
|
return {
|
|
type: "string",
|
|
...options,
|
|
};
|
|
}
|
|
|
|
export function selectSetting<TValue extends string>(
|
|
options: Omit<SelectSetting<TValue>, "type">,
|
|
): SelectSetting<TValue> {
|
|
return {
|
|
type: "select",
|
|
...options,
|
|
};
|
|
}
|
|
|
|
export function buttonSetting(
|
|
options: Omit<ButtonSetting, "type">,
|
|
): ButtonSetting {
|
|
return {
|
|
type: "button",
|
|
...options,
|
|
};
|
|
}
|
|
|
|
|
|
export function componentSetting(
|
|
options: Omit<ComponentSetting, "type">,
|
|
): ComponentSetting {
|
|
return {
|
|
type: "component",
|
|
...options,
|
|
};
|
|
}
|
|
|
|
export function hotkeySetting(
|
|
options: Omit<HotkeySetting, "type">,
|
|
): HotkeySetting {
|
|
return {
|
|
type: "hotkey",
|
|
...options,
|
|
};
|
|
}
|
|
|
|
export function defineSettings<TSettings extends Record<string, any>>(settings: TSettings): TSettings {
|
|
return settings;
|
|
}
|
|
|
|
export function Setting(settingDef: any): PropertyDecorator {
|
|
return (target, propertyKey) => {
|
|
const proto = target.constructor.prototype;
|
|
if (!Object.hasOwn(proto, "settings")) {
|
|
Object.defineProperty(proto, "settings", {
|
|
value: {},
|
|
writable: true,
|
|
configurable: true,
|
|
enumerable: true,
|
|
});
|
|
}
|
|
|
|
proto.settings[propertyKey] = settingDef;
|
|
};
|
|
}
|