From d2117259eb5dc8c9db533f9babc5d38f02040043 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Sep 2024 03:50:51 +0000 Subject: [PATCH 1/6] Bump express-static-gzip from 2.1.7 to 2.1.8 Bumps [express-static-gzip](https://github.com/tkoenig89/express-static-gzip) from 2.1.7 to 2.1.8. - [Release notes](https://github.com/tkoenig89/express-static-gzip/releases) - [Commits](https://github.com/tkoenig89/express-static-gzip/compare/v2.1.7...v2.1.8) --- updated-dependencies: - dependency-name: express-static-gzip dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- package-lock.json | 11 +++++------ package.json | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index 06c4350ca..16d308bf5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,7 +25,7 @@ "expr-eval": "^2.0.2", "express": "^4.21.0", "express-async-handler": "^1.2.0", - "express-static-gzip": "2.1.7", + "express-static-gzip": "2.1.8", "fs-extra": "11.2.0", "js-yaml": "^4.1.0", "jwt-simple": "^0.5.6", @@ -6362,12 +6362,11 @@ "license": "MIT" }, "node_modules/express-static-gzip": { - "version": "2.1.7", - "resolved": "https://registry.npmjs.org/express-static-gzip/-/express-static-gzip-2.1.7.tgz", - "integrity": "sha512-QOCZUC+lhPPCjIJKpQGu1Oa61Axg9Mq09Qvit8Of7kzpMuwDeMSqjjQteQS3OVw/GkENBoSBheuQDWPlngImvw==", - "license": "MIT", + "version": "2.1.8", + "resolved": "https://registry.npmjs.org/express-static-gzip/-/express-static-gzip-2.1.8.tgz", + "integrity": "sha512-g8tiJuI9Y9Ffy59ehVXvqb0hhP83JwZiLxzanobPaMbkB5qBWA8nuVgd+rcd5qzH3GkgogTALlc0BaADYwnMbQ==", "dependencies": { - "serve-static": "^1.14.1" + "serve-static": "^1.16.2" } }, "node_modules/express/node_modules/cookie": { diff --git a/package.json b/package.json index f760cc096..ef39fbf6f 100644 --- a/package.json +++ b/package.json @@ -100,7 +100,7 @@ "expr-eval": "^2.0.2", "express": "^4.21.0", "express-async-handler": "^1.2.0", - "express-static-gzip": "2.1.7", + "express-static-gzip": "2.1.8", "fs-extra": "11.2.0", "js-yaml": "^4.1.0", "jwt-simple": "^0.5.6", From 1645a5acf41d18bdd0b073a919d42e38b6b2b3e0 Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Mon, 16 Sep 2024 01:39:44 -0400 Subject: [PATCH 2/6] Lint App.js Just whitespace changes --- server/app.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/server/app.js b/server/app.js index c03fb2dc2..c97fc302e 100644 --- a/server/app.js +++ b/server/app.js @@ -203,22 +203,22 @@ app.get('/download/:id', asyncHandler(getBrew('share')), (req, res)=>{ }); //Serve brew metadata -app.get('/metadata/:id', asyncHandler(getBrew('share')), (req, res) => { +app.get('/metadata/:id', asyncHandler(getBrew('share')), (req, res)=>{ const { brew } = req; sanitizeBrew(brew, 'share'); - - const fields = [ 'title', 'pageCount', 'description', 'authors', 'lang', - 'published', 'views', 'shareId', 'createdAt', 'updatedAt', + + const fields = ['title', 'pageCount', 'description', 'authors', 'lang', + 'published', 'views', 'shareId', 'createdAt', 'updatedAt', 'lastViewed', 'thumbnail', 'tags' ]; - - const metadata = fields.reduce((acc, field) => { - if (brew[field] !== undefined) acc[field] = brew[field]; + + const metadata = fields.reduce((acc, field)=>{ + if(brew[field] !== undefined) acc[field] = brew[field]; return acc; }, {}); res.status(200).json(metadata); }); - + //Serve brew styling app.get('/css/:id', asyncHandler(getBrew('share')), (req, res)=>{getCSS(req, res);}); @@ -378,7 +378,7 @@ app.get('/share/:id', asyncHandler(getBrew('share')), asyncHandler(async (req, r app.get('/account', asyncHandler(async (req, res, next)=>{ const data = {}; data.title = 'Account Information Page'; - + if(!req.account) { res.set('WWW-Authenticate', 'Bearer realm="Authorization Required"'); const error = new Error('No valid account'); @@ -462,8 +462,8 @@ app.get('/vault', asyncHandler(async(req, res, next)=>{ //Send rendered page app.use(asyncHandler(async (req, res, next)=>{ - if (!req.route) return res.redirect('/'); // Catch-all for invalid routes - + if(!req.route) return res.redirect('/'); // Catch-all for invalid routes + const page = await renderPage(req, res); if(!page) return; res.send(page); From b5490e3a5355784292d9a58200dba7aae739f19b Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Mon, 16 Sep 2024 01:40:21 -0400 Subject: [PATCH 3/6] Lint editor.jsx --- client/homebrew/editor/editor.jsx | 62 +++++++++++++++---------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index 0ecb1787f..5c198c3b3 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -36,7 +36,7 @@ const Editor = createClass({ onStyleChange : ()=>{}, onMetaChange : ()=>{}, reportError : ()=>{}, - + onCursorPageChange : ()=>{}, onViewPageChange : ()=>{}, @@ -45,7 +45,7 @@ const Editor = createClass({ currentEditorCursorPageNum : 1, currentEditorViewPageNum : 1, - currentBrewRendererPageNum : 1, + currentBrewRendererPageNum : 1, }; }, getInitialState : function() { @@ -70,8 +70,8 @@ const Editor = createClass({ document.getElementById('BrewRenderer').addEventListener('keydown', this.handleControlKeys); document.addEventListener('keydown', this.handleControlKeys); - this.codeEditor.current.codeMirror.on('cursorActivity', (cm)=>{this.updateCurrentCursorPage(cm.getCursor())}); - this.codeEditor.current.codeMirror.on('scroll', _.throttle(()=>{this.updateCurrentViewPage(this.codeEditor.current.getTopVisibleLine())}, 200)); + this.codeEditor.current.codeMirror.on('cursorActivity', (cm)=>{this.updateCurrentCursorPage(cm.getCursor());}); + this.codeEditor.current.codeMirror.on('scroll', _.throttle(()=>{this.updateCurrentViewPage(this.codeEditor.current.getTopVisibleLine());}, 200)); const editorTheme = window.localStorage.getItem(EDITOR_THEME_KEY); if(editorTheme) { @@ -109,9 +109,9 @@ const Editor = createClass({ if(!(e.ctrlKey && e.metaKey && e.shiftKey)) return; const LEFTARROW_KEY = 37; const RIGHTARROW_KEY = 39; - if (e.keyCode == RIGHTARROW_KEY) this.brewJump(); - if (e.keyCode == LEFTARROW_KEY) this.sourceJump(); - if (e.keyCode == LEFTARROW_KEY || e.keyCode == RIGHTARROW_KEY) { + if(e.keyCode == RIGHTARROW_KEY) this.brewJump(); + if(e.keyCode == LEFTARROW_KEY) this.sourceJump(); + if(e.keyCode == LEFTARROW_KEY || e.keyCode == RIGHTARROW_KEY) { e.stopPropagation(); e.preventDefault(); } @@ -128,14 +128,14 @@ const Editor = createClass({ updateCurrentCursorPage : function(cursor) { const lines = this.props.brew.text.split('\n').slice(0, cursor.line + 1); const pageRegex = this.props.brew.renderer == 'V3' ? /^\\page$/ : /\\page/; - const currentPage = lines.reduce((count, line) => count + (pageRegex.test(line) ? 1 : 0), 1); + const currentPage = lines.reduce((count, line)=>count + (pageRegex.test(line) ? 1 : 0), 1); this.props.onCursorPageChange(currentPage); }, updateCurrentViewPage : function(topScrollLine) { const lines = this.props.brew.text.split('\n').slice(0, topScrollLine + 1); const pageRegex = this.props.brew.renderer == 'V3' ? /^\\page$/ : /\\page/; - const currentPage = lines.reduce((count, line) => count + (pageRegex.test(line) ? 1 : 0), 1); + const currentPage = lines.reduce((count, line)=>count + (pageRegex.test(line) ? 1 : 0), 1); this.props.onViewPageChange(currentPage); }, @@ -167,7 +167,7 @@ const Editor = createClass({ // Record details of folded sections if(mark.__isFold) { const fold = mark.find(); - foldLines.push({from: fold.from?.line, to: fold.to?.line}); + foldLines.push({ from: fold.from?.line, to: fold.to?.line }); } return !mark.__isFold; }); //Don't undo code folding @@ -185,7 +185,7 @@ const Editor = createClass({ // Don't process lines inside folded text // If the current lineNumber is inside any folded marks, skip line styling - if (foldLines.some(fold => lineNumber >= fold.from && lineNumber <= fold.to)) + if(foldLines.some((fold)=>lineNumber >= fold.from && lineNumber <= fold.to)) return; // Styling for \page breaks @@ -211,7 +211,7 @@ const Editor = createClass({ // definition lists if(line.includes('::')){ - if(/^:*$/.test(line) == true){ return }; + if(/^:*$/.test(line) == true){ return; }; const regex = /^([^\n]*?:?\s?)(::[^\n]*)(?:\n|$)/ymd; // the `d` flag, for match indices, throws an ESLint error. let match; while ((match = regex.exec(line)) != null){ @@ -219,10 +219,10 @@ const Editor = createClass({ codeMirror.markText({ line: lineNumber, ch: match.indices[1][0] }, { line: lineNumber, ch: match.indices[1][1] }, { className: 'dt-highlight' }); codeMirror.markText({ line: lineNumber, ch: match.indices[2][0] }, { line: lineNumber, ch: match.indices[2][1] }, { className: 'dd-highlight' }); const ddIndex = match.indices[2][0]; - let colons = /::/g; - let colonMatches = colons.exec(match[2]); + const colons = /::/g; + const colonMatches = colons.exec(match[2]); if(colonMatches !== null){ - codeMirror.markText({ line: lineNumber, ch: colonMatches.index + ddIndex }, { line: lineNumber, ch: colonMatches.index + colonMatches[0].length + ddIndex }, { className: 'dl-colon-highlight'} ) + codeMirror.markText({ line: lineNumber, ch: colonMatches.index + ddIndex }, { line: lineNumber, ch: colonMatches.index + colonMatches[0].length + ddIndex }, { className: 'dl-colon-highlight' }); } } } @@ -232,12 +232,12 @@ const Editor = createClass({ let startIndex = line.indexOf('^'); const superRegex = /\^(?!\s)(?=([^\n\^]*[^\s\^]))\1\^/gy; const subRegex = /\^\^(?!\s)(?=([^\n\^]*[^\s\^]))\1\^\^/gy; - + while (startIndex >= 0) { superRegex.lastIndex = subRegex.lastIndex = startIndex; let isSuper = false; - let match = subRegex.exec(line) || superRegex.exec(line); - if (match) { + const match = subRegex.exec(line) || superRegex.exec(line); + if(match) { isSuper = !subRegex.lastIndex; codeMirror.markText({ line: lineNumber, ch: match.index }, { line: lineNumber, ch: match.index + match[0].length }, { className: isSuper ? 'superscript' : 'subscript' }); } @@ -287,18 +287,18 @@ const Editor = createClass({ while (startIndex >= 0) { emojiRegex.lastIndex = startIndex; - let match = emojiRegex.exec(line); - if (match) { + const match = emojiRegex.exec(line); + if(match) { let tokens = Markdown.marked.lexer(match[0]); - tokens = tokens[0].tokens.filter(t => t.type == 'emoji') - if (!tokens.length) + tokens = tokens[0].tokens.filter((t)=>t.type == 'emoji'); + if(!tokens.length) return; - let startPos = { line: lineNumber, ch: match.index }; - let endPos = { line: lineNumber, ch: match.index + match[0].length }; + const startPos = { line: lineNumber, ch: match.index }; + const endPos = { line: lineNumber, ch: match.index + match[0].length }; // Iterate over conflicting marks and clear them - var marks = codeMirror.findMarks(startPos, endPos); + const marks = codeMirror.findMarks(startPos, endPos); marks.forEach(function(marker) { if(!marker.__isFold) marker.clear(); }); @@ -322,10 +322,10 @@ const Editor = createClass({ const currentPos = brewRenderer.scrollTop; const targetPos = window.frames['BrewRenderer'].contentDocument.getElementById(`p${targetPage}`).getBoundingClientRect().top; - const checkIfScrollComplete = () => { + const checkIfScrollComplete = ()=>{ let scrollingTimeout; clearTimeout(scrollingTimeout); // Reset the timer every time a scroll event occurs - scrollingTimeout = setTimeout(() => { + scrollingTimeout = setTimeout(()=>{ isJumping = false; brewRenderer.removeEventListener('scroll', checkIfScrollComplete); }, 150); // If 150 ms pass without a brewRenderer scroll event, assume scrolling is done @@ -364,16 +364,16 @@ const Editor = createClass({ let currentY = this.codeEditor.current.codeMirror.getScrollInfo().top; let targetY = this.codeEditor.current.codeMirror.heightAtLine(targetLine, 'local', true); - - const checkIfScrollComplete = () => { + + const checkIfScrollComplete = ()=>{ let scrollingTimeout; clearTimeout(scrollingTimeout); // Reset the timer every time a scroll event occurs - scrollingTimeout = setTimeout(() => { + scrollingTimeout = setTimeout(()=>{ isJumping = false; this.codeEditor.current.codeMirror.off('scroll', checkIfScrollComplete); }, 150); // If 150 ms pass without a scroll event, assume scrolling is done }; - + isJumping = true; checkIfScrollComplete(); this.codeEditor.current.codeMirror.on('scroll', checkIfScrollComplete); From 5cc5eec6194016af92098c944ad3fdb984c17d64 Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Mon, 16 Sep 2024 01:41:46 -0400 Subject: [PATCH 4/6] Lint toolbar and snippetbar --- client/homebrew/brewRenderer/toolBar/toolBar.jsx | 6 +++--- client/homebrew/editor/snippetbar/snippetbar.jsx | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/client/homebrew/brewRenderer/toolBar/toolBar.jsx b/client/homebrew/brewRenderer/toolBar/toolBar.jsx index d83fa78f9..73b48d778 100644 --- a/client/homebrew/brewRenderer/toolBar/toolBar.jsx +++ b/client/homebrew/brewRenderer/toolBar/toolBar.jsx @@ -56,7 +56,7 @@ const ToolBar = ({ onZoomChange, currentPage, onPageChange, totalPages })=>{ } else if(mode == 'fit'){ // find the page with the largest single dim (height or width) so that zoom can be adapted to fit it. - const minDimRatio = [...pages].reduce((minRatio, page) => Math.min(minRatio, iframeWidth / page.offsetWidth, iframeHeight / page.offsetHeight), Infinity); + const minDimRatio = [...pages].reduce((minRatio, page)=>Math.min(minRatio, iframeWidth / page.offsetWidth, iframeHeight / page.offsetHeight), Infinity); desiredZoom = minDimRatio * 100; } @@ -67,9 +67,9 @@ const ToolBar = ({ onZoomChange, currentPage, onPageChange, totalPages })=>{ return deltaZoom; }; - return ( + return (
- + {/*v=====----------------------< Zoom Controls >---------------------=====v*/}
; } diff --git a/client/homebrew/pages/vaultPage/vaultPage.jsx b/client/homebrew/pages/vaultPage/vaultPage.jsx index a550ec578..bad1fbd57 100644 --- a/client/homebrew/pages/vaultPage/vaultPage.jsx +++ b/client/homebrew/pages/vaultPage/vaultPage.jsx @@ -330,7 +330,7 @@ const VaultPage = (props)=>{ if(error) { const errorText = ErrorIndex()[error.HBErrorCode.toString()] || ''; - + return (

Error: {errorText}

diff --git a/shared/naturalcrit/splitPane/splitPane.jsx b/shared/naturalcrit/splitPane/splitPane.jsx index 01807db70..23ae5d321 100644 --- a/shared/naturalcrit/splitPane/splitPane.jsx +++ b/shared/naturalcrit/splitPane/splitPane.jsx @@ -15,12 +15,12 @@ const SplitPane = createClass({ getInitialState : function() { return { - currentDividerPos : null, - windowWidth : 0, - isDragging : false, - moveSource : false, - moveBrew : false, - showMoveArrows : true + currentDividerPos : null, + windowWidth : 0, + isDragging : false, + moveSource : false, + moveBrew : false, + showMoveArrows : true }; }, @@ -45,7 +45,7 @@ const SplitPane = createClass({ // This lives here instead of in the initial render because you cannot touch localStorage until the componant mounts. const loadLiveScroll = window.localStorage.getItem('liveScroll') === 'true'; - this.setState({ liveScroll : loadLiveScroll }); + this.setState({ liveScroll: loadLiveScroll }); }, componentWillUnmount : function() { @@ -130,7 +130,7 @@ const SplitPane = createClass({
@@ -160,7 +160,7 @@ const SplitPane = createClass({ ...(this.props.showDividerButtons && { moveBrew : this.state.moveBrew, moveSource : this.state.moveSource, - liveScroll : this.state.liveScroll, + liveScroll : this.state.liveScroll, setMoveArrows : this.setMoveArrows, }), })}