| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- //
- // App
- //
- const _init = app.init;
- app.init = function () {
- console.time("Init");
- _init.call(app);
- console.timeEnd("Init");
- return console.time("Load");
- };
- const _start = app.start;
- app.start = function () {
- console.timeEnd("Load");
- console.time("Start");
- _start.call(app, ...arguments);
- return console.timeEnd("Start");
- };
- //
- // Searcher
- //
- app.Searcher = class TimingSearcher extends app.Searcher {
- setup() {
- console.groupCollapsed(`Search: ${this.query}`);
- console.time("Total");
- return super.setup();
- }
- match() {
- if (this.matcher) {
- console.timeEnd(this.matcher.name);
- }
- return super.match();
- }
- setupMatcher() {
- console.time(this.matcher.name);
- return super.setupMatcher();
- }
- end() {
- console.log(`Results: ${this.totalResults}`);
- console.timeEnd("Total");
- console.groupEnd();
- return super.end();
- }
- kill() {
- if (this.timeout) {
- if (this.matcher) {
- console.timeEnd(this.matcher.name);
- }
- console.groupEnd();
- console.timeEnd("Total");
- console.warn("Killed");
- }
- return super.kill();
- }
- };
- //
- // View tree
- //
- this.viewTree = function (view, level, visited) {
- if (view == null) {
- view = app.document;
- }
- if (level == null) {
- level = 0;
- }
- if (visited == null) {
- visited = [];
- }
- if (visited.includes(view)) {
- return;
- }
- visited.push(view);
- console.log(
- `%c ${Array(level + 1).join(" ")}${
- view.constructor.name
- }: ${!!view.activated}`,
- "color:" + ((view.activated && "green") || "red"),
- );
- for (var key of Object.keys(view || {})) {
- var value = view[key];
- if (key !== "view" && value) {
- if (typeof value === "object" && value.setupElement) {
- this.viewTree(value, level + 1, visited);
- } else if (value.constructor.toString().match(/Object\(\)/)) {
- for (var k of Object.keys(value || {})) {
- var v = value[k];
- if (v && typeof v === "object" && v.setupElement) {
- this.viewTree(v, level + 1, visited);
- }
- }
- }
- }
- }
- };
|