Make some Vue components available to plugins, add highlight.js module and some tidying
This commit is contained in:
parent
a6c91d5e27
commit
2e2d0dd6f6
|
@ -11,6 +11,7 @@
|
||||||
import { EmoteModule } from 'builtin';
|
import { EmoteModule } from 'builtin';
|
||||||
import { SettingsSet, SettingsCategory, Setting, SettingsScheme } from 'structs';
|
import { SettingsSet, SettingsCategory, Setting, SettingsScheme } from 'structs';
|
||||||
import { BdMenu, Modals, DOM, Reflection } from 'ui';
|
import { BdMenu, Modals, DOM, Reflection } from 'ui';
|
||||||
|
import * as CommonComponents from 'commoncomponents';
|
||||||
import { Utils, Filters, ClientLogger as Logger, ClientIPC, AsyncEventEmitter } from 'common';
|
import { Utils, Filters, ClientLogger as Logger, ClientIPC, AsyncEventEmitter } from 'common';
|
||||||
import Settings from './settings';
|
import Settings from './settings';
|
||||||
import ExtModuleManager from './extmodulemanager';
|
import ExtModuleManager from './extmodulemanager';
|
||||||
|
@ -58,6 +59,13 @@ export default class PluginApi {
|
||||||
get AsyncEventEmitter() { return AsyncEventEmitter }
|
get AsyncEventEmitter() { return AsyncEventEmitter }
|
||||||
get EventsWrapper() { return EventsWrapper }
|
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
|
* Logger
|
||||||
*/
|
*/
|
||||||
|
@ -431,37 +439,13 @@ export default class PluginApi {
|
||||||
getModuleByProperties: this.getWebpackModuleByProperties.bind(this),
|
getModuleByProperties: this.getWebpackModuleByProperties.bind(this),
|
||||||
getModuleByPrototypeFields: this.getWebpackModuleByPrototypeFields.bind(this),
|
getModuleByPrototypeFields: this.getWebpackModuleByPrototypeFields.bind(this),
|
||||||
getModulesByProperties: this.getWebpackModulesByProperties.bind(this),
|
getModulesByProperties: this.getWebpackModulesByProperties.bind(this),
|
||||||
getModulesByPrototypeFields: this.getWebpackModulesByPrototypeFields.bind(this)
|
getModulesByPrototypeFields: this.getWebpackModulesByPrototypeFields.bind(this),
|
||||||
|
KnownModules: WebpackModules.KnownModules
|
||||||
}, 'require', {
|
}, 'require', {
|
||||||
get: () => this.webpackRequire
|
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
|
* Patcher
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -8,15 +8,15 @@
|
||||||
* LICENSE file in the root directory of this source tree.
|
* 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 ContentManager from './contentmanager';
|
||||||
import ExtModuleManager from './extmodulemanager';
|
import ExtModuleManager from './extmodulemanager';
|
||||||
import Plugin from './plugin';
|
import Plugin from './plugin';
|
||||||
import PluginApi from './pluginapi';
|
import PluginApi from './pluginapi';
|
||||||
import Vendor from './vendor';
|
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 {
|
export default class extends ContentManager {
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ export default class extends ContentManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const deps = [];
|
const deps = {};
|
||||||
if (dependencies) {
|
if (dependencies) {
|
||||||
for (const [key, value] of Object.entries(dependencies)) {
|
for (const [key, value] of Object.entries(dependencies)) {
|
||||||
const extModule = ExtModuleManager.findModule(key);
|
const extModule = ExtModuleManager.findModule(key);
|
||||||
|
|
|
@ -139,6 +139,7 @@ const KnownModules = {
|
||||||
Strings: Filters.byProperties(["TEXT", "TEXTAREA_PLACEHOLDER"]),
|
Strings: Filters.byProperties(["TEXT", "TEXTAREA_PLACEHOLDER"]),
|
||||||
StringFormats: Filters.byProperties(['a', 'z']),
|
StringFormats: Filters.byProperties(['a', 'z']),
|
||||||
StringUtils: Filters.byProperties(["toASCII"]),
|
StringUtils: Filters.byProperties(["toASCII"]),
|
||||||
|
hljs: Filters.byProperties(['highlight', 'highlightBlock']),
|
||||||
|
|
||||||
/* URLs and Utils */
|
/* URLs and Utils */
|
||||||
URLParser: Filters.byProperties(['Url', 'parse']),
|
URLParser: Filters.byProperties(['Url', 'parse']),
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
@import './partials/index.scss';
|
@import './partials/index.scss';
|
||||||
|
|
|
@ -34,28 +34,13 @@ export default class {
|
||||||
remote.BrowserWindow.getFocusedWindow().webContents.on('did-navigate-in-page', (e, url, isMainFrame) => {
|
remote.BrowserWindow.getFocusedWindow().webContents.on('did-navigate-in-page', (e, url, isMainFrame) => {
|
||||||
const { currentGuild, currentChannel } = DiscordApi;
|
const { currentGuild, currentChannel } = DiscordApi;
|
||||||
|
|
||||||
if (!this.pathCache.server) {
|
if (!this.pathCache.server)
|
||||||
Events.emit('server-switch', { server: currentGuild, channel: currentChannel });
|
Events.emit('server-switch', { server: currentGuild, channel: currentChannel });
|
||||||
this.pathCache.server = currentGuild;
|
else if (!this.pathCache.channel)
|
||||||
this.pathCache.channel = currentChannel;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.pathCache.channel) {
|
|
||||||
Events.emit('channel-switch', currentChannel);
|
Events.emit('channel-switch', currentChannel);
|
||||||
this.pathCache.server = currentGuild;
|
else if (currentGuild && currentGuild.id && this.pathCache.server && this.pathCache.server.id !== currentGuild.id)
|
||||||
this.pathCache.channel = currentChannel;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currentGuild && currentGuild.id && this.pathCache.server && this.pathCache.server.id !== currentGuild.id) {
|
|
||||||
Events.emit('server-switch', { server: currentGuild, channel: currentChannel });
|
Events.emit('server-switch', { server: currentGuild, channel: currentChannel });
|
||||||
this.pathCache.server = currentGuild;
|
else if (currentChannel && currentChannel.id && this.pathCache.channel && this.pathCache.channel.id !== currentChannel.id)
|
||||||
this.pathCache.channel = currentChannel;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currentChannel && currentChannel.id && this.pathCache.channel && this.pathCache.channel.id !== currentChannel.id)
|
|
||||||
Events.emit('channel-switch', currentChannel);
|
Events.emit('channel-switch', currentChannel);
|
||||||
|
|
||||||
this.pathCache.server = currentGuild;
|
this.pathCache.server = currentGuild;
|
||||||
|
|
|
@ -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';
|
|
@ -101,7 +101,8 @@
|
||||||
methods: {
|
methods: {
|
||||||
itemOnClick(id) {
|
itemOnClick(id) {
|
||||||
if (this.animating || id === this.activeIndex) return;
|
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.sidebarItems.find(item => item.id === id).active = true;
|
||||||
this.animating = true;
|
this.animating = true;
|
||||||
this.lastActiveIndex = this.activeIndex;
|
this.lastActiveIndex = this.activeIndex;
|
||||||
|
|
|
@ -10,12 +10,6 @@
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<v-popover class="bd-content-author bd-inline" popoverClass="bd-popover bd-content-author-links" trigger="click" placement="top" :disabled="!hasLinks">
|
<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>
|
<span :class="{'bd-content-author-link': hasLinks}">{{ author.name || author }}</span><span v-text="after" @click.stop></span>
|
||||||
|
|
||||||
<template slot="popover">
|
<template slot="popover">
|
||||||
|
@ -50,8 +44,7 @@
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
},
|
},
|
||||||
openUserProfileModal(discord_id) {
|
openUserProfileModal(discord_id) {
|
||||||
const UserProfileModal = WebpackModules.getModuleByProps(['fetchMutualFriends', 'setSection']);
|
WebpackModules.getModuleByName('UserProfileModal').open(discord_id);
|
||||||
UserProfileModal.open(discord_id);
|
|
||||||
BdMenu.close();
|
BdMenu.close();
|
||||||
},
|
},
|
||||||
openGitHub() {
|
openGitHub() {
|
||||||
|
|
|
@ -5,3 +5,8 @@ export { default as ButtonGroup } from './ButtonGroup.vue';
|
||||||
export { default as Button } from './Button.vue';
|
export { default as Button } from './Button.vue';
|
||||||
export { default as Modal } from './Modal.vue';
|
export { default as Modal } from './Modal.vue';
|
||||||
export * from './MaterialIcon';
|
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';
|
||||||
|
|
|
@ -109,9 +109,9 @@ class Reflection {
|
||||||
let lastInstance = instance;
|
let lastInstance = instance;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
if (typeof lastInstance.return.type === 'string') break;
|
||||||
if (lastInstance.return.type) components.push(lastInstance.return.type);
|
if (lastInstance.return.type) components.push(lastInstance.return.type);
|
||||||
lastInstance = lastInstance.return;
|
lastInstance = lastInstance.return;
|
||||||
if (typeof lastInstance.return.type === 'string') return components;
|
|
||||||
} while (lastInstance.return);
|
} while (lastInstance.return);
|
||||||
|
|
||||||
return components;
|
return components;
|
||||||
|
|
|
@ -16,8 +16,8 @@
|
||||||
},
|
},
|
||||||
"private": false,
|
"private": false,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"node-sass": "^4.7.2",
|
"nedb": "^1.8.0",
|
||||||
"nedb": "^1.8.0"
|
"node-sass": "^4.7.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"archiver": "^2.1.1",
|
"archiver": "^2.1.1",
|
||||||
|
|
Loading…
Reference in New Issue