Skip to content

Commit

Permalink
Various updates and performance
Browse files Browse the repository at this point in the history
  • Loading branch information
fetacore committed Mar 8, 2018
1 parent f6245c9 commit ca4b9af
Show file tree
Hide file tree
Showing 9 changed files with 156 additions and 64 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -2,3 +2,6 @@
prod
node_modules
src/entry
src/react/inf.min.js
beforePackLinuxNoAutoupdatesDeb.js
beforePackLinuxNoAutoupdatesRpm.js
30 changes: 25 additions & 5 deletions beforeBundle.js
Expand Up @@ -38,20 +38,40 @@ fs.readFile(__dirname + '/node_modules/brace/ext/language_tools.js', 'utf-8', (e
'var completers = [snippetCompleter, textCompleter, keyWordCompleter];',
'var completers = [snippetCompleter, keyWordCompleter];'
).replace(
'#fbfbfb', '#141414'
'#fbfbfb', '#f7f7f7'
).replace(
'#444', '#696969'
'#444', '#383838'
).replace(
'rgba(194, 193, 208, 0.09)', '#171717'
'rgba(194, 193, 208, 0.09)', '#adadad'
).replace(
'#CAD6FA', '#585858'
'#CAD6FA', '#adadad'
).replace(
'rgba(233,233,253,0.4)', '#b9b9b9'
'rgba(233,233,253,0.4)', '#adadad'
).replace(
'lightgray', 'black'
)
fs.writeFileSync(__dirname + '/node_modules/brace/ext/language_tools.js', dataXwrisSkatila)
})

// fs.readFile(__dirname + '/node_modules/brace/mode/latex.js', 'utf-8', (err, data) => {
// let dataXwrisSkatila = data.replace(
// '\"require\",\"exports\",\"module\",\"ace/lib/oop\",\"ace/mode/text_highlight_rules\"',
// '\"require",\"exports\",\"module\",\"ace/lib/oop\",\"ace/lib/lang\",\"ace/mode/text_highlight_rules\"'
// ).replace(
// 'var oop = acequire(\"../lib/oop\");\nvar TextHighlightRules = acequire(\"./text_highlight_rules\").TextHighlightRules;',
// 'var oop = acequire(\"../lib/oop\");\nvar lang = acequire(\"../lib/lang\");\nvar TextHighlightRules = acequire(\"./text_highlight_rules\").TextHighlightRules;'
// ).replace(
// 'var LatexHighlightRules = function() {',
// 'var LatexHighlightRules = function(textClass) {\n\n\tif (!textClass)\n textClass = \"text\";'
// )
// fs.writeFileSync(__dirname + '/node_modules/brace/mode/latex.js', dataXwrisSkatila)
// })

// fs.readFile(__dirname + '/node_modules/brace/snippets/tex.js', 'utf-8', (err, data) => {
// let newSnips = data
// shelljs.mkdir('-p', __dirname + fpresolver + 'src' + fpresolver + 'snippets' + fpresolver)
// fs.writeFileSync(__dirname + '/src/snippets/latex.js', newSnips)
// })

fs.writeFileSync(__dirname + '/src/react/reactPdf/pdf.worker.min.js', worker)
fs.writeFileSync(__dirname + '/src/static/polyfill.min.js', poly)
2 changes: 2 additions & 0 deletions beforeDist.js
Expand Up @@ -19,6 +19,8 @@ switch (process.platform) {

function removeUnnecessary () {
shelljs.rm('-rf',
__dirname + fpresolver + 'src' + fpresolver + 'index.min.js',
__dirname + fpresolver + 'src' + fpresolver + 'react' + fpresolver + 'inf.min.js',
__dirname + fpresolver + 'prod' + fpresolver + 'dist' + fpresolver + unpacked + fpresolver + 'locales' + fpresolver,
__dirname + fpresolver + 'prod' + fpresolver + 'dist' + fpresolver + unpacked + fpresolver + 'pdf_viewer_resources.pak'
)
Expand Down
45 changes: 42 additions & 3 deletions beforePackage.js
@@ -1,13 +1,26 @@
const fs = require('fs')
const path = require('path')
const shelljs = require('shelljs')
var UglifyJS = require("uglify-es");

if (process.platform == 'win32') {
var fpresolver = '\\'
} else {
var fpresolver = '/'
}

var uglifyOptions = {
ecma: 6,
compress: {
drop_console: true,
passes: 2
},
mangle: true,
output: {
beautify: false,
}
};

function copyPasteStuff () {
shelljs.cp('-R', __dirname + fpresolver + 'src' + fpresolver, __dirname + fpresolver + 'prod' + fpresolver)
shelljs.cp(__dirname + fpresolver + 'package.json', __dirname + fpresolver + 'prod' + fpresolver)
Expand All @@ -17,6 +30,7 @@ function copyPasteStuff () {

function removeStuff () {
shelljs.rm('-rf',
__dirname + fpresolver + 'src' + fpresolver + 'entry' + fpresolver,
__dirname + fpresolver + 'prod' + fpresolver + 'src' + fpresolver + 'entry' + fpresolver,
__dirname + fpresolver + 'prod' + fpresolver + 'src' + fpresolver + 'entryDev.js',
__dirname + fpresolver + 'prod' + fpresolver + 'src' + fpresolver + 'react' + fpresolver + 'assets' + fpresolver + 'ace' + fpresolver,
Expand Down Expand Up @@ -62,9 +76,9 @@ function removeLines () {
alert(err)
} else {
let htmlXwrisSkata = data.replace(
'<!-- <script src="../src/entry/bundle.js"></script> -->', ''
'<!-- <script src=\"./react/inf.min.js\"></script> -->', '<script src=\"./react/inf.min.js\"></script>'
).replace(
'<!-- <script src="entryDev.js"></script> -->', ''
'<script src=\"entryDev.js\"></script>', ''
)
fs.writeFileSync(__dirname + '/prod/src/index.html', htmlXwrisSkata)
}
Expand All @@ -74,11 +88,36 @@ function removeLines () {
alert(err)
} else {
let packXwrisSkata = data.replace(
'electron-prebuilt-compile', 'electron'
'\"electron-prebuilt-compile\": \"2.0.0-beta.1\",', '\"electron\": \"1.8.3\",'
).replace(
'\"src/index.js\"', '\"src/index.min.js\"'
).replace(
'\"uglify-js\": \"^3.3.13\"', '\"uglify-es\": \"^3.3.9\"'
)
fs.writeFileSync(__dirname + '/prod/package.json', packXwrisSkata)
}
})
fixIndex()
}

function fixIndex () {
fs.readFile(__dirname + '/prod/src/index.js', 'utf-8', (err, data) => {
if (err) {
alert(err)
} else {
let mini = UglifyJS.minify(data, uglifyOptions);
fs.writeFile(__dirname + '/prod/src/index.min.js', mini.code, (err) => {
if (err) {
alert(err)
} else {
shelljs.rm('-rf',
__dirname + fpresolver + 'prod' + fpresolver + 'src' + fpresolver + 'index.js'
)
}
})

}
})
}

shelljs.mkdir('-p', __dirname + fpresolver + 'prod' + fpresolver)
Expand Down
17 changes: 8 additions & 9 deletions package.json
@@ -1,18 +1,16 @@
{
"name": "InfiniTex",
"productName": "InfiniTex",
"version": "0.9.3",
"version": "0.9.5",
"description": "A new age editor for academics who seek freedom and people with cryptography needs in rich text environments.",
"main": "src/index.js",
"scripts": {
"start": "electron .",
"preminify": "node ./beforeBundle.js",
"minify": "browserify ./src/entryDev.js -g [ envify --NODE_ENV production --BABEL_ENV production ] -t [ babelify --presets [ env --targets [ electron ] react ] --plugins transform-async-to-generator ] --full-path=false --exclude electron --exclude shelljs -o ./src/entry/bundle.js",
"postminify": "uglifyjs --ecma 7 --compress drop_console=true --mangle -- ./src/entry/bundle.js > ./src/react/inf.min.js",
"package": "node ./beforePackage.js && cd prod && yarn && electron-builder --dir",
"dist": "node ./beforePackage.js && cd prod && yarn && electron-builder",
"dist:deb": "node ./beforePackLinuxNoAutoupdatesDeb.js && cd prod && yarn && electron-builder",
"dist:rpm": "node ./beforePackLinuxNoAutoupdatesRpm.js && cd prod && yarn && electron-builder"
"minify": "browserify ./src/entryDev.js -g [ envify --NODE_ENV production --BABEL_ENV production ] -g uglifyify -t [ babelify --presets [ env --targets [ electron ] react ] --plugins transform-async-to-generator ] --full-path=false --exclude electron --exclude shelljs -o ./src/entry/bundle.js",
"postminify": "uglifyjs --compress drop_console=true --mangle -- ./src/entry/bundle.js > ./src/react/inf.min.js",
"package": "npm run minify && node ./beforePackage.js && cd prod && yarn && electron-builder --dir",
"dist": "npm run minify && node ./beforePackage.js && cd prod && yarn && electron-builder"
},
"build": {
"appId": "com.fetacore.InfiniTex",
Expand Down Expand Up @@ -138,7 +136,7 @@
"babelify": "^8.0.0",
"brace": "^0.11.1",
"browserify": "^16.1.1",
"electron-builder": "^20.3.1",
"electron-builder": "^20.4.0",
"electron-devtools-installer": "^2.2.3",
"electron-prebuilt-compile": "2.0.0-beta.1",
"electron-reload": "^1.2.2",
Expand All @@ -159,6 +157,7 @@
"react-resizable": "^1.7.5",
"react-transition-group": "^2.2.1",
"request": "^2.83.0",
"uglify-es": "^3.3.9"
"uglify-js": "^3.3.13",
"uglifyify": "^4.0.5"
}
}
4 changes: 2 additions & 2 deletions src/index.html
Expand Up @@ -13,6 +13,6 @@
<script src="../node_modules/katex/dist/katex.min.js"></script>
<script src="./react/assets/quill/highlight.pack.js"></script>
<script src="./static/polyfill.min.js"></script>
<script src="./react/inf.min.js"></script>
<!-- <script src="entryDev.js"></script> -->
<!-- <script src="./react/inf.min.js"></script> -->
<script src="entryDev.js"></script>
</html>
31 changes: 18 additions & 13 deletions src/react/Grid.jsx
Expand Up @@ -41,11 +41,9 @@ import EditorFormatPaint from 'material-ui/svg-icons/editor/format-paint'
import NavigationArrowForward from 'material-ui/svg-icons/navigation/arrow-forward'
import AceEditor from 'react-ace'
import brace from 'brace'
import 'brace/mode/latex.js'
import 'brace/mode/tex.js'
import 'brace/mode/snippets.js'
import 'brace/snippets/tex.js'
import 'brace/snippets/latex.js'
import 'brace/ext/language_tools.js'
import 'brace/ext/searchbox.js'
import 'brace/keybinding/vim.js'
Expand Down Expand Up @@ -261,17 +259,18 @@ export default class Grid extends React.Component {
default:
fpresolver = '/'
}
let filetitle = fileName.slice(fileName.lastIndexOf(fpresolver) + 1, fileName.length)
if (fileName == null) {
this.onNotification('FileWasNotSaved')
return
} else if (filetitle.indexOf(' ') !== -1) {
this.onNotification('IncorrectFilename')
return
} else {
let filetitle = fileName.slice(fileName.lastIndexOf(fpresolver) + 1, fileName.length)
// fileName is a string that contains the path and filename created in the save file dialog.
ipcRenderer.send('createTexBibFile', [fileName, this.state.packages + this.state.texfilecontent + '\\end{document}', this.state.bibfilecontent])
this.setState({ filepath: fileName })
}
// fileName is a string that contains the path and filename created in the save file dialog.
ipcRenderer.send('createTexBibFile', [fileName, this.state.packages + this.state.texfilecontent + '\\end{document}', this.state.bibfilecontent])
this.setState({ filepath: fileName })
})
ipcRenderer.on('openTexDialogFilename', (event, fileNames) => {
if (fileNames == null) {
Expand Down Expand Up @@ -535,7 +534,9 @@ You can refer to the graph as \\ref{figure:nickname}\n'
})
}

onFocusMainEditor () {
onFocusMainEditor (event) {
event.preventDefault()
event.stopPropagation()
let crsr = this.refs.mainEditor.editor.selection.getCursor()
this.setState({
texRow: crsr.row,
Expand All @@ -545,11 +546,13 @@ You can refer to the graph as \\ref{figure:nickname}\n'
this.refs.mainEditor.editor.clearSelection()
setTimeout(() => {
this.focusEditor(0)
}, 5)
}, 0.1)
})
}

onFocusBibEditor () {
onFocusBibEditor (event) {
event.preventDefault()
event.stopPropagation()
let crsr = this.refs.bibEditor.editor.selection.getCursor()
this.setState({
bibRow: crsr.row,
Expand All @@ -558,11 +561,13 @@ You can refer to the graph as \\ref{figure:nickname}\n'
this.refs.bibEditor.editor.clearSelection()
setTimeout(() => {
this.focusEditor(1)
}, 5)
}, 0.1)
})
}

onFocusSplitEditor () {
onFocusSplitEditor (event) {
event.preventDefault()
event.stopPropagation()
let crsr = this.refs.splitEditor.editor.selection.getCursor()
this.setState({
splitRow: crsr.row,
Expand All @@ -571,7 +576,7 @@ You can refer to the graph as \\ref{figure:nickname}\n'
this.refs.splitEditor.editor.clearSelection()
setTimeout(() => {
this.focusEditor(2)
}, 5)
}, 0.1)
})
}

Expand Down Expand Up @@ -3084,7 +3089,7 @@ note = ,\n\u007D\n'
/>
<div style={{height: separateTexBibHeight, backgroundColor: '#fff'}}></div>
<AceEditor
mode='latex'
mode='tex'
theme={aceEditorTheme}
snippets='tex'
name='bibEditor'
Expand Down
1 change: 0 additions & 1 deletion src/react/inf.min.js

This file was deleted.

0 comments on commit ca4b9af

Please sign in to comment.