handlerHoverElement.js 963 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import { getBlockConnection, attachDebugger } from '../helper';
  2. export async function hoverElement(block) {
  3. const nextBlockId = getBlockConnection(block);
  4. try {
  5. if (!this.activeTab.id) throw new Error('no-tab');
  6. if (BROWSER_TYPE !== 'chrome') {
  7. const error = new Error('browser-not-supported');
  8. error.data = { browser: BROWSER_TYPE };
  9. throw error;
  10. }
  11. const { debugMode, executedBlockOnWeb } = this.settings;
  12. if (!debugMode) {
  13. await attachDebugger(this.activeTab.id);
  14. }
  15. await this._sendMessageToTab({
  16. ...block,
  17. debugMode,
  18. executedBlockOnWeb,
  19. activeTabId: this.activeTab.id,
  20. frameSelector: this.frameSelector,
  21. });
  22. if (!debugMode) {
  23. chrome.debugger.detach({ tabId: this.activeTab.id });
  24. }
  25. return {
  26. data: '',
  27. nextBlockId,
  28. };
  29. } catch (error) {
  30. error.nextBlockId = nextBlockId;
  31. throw error;
  32. }
  33. }
  34. export default hoverElement;