diff --git a/.electron-vue/build.js b/.electron-vue/build.js
deleted file mode 100644
index 84fd546a4..000000000
--- a/.electron-vue/build.js
+++ /dev/null
@@ -1,135 +0,0 @@
-'use strict'
-
-process.env.NODE_ENV = 'production'
-
-const { say } = require('cfonts')
-const path = require('path')
-const chalk = require('chalk')
-const del = require('del')
-const fs = require('fs-extra')
-const webpack = require('webpack')
-const Listr = require('listr')
-
-
-const mainConfig = require('./webpack.main.config')
-const rendererConfig = require('./webpack.renderer.config')
-
-const doneLog = chalk.bgGreen.white(' DONE ') + ' '
-const errorLog = chalk.bgRed.white(' ERROR ') + ' '
-const okayLog = chalk.bgBlue.white(' OKAY ') + ' '
-const isCI = process.env.CI || false
-
-if (process.env.BUILD_TARGET === 'clean') clean()
-else if (process.env.BUILD_TARGET === 'web') web()
-else build()
-
-function clean () {
- del.sync(['build/*', '!build/icons', '!build/icons/icon.*'])
- console.log(`\n${doneLog}\n`)
- process.exit()
-}
-
-async function build () {
- greeting()
-
- del.sync(['dist/electron/*', '!.gitkeep'])
- del.sync(['static/themes/*'])
-
- const from = path.resolve(__dirname, '../src/muya/themes')
- const to = path.resolve(__dirname, '../static/themes')
- await fs.copy(from, to)
-
- let results = ''
-
- const tasks = new Listr(
- [
- {
- title: 'building main process',
- task: async () => {
- await pack(mainConfig)
- .then(result => {
- results += result + '\n\n'
- })
- .catch(err => {
- console.log(`\n ${errorLog}failed to build main process`)
- console.error(`\n${err}\n`)
- process.exit(1)
- })
- }
- },
- {
- title: 'building renderer process',
- task: async () => {
- await pack(rendererConfig)
- .then(result => {
- results += result + '\n\n'
- })
- .catch(err => {
- console.log(`\n ${errorLog}failed to build renderer process`)
- console.error(`\n${err}\n`)
- process.exit(1)
- })
- }
- }
- ],
- { concurrent: 2 }
- )
-
- await tasks
- .run()
- .then(() => {
- process.stdout.write('\x1B[2J\x1B[0f')
- console.log(`\n\n${results}`)
- console.log(`${okayLog}take it away ${chalk.yellow('`electron-builder`')}\n`)
- process.exit()
- })
- .catch(err => {
- process.exit(1)
- })
-}
-
-function pack (config) {
- return new Promise((resolve, reject) => {
- webpack(config, (err, stats) => {
- if (err) reject(err.stack || err)
- else if (stats.hasErrors()) {
- let err = ''
-
- stats.toString({
- chunks: false,
- colors: true
- })
- .split(/\r?\n/)
- .forEach(line => {
- err += ` ${line}\n`
- })
-
- reject(err)
- } else {
- resolve(stats.toString({
- chunks: false,
- colors: true
- }))
- }
- })
- })
-}
-
-function greeting () {
- const cols = process.stdout.columns
- let text = ''
-
- if (cols > 155) text = 'building marktext'
- else if (cols > 76) text = 'building|marktext'
- else text = false
-
- if (text && !isCI) {
- say(text, {
- colors: ['yellow'],
- font: 'simple3d',
- space: false
- })
- } else {
- console.log(chalk.yellow.bold('\n building marktext'))
- }
-}
diff --git a/.electron-vue/dev-client.js b/.electron-vue/dev-client.js
deleted file mode 100644
index 147c7806a..000000000
--- a/.electron-vue/dev-client.js
+++ /dev/null
@@ -1,40 +0,0 @@
-const hotClient = require('webpack-hot-middleware/client?reload=true')
-
-hotClient.subscribe(event => {
- /**
- * Reload browser when HTMLWebpackPlugin emits a new index.html
- *
- * Currently disabled until jantimon/html-webpack-plugin#680 is resolved.
- * https://github.com/SimulatedGREG/electron-vue/issues/437
- * https://github.com/jantimon/html-webpack-plugin/issues/680
- */
- // if (event.action === 'reload') {
- // window.location.reload()
- // }
-
- /**
- * Notify `mainWindow` when `main` process is compiling,
- * giving notice for an expected reload of the `electron` process
- */
- if (event.action === 'compiling') {
- document.body.innerHTML += `
-
-
-
- Compiling Main Process...
-
- `
- }
-})
diff --git a/.electron-vue/dev-runner.js b/.electron-vue/dev-runner.js
deleted file mode 100644
index 676a314de..000000000
--- a/.electron-vue/dev-runner.js
+++ /dev/null
@@ -1,197 +0,0 @@
-'use strict'
-
-const chalk = require('chalk')
-const electron = require('electron')
-const path = require('path')
-const { say } = require('cfonts')
-const { spawn } = require('child_process')
-const webpack = require('webpack')
-const HtmlWebpackPlugin = require('html-webpack-plugin')
-const WebpackDevServer = require('webpack-dev-server')
-const webpackHotMiddleware = require('webpack-hot-middleware')
-
-const mainConfig = require('./webpack.main.config')
-const rendererConfig = require('./webpack.renderer.config')
-
-let electronProcess = null
-let manualRestart = false
-let hotMiddleware
-
-function logStats (proc, data) {
- let log = ''
-
- log += chalk.yellow.bold(`┏ ${proc} Process ${new Array((19 - proc.length) + 1).join('-')}`)
- log += '\n\n'
-
- if (typeof data === 'object') {
- data.toString({
- colors: true,
- chunks: false
- }).split(/\r?\n/).forEach(line => {
- log += ' ' + line + '\n'
- })
- } else {
- log += ` ${data}\n`
- }
-
- log += '\n' + chalk.yellow.bold(`┗ ${new Array(28 + 1).join('-')}`) + '\n'
-
- console.log(log)
-}
-
-function startRenderer () {
- return new Promise((resolve, reject) => {
- rendererConfig.entry.renderer = [path.join(__dirname, 'dev-client')].concat(rendererConfig.entry.renderer)
-
- const compiler = webpack(rendererConfig)
- hotMiddleware = webpackHotMiddleware(compiler, {
- log: false,
- heartbeat: 2500
- })
-
- compiler.hooks.compilation.tap('HtmlWebpackPluginAfterEmit', compilation => {
- HtmlWebpackPlugin.getHooks(compilation).afterEmit.tapAsync(
- 'AfterPlugin',
- (data, cb) => {
- hotMiddleware.publish({ action: 'reload' })
- // Tell webpack to move on
- cb(null, data)
- }
- )
- })
-
- compiler.hooks.done.tap('AfterCompiler', stats => {
- logStats('Renderer', stats)
- })
-
- const server = new WebpackDevServer({
- host: '127.0.0.1',
- port: 9091,
- hot: true,
- liveReload: true,
- compress: true,
- static: [
- {
- directory: path.join(__dirname, '../node_modules/codemirror/mode'),
- publicPath: '/codemirror/mode',
- watch: false
- }
- ],
- onBeforeSetupMiddleware ({ app, middleware }) {
- app.use(hotMiddleware)
- middleware.waitUntilValid(() => {
- resolve()
- })
- }
- }, compiler)
-
- server.start()
- })
-}
-
-function startMain () {
- return new Promise((resolve, reject) => {
- mainConfig.entry.main = [path.join(__dirname, '../src/main/index.dev.js')].concat(mainConfig.entry.main)
-
- const compiler = webpack(mainConfig)
-
- compiler.hooks.watchRun.tapAsync('Compiling', (_, done) => {
- logStats('Main', chalk.white.bold('compiling...'))
- hotMiddleware.publish({ action: 'compiling' })
- done()
- })
-
- compiler.watch({}, (err, stats) => {
- if (err) {
- console.log(err)
- return
- }
-
- logStats('Main', stats)
-
- if (electronProcess && electronProcess.kill) {
- manualRestart = true
- process.kill(electronProcess.pid)
- electronProcess = null
- startElectron()
-
- setTimeout(() => {
- manualRestart = false
- }, 5000)
- }
-
- resolve()
- })
- })
-}
-
-function startElectron () {
- electronProcess = spawn(electron, [
- '--inspect=5858',
- '--remote-debugging-port=8315',
- '--nolazy',
- path.join(__dirname, '../dist/electron/main.js')
- ])
-
- electronProcess.stdout.on('data', data => {
- electronLog(data, 'blue')
- })
- electronProcess.stderr.on('data', data => {
- electronLog(data, 'red')
- })
-
- electronProcess.on('close', () => {
- if (!manualRestart) process.exit()
- })
-}
-
-function electronLog (data, color) {
- let log = ''
- data = data.toString().split(/\r?\n/)
- data.forEach(line => {
- log += ` ${line}\n`
- })
- if (/[0-9A-z]+/.test(log)) {
- console.log(
- chalk[color].bold('┏ Electron -------------------') +
- '\n\n' +
- log +
- chalk[color].bold('┗ ----------------------------') +
- '\n'
- )
- }
-}
-
-function greeting () {
- const cols = process.stdout.columns
- let text = ''
-
- if (cols > 155) text = 'building marktext'
- else if (cols > 76) text = 'building|marktext'
- else text = false
-
- if (text) {
- say(text, {
- colors: ['yellow'],
- font: 'simple3d',
- space: false
- })
- } else {
- console.log(chalk.yellow.bold('\n building marktext'))
- }
- console.log(chalk.blue(' getting ready...') + '\n')
-}
-
-function init () {
- greeting()
-
- Promise.all([startRenderer(), startMain()])
- .then(() => {
- startElectron()
- })
- .catch(err => {
- console.error(err)
- })
-}
-
-init()
diff --git a/.electron-vue/electron-builder/afterPack.js b/.electron-vue/electron-builder/afterPack.js
deleted file mode 100644
index 7f4a10e87..000000000
--- a/.electron-vue/electron-builder/afterPack.js
+++ /dev/null
@@ -1,51 +0,0 @@
-'use strict'
-const fs = require('fs')
-const path = require('path')
-const { exec: execNode } = require("child_process")
-const util = require('util')
-
-const exec = util.promisify(execNode)
-
-// interface AfterPackContext {
-// outDir: string
-// appOutDir: string
-// packager: PlatformPackager
-// electronPlatformName: string
-// arch: Arch
-// targets: Array
-// }
-
-/**
- *
- * @param {AfterPackContext} context
- */
-const afterPack = async (context) => {
- // Workaround to remove debug information from production binaries on Linux (Electron#32669).
- if (context.packager.platform.name === 'linux') {
- console.log('[afterPack] Removing Electron debug information on Linux')
-
- const { appOutDir } = context
- const chromeCrashpadHandlerPath = path.join(appOutDir, 'chrome_crashpad_handler')
- const libvkPath = path.join(appOutDir, 'libvk_swiftshader.so')
-
- if (fs.existsSync(chromeCrashpadHandlerPath)) {
- const { err } = await exec(`strip "${chromeCrashpadHandlerPath}"`)
- if (err) {
- console.log('[afterPack] Unable to strip "chrome_crashpad_handler".')
- }
- } else {
- console.log(`[afterPack] "chrome_crashpad_handler" doesn't exists: "${chromeCrashpadHandlerPath}".`)
- }
-
- if (fs.existsSync(libvkPath)) {
- const { err } = await exec(`strip "${libvkPath}"`)
- if (err) {
- console.log('[afterPack] Unable to strip "libvk_swiftshader.so".')
- }
- } else {
- console.log(`[afterPack] "libvk_swiftshader.so" doesn't exists: "${libvkPath}".`)
- }
- }
-}
-
-exports.default = afterPack
diff --git a/.electron-vue/marktextEnvironment.js b/.electron-vue/marktextEnvironment.js
deleted file mode 100644
index d347b0398..000000000
--- a/.electron-vue/marktextEnvironment.js
+++ /dev/null
@@ -1,38 +0,0 @@
-const { GitRevisionPlugin } = require('git-revision-webpack-plugin')
-const { version } = require('../package.json')
-
-const getEnvironmentDefinitions = function () {
- let shortHash = 'N/A'
- let fullHash = 'N/A'
- try {
- const gitRevisionPlugin = new GitRevisionPlugin()
- shortHash = gitRevisionPlugin.version()
- fullHash = gitRevisionPlugin.commithash()
- } catch(_) {
- // Ignore error if we build without git.
- }
-
- const isStableRelease = !!process.env.MARKTEXT_IS_STABLE
- const versionSuffix = isStableRelease ? '' : ` (${shortHash})`
- return {
- 'global.MARKTEXT_GIT_SHORT_HASH': JSON.stringify(shortHash),
- 'global.MARKTEXT_GIT_HASH': JSON.stringify(fullHash),
-
- 'global.MARKTEXT_VERSION': JSON.stringify(version),
- 'global.MARKTEXT_VERSION_STRING': JSON.stringify(`v${version}${versionSuffix}`),
- 'global.MARKTEXT_IS_STABLE': JSON.stringify(isStableRelease)
- }
-}
-
-const getRendererEnvironmentDefinitions = function () {
- const env = getEnvironmentDefinitions()
- return {
- 'process.versions.MARKTEXT_VERSION': env['global.MARKTEXT_VERSION'],
- 'process.versions.MARKTEXT_VERSION_STRING': env['global.MARKTEXT_VERSION_STRING'],
- }
-}
-
-module.exports = {
- getEnvironmentDefinitions: getEnvironmentDefinitions,
- getRendererEnvironmentDefinitions: getRendererEnvironmentDefinitions
-}
diff --git a/.electron-vue/postinstall.js b/.electron-vue/postinstall.js
deleted file mode 100755
index fd81fb1d8..000000000
--- a/.electron-vue/postinstall.js
+++ /dev/null
@@ -1,32 +0,0 @@
-'use strict'
-const fs = require('fs')
-const path = require('path')
-
-// WORKAROUND: Fix slow startup time on Windows due to blocking powershell call(s) in windows-release.
-// Replace the problematic file with our "fixed" version.
-const windowsReleasePath = path.resolve(__dirname, '../node_modules/windows-release')
-if (fs.existsSync(windowsReleasePath)) {
- const windowsReleaseJson = path.join(windowsReleasePath, 'package.json')
- const packageJson = JSON.parse(fs.readFileSync(windowsReleaseJson, { encoding : 'utf-8' }))
-
- const windowsReleaseMajor = Number(packageJson.version.match(/^(\d+)\./)[1])
- if (windowsReleaseMajor >= 5) {
- console.error('[ERROR] "windows-release" workaround failed because version is >=5.\n')
- process.exit(1)
- }
-
- const srcPath = path.resolve(__dirname, '../resources/build/windows-release.js')
- const destPath = path.join(windowsReleasePath, 'index.js')
- fs.copyFileSync(srcPath, destPath)
-}
-
-// WORKAROUND: electron-builder downloads the wrong prebuilt architecture on macOS and the reason is unknown.
-// For now, we rebuild all native libraries from source.
-const keytarPath = path.resolve(__dirname, '../node_modules/keytar')
-if (process.platform === 'darwin' && fs.existsSync(keytarPath)) {
- const keytarPackageJsonPath = path.join(keytarPath, 'package.json')
- let packageText = fs.readFileSync(keytarPackageJsonPath, { encoding : 'utf-8' })
-
- packageText = packageText.replace(/"install": "prebuild-install \|\| npm run build",/i, '"install": "npm run build",')
- fs.writeFileSync(keytarPackageJsonPath, packageText, { encoding : 'utf-8' })
-}
diff --git a/.electron-vue/preinstall.js b/.electron-vue/preinstall.js
deleted file mode 100644
index 6f19d4458..000000000
--- a/.electron-vue/preinstall.js
+++ /dev/null
@@ -1,12 +0,0 @@
-'use strict'
-
-const nodeMajor = Number(process.versions.node.match(/^(\d+)\./)[1])
-if (nodeMajor < 14) {
- console.error('[ERROR] Node.js v14 or above is required.\n')
- process.exit(1)
-}
-
-if (!/yarn$/.test(process.env.npm_execpath)) {
- console.error('[ERROR] Please use yarn to install dependencies.\n')
- process.exit(1)
-}
diff --git a/.electron-vue/webpack.main.config.js b/.electron-vue/webpack.main.config.js
deleted file mode 100644
index 6ec024696..000000000
--- a/.electron-vue/webpack.main.config.js
+++ /dev/null
@@ -1,112 +0,0 @@
-'use strict'
-
-process.env.BABEL_ENV = 'main'
-
-const path = require('path')
-const webpack = require('webpack')
-const ESLintPlugin = require('eslint-webpack-plugin')
-
-const { getEnvironmentDefinitions } = require('./marktextEnvironment')
-const { dependencies } = require('../package.json')
-
-const isProduction = process.env.NODE_ENV === 'production'
-
-/** @type {import('webpack').Configuration} */
-const mainConfig = {
- mode: 'development',
- devtool: 'eval-cheap-module-source-map',
- optimization: {
- emitOnErrors: false
- },
- entry: {
- main: path.join(__dirname, '../src/main/index.js')
- },
- externals: [
- ...Object.keys(dependencies || {})
- ],
- module: {
- rules: [
- {
- test: /\.js$/,
- use: 'babel-loader',
- exclude: /node_modules/
- },
- {
- test: /\.node$/,
- loader: 'node-loader',
- options: {
- name: '[name].[ext]'
- }
- }
- ]
- },
- node: {
- __dirname: !isProduction,
- __filename: !isProduction
- },
- cache: false,
- output: {
- filename: '[name].js',
- libraryTarget: 'commonjs2',
- path: path.join(__dirname, '../dist/electron')
- },
- plugins: [
- new ESLintPlugin({
- extensions: ['js'],
- files: [
- 'src',
- 'test'
- ],
- exclude: [
- 'node_modules'
- ],
- emitError: true,
- failOnError: true,
- // NB: Threads must be disabled, otherwise no errors are emitted.
- threads: false,
- formatter: require('eslint-friendly-formatter'),
- context: path.resolve(__dirname, '../'),
- overrideConfigFile: '.eslintrc.js'
- }),
- // Add global environment definitions.
- new webpack.DefinePlugin(getEnvironmentDefinitions())
- ],
- resolve: {
- alias: {
- 'common': path.join(__dirname, '../src/common')
- },
- extensions: ['.js', '.json', '.node']
- },
- target: 'electron-main'
-}
-
-// Fix debugger breakpoints
-if (!isProduction && process.env.MARKTEXT_BUILD_VSCODE_DEBUG) {
- mainConfig.devtool = 'inline-source-map'
-}
-
-/**
- * Adjust mainConfig for development settings
- */
-if (!isProduction) {
- mainConfig.cache = {
- name: 'main-dev',
- type: 'filesystem'
- }
- mainConfig.plugins.push(
- new webpack.DefinePlugin({
- '__static': `"${path.join(__dirname, '../static').replace(/\\/g, '\\\\')}"`
- })
- )
-}
-
-/**
- * Adjust mainConfig for production settings
- */
-if (isProduction) {
- mainConfig.devtool = 'nosources-source-map'
- mainConfig.mode = 'production'
- mainConfig.optimization.minimize = true
-}
-
-module.exports = mainConfig
diff --git a/.electron-vue/webpack.renderer.config.js b/.electron-vue/webpack.renderer.config.js
deleted file mode 100644
index 3abf3145c..000000000
--- a/.electron-vue/webpack.renderer.config.js
+++ /dev/null
@@ -1,285 +0,0 @@
-'use strict'
-
-process.env.BABEL_ENV = 'renderer'
-
-const path = require('path')
-const webpack = require('webpack')
-const CopyWebpackPlugin = require('copy-webpack-plugin')
-const MiniCssExtractPlugin = require("mini-css-extract-plugin")
-const HtmlWebpackPlugin = require('html-webpack-plugin')
-const VueLoaderPlugin = require('vue-loader/lib/plugin')
-const SpritePlugin = require('svg-sprite-loader/plugin')
-const postcssPresetEnv = require('postcss-preset-env')
-const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
-const ESLintPlugin = require('eslint-webpack-plugin')
-
-const { getRendererEnvironmentDefinitions } = require('./marktextEnvironment')
-const { dependencies } = require('../package.json')
-
-const isProduction = process.env.NODE_ENV === 'production'
-/**
- * List of node_modules to include in webpack bundle
- * Required for specific packages like Vue UI libraries
- * that provide pure *.vue files that need compiling
- * https://simulatedgreg.gitbooks.io/electron-vue/content/en/webpack-configurations.html#white-listing-externals
- */
-const whiteListedModules = ['vue']
-
-/** @type {import('webpack').Configuration} */
-const rendererConfig = {
- mode: 'development',
- devtool: 'eval-cheap-module-source-map',
- optimization: {
- emitOnErrors: false
- },
- infrastructureLogging: {
- level: 'warn',
- },
- entry: {
- renderer: path.join(__dirname, '../src/renderer/main.js')
- },
- externals: [
- ...Object.keys(dependencies || {}).filter(d => !whiteListedModules.includes(d))
- ],
- module: {
- rules: [
- {
- test: require.resolve(path.join(__dirname, '../src/muya/lib/assets/libs/snap.svg-min.js')),
- use: 'imports-loader?this=>window,fix=>module.exports=0'
- },
- {
- test: /\.vue$/,
- use: {
- loader: 'vue-loader',
- options: {
- sourceMap: true
- }
- }
- },
- {
- test: /(theme\-chalk(?:\/|\\)index|exportStyle|katex|github\-markdown|prism[\-a-z]*|\.theme|headerFooterStyle)\.css$/,
- use: [
- 'to-string-loader',
- 'css-loader'
- ]
- },
- {
- test: /\.css$/,
- exclude: /(theme\-chalk(?:\/|\\)index|exportStyle|katex|github\-markdown|prism[\-a-z]*|\.theme|headerFooterStyle)\.css$/,
- use: [
- isProduction ? MiniCssExtractPlugin.loader : 'style-loader',
- {
- loader: 'css-loader',
- options: { importLoaders: 1 }
- },
- {
- loader: 'postcss-loader',
- options: {
- postcssOptions: {
- plugins: [
- postcssPresetEnv({ stage: 0 })
- ],
- },
- }
- }
- ]
- },
- {
- test: /\.html$/,
- use: 'vue-html-loader'
- },
- {
- test: /\.js$/,
- use: [
- {
- loader: 'babel-loader',
- options: {
- cacheDirectory: true
- }
- }
- ],
- exclude: /node_modules/
- },
- {
- test: /\.node$/,
- loader: 'node-loader',
- options: {
- name: '[name].[ext]'
- }
- },
- {
- test: /\.svg$/,
- use: [
- {
- loader: 'svg-sprite-loader',
- options: {
- extract: true,
- publicPath: './static/'
- }
- },
- 'svgo-loader'
- ]
- },
- {
- test: /\.(png|jpe?g|gif)(\?.*)?$/,
- type: 'asset',
- generator: {
- filename: 'images/[name].[contenthash:8][ext]'
- }
- },
- {
- test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
- type: 'asset/resource',
- generator: {
- filename: 'media/[name].[contenthash:8][ext]'
- }
- },
- {
- test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
- type: 'asset/resource',
- generator: {
- filename: 'fonts/[name].[contenthash:8][ext]'
- }
- },
- {
- test: /\.md$/,
- type: 'asset/source'
- }
- ]
- },
- node: {
- __dirname: !isProduction,
- __filename: !isProduction
- },
- plugins: [
- new ESLintPlugin({
- cache: !isProduction,
- extensions: ['js', 'vue'],
- files: [
- 'src',
- 'test'
- ],
- exclude: [
- 'node_modules'
- ],
- emitError: true,
- failOnError: true,
- // NB: Threads must be disabled, otherwise no errors are emitted.
- threads: false,
- formatter: require('eslint-friendly-formatter'),
- context: path.resolve(__dirname, '../'),
- overrideConfigFile: '.eslintrc.js'
- }),
- new SpritePlugin(),
- new HtmlWebpackPlugin({
- filename: 'index.html',
- template: path.resolve(__dirname, '../src/index.ejs'),
- minify: {
- collapseWhitespace: true,
- removeAttributeQuotes: true,
- removeComments: true,
- minifyJS: true,
- minifyCSS: true
- },
- isBrowser: false,
- isDevelopment: !isProduction,
- nodeModules: !isProduction
- ? path.resolve(__dirname, '../node_modules')
- : false
- }),
- new webpack.DefinePlugin(getRendererEnvironmentDefinitions()),
- // Use node http request instead axios's XHR adapter.
- new webpack.NormalModuleReplacementPlugin(
- /.+[\/\\]node_modules[\/\\]axios[\/\\]lib[\/\\]adapters[\/\\]xhr\.js$/,
- 'http.js'
- ),
- new VueLoaderPlugin()
- ],
- cache: false,
- output: {
- filename: '[name].js',
- libraryTarget: 'commonjs2',
- path: path.join(__dirname, '../dist/electron'),
- assetModuleFilename: 'assets/[name].[contenthash:8][ext]',
- asyncChunks: true
- },
- resolve: {
- alias: {
- 'main': path.join(__dirname, '../src/main'),
- '@': path.join(__dirname, '../src/renderer'),
- 'common': path.join(__dirname, '../src/common'),
- 'muya': path.join(__dirname, '../src/muya'),
- snapsvg: path.join(__dirname, '../src/muya/lib/assets/libs/snap.svg-min.js'),
- 'vue$': 'vue/dist/vue.esm.js'
- },
- extensions: ['.js', '.vue', '.json', '.css', '.node']
- },
- target: 'electron-renderer'
-}
-
-/**
- * Adjust rendererConfig for development settings
- */
-if (!isProduction) {
- rendererConfig.cache = { type: 'memory' }
- // NOTE: Caching between builds is currently not possible because all SVGs are invalid on second build due to svgo-loader.
- // rendererConfig.cache = {
- // name: 'renderer-dev',
- // type: 'filesystem'
- // }
- rendererConfig.plugins.push(
- new webpack.DefinePlugin({
- '__static': `"${path.join(__dirname, '../static').replace(/\\/g, '\\\\')}"`
- })
- )
-}
-
-if (process.env.NODE_ENV !== 'production' && process.env.NODE_ENV !== 'test' &&
- !process.env.MARKTEXT_DEV_HIDE_BROWSER_ANALYZER) {
- rendererConfig.plugins.push(
- new BundleAnalyzerPlugin()
- )
-}
-
-// Fix debugger breakpoints
-if (!isProduction && process.env.MARKTEXT_BUILD_VSCODE_DEBUG) {
- rendererConfig.devtool = 'inline-source-map'
-}
-
-/**
- * Adjust rendererConfig for production settings
- */
-if (isProduction) {
- rendererConfig.devtool = 'nosources-source-map'
- rendererConfig.mode = 'production'
- rendererConfig.optimization.minimize = true
-
- rendererConfig.plugins.push(
- new webpack.DefinePlugin({
- 'process.env.UNSPLASH_ACCESS_KEY': JSON.stringify(process.env.UNSPLASH_ACCESS_KEY)
- }),
- new MiniCssExtractPlugin({
- // Options similar to the same options in webpackOptions.output
- // both options are optional
- filename: '[name].[contenthash].css',
- chunkFilename: '[id].[contenthash].css'
- }),
- new CopyWebpackPlugin({
- patterns: [
- {
- from: path.join(__dirname, '../static'),
- to: path.join(__dirname, '../dist/electron/static'),
- globOptions: {
- ignore: ['.*']
- }
- },
- {
- from: path.resolve(__dirname, '../node_modules/codemirror/mode/*/*').replace(/\\/g, '/'),
- to: path.join(__dirname, '../dist/electron/codemirror/mode/[name]/[name][ext]')
- }
- ]
- })
- )
-}
-
-module.exports = rendererConfig
diff --git a/.eslintrc.js b/.eslintrc.js
index 992d0e0d6..0f35f95eb 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -1,29 +1,37 @@
module.exports = {
- root: true,
- parserOptions: {
- parser: '@babel/eslint-parser',
- ecmaVersion: 11,
- ecmaFeatures: {
- impliedStrict: true
- },
- sourceType: 'module'
- },
env: {
browser: true,
- es6: true,
+ es2021: true,
node: true
},
extends: [
'standard',
- 'eslint:recommended',
- 'plugin:vue/base',
- 'plugin:import/errors',
- 'plugin:import/warnings'
+ 'plugin:vue/vue3-essential'
+ ],
+ overrides: [
+ {
+ env: {
+ node: true
+ },
+ files: [
+ '.eslintrc.{js,cjs}'
+ ],
+ parserOptions: {
+ sourceType: 'script'
+ }
+ }
],
globals: {
__static: true
},
- plugins: ['html', 'vue'],
+ parserOptions: {
+ ecmaVersion: 'latest',
+ sourceType: 'module'
+ },
+ plugins: [
+ 'html',
+ 'vue'
+ ],
rules: {
// Two spaces but disallow semicolons
indent: ['error', 2, { 'SwitchCase': 1, 'ignoreComments': true }],
diff --git a/.gitignore b/.gitignore
index 2f74b8807..a3d98f03c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -178,3 +178,5 @@ dist
# .pnp.*
# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,node,yarn
+
+.vite
diff --git a/babel.config.js b/babel.config.js
deleted file mode 100644
index a1642c7d0..000000000
--- a/babel.config.js
+++ /dev/null
@@ -1,56 +0,0 @@
-const proposalClassProperties = require('@babel/plugin-proposal-class-properties')
-const syntaxClassProperties = require('@babel/plugin-syntax-class-properties')
-const transformRuntime = require('@babel/plugin-transform-runtime')
-const syntaxDynamicImport = require('@babel/plugin-syntax-dynamic-import')
-const functionBind = require('@babel/plugin-proposal-function-bind')
-const exportDefault = require('@babel/plugin-proposal-export-default-from')
-const isTanbul = require('babel-plugin-istanbul')
-const component = require('babel-plugin-component')
-const presetEnv = require('@babel/preset-env')
-
-const presetsHash = {
- test: [
- [presetEnv,
- {
- targets: { 'node': 16 }
- }]
- ],
- main: [
- [presetEnv,
- {
- targets: { 'node': 16 }
- }]
- ],
- renderer: [
- [presetEnv,
- {
- useBuiltIns: false,
- targets: {
- electron: require('electron/package.json').version,
- node: 16
- }
- }]
- ]
-}
-
-module.exports = function (api) {
- const plugins = [ proposalClassProperties, syntaxClassProperties, transformRuntime, syntaxDynamicImport, functionBind, exportDefault ]
- const env = api.env()
- const presets = presetsHash[env]
-
- if (env === 'test') {
- plugins.push(isTanbul)
- } else if (env === 'renderer') {
- plugins.push(
- [component, {
- style: false,
- libraryName: 'element-ui'
- }
- ])
- }
-
- return {
- presets,
- plugins
- }
-}
diff --git a/forge.config.js b/forge.config.js
new file mode 100644
index 000000000..2338ca070
--- /dev/null
+++ b/forge.config.js
@@ -0,0 +1,54 @@
+module.exports = {
+ packagerConfig: {
+ asar: true
+ },
+ rebuildConfig: {},
+ makers: [
+ {
+ name: '@electron-forge/maker-squirrel',
+ config: {}
+ },
+ {
+ name: '@electron-forge/maker-zip',
+ platforms: ['darwin']
+ },
+ {
+ name: '@electron-forge/maker-deb',
+ config: {}
+ },
+ {
+ name: '@electron-forge/maker-rpm',
+ config: {}
+ }
+ ],
+ plugins: [
+ {
+ name: '@electron-forge/plugin-auto-unpack-natives',
+ config: {}
+ },
+ {
+ name: '@electron-forge/plugin-vite',
+ config: {
+ // `build` can specify multiple entry builds, which can be Main process, Preload scripts, Worker process, etc.
+ // If you are familiar with Vite configuration, it will look really familiar.
+ build: [
+ {
+ // `entry` is just an alias for `build.lib.entry` in the corresponding file of `config`.
+ entry: 'src/main/index.js',
+ config: 'vite.main.config.mjs'
+ },
+ {
+ entry: 'src/main/preload.js',
+ config: 'vite.preload.config.mjs'
+ }
+ ],
+ renderer: [
+ {
+ name: 'main_window',
+ config: 'vite.renderer.config.mjs'
+ }
+ ]
+ }
+ }
+ ]
+}
diff --git a/src/index.ejs b/index.html
similarity index 72%
rename from src/index.ejs
rename to index.html
index 7f1b9ded5..4d035aea6 100644
--- a/src/index.ejs
+++ b/index.html
@@ -61,12 +61,6 @@
}
}
- <% if (htmlWebpackPlugin.options.nodeModules) { %>
-
-
- <% } %>
@@ -84,11 +78,11 @@
const params = new URLSearchParams(window.location.search)
const THEMES_COLOR = {
'one-dark': 'rgba(77, 120, 204, 1)',
- 'dark': '#409eff',
- 'graphite': 'rgb(104, 134, 170)',
+ dark: '#409eff',
+ graphite: 'rgb(104, 134, 170)',
'material-dark': '#f48237',
- 'light': 'rgba(33, 181, 111, 1)',
- 'ulysses': 'rgb(12, 139, 186)'
+ light: 'rgba(33, 181, 111, 1)',
+ ulysses: 'rgb(12, 139, 186)'
}
const dots = document.querySelectorAll('.dot')
@@ -97,13 +91,6 @@
})
-
- <% if (!htmlWebpackPlugin.options.isBrowser && !htmlWebpackPlugin.options.isDevelopment) { %>
-
- <% } %>
-
-
+