1
0

debug.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. // TODO: This file was created by bulk-decaffeinate.
  2. // Sanity-check the conversion and remove this comment.
  3. /*
  4. * decaffeinate suggestions:
  5. * DS102: Remove unnecessary code created because of implicit returns
  6. * DS203: Remove `|| {}` from converted for-own loops
  7. * DS207: Consider shorter variations of null checks
  8. * DS208: Avoid top-level this
  9. * DS209: Avoid top-level return
  10. * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
  11. */
  12. //
  13. // App
  14. //
  15. const _init = app.init;
  16. app.init = function () {
  17. console.time("Init");
  18. _init.call(app);
  19. console.timeEnd("Init");
  20. return console.time("Load");
  21. };
  22. const _start = app.start;
  23. app.start = function () {
  24. console.timeEnd("Load");
  25. console.time("Start");
  26. _start.call(app, ...arguments);
  27. return console.timeEnd("Start");
  28. };
  29. //
  30. // Searcher
  31. //
  32. app.Searcher = class TimingSearcher extends app.Searcher {
  33. setup() {
  34. console.groupCollapsed(`Search: ${this.query}`);
  35. console.time("Total");
  36. return super.setup();
  37. }
  38. match() {
  39. if (this.matcher) {
  40. console.timeEnd(this.matcher.name);
  41. }
  42. return super.match();
  43. }
  44. setupMatcher() {
  45. console.time(this.matcher.name);
  46. return super.setupMatcher();
  47. }
  48. end() {
  49. console.log(`Results: ${this.totalResults}`);
  50. console.timeEnd("Total");
  51. console.groupEnd();
  52. return super.end();
  53. }
  54. kill() {
  55. if (this.timeout) {
  56. if (this.matcher) {
  57. console.timeEnd(this.matcher.name);
  58. }
  59. console.groupEnd();
  60. console.timeEnd("Total");
  61. console.warn("Killed");
  62. }
  63. return super.kill();
  64. }
  65. };
  66. //
  67. // View tree
  68. //
  69. this.viewTree = function (view, level, visited) {
  70. if (view == null) {
  71. view = app.document;
  72. }
  73. if (level == null) {
  74. level = 0;
  75. }
  76. if (visited == null) {
  77. visited = [];
  78. }
  79. if (visited.indexOf(view) >= 0) {
  80. return;
  81. }
  82. visited.push(view);
  83. console.log(
  84. `%c ${Array(level + 1).join(" ")}${
  85. view.constructor.name
  86. }: ${!!view.activated}`,
  87. "color:" + ((view.activated && "green") || "red"),
  88. );
  89. for (var key of Object.keys(view || {})) {
  90. var value = view[key];
  91. if (key !== "view" && value) {
  92. if (typeof value === "object" && value.setupElement) {
  93. this.viewTree(value, level + 1, visited);
  94. } else if (value.constructor.toString().match(/Object\(\)/)) {
  95. for (var k of Object.keys(value || {})) {
  96. var v = value[k];
  97. if (v && typeof v === "object" && v.setupElement) {
  98. this.viewTree(v, level + 1, visited);
  99. }
  100. }
  101. }
  102. }
  103. }
  104. };