From 898b61a3a0deb406588f89920f4b2d53f76abbba Mon Sep 17 00:00:00 2001 From: Jeremy Ruston <174761+Jermolene@users.noreply.github.com> Date: Thu, 31 Aug 2023 09:18:36 +0100 Subject: [PATCH] Experimental debug view --- core/modules/debug-view.js | 54 +++++++++++++++++++++++++++++++++ core/modules/filters.js | 8 +++++ core/modules/startup/startup.js | 2 ++ 3 files changed, 64 insertions(+) create mode 100644 core/modules/debug-view.js diff --git a/core/modules/debug-view.js b/core/modules/debug-view.js new file mode 100644 index 000000000..c4bb2176f --- /dev/null +++ b/core/modules/debug-view.js @@ -0,0 +1,54 @@ +/*\ +title: $:/core/modules/debug-view.js +type: application/javascript +module-type: global + +debug-view module supports the optional external debug window + +\*/ +(function(){ + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +var dm = $tw.utils.domMaker; + +/* +Instantiate the debug view +*/ +function DebugView(options) { + if($tw.browser) { + this.outputFilters = dm("div",{ + text: "Yes" + }) + this.container = dm("div",{ + "class": "tc-debug-view", + children: [ + dm("div",{ + children: [ + dm("h1",{ + text: "TiddlyWiki Debug View" + }), + dm("h2",{ + text: "Filter Execution" + }), + this.outputFilters + ] + }) + ] + }); + document.body.appendChild(this.container); + } +} + +/* +Show a generic network error alert +*/ +DebugView.prototype.displayError = function(msg,err) { + +}; + +exports.DebugView = DebugView; + +})(); diff --git a/core/modules/filters.js b/core/modules/filters.js index 1bb5fe9ff..3a3be8194 100644 --- a/core/modules/filters.js +++ b/core/modules/filters.js @@ -330,6 +330,14 @@ exports.compileFilter = function(filterString) { } })()); }); + // If we're debugging then wrap each operation function with debug code + if(true) { + $tw.utils.each(operationFunctions,function(operationFunction,index) { + operationFunctions[index] = function(results,source,widget) { + return operationFunction(results,source,widget); + }; + }); + } // Return a function that applies the operations to a source iterator of tiddler titles var fnMeasured = $tw.perf.measure("filter: " + filterString,function filterFunction(source,widget) { if(!source) { diff --git a/core/modules/startup/startup.js b/core/modules/startup/startup.js index e0990228f..ba1e0a52d 100755 --- a/core/modules/startup/startup.js +++ b/core/modules/startup/startup.js @@ -23,6 +23,8 @@ var PERFORMANCE_INSTRUMENTATION_CONFIG_TITLE = "$:/config/Performance/Instrument var widget = require("$:/core/modules/widgets/widget.js"); exports.startup = function() { + // Debug view + $tw.debugView = new $tw.DebugView(); // Minimal browser detection if($tw.browser) { $tw.browser.isIE = (/msie|trident/i.test(navigator.userAgent));