|
1 | 1 | import classify from '@ember/debug/ember-inspector-support/utils/classify'; |
2 | 2 | import bound from '@ember/debug/ember-inspector-support/utils/bound-method'; |
3 | 3 | import getObjectName from '../utils/get-object-name'; |
| 4 | +import type RenderTree from './render-tree'; |
| 5 | +import type ObjectInspector from '../object-inspector'; |
4 | 6 |
|
5 | | -function makeHighlight(id) { |
| 7 | +function makeHighlight(id: string) { |
6 | 8 | return `<div id="ember-inspector-highlight-${id}" role="presentation"></div>`; |
7 | 9 | } |
8 | 10 |
|
9 | | -function makeTooltip(id) { |
| 11 | +function makeTooltip(id: string) { |
10 | 12 | let prefix = 'ember-inspector-tooltip'; |
11 | 13 |
|
12 | 14 | return ` |
@@ -226,13 +228,37 @@ function makeStylesheet(id) { |
226 | 228 | } |
227 | 229 |
|
228 | 230 | export default class ViewInspection { |
| 231 | + renderTree: RenderTree; |
| 232 | + objectInspector: ObjectInspector; |
| 233 | + private didShow: boolean; |
| 234 | + private didHide: boolean; |
| 235 | + private didStartInspecting: boolean; |
| 236 | + private didStopInspecting: boolean; |
| 237 | + private id: string; |
| 238 | + private currentId: string; |
| 239 | + private lastMatchId: string; |
| 240 | + private isInspecting: boolean; |
| 241 | + private lastTarget: boolean; |
| 242 | + private isShowing: boolean; |
| 243 | + private isPinned: boolean; |
| 244 | + |
| 245 | + private highlight: HTMLElement; |
| 246 | + private tooltip: HTMLElement; |
| 247 | + private stylesheet: HTMLElement; |
229 | 248 | constructor({ |
230 | 249 | renderTree, |
231 | 250 | objectInspector, |
232 | 251 | didShow, |
233 | 252 | didHide, |
234 | 253 | didStartInspecting, |
235 | 254 | didStopInspecting, |
| 255 | + }: { |
| 256 | + renderTree: RenderTree; |
| 257 | + objectInspector: ObjectInspector; |
| 258 | + didShow: boolean; |
| 259 | + didHide: boolean; |
| 260 | + didStartInspecting: boolean; |
| 261 | + didStopInspecting: boolean; |
236 | 262 | }) { |
237 | 263 | this.renderTree = renderTree; |
238 | 264 | this.objectInspector = objectInspector; |
@@ -641,7 +667,7 @@ export default class ViewInspection { |
641 | 667 | return [['tag', stringified]]; |
642 | 668 | } |
643 | 669 |
|
644 | | - _positionTooltip(highlightRect) { |
| 670 | + _positionTooltip(highlightRect: DOMRect) { |
645 | 671 | // Positioning the tooltip: the goal is to match the Chrome's Element |
646 | 672 | // inspection tooltip's positioning behavior as closely as possible. |
647 | 673 |
|
@@ -710,20 +736,20 @@ export default class ViewInspection { |
710 | 736 | tooltipStyle.top = `${scrollY + attachmentTop}px`; |
711 | 737 | tooltipStyle.left = `${scrollX + attachmentLeft - leftOffset}px`; |
712 | 738 |
|
713 | | - let arrow = this.tooltip.querySelector('.ember-inspector-tooltip-arrow'); |
| 739 | + let arrow = this.tooltip.querySelector('.ember-inspector-tooltip-arrow')! as HTMLElement; |
714 | 740 |
|
715 | 741 | arrow.style.left = `${Math.max(leftOffset, 0) + arrowLeft}px`; |
716 | 742 | } |
717 | 743 |
|
718 | | - _insertHTML(html) { |
| 744 | + _insertHTML(html: string) { |
719 | 745 | document.body.insertAdjacentHTML('beforeend', html.trim()); |
720 | | - return document.body.lastChild; |
| 746 | + return document.body.lastChild as HTMLElement; |
721 | 747 | } |
722 | 748 |
|
723 | | - _insertStylesheet(content) { |
| 749 | + _insertStylesheet(content: string) { |
724 | 750 | let style = document.createElement('style'); |
725 | 751 | style.appendChild(document.createTextNode(content)); |
726 | 752 | document.head.appendChild(style); |
727 | | - return style; |
| 753 | + return style as HTMLElement; |
728 | 754 | } |
729 | 755 | } |
0 commit comments