pleroma/packages/pl-fe/src/globals.ts
marcin mikołajczak 966b04fdf0 Call it pl-fe internally
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2024-08-28 13:41:08 +02:00

25 lines
678 B
TypeScript

/**
* globals: do things through the console.
* This feature is for developers.
*/
import { changeSettingImmediate } from 'pl-fe/actions/settings';
import type { Store } from 'pl-fe/store';
/** Add PlFe globals to the window. */
const createGlobals = (store: Store) => {
const PlFe = {
/** Become a developer with `plFe.isDeveloper()` */
isDeveloper: (bool = true): boolean => {
if (![true, false].includes(bool)) {
throw `Invalid option ${bool}. Must be true or false.`;
}
store.dispatch(changeSettingImmediate(['isDeveloper'], bool) as any);
return bool;
},
};
(window as any).plFe = PlFe;
};
export { createGlobals };