[everything] run prettier.

master
Drake 2 years ago
parent d50b3ef708
commit 428886645f

@ -1,8 +1,8 @@
import esbuild from 'esbuild' import esbuild from "esbuild";
import babel from 'esbuild-plugin-babel' import babel from "esbuild-plugin-babel";
(async ()=>{ (async () => {
try { try {
await esbuild.build({ await esbuild.build({
entryPoints: ["src/index.js"], entryPoints: ["src/index.js"],
bundle: true, bundle: true,
@ -11,12 +11,12 @@ try {
target: "es2021", target: "es2021",
outfile: "dist/build.js", outfile: "dist/build.js",
plugins: [babel()] plugins: [babel()]
}) });
console.log("Build succeeded!") console.log("Build succeeded!");
process.exit(0) process.exit(0);
} catch (e) { } catch (e) {
console.error(e) console.error(e);
console.log("Build failed!") console.log("Build failed!");
process.exit(1) process.exit(1);
} }
})() //IIFE to shutup lsp })(); //IIFE to shutup lsp

File diff suppressed because it is too large Load Diff

4
shims/react.js vendored

@ -1,3 +1,3 @@
import { React } from "../src/api/common.js" import { React } from "../src/api/common.js";
export { React } export { React };

@ -28,7 +28,7 @@ function init(obj: Object) {
// } // }
function add(command: { function add(command: {
name: string, name: string,
callback: (args: Array<any>) => string, callback: (args: Array<any>) => string
}): () => void { }): () => void {
let sym = Symbol(command.name); let sym = Symbol(command.name);
window.demon[commandsSym][sym] = command; window.demon[commandsSym][sym] = command;
@ -39,5 +39,5 @@ function add(command: {
export default { export default {
add: add, add: add,
init: init, init: init
}; };

@ -1,9 +1,9 @@
// @flow // @flow
import webpack from "./webpack.js" import webpack from "./webpack.js";
import * as idb from "idb-keyval"; import * as idb from "idb-keyval";
const common: {React: Object, ReactDOM: Object} = { const common: { React: Object, ReactDOM: Object } = {
React: webpack.findByProps( React: webpack.findByProps(
"__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED", "__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED",
"createElement" "createElement"
@ -12,7 +12,7 @@ const common: {React: Object, ReactDOM: Object} = {
"__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED", "__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED",
"hydrate" "hydrate"
), ),
"idb_keyval": idb idb_keyval: idb
} };
export default common; export default common;

@ -18,12 +18,12 @@
// return map; // return map;
//})(); //})();
function getAllClasses() { function getAllClasses() {
return document.styleSheets[0].rules || document.styleSheets[0].cssRules return document.styleSheets[0].rules || document.styleSheets[0].cssRules;
} }
function getClassListByName(className) { function getClassListByName(className) {
const classes = getAllClasses() const classes = getAllClasses();
return classes return classes;
} }
//how to define getters and setters on an object: //how to define getters and setters on an object:
@ -41,20 +41,16 @@ function getClassListByName(className) {
// }, // },
//}); //});
function getProxyObj(classes) { function getProxyObj(classes) {}
}
function init(obj: Object) { function init(obj: Object) {
obj.demon.css = { obj.demon.css = {
classes: { classes: {
get: (className) => { get: (className) => {}
}
}
} }
};
} }
export default { export default {
init init
} };

@ -30,7 +30,7 @@ async function addPlugin(iife: string): Promise<boolean> {
// whether the plugin is started or stopped isn't going to be stored in the iDB, so it can be accessed more easily by all components // whether the plugin is started or stopped isn't going to be stored in the iDB, so it can be accessed more easily by all components
metadata: metadata, metadata: metadata,
iife: iife, iife: iife,
enabled: false, // should plugins be enabled by default? not sure enabled: false // should plugins be enabled by default? not sure
}; };
const globalSettings: Object = await get("demoncord"); const globalSettings: Object = await get("demoncord");
/*try { /*try {
@ -70,7 +70,7 @@ async function startPlugin(name: string): Promise<boolean> {
const onStart: (ctx: Object) => void = exports.onStart; const onStart: (ctx: Object) => void = exports.onStart;
let ctx = {}; // ctx is how you're going to store things that need to be accessed in both onStart and onStop. dumb, i know let ctx = {}; // ctx is how you're going to store things that need to be accessed in both onStart and onStop. dumb, i know
if (plug.metadata.cumcord) { if (plug.metadata.cumcord) {
ctx.cumcord = window.demon //TODO: explicit cumcord compat layer. ctx.cumcord = window.demon; //TODO: explicit cumcord compat layer.
} }
onStart(ctx); onStart(ctx);
if (exports.settings) if (exports.settings)
@ -89,7 +89,7 @@ async function stopPlugin(name: string): Promise<boolean> {
const globalSettings = await get("demoncord"); const globalSettings = await get("demoncord");
if (globalSettings["plugin"][name] === undefined) { if (globalSettings["plugin"][name] === undefined) {
logger.error("Cannot stop non-existant or non-running plugin!", [ logger.error("Cannot stop non-existant or non-running plugin!", [
"Plugins", "Plugins"
]); ]);
return false; return false;
} else { } else {
@ -123,5 +123,5 @@ export default {
delPlugin, delPlugin,
startPlugin, startPlugin,
stopPlugin, stopPlugin,
togglePlugin, togglePlugin
}; };

@ -1,18 +1,16 @@
// @flow // @flow
import webpack from "../../webpack.js" import webpack from "../../webpack.js";
import common from "../../common.js" import common from "../../common.js";
const React = common.React const React = common.React;
const FormTitle = webpack.findByDisplayName("FormTitle") const FormTitle = webpack.findByDisplayName("FormTitle");
const FormDivider = webpack.findByDisplayName("FormDivider") const FormDivider = webpack.findByDisplayName("FormDivider");
const FormSection = webpack.findByDisplayName("FormSection") const FormSection = webpack.findByDisplayName("FormSection");
export default function(): any { export default function (): any {
return ( return (
<FormSection> <FormSection>
<FormTitle tag="h1"> <FormTitle tag="h1">Demoncord Settings</FormTitle>
Demoncord Settings
</FormTitle>
</FormSection> </FormSection>
) );
} }

@ -1,17 +1,17 @@
// @flow // @flow
import tmp from "./settingsInj.js" import tmp from "./settingsInj.js";
const registerSettingsEntry = tmp.registerSettingsEntry const registerSettingsEntry = tmp.registerSettingsEntry;
import common from "../common.js" import common from "../common.js";
const React = common.React const React = common.React;
import Settings from "./components/settings.jsx" import Settings from "./components/settings.jsx";
function init() { function init() {
console.log(Settings) console.log(Settings);
console.log(Settings()) console.log(Settings());
registerSettingsEntry("General Settings", undefined, Settings) registerSettingsEntry("General Settings", undefined, Settings);
} }
export default { export default {
init init
} };

@ -1,7 +1,7 @@
// @flow // @flow
import webpack from "../webpack.js"; import webpack from "../webpack.js";
import common from "../common.js" import common from "../common.js";
const React = common.React; const React = common.React;
const settingsSym = Symbol("__settings"); const settingsSym = Symbol("__settings");
@ -9,33 +9,32 @@ const settingsSym = Symbol("__settings");
// super secret value that shouldnt be exposed, used internally to avoid section conflicts and the like // super secret value that shouldnt be exposed, used internally to avoid section conflicts and the like
const ovrwrtSctnSym: symbol = Symbol("__overwriteSection"); const ovrwrtSctnSym: symbol = Symbol("__overwriteSection");
const settingsView = webpack.findByDisplayName("SettingsView") const settingsView = webpack.findByDisplayName("SettingsView");
type getPredicateSectionsEntry = type getPredicateSectionsEntry =
| { | {
section: "HEADER", section: "HEADER",
label: string, label: string
} }
| { | {
section: "DIVIDER", section: "DIVIDER"
} }
| { | {
section: string, section: string,
label: string, label: string,
component: Function, component: Function
}; };
function patch(args: mixed, ret: getPredicateSectionsEntry[]) { function patch(args: mixed, ret: getPredicateSectionsEntry[]) {
const processedEntries = window.demon[settingsSym].entries.map((e) => ({ const processedEntries = window.demon[settingsSym].entries.map((e) => ({
section: section: (e[ovrwrtSctnSym] ?? "DEMON_SETTINGS_LOADER_") + e.name,
(e[ovrwrtSctnSym] ?? "DEMON_SETTINGS_LOADER_") +
e.name,
label: e.name, label: e.name,
element: e.component, element: e.component
})); }));
processedEntries.map((e) => {console.log(e)}) processedEntries.map((e) => {
console.log(e);
});
const injectionIndex = const injectionIndex =
2 + ret.findIndex((section) => section.section === "Game Activity"); 2 + ret.findIndex((section) => section.section === "Game Activity");
@ -56,7 +55,7 @@ function init() {
settingsView.default.prototype, settingsView.default.prototype,
patch patch
), ),
entries: [], entries: []
}; };
// debug // debug
@ -70,9 +69,7 @@ function unInit() {
function unregisterSettingsEntry(name: string) { function unregisterSettingsEntry(name: string) {
let s = window.demon[settingsSym]; let s = window.demon[settingsSym];
s.entries = s.entries.filter( s.entries = s.entries.filter((e) => (e[ovrwrtSctnSym] ?? e.name) !== name);
(e) => (e[ovrwrtSctnSym] ?? e.name) !== name
);
} }
function registerSettingsEntry( function registerSettingsEntry(
@ -83,7 +80,7 @@ function registerSettingsEntry(
let entry: { [symbol | string]: any } = { name, component }; let entry: { [symbol | string]: any } = { name, component };
if (section) entry[ovrwrtSctnSym] = section; if (section) entry[ovrwrtSctnSym] = section;
//entry.component.type = entry.component.type.default //entry.component.type = entry.component.type.default
console.log(entry) console.log(entry);
window.demon[settingsSym].entries.push(entry); window.demon[settingsSym].entries.push(entry);
return () => unregisterSettingsEntry(name); return () => unregisterSettingsEntry(name);
} }
@ -93,5 +90,5 @@ export default {
unInit, unInit,
registerSettingsEntry, registerSettingsEntry,
unregisterSettingsEntry, unregisterSettingsEntry,
ovrwrtSctnSymm: ovrwrtSctnSym, ovrwrtSctnSymm: ovrwrtSctnSym
}; };

@ -79,5 +79,5 @@ export default {
warn, warn,
error, error,
trace, trace,
group, group
}; };

@ -1,5 +1,5 @@
// @flow // @flow
type ModuleType = Object/* { [symbol]: any } */; type ModuleType = Object /* { [symbol]: any } */;
type FilterFunc = (module: ModuleType) => boolean; type FilterFunc = (module: ModuleType) => boolean;
function getModules(): any { function getModules(): any {
@ -10,7 +10,7 @@ function getModules(): any {
{}, {},
(e) => { (e) => {
modules = e; modules = e;
}, }
]); ]);
return modules.c; return modules.c;
@ -38,7 +38,7 @@ type WebpackModules = {
findAll: (filter: FilterFunc) => Object[], findAll: (filter: FilterFunc) => Object[],
findByProps: (...props: string[]) => Object, findByProps: (...props: string[]) => Object,
findByPropsAll: (...props: string[]) => Object[], findByPropsAll: (...props: string[]) => Object[],
findByDisplayName: (prop: string) => Object[], findByDisplayName: (prop: string) => Object[]
}; };
let webpack: WebpackModules = { let webpack: WebpackModules = {
@ -57,7 +57,7 @@ let webpack: WebpackModules = {
); );
}, },
findByDisplayName: (prop: string) => { findByDisplayName: (prop: string) => {
return webpack.find((m) => m?.default?.displayName === prop) return webpack.find((m) => m?.default?.displayName === prop);
} }
}; };

@ -1,7 +1,7 @@
import init from "./init.js" import init from "./init.js";
if (window.demon) { if (window.demon) {
delete window.demon; // this is a very good idea delete window.demon; // this is a very good idea
} }
init(window) init(window);

@ -5,8 +5,8 @@ import common from "./api/common";
import commands from "./api/commands"; import commands from "./api/commands";
import plugins from "./api/plugins"; import plugins from "./api/plugins";
import settingsInj from "./api/settings/settingsInj"; import settingsInj from "./api/settings/settingsInj";
import settings from "./api/settings/settings" import settings from "./api/settings/settings";
import css from "./api/css" import css from "./api/css";
async function init(obj: Object): Promise<void> { async function init(obj: Object): Promise<void> {
const patcher = new Patcher(); const patcher = new Patcher();
@ -32,22 +32,22 @@ async function init(obj: Object): Promise<void> {
}, },
before: patcher.before, before: patcher.before,
instead: patcher.instead, instead: patcher.instead,
after: patcher.after, after: patcher.after
}, },
webpack, webpack,
common, common,
commands: { commands: {
add: commands.add, add: commands.add
}, },
__DO_NOT_USE_OR_YOU_WILL_BE_FIRED_UNTO_THE_DEPTHS_OF_HELL: { __DO_NOT_USE_OR_YOU_WILL_BE_FIRED_UNTO_THE_DEPTHS_OF_HELL: {
plugins, plugins
} }
}; };
commands.init(obj); commands.init(obj);
settingsInj.init(); settingsInj.init();
plugins.init(obj); plugins.init(obj);
settings.init(); settings.init();
css.init(obj) css.init(obj);
} }
export default init; export default init;

Loading…
Cancel
Save