mirror of https://github.com/vizality/vizality
Further refactoring, renaming, and more...
Note: Repository is currently in an unusable state at this pointpull/2/head
parent
8920e9626d
commit
6a7d290d69
@ -1,18 +1,15 @@
|
||||
const { React, getModuleByDisplayName } = require('@webpack');
|
||||
const { Text } = require('@components');
|
||||
const { Webpack, Components } = require('@modules');
|
||||
|
||||
const Autocomplete = getModuleByDisplayName('Autocomplete');
|
||||
const Autocomplete = Webpack.getModuleByDisplayName('Autocomplete');
|
||||
|
||||
class Command extends Autocomplete.Command {
|
||||
module.exports = class Command extends Autocomplete.Command {
|
||||
renderContent () {
|
||||
const res = super.renderContent();
|
||||
res.props.children[0] = React.createElement(Text, {
|
||||
res.props.children[0] = Webpack.React.createElement(Components.Text, {
|
||||
children: this.props.prefix ? this.props.prefix : vizality.api.commands.prefix,
|
||||
style: { color: '#72767d' }
|
||||
});
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Command;
|
||||
};
|
||||
|
@ -1,23 +1,19 @@
|
||||
const { Plugin } = require('@entities');
|
||||
const { unpatch } = require('@patcher');
|
||||
const { Patcher, Entities: { Plugin } } = require('@modules');
|
||||
|
||||
const commands = require('./commands');
|
||||
const monkeypatchMessages = require('./monkeypatchMessages.js');
|
||||
const injectAutocomplete = require('./injectAutocomplete.js');
|
||||
|
||||
class Commands extends Plugin {
|
||||
module.exports = class Commands extends Plugin {
|
||||
onStart () {
|
||||
Object.values(commands).forEach(command => vizality.api.commands.registerCommand(command));
|
||||
|
||||
monkeypatchMessages.call(this);
|
||||
injectAutocomplete.call(this);
|
||||
}
|
||||
|
||||
onStop () {
|
||||
Object.values(commands).forEach(command => vizality.api.commands.unregisterCommand(command.command));
|
||||
unpatch('vz-commands-autocomplete-prefix');
|
||||
unpatch('vz-commands-autocomplete');
|
||||
Patcher.unpatch('vz-commands-autocomplete-prefix');
|
||||
Patcher.unpatch('vz-commands-autocomplete');
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Commands;
|
||||
};
|
||||
|
@ -1,19 +0,0 @@
|
||||
const { logger: { warn } } = require('@utilities');
|
||||
|
||||
const classes = require('../classes');
|
||||
|
||||
const _checkForUndefined = async (obj = classes, currentPath) => {
|
||||
const _module = 'Module';
|
||||
const _submodule = 'Classes:_checkForUndefined';
|
||||
|
||||
for (const key in obj) {
|
||||
if (typeof obj[key] === 'object') {
|
||||
const newPath = currentPath ? `${currentPath}.${key}` : key;
|
||||
_checkForUndefined(obj[key], newPath);
|
||||
} else if (typeof obj[key] === 'undefined') {
|
||||
warn(_module, _submodule, null, `Value not found: ${currentPath}.${key}`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = _checkForUndefined;
|
@ -1,43 +0,0 @@
|
||||
const { DIR: { LIBRARIES_DIR } } = require('@constants');
|
||||
const { logger: { warn } } = require('@utilities');
|
||||
|
||||
const { promises: { writeFile, mkdir }, existsSync } = require('fs');
|
||||
const { join } = require('path');
|
||||
|
||||
const classes = require('../classes');
|
||||
|
||||
const _generateSassClasses = async (obj = classes, currentPath) => {
|
||||
const module = 'Module';
|
||||
const submodule = 'Classes:_generateSassClasses';
|
||||
|
||||
const SassClassFolder = join(LIBRARIES_DIR, 'sass', 'classes');
|
||||
|
||||
if (!existsSync(SassClassFolder)) {
|
||||
await mkdir(SassClassFolder);
|
||||
}
|
||||
|
||||
let generatedSass = '';
|
||||
|
||||
for (const key in obj) {
|
||||
if (typeof obj[key] === 'object') {
|
||||
const newPath = currentPath ? `${currentPath}.${key}` : key;
|
||||
_generateSassClasses(obj[key], newPath);
|
||||
} else if (typeof obj[key] === 'string') {
|
||||
generatedSass += `$${key}: '.${obj[key].split(' ')[0]}';\n`;
|
||||
} else if (typeof obj[key] === 'undefined') {
|
||||
warn(module, submodule, null, `No value found for '${currentPath}.${key}'`);
|
||||
}
|
||||
}
|
||||
|
||||
const moduleFolder = join(SassClassFolder, currentPath.split('.').join('/'));
|
||||
|
||||
await mkdir(moduleFolder, { recursive: true });
|
||||
|
||||
generatedSass = generatedSass.trim().split('\n').sort().join('\n').replace(/,/g, '');
|
||||
|
||||
if (generatedSass) {
|
||||
await writeFile(join(moduleFolder, '_index.scss'), generatedSass, 'utf8');
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = _generateSassClasses;
|
@ -1,9 +1,9 @@
|
||||
const { getModule } = require('@webpack');
|
||||
const Webpack = require('@webpack');
|
||||
|
||||
const components = {
|
||||
...getModule('attachment'),
|
||||
...getModule('members'),
|
||||
hunk: getModule('members').hunk
|
||||
...Webpack.getModule('attachment'),
|
||||
...Webpack.getModule('members'),
|
||||
hunk: Webpack.getModule('members').hunk
|
||||
};
|
||||
|
||||
module.exports = components;
|
||||
|
@ -1,9 +0,0 @@
|
||||
const { object: { findEntriesByValue } } = require('@utilities');
|
||||
|
||||
const classes = require('../classes');
|
||||
|
||||
const findClass = (value, exact = false) => {
|
||||
return findEntriesByValue(classes, value, exact);
|
||||
};
|
||||
|
||||
module.exports = findClass;
|
@ -1,37 +1,72 @@
|
||||
const { DIR: { LIBRARIES_DIR } } = require('@constants');
|
||||
const { logger: { log } } = require('@utilities');
|
||||
|
||||
const { promises: { writeFile, mkdir }, existsSync } = require('fs');
|
||||
const { join } = require('path');
|
||||
const { existsSync } = require('fs');
|
||||
|
||||
const _checkForUndefined = require('./_checkForUndefined');
|
||||
const _generateSassClasses = require('./_generateSassClasses');
|
||||
const findClass = require('./findClass');
|
||||
|
||||
const components = require('./components');
|
||||
const layout = require('./layout');
|
||||
const views = require('./views');
|
||||
const plugins = require('./plugins');
|
||||
const vizality = require('./vizality');
|
||||
|
||||
const classes = {
|
||||
components,
|
||||
layout,
|
||||
views,
|
||||
plugins,
|
||||
vizality
|
||||
};
|
||||
|
||||
module.exports = { classes, findClass };
|
||||
const Constants = require('@constants');
|
||||
const Util = require('@util');
|
||||
|
||||
_checkForUndefined();
|
||||
const { components, layout, views, plugins, vizality } = require('.');
|
||||
|
||||
const _module = 'Module';
|
||||
const _submodule = 'Classes';
|
||||
const SassClassFolder = join(LIBRARIES_DIR, 'sass', 'classes');
|
||||
|
||||
module.exports = class Classes {
|
||||
static get components () { return components; }
|
||||
static get layout () { return layout; }
|
||||
static get views () { return views; }
|
||||
static get plugins () { return plugins; }
|
||||
static get vizality () { return vizality; }
|
||||
|
||||
static findClass (value, exact = false) {
|
||||
return Util.Object.findEntriesByValue(this, value, exact);
|
||||
}
|
||||
|
||||
static async _checkForUndefined (obj = this, currentPath) {
|
||||
for (const key in obj) {
|
||||
if (typeof obj[key] === 'object') {
|
||||
const newPath = currentPath ? `${currentPath}.${key}` : key;
|
||||
this._checkForUndefined(obj[key], newPath);
|
||||
} else if (typeof obj[key] === 'undefined') {
|
||||
Util.Logger.warn(_module, `${_submodule}:_checkForUndefined`, null, `Value not found: ${currentPath}.${key}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static async _generateSassClasses (obj = this, currentPath) {
|
||||
const SassClassFolder = join(Constants.Directories.LIBRARIES, 'sass', 'classes');
|
||||
|
||||
if (!existsSync(SassClassFolder)) {
|
||||
await mkdir(SassClassFolder);
|
||||
}
|
||||
|
||||
let generatedSass = '';
|
||||
|
||||
for (const key in obj) {
|
||||
if (typeof obj[key] === 'object') {
|
||||
const newPath = currentPath ? `${currentPath}.${key}` : key;
|
||||
this._generateSassClasses(obj[key], newPath);
|
||||
} else if (typeof obj[key] === 'string') {
|
||||
generatedSass += `$${key}: '.${obj[key].split(' ')[0]}';\n`;
|
||||
} else if (typeof obj[key] === 'undefined') {
|
||||
Util.Logger.warn(_module, `${_submodule}:_generateSassClasses`, null, `No value found for '${currentPath}.${key}'`);
|
||||
}
|
||||
}
|
||||
|
||||
const moduleFolder = join(SassClassFolder, currentPath.split('.').join('/'));
|
||||
await mkdir(moduleFolder, { recursive: true });
|
||||
generatedSass = generatedSass.trim().split('\n').sort().join('\n').replace(/,/g, '');
|
||||
|
||||
if (generatedSass) {
|
||||
await writeFile(join(moduleFolder, '_index.scss'), generatedSass, 'utf8');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
module.exports._checkForUndefined();
|
||||
|
||||
const SassClassFolder = join(Constants.Directories.LIBRARIES, 'sass', 'classes');
|
||||
|
||||
if (!existsSync(SassClassFolder)) {
|
||||
_generateSassClasses();
|
||||
module.exports._generateSassClasses();
|
||||
} else {
|
||||
log(_module, _submodule, null, `Directory 'src\\.vizality\\libraries\\sass\\classes' already exists. Skipping file generation...`);
|
||||
Util.Logger.log(_module, _submodule, null, `Directory 'src\\.vizality\\libraries\\sass\\classes' already exists. Skipping file generation...`);
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
const { getModule } = require('@webpack');
|
||||
const Webpack = require('@webpack');
|
||||
|
||||
const views = {
|
||||
...getModule('attachment'),
|
||||
...getModule('members')
|
||||
...Webpack.getModule('attachment'),
|
||||
...Webpack.getModule('members')
|
||||
};
|
||||
|
||||
module.exports = views;
|
||||
|
@ -1,8 +1,8 @@
|
||||
const { joinClassNames } = require('@utilities');
|
||||
const { React } = require('@webpack');
|
||||
const Webpack = require('@webpack');
|
||||
const Util = require('@util');
|
||||
|
||||
const Badge = React.memo(({ type, className, ...props }) =>
|
||||
<div className={joinClassNames('vizality-badge', type, className)} {...props}></div>
|
||||
const Badge = Webpack.React.memo(({ type, className, ...props }) =>
|
||||
<div className={Util.Misc.joinClassNames('vizality-badge', type, className)} {...props}></div>
|
||||
);
|
||||
|
||||
module.exports = Badge;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue