From c5bf0f95e6dadbe1618601cd3be85d68be335a1a Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Thu, 2 May 2024 13:27:41 -0400 Subject: [PATCH 01/18] change filter --- app/Http/Controllers/CodeController.php | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/CodeController.php b/app/Http/Controllers/CodeController.php index c6fc45f..e5f2340 100644 --- a/app/Http/Controllers/CodeController.php +++ b/app/Http/Controllers/CodeController.php @@ -486,6 +486,8 @@ function compileCode($code) ->timeout(10) ->command($compilerCommand)->run(); + $log->info("compiler exited with code: " . $compilerProcessResult->exitCode()); + if($compilerProcessResult->exitCode() !== 0) { $response = [ @@ -554,14 +556,22 @@ function compileCode($code) function filterOutput($text) { - $text = array_filter(explode("\n", $text), function($value) - { - return (strpos($value, "undefined symbol") !== false) || - (strpos($value, "duplicate symbol") !== false) || - (strpos($value, "pgetinker.cpp") === 0); - }); + + $text = str_replace("/opt/emsdk/upstream/emscripten/cache/sysroot", "/***", $text); - return implode("\n", $text); + return $text; + // $text = explode("\n", $text); + + // for($i = 0 $i < count($text)) + + // // $text = array_filter(explode("\n", $text), function($value) + // // { + // // return (strpos($value, "undefined symbol") !== false) || + // // (strpos($value, "duplicate symbol") !== false) || + // // (strpos($value, "pgetinker.cpp") === 0); + // // }); + + // return implode("\n", $text); } } From 5b46af722e3b1fc4280d7c7cc364f344ea29c418 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Thu, 2 May 2024 13:28:14 -0400 Subject: [PATCH 02/18] scroll to the top of the editor when loading the default code --- resources/js/app.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/resources/js/app.js b/resources/js/app.js index 55ea12c..10a6868 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -49,6 +49,10 @@ class PGEtinker axios.get("/api/default-code").then((response) => { this.monacoModel.setValue(response.data.code); + this.monacoEditor.revealPositionInCenter({ + column: 1, + lineNumber: 1, + }); }).catch((reason) => console.log(reason)); }); From 604343861fbbc5d26d0cede5c104f2b304b99b6b Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Thu, 2 May 2024 13:29:44 -0400 Subject: [PATCH 03/18] add scaffolding for the new layout elements --- resources/css/app.scss | 7 +++++ resources/css/console-panel.scss | 5 ++++ resources/css/info-panel.scss | 6 +++++ resources/js/app.js | 16 +++++++++++ resources/js/lib/defaultLayout.js | 44 +++++++++++++++++++++++-------- resources/views/home.blade.php | 4 --- 6 files changed, 67 insertions(+), 15 deletions(-) create mode 100644 resources/css/console-panel.scss create mode 100644 resources/css/info-panel.scss diff --git a/resources/css/app.scss b/resources/css/app.scss index 6441c8f..9fef28c 100644 --- a/resources/css/app.scss +++ b/resources/css/app.scss @@ -233,6 +233,13 @@ nav .navbar-right-menu .menu-item { text-align: center; } +.lm_stack .lm_content { + overflow: hidden; + overflow-y: auto; +} + +@import "./console-panel.scss"; @import "./editor-panel.scss"; +@import "./info-panel.scss"; @import "./player-panel.scss"; @import "./dialog.scss"; diff --git a/resources/css/console-panel.scss b/resources/css/console-panel.scss new file mode 100644 index 0000000..0d82b56 --- /dev/null +++ b/resources/css/console-panel.scss @@ -0,0 +1,5 @@ +#console-panel { + white-space: pre; + padding: 1rem 1rem 2rem 1rem; + font-family: "Droid Sans Mono", "monospace", monospace; +} diff --git a/resources/css/info-panel.scss b/resources/css/info-panel.scss new file mode 100644 index 0000000..dcd7641 --- /dev/null +++ b/resources/css/info-panel.scss @@ -0,0 +1,6 @@ + +#info-panel { + white-space: pre; + padding: 1rem 1rem 2rem 1rem; + font-family: "Droid Sans Mono", "monospace", monospace; +} diff --git a/resources/js/app.js b/resources/js/app.js index 10a6868..512358a 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -353,6 +353,22 @@ class PGEtinker { this.layout = new GoldenLayout(this.layoutConfig, document.querySelector("#content")) + this.layout.registerComponent('consoleComponent', function(container) + { + container.getElement().html(` +
+
+ `); + }); + + this.layout.registerComponent('infoComponent', function(container) + { + container.getElement().html(` +
+
+ `); + }); + this.layout.registerComponent('playerComponent', function(container) { container.getElement().html(` diff --git a/resources/js/lib/defaultLayout.js b/resources/js/lib/defaultLayout.js index 2f8d21a..f220264 100644 --- a/resources/js/lib/defaultLayout.js +++ b/resources/js/lib/defaultLayout.js @@ -3,19 +3,41 @@ const defaultLayout = { showPopoutIcon: false, }, content: [{ - type: 'row', + type: 'column', content:[{ - type: 'component', - componentName: 'editorComponent', - componentState: {}, - isClosable: false, - title: 'C++ Editor', + type: 'row', + content:[{ + type: 'component', + componentName: 'editorComponent', + componentState: {}, + isClosable: false, + title: 'C++ Editor', + },{ + type: 'component', + componentName: 'playerComponent', + componentState: {}, + isClosable: false, + title: 'Emscripten Player', + }], },{ - type: 'component', - componentName: 'playerComponent', - componentState: {}, - isClosable: false, - title: 'Emscripten Player', + type: 'stack', + id: 'information-stack', + height: 25, + content: [{ + type: 'component', + componentName: 'infoComponent', + componentState: {}, + isClosable: false, + title: 'Build Information', + id: 'info', + },{ + type: 'component', + componentName: 'consoleComponent', + componentState: {}, + isClosable: false, + title: 'Console', + id: 'console', + }] }], }], }; diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php index 84735fc..c260eab 100644 --- a/resources/views/home.blade.php +++ b/resources/views/home.blade.php @@ -38,10 +38,6 @@ Restore Default Layout - - - Show/Hide Console - From ed9baaec7555e457afc467ed543cbbf1a334a66d Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Thu, 2 May 2024 13:30:15 -0400 Subject: [PATCH 04/18] remove handler for non-existant button --- resources/js/app.js | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/resources/js/app.js b/resources/js/app.js index 512358a..cfc83f0 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -80,19 +80,6 @@ class PGEtinker this.SetupLayout(); }); - // Toggle Console Button - document.querySelector("#toggle-console").addEventListener("click", (event) => - { - event.preventDefault(); - - this.consoleShown = !this.consoleShown; - window.localStorage.setItem("pgetinkerConsoleShown", this.consoleShown); - - document.querySelector("#player-panel iframe").contentWindow.postMessage({ - message: "toggle-console", - }, "*"); - }); - // Download Button document.querySelector("#download").addEventListener("click", (event) => { From 3eed4364205cf6e93eaaf4676aeb1df64b3a5bda Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Thu, 2 May 2024 13:30:44 -0400 Subject: [PATCH 05/18] add transmitter for console output --- third_party/emscripten_shell.html | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/third_party/emscripten_shell.html b/third_party/emscripten_shell.html index ee782f5..e8d6eb2 100644 --- a/third_party/emscripten_shell.html +++ b/third_party/emscripten_shell.html @@ -99,6 +99,12 @@ return (...args) => { var text = args.join(' '); console.log(text); + + window.parent.postMessage({ + message: "console-output", + data: text + "\n", + }, "*"); + if (element) { element.value += text + "\n"; element.scrollTop = element.scrollHeight; // focus on bottom From c9519317cfb0a2211e6654511f6fd6d9bd24d73d Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Thu, 2 May 2024 13:31:48 -0400 Subject: [PATCH 06/18] add handler for console output --- resources/js/app.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/resources/js/app.js b/resources/js/app.js index cfc83f0..a06dc85 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -220,6 +220,28 @@ class PGEtinker value: this.consoleShown }, "*"); } + + if(event.data.message === "console-output") + { + let elem = document.querySelector('#console-panel'); + elem.innerHTML += event.data.data; + elem.parentElement.scrollTop = elem.parentElement.scrollHeight; + + let informationStack = this.layout.root.getItemsById('information-stack'); + if(informationStack.length == 0) + return; + + informationStack = informationStack[0]; + + let consolePanel = informationStack.getItemsById('console'); + if(consolePanel.length == 0) + return; + + consolePanel = consolePanel[0]; + + informationStack.setActiveContentItem(consolePanel); + } + }); let agreedToTerms = window.localStorage.getItem("pgetinkerAgreedToTerms"); From d1069318aebf106d6ed826099e33d9a7210f93de Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Thu, 2 May 2024 13:41:10 -0400 Subject: [PATCH 07/18] formatting --- resources/css/app.scss | 2 -- 1 file changed, 2 deletions(-) diff --git a/resources/css/app.scss b/resources/css/app.scss index 9fef28c..57bdde8 100644 --- a/resources/css/app.scss +++ b/resources/css/app.scss @@ -216,8 +216,6 @@ nav .navbar-right-menu .menu-item { margin-top: -3px; } - - #content { position: absolute; top: 49px; From 9e654b327a4f5222b873f7a081f0b7c038e1b3ac Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Thu, 2 May 2024 13:42:38 -0400 Subject: [PATCH 08/18] set info panel active during compile --- resources/js/app.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/resources/js/app.js b/resources/js/app.js index a06dc85..030a2d1 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -278,6 +278,19 @@ class PGEtinker return false; } + let informationStack = this.layout.root.getItemsById('information-stack'); + if(informationStack.length == 0) + informationStack = null; + + let infoPanel = this.layout.root.getItemsById('info'); + if(infoPanel.length == 0) + infoPanel = null; + + if(!(informationStack == null || infoPanel == null)) + { + informationStack[0].setActiveContentItem(infoPanel[0]); + } + this.compiling = true; this.lastPlayerHtml = ""; @@ -288,7 +301,10 @@ class PGEtinker document.querySelector("#player-panel .compiling").classList.toggle("display-flex", true); document.querySelector("#player-panel .compiling-failed").classList.toggle("display-flex", false); - + + document.querySelector("#info-panel").innerHTML = ""; + document.querySelector("#console-panel").innerHTML = ""; + monaco.editor.removeAllMarkers("owner"); this.monacoEditor.trigger("", "closeMarkersNavigation"); @@ -313,6 +329,10 @@ class PGEtinker compileFailHandler(stderr) { const compilerRegex = /:(\d+):(\d+): (fatal error|error|warning): (.*)/gm; + let infoPanel = document.querySelector("#info-panel"); + infoPanel.innerHTML = stderr; + infoPanel.parentElement.scrollTop = infoPanel.parentElement.scrollHeight; + const linkerRegex = /wasm-ld: error: pgetinker.o: (.*): (.*)/gm; let markers = []; From 58217d4ec73495fca3806b2f2962b56007af6782 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Thu, 2 May 2024 13:43:45 -0400 Subject: [PATCH 09/18] fix compilerRegex and properly set severity' --- resources/js/app.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/resources/js/app.js b/resources/js/app.js index 030a2d1..35c6830 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -328,22 +328,30 @@ class PGEtinker compileFailHandler(stderr) { - const compilerRegex = /:(\d+):(\d+): (fatal error|error|warning): (.*)/gm; let infoPanel = document.querySelector("#info-panel"); infoPanel.innerHTML = stderr; infoPanel.parentElement.scrollTop = infoPanel.parentElement.scrollHeight; + const compilerRegex = /pgetinker.cpp:(\d+):(\d+): (fatal error|error|warning|note): (.*)/gm; const linkerRegex = /wasm-ld: error: pgetinker.o: (.*): (.*)/gm; let markers = []; let matches; - + while((matches = compilerRegex.exec(stderr)) !== null) { + let severity = monaco.MarkerSeverity.Error; + + if(matches[3] == "warning") + severity = monaco.MarkerSeverity.Warning; + + if(matches[3] == "note") + severity = monaco.MarkerSeverity.Info; + markers.push({ message: matches[4], - severity: (matches[3] === "warning") ? monaco.MarkerSeverity.Warning : monaco.MarkerSeverity.Error, + severity: severity, startLineNumber: parseInt(matches[1]), startColumn: parseInt(matches[2]), endLineNumber: parseInt(matches[1]), From 08d489580a0b0a718bbbe1692391ede1519424fe Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Thu, 2 May 2024 14:25:37 -0400 Subject: [PATCH 10/18] parse markdown urls in news API --- CHANGELOG.md | 6 ++++++ routes/api.php | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 82263b7..7c6e27c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. Each batch It is a summary of changes that would be pertinent to the end user of the PGEtinker website. For a comprehensive history of changes made to the project, please refer to the repository's commit history. +## 2024-05-02 + +- Fixed [Issue #50](https://github.com/Moros1138/PGEtinker/issues/50) +- Added Build Information panel +- Added Console panel + ## 2024-05-01 - Added the changelog diff --git a/routes/api.php b/routes/api.php index c4567b7..193f024 100644 --- a/routes/api.php +++ b/routes/api.php @@ -53,6 +53,13 @@ break; } + $lines[$i] = preg_replace( + '/\[(.*)\]\((.*)\)/', + "$1", + $lines[$i], + 1 + ); + $tokens = explode(" ", $lines[$i]); if($tokens[0] == "-") { From 595c67a6b946da84ebf991708290d1eb620be787 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Thu, 2 May 2024 14:25:56 -0400 Subject: [PATCH 11/18] exclude A tags from the anywhere click handler --- resources/js/lib/newsDialog.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/resources/js/lib/newsDialog.js b/resources/js/lib/newsDialog.js index cf577c9..7804c72 100644 --- a/resources/js/lib/newsDialog.js +++ b/resources/js/lib/newsDialog.js @@ -7,6 +7,9 @@ export default function newsDialog() if(newsDialog == null) return; + if(event.target.tagName == 'A') + return; + newsDialog.dispatchEvent(new Event("close-dialog")); } From 641f02142282514f5e694817055953f58abba57b Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Thu, 2 May 2024 14:26:24 -0400 Subject: [PATCH 12/18] allow stacks to scroll --- resources/css/app.scss | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/resources/css/app.scss b/resources/css/app.scss index 57bdde8..e79d28b 100644 --- a/resources/css/app.scss +++ b/resources/css/app.scss @@ -232,8 +232,7 @@ nav .navbar-right-menu .menu-item { } .lm_stack .lm_content { - overflow: hidden; - overflow-y: auto; + overflow: auto; } @import "./console-panel.scss"; From 12868399bc01dde174b795b0863cde35c5d9becf Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Thu, 2 May 2024 14:28:01 -0400 Subject: [PATCH 13/18] ensure new panels exist in the layout before using them --- resources/js/app.js | 49 +++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/resources/js/app.js b/resources/js/app.js index 35c6830..b86dfcc 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -27,6 +27,9 @@ class PGEtinker monacoModel = null; monacoModelIntellisense = null; + consolePanelExist = false; + informationPanelExist = false; + constructor() { this.sharedFlag = (window.location.pathname.indexOf("/s/") === 0); @@ -223,23 +226,18 @@ class PGEtinker if(event.data.message === "console-output") { + if(!this.informationPanelExist) + return; + let elem = document.querySelector('#console-panel'); elem.innerHTML += event.data.data; elem.parentElement.scrollTop = elem.parentElement.scrollHeight; - let informationStack = this.layout.root.getItemsById('information-stack'); - if(informationStack.length == 0) - return; - - informationStack = informationStack[0]; - - let consolePanel = informationStack.getItemsById('console'); - if(consolePanel.length == 0) - return; - - consolePanel = consolePanel[0]; - - informationStack.setActiveContentItem(consolePanel); + let consolePanel = this.layout.root.getItemsById('console')[0]; + if(consolePanel.parent.isStack) + { + consolePanel.parent.setActiveContentItem(consolePanel); + } } }); @@ -278,17 +276,16 @@ class PGEtinker return false; } - let informationStack = this.layout.root.getItemsById('information-stack'); - if(informationStack.length == 0) - informationStack = null; - - let infoPanel = this.layout.root.getItemsById('info'); - if(infoPanel.length == 0) - infoPanel = null; - - if(!(informationStack == null || infoPanel == null)) + if(this.informationPanelExist) { - informationStack[0].setActiveContentItem(infoPanel[0]); + let infoPanel = this.layout.root.getItemsById('info')[0]; + if(infoPanel.parent.isStack) + { + infoPanel.parent.setActiveContentItem(infoPanel); + } + + document.querySelector("#info-panel").innerHTML = ""; + document.querySelector("#console-panel").innerHTML = ""; } this.compiling = true; @@ -302,9 +299,6 @@ class PGEtinker document.querySelector("#player-panel .compiling").classList.toggle("display-flex", true); document.querySelector("#player-panel .compiling-failed").classList.toggle("display-flex", false); - document.querySelector("#info-panel").innerHTML = ""; - document.querySelector("#console-panel").innerHTML = ""; - monaco.editor.removeAllMarkers("owner"); this.monacoEditor.trigger("", "closeMarkersNavigation"); @@ -451,6 +445,9 @@ class PGEtinker this.layout.on("initialised", () => { + this.informationPanelExist = (this.layout.root.getItemsById('info').length > 0); + this.consolePanelExist = (this.layout.root.getItemsById('console').length > 0); + this.layoutInitialized = true; window.addEventListener("resize", (event) => this.layout.updateSize()); From 1e6198d0afc494f344566095efca13ddf289c891 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Thu, 2 May 2024 14:30:22 -0400 Subject: [PATCH 14/18] update changelog --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c6e27c..ff64aac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,8 @@ It is a summary of changes that would be pertinent to the end user of the PGEtin ## 2024-05-02 - Fixed [Issue #50](https://github.com/Moros1138/PGEtinker/issues/50) -- Added Build Information panel -- Added Console panel +- Added Build Information panel (Requires you to reset to default layout) +- Added Console panel (Requires you to reset to default layout) ## 2024-05-01 From 2981aad7619a6a738df0e24614875f2fb347fa76 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Thu, 2 May 2024 14:44:30 -0400 Subject: [PATCH 15/18] change order of buttons --- resources/views/home.blade.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php index c260eab..8ea3e89 100644 --- a/resources/views/home.blade.php +++ b/resources/views/home.blade.php @@ -71,14 +71,14 @@