2021-11-02 09:47:26 -07:00
|
|
|
/**
|
|
|
|
* globals: do things through the console.
|
|
|
|
* This feature is for developers.
|
|
|
|
*/
|
2024-08-28 04:41:08 -07:00
|
|
|
import { changeSettingImmediate } from 'pl-fe/actions/settings';
|
2021-11-02 09:47:26 -07:00
|
|
|
|
2024-08-28 04:41:08 -07:00
|
|
|
import type { Store } from 'pl-fe/store';
|
2022-04-24 12:28:07 -07:00
|
|
|
|
2024-08-28 04:41:08 -07:00
|
|
|
/** Add PlFe globals to the window. */
|
2024-05-12 16:18:04 -07:00
|
|
|
const createGlobals = (store: Store) => {
|
2024-08-28 04:41:08 -07:00
|
|
|
const PlFe = {
|
|
|
|
/** Become a developer with `plFe.isDeveloper()` */
|
2022-04-24 12:28:07 -07:00
|
|
|
isDeveloper: (bool = true): boolean => {
|
2021-11-02 09:47:26 -07:00
|
|
|
if (![true, false].includes(bool)) {
|
|
|
|
throw `Invalid option ${bool}. Must be true or false.`;
|
|
|
|
}
|
2022-04-24 12:28:07 -07:00
|
|
|
store.dispatch(changeSettingImmediate(['isDeveloper'], bool) as any);
|
2021-11-02 09:47:26 -07:00
|
|
|
return bool;
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2024-08-28 04:41:08 -07:00
|
|
|
(window as any).plFe = PlFe;
|
2021-11-02 09:47:26 -07:00
|
|
|
};
|
2024-05-12 16:18:04 -07:00
|
|
|
|
|
|
|
export { createGlobals };
|