Make some Vue components available to plugins, add highlight.js module and some tidying

This commit is contained in:
Samuel Elliott 2018-04-29 01:57:09 +01:00
parent a6c91d5e27
commit 2e2d0dd6f6
No known key found for this signature in database
GPG Key ID: 8420C7CDE43DC4D6
11 changed files with 40 additions and 63 deletions

View File

@ -11,6 +11,7 @@
import { EmoteModule } from 'builtin';
import { SettingsSet, SettingsCategory, Setting, SettingsScheme } from 'structs';
import { BdMenu, Modals, DOM, Reflection } from 'ui';
import * as CommonComponents from 'commoncomponents';
import { Utils, Filters, ClientLogger as Logger, ClientIPC, AsyncEventEmitter } from 'common';
import Settings from './settings';
import ExtModuleManager from './extmodulemanager';
@ -58,6 +59,13 @@ export default class PluginApi {
get AsyncEventEmitter() { return AsyncEventEmitter }
get EventsWrapper() { return EventsWrapper }
get CommonComponents() { return CommonComponents }
get Filters() { return Filters }
get Discord() { return DiscordApi }
get DiscordApi() { return DiscordApi }
get ReactComponents() { return ReactComponents }
get Reflection() { return Reflection }
/**
* Logger
*/
@ -431,37 +439,13 @@ export default class PluginApi {
getModuleByProperties: this.getWebpackModuleByProperties.bind(this),
getModuleByPrototypeFields: this.getWebpackModuleByPrototypeFields.bind(this),
getModulesByProperties: this.getWebpackModulesByProperties.bind(this),
getModulesByPrototypeFields: this.getWebpackModulesByPrototypeFields.bind(this)
getModulesByPrototypeFields: this.getWebpackModulesByPrototypeFields.bind(this),
KnownModules: WebpackModules.KnownModules
}, 'require', {
get: () => this.webpackRequire
});
}
/**
* Filters
*/
get Filters() { return Filters }
/**
* DiscordApi
*/
get Discord() { return DiscordApi }
get DiscordApi() { return DiscordApi }
/**
* ReactComponents
*/
get ReactComponents() { return ReactComponents }
/**
* Reflection
*/
get Reflection() { return Reflection }
/**
* Patcher
*/

View File

@ -8,15 +8,15 @@
* LICENSE file in the root directory of this source tree.
*/
import { Events, Permissions } from 'modules';
import { Modals } from 'ui';
import { ErrorEvent } from 'structs';
import { ClientLogger as Logger } from 'common';
import ContentManager from './contentmanager';
import ExtModuleManager from './extmodulemanager';
import Plugin from './plugin';
import PluginApi from './pluginapi';
import Vendor from './vendor';
import { ClientLogger as Logger } from 'common';
import { Events, Permissions } from 'modules';
import { Modals } from 'ui';
import { ErrorEvent } from 'structs';
export default class extends ContentManager {
@ -85,7 +85,7 @@ export default class extends ContentManager {
}
}
const deps = [];
const deps = {};
if (dependencies) {
for (const [key, value] of Object.entries(dependencies)) {
const extModule = ExtModuleManager.findModule(key);

View File

@ -139,6 +139,7 @@ const KnownModules = {
Strings: Filters.byProperties(["TEXT", "TEXTAREA_PLACEHOLDER"]),
StringFormats: Filters.byProperties(['a', 'z']),
StringUtils: Filters.byProperties(["toASCII"]),
hljs: Filters.byProperties(['highlight', 'highlightBlock']),
/* URLs and Utils */
URLParser: Filters.byProperties(['Url', 'parse']),

View File

@ -1 +1 @@
@import './partials/index.scss';
@import './partials/index.scss';

View File

@ -34,28 +34,13 @@ export default class {
remote.BrowserWindow.getFocusedWindow().webContents.on('did-navigate-in-page', (e, url, isMainFrame) => {
const { currentGuild, currentChannel } = DiscordApi;
if (!this.pathCache.server) {
if (!this.pathCache.server)
Events.emit('server-switch', { server: currentGuild, channel: currentChannel });
this.pathCache.server = currentGuild;
this.pathCache.channel = currentChannel;
return;
}
if (!this.pathCache.channel) {
else if (!this.pathCache.channel)
Events.emit('channel-switch', currentChannel);
this.pathCache.server = currentGuild;
this.pathCache.channel = currentChannel;
return;
}
if (currentGuild && currentGuild.id && this.pathCache.server && this.pathCache.server.id !== currentGuild.id) {
else if (currentGuild && currentGuild.id && this.pathCache.server && this.pathCache.server.id !== currentGuild.id)
Events.emit('server-switch', { server: currentGuild, channel: currentChannel });
this.pathCache.server = currentGuild;
this.pathCache.channel = currentChannel;
return;
}
if (currentChannel && currentChannel.id && this.pathCache.channel && this.pathCache.channel.id !== currentChannel.id)
else if (currentChannel && currentChannel.id && this.pathCache.channel && this.pathCache.channel.id !== currentChannel.id)
Events.emit('channel-switch', currentChannel);
this.pathCache.server = currentGuild;

View File

@ -0,0 +1,8 @@
export * from './components/common';
export { default as SettingsPanel } from './components/bd/SettingsPanel.vue';
export { default as Setting } from './components/bd/setting/Setting.vue';
export { default as Card } from './components/bd/Card.vue';
export { default as ContentAuthor } from './components/bd/ContentAuthor.vue';
export { default as BdBadge } from './components/bd/BdBadge.vue';
export { default as BdMessageBadge } from './components/bd/BdMessageBadge.vue';

View File

@ -101,7 +101,8 @@
methods: {
itemOnClick(id) {
if (this.animating || id === this.activeIndex) return;
if (this.activeIndex >= 0) this.sidebarItems.find(item => item.id === this.activeIndex).active = false;
const activeItem = this.sidebarItems.find(item => item.id === this.activeIndex);
if (activeItem) activeItem.active = false;
this.sidebarItems.find(item => item.id === id).active = true;
this.animating = true;
this.lastActiveIndex = this.activeIndex;

View File

@ -10,12 +10,6 @@
<template>
<v-popover class="bd-content-author bd-inline" popoverClass="bd-popover bd-content-author-links" trigger="click" placement="top" :disabled="!hasLinks">
<!-- <template v-if="typeof author === 'string'">{{ author }}</template>
<a v-else-if="author.url" :href="author.url" @click="openLink">{{ author.name }}</a>
<a v-else-if="author.github_username" :href="'https://github.com/' + author.github_username" @click="openLink">{{ author.name }}</a>
<span v-else-if="author.discord_id" @click="openUserProfileModal(author.discord_id)">{{ author.name }}</span>
<template v-else>{{ author.name }}</template> -->
<span :class="{'bd-content-author-link': hasLinks}">{{ author.name || author }}</span><span v-text="after" @click.stop></span>
<template slot="popover">
@ -50,8 +44,7 @@
e.preventDefault();
},
openUserProfileModal(discord_id) {
const UserProfileModal = WebpackModules.getModuleByProps(['fetchMutualFriends', 'setSection']);
UserProfileModal.open(discord_id);
WebpackModules.getModuleByName('UserProfileModal').open(discord_id);
BdMenu.close();
},
openGitHub() {

View File

@ -5,3 +5,8 @@ export { default as ButtonGroup } from './ButtonGroup.vue';
export { default as Button } from './Button.vue';
export { default as Modal } from './Modal.vue';
export * from './MaterialIcon';
export { default as RefreshBtn } from './RefreshBtn.vue';
export { default as RadioGroup } from './RadioGroup.vue';
export { default as Dropdown } from './Dropdown.vue';
export { default as Drawer } from './Drawer.vue';

View File

@ -109,9 +109,9 @@ class Reflection {
let lastInstance = instance;
do {
if (typeof lastInstance.return.type === 'string') break;
if (lastInstance.return.type) components.push(lastInstance.return.type);
lastInstance = lastInstance.return;
if (typeof lastInstance.return.type === 'string') return components;
} while (lastInstance.return);
return components;

View File

@ -16,8 +16,8 @@
},
"private": false,
"dependencies": {
"node-sass": "^4.7.2",
"nedb": "^1.8.0"
"nedb": "^1.8.0",
"node-sass": "^4.7.2"
},
"devDependencies": {
"archiver": "^2.1.1",