-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/main.js b/src/main.js
index 3325f241..ff4ca70b 100644
--- a/src/main.js
+++ b/src/main.js
@@ -22,12 +22,18 @@ import Image from './components/Tools/Image.vue';
import Entity from './components/Entities/Entity.vue';
import GlobalMixin from './mixins/global';
import gitlab from './storage/gitlab';
+import dhhtml from 'dochub-plugin-html';
+
+// eslint-disable-next-line no-console
+console.info(dhhtml);
import 'swagger-ui/dist/swagger-ui.css';
import 'vuetify/dist/vuetify.min.css';
import '@/assets/styles/main.css';
+window.DocHub = {};
+
window.Vue = Vue;
window.Router = router;
diff --git a/src/router/index.js b/src/router/index.js
index e380f3ad..c9657770 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -1,8 +1,6 @@
import Vue from 'vue';
import Router from 'vue-router';
import Doc from '../components/Docs/DocHubDoc';
-import Conditions from '../components/Conditions';
-import DiffViewer from '../components/DiffViewer';
import Main from '../components/Main';
import config from '../../config';
import consts from '../consts';
@@ -47,18 +45,6 @@ const rConfig = {
component: Main,
props: middleware
},
- {
- name: 'conditions',
- path: '/diff/:source/:target',
- component: Conditions,
- props: middleware
- },
- {
- name: 'diff',
- path: '/diff/:source/:target/:mode',
- component: DiffViewer,
- props: middleware
- },
{
name: 'doc',
path: '/docs/:document',
diff --git a/src/storage/plugins.js b/src/storage/plugins.js
index 09b025ac..01cfa94a 100644
--- a/src/storage/plugins.js
+++ b/src/storage/plugins.js
@@ -1,6 +1,9 @@
/* Модуль работы с плагинами */
+/*
import Vue from 'vue';
import env from '@/helpers/env';
+import requests from '@/helpers/requests';
+*/
export default {
namespaced: true,
@@ -15,15 +18,65 @@ export default {
registerDocument(state, document) {
state.documents[document.type] = document.component;
}
- },
+ }
+ /*
+ ,
actions: {
// Загружаем плагины
init(context) {
let counter = 0;
- if (env.isProduction()) {
- // eslint-disable-next-line no-console
- console.info('В проде плагинов еще нет :(');
+ if (!env.isProduction()) {
+ // Получаем данные манифеста приложения
+ requests.request('manifest.json', window.origin).then((response) => {
+ (response?.data?.plugins || []).map((url) => {
+ counter++;
+
+ const decCounter = () => !(--counter) && context.commit('setReady', true);
+ const id = url.split('/').pop().split('.').slice(0,1);
+
+ const script = document.createElement('script');
+ script.src = url;
+ script.onload = function() {
+ window[id].get('entry').then((plugin) => {
+ // eslint-disable-next-line no-console
+ console.info('YOUHOO!!!', plugin);
+ // eslint-disable-next-line no-debugger
+ debugger;
+ try {
+ const entry = plugin().default;
+ entry({
+ documents: {
+ register(type, component) {
+ Vue.component(`plugin-doc-${type}`, component);
+ context.commit('registerDocument', { type, component });
+ }
+ }
+ });
+ } catch (e) {
+ // eslint-disable-next-line no-console
+ console.error(`Ощибка инициализации плагина [${url}]`, e);
+ }
+
+ }).catch((e) => {
+ // eslint-disable-next-line no-console
+ console.error(`Ошибка инициализации плагина [${url}]`, e);
+ }).finally(decCounter);
+ };
+ script.onerror = (e) => {
+ // eslint-disable-next-line no-console
+ console.error(`Ошибка загрузки плагина [${url}]`, e);
+ decCounter();
+ };
+ document.head.appendChild(script);
+
+ if (!counter) context.commit('setReady', true);
+ });
+ }).catch((e) => {
+ // eslint-disable-next-line no-console
+ console.error('Не удалось загрузить манифест приложения', e);
+ context.commit('setReady', true);
+ });
} else {
const config = require('../../package.json');
for(const id in config.plugins || {}) {
@@ -54,4 +107,5 @@ export default {
}
}
}
+ */
};
diff --git a/vue.config.js b/vue.config.js
index 7bbd5a8d..5cd7fd1f 100644
--- a/vue.config.js
+++ b/vue.config.js
@@ -1,9 +1,61 @@
-
+const WebpackPwaManifest = require('webpack-pwa-manifest');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const HtmlWebpackInlineSourcePlugin = require('html-webpack-inline-source-plugin');
+const pkg = require('./package.json');
+const PluginMaker = require('./src/building/plugin-maker');
+
// const fs = require('fs');
+const plugins = [];
+const entries = {};
+
+if (process.env.VUE_APP_DOCHUB_MODE === 'plugin') {
+ plugins.push(new HtmlWebpackPlugin({
+ filename: 'plugin.html',
+ template: 'src/plugin.html',
+ inlineSource: '.(woff(2)?|ttf|eot|svg|js|css)$',
+ inject: true,
+ minify: {
+ removeComments: true,
+ collapseWhitespace: true,
+ removeAttributeQuotes: true,
+ minifyCSS: true,
+ minifyJS: true
+ // more options:
+ // https://github.com/kangax/html-minifier#options-quick-reference
+ }
+ }));
+ plugins.push(new HtmlWebpackInlineSourcePlugin());
+} else if (process.env.NODE_ENV === 'production') {
+ const manifest = {
+ name: 'DocHub',
+ short_name: 'DocHub',
+ description: 'Actitecture as a code',
+ background_color: '#ffffff',
+ crossorigin: 'use-credentials',
+ plugins:[],
+ filename: 'manifest.json'
+ };
+
+ const shared = {};
+ for (const pluginID in pkg.plugins || {}) {
+ manifest.plugins.push(`/plugins/${pluginID}.js`);
+ shared[pluginID] = {
+ packageName: 'packageName',
+ shareKey: 'shareKey',
+ shareScope: 'shareScope',
+ singleton: true
+ };
+ }
+
+ plugins.push(new WebpackPwaManifest(manifest));
+ plugins.push(new PluginMaker());
+
+ for (const pluginID in pkg.plugins || {}) {
+ entries[`plugins/${pluginID}`] = `./plugins/${pkg.plugins[pluginID]}.js`;
+ }
+}
// Дефолтная конфигурация dev-сервера
let config = {
@@ -17,17 +69,14 @@ let config = {
},
transpileDependencies: ['vueitfy'],
configureWebpack: {
+ experiments: {
+ outputModule: true
+ },
optimization: {
splitChunks: false
},
- plugins: [
- new HtmlWebpackPlugin({
- filename: 'plugin.html',
- template: 'src/plugin.html',
- inlineSource: '.(woff(2)?|ttf|eot|svg|js|css)$'
- }),
- new HtmlWebpackInlineSourcePlugin()
- ],
+ entry: {...entries},
+ plugins,
module: {
rules: [
{
@@ -36,10 +85,14 @@ let config = {
type: 'javascript/auto'
}
]
- }
- }
+ },
+ output: {
+ filename: '[name].js'
+ }
+ }
};
+
// Подключает сертификаты, если они обнаружены
/*
if(fs.lstatSync(__dirname + '/certs').isDirectory()) {