Experimental debug view

This commit is contained in:
Jeremy Ruston 2023-08-31 09:18:36 +01:00
parent 5bce35d90b
commit 898b61a3a0
3 changed files with 64 additions and 0 deletions

View File

@ -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;
})();

View File

@ -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) {

View File

@ -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));