sources_module.js 301 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487
  1. Sources.AddSourceMapURLDialog=class extends UI.HBox{constructor(callback){super(true);this.registerRequiredCSS('sources/dialog.css');this.contentElement.createChild('label').textContent=Common.UIString('Source map URL: ');this._input=UI.createInput('add-source-map','text');this._input.addEventListener('keydown',this._onKeyDown.bind(this),false);this.contentElement.appendChild(this._input);const addButton=UI.createTextButton(ls`Add`,this._apply.bind(this));this.contentElement.appendChild(addButton);this._dialog=new UI.Dialog();this._dialog.setSizeBehavior(UI.GlassPane.SizeBehavior.MeasureContent);this._dialog.setDefaultFocusedElement(this._input);this._done=function(value){this._dialog.hide();callback(value);};}
  2. show(){super.show(this._dialog.contentElement);this._dialog.show();}
  3. _apply(){this._done(this._input.value);}
  4. _onKeyDown(event){if(isEnterKey(event)){event.consume(true);this._apply();}}};;Sources.BreakpointEditDialog=class extends UI.Widget{constructor(editorLineNumber,oldCondition,preferLogpoint,onFinish){super(true);this.registerRequiredCSS('sources/breakpointEditDialog.css');this._onFinish=onFinish;this._finished=false;this._editor=null;this.element.tabIndex=-1;const logpointPrefix=Sources.BreakpointEditDialog.LogpointPrefix;const logpointSuffix=Sources.BreakpointEditDialog._LogpointSuffix;this._isLogpoint=oldCondition.startsWith(logpointPrefix)&&oldCondition.endsWith(logpointSuffix);if(this._isLogpoint){oldCondition=oldCondition.substring(logpointPrefix.length,oldCondition.length-logpointSuffix.length);}
  5. this._isLogpoint=this._isLogpoint||preferLogpoint;this.element.classList.add('sources-edit-breakpoint-dialog');const toolbar=new UI.Toolbar('source-frame-breakpoint-toolbar',this.contentElement);toolbar.appendText(`Line ${editorLineNumber + 1}:`);this._typeSelector=new UI.ToolbarComboBox(this._onTypeChanged.bind(this),ls`Breakpoint type`);this._typeSelector.createOption(ls`Breakpoint`,Sources.BreakpointEditDialog.BreakpointType.Breakpoint);const conditionalOption=this._typeSelector.createOption(ls`Conditional breakpoint`,Sources.BreakpointEditDialog.BreakpointType.Conditional);const logpointOption=this._typeSelector.createOption(ls`Logpoint`,Sources.BreakpointEditDialog.BreakpointType.Logpoint);this._typeSelector.select(this._isLogpoint?logpointOption:conditionalOption);toolbar.appendToolbarItem(this._typeSelector);self.runtime.extension(UI.TextEditorFactory).instance().then(factory=>{const editorOptions={lineNumbers:false,lineWrapping:true,mimeType:'javascript',autoHeight:true};this._editor=factory.createEditor(editorOptions);this._updatePlaceholder();this._editor.widget().element.classList.add('condition-editor');this._editor.configureAutocomplete(ObjectUI.JavaScriptAutocompleteConfig.createConfigForEditor(this._editor));if(oldCondition){this._editor.setText(oldCondition);}
  6. this._editor.widget().markAsExternallyManaged();this._editor.widget().show(this.contentElement);this._editor.setSelection(this._editor.fullRange());this._editor.widget().focus();this._editor.widget().element.addEventListener('keydown',this._onKeyDown.bind(this),true);this.contentElement.addEventListener('blur',event=>{if(event.relatedTarget&&!event.relatedTarget.isSelfOrDescendant(this.element)){this._finishEditing(true);}},true);});}
  7. static _conditionForLogpoint(condition){return`${Sources.BreakpointEditDialog.LogpointPrefix}${condition}${Sources.BreakpointEditDialog._LogpointSuffix}`;}
  8. _onTypeChanged(){const value=this._typeSelector.selectedOption().value;this._isLogpoint=value===Sources.BreakpointEditDialog.BreakpointType.Logpoint;this._updatePlaceholder();if(value===Sources.BreakpointEditDialog.BreakpointType.Breakpoint){this._editor.setText('');this._finishEditing(true);}}
  9. _updatePlaceholder(){const selectedValue=this._typeSelector.selectedOption().value;if(selectedValue===Sources.BreakpointEditDialog.BreakpointType.Conditional){this._editor.setPlaceholder(ls`Expression to check before pausing, e.g. x > 5`);this._typeSelector.element.title=ls`Pause only when the condition is true`;}else if(selectedValue===Sources.BreakpointEditDialog.BreakpointType.Logpoint){this._editor.setPlaceholder(ls`Log message, e.g. 'x is', x`);this._typeSelector.element.title=ls`Log a message to Console, do not break`;}}
  10. _finishEditing(committed){if(this._finished){return;}
  11. this._finished=true;this._editor.widget().detach();let condition=this._editor.text();if(this._isLogpoint){condition=Sources.BreakpointEditDialog._conditionForLogpoint(condition);}
  12. this._onFinish({committed,condition});}
  13. async _onKeyDown(event){if(isEnterKey(event)&&!event.shiftKey){event.consume(true);const expression=this._editor.text();if(event.ctrlKey||await ObjectUI.JavaScriptAutocomplete.isExpressionComplete(expression)){this._finishEditing(true);}else{this._editor.newlineAndIndent();}}
  14. if(isEscKey(event)){this._finishEditing(false);}}};Sources.BreakpointEditDialog.LogpointPrefix='/** DEVTOOLS_LOGPOINT */ console.log(';Sources.BreakpointEditDialog._LogpointSuffix=')';Sources.BreakpointEditDialog.BreakpointType={Breakpoint:'Breakpoint',Conditional:'Conditional',Logpoint:'Logpoint',};;Sources.CallStackSidebarPane=class extends UI.SimpleView{constructor(){super(Common.UIString('Call Stack'),true);this.registerRequiredCSS('sources/callStackSidebarPane.css');this._blackboxedMessageElement=this._createBlackboxedMessageElement();this.contentElement.appendChild(this._blackboxedMessageElement);this._notPausedMessageElement=this.contentElement.createChild('div','gray-info-message');this._notPausedMessageElement.textContent=Common.UIString('Not paused');this._items=new UI.ListModel();this._list=new UI.ListControl(this._items,this,UI.ListMode.NonViewport);this.contentElement.appendChild(this._list.element);this._list.element.addEventListener('contextmenu',this._onContextMenu.bind(this),false);this._list.element.addEventListener('click',this._onClick.bind(this),false);this._showMoreMessageElement=this._createShowMoreMessageElement();this._showMoreMessageElement.classList.add('hidden');this.contentElement.appendChild(this._showMoreMessageElement);this._showBlackboxed=false;this._locationPool=new Bindings.LiveLocationPool();this._updateThrottler=new Common.Throttler(100);this._maxAsyncStackChainDepth=Sources.CallStackSidebarPane._defaultMaxAsyncStackChainDepth;this._update();this._updateItemThrottler=new Common.Throttler(100);this._scheduledForUpdateItems=new Set();}
  15. flavorChanged(object){this._showBlackboxed=false;this._maxAsyncStackChainDepth=Sources.CallStackSidebarPane._defaultMaxAsyncStackChainDepth;this._update();}
  16. _update(){this._updateThrottler.schedule(()=>this._doUpdate());}
  17. async _doUpdate(){this._locationPool.disposeAll();const details=UI.context.flavor(SDK.DebuggerPausedDetails);if(!details){this._notPausedMessageElement.classList.remove('hidden');this._blackboxedMessageElement.classList.add('hidden');this._showMoreMessageElement.classList.add('hidden');this._items.replaceAll([]);UI.context.setFlavor(SDK.DebuggerModel.CallFrame,null);return;}
  18. let debuggerModel=details.debuggerModel;this._notPausedMessageElement.classList.add('hidden');const items=details.callFrames.map(frame=>{const item=Sources.CallStackSidebarPane.Item.createForDebuggerCallFrame(frame,this._locationPool,this._refreshItem.bind(this));item[Sources.CallStackSidebarPane._debuggerCallFrameSymbol]=frame;return item;});let asyncStackTrace=details.asyncStackTrace;if(!asyncStackTrace&&details.asyncStackTraceId){if(details.asyncStackTraceId.debuggerId){debuggerModel=SDK.DebuggerModel.modelForDebuggerId(details.asyncStackTraceId.debuggerId);}
  19. asyncStackTrace=debuggerModel?await debuggerModel.fetchAsyncStackTrace(details.asyncStackTraceId):null;}
  20. let peviousStackTrace=details.callFrames;let maxAsyncStackChainDepth=this._maxAsyncStackChainDepth;while(asyncStackTrace&&maxAsyncStackChainDepth>0){let title='';const isAwait=asyncStackTrace.description==='async function';if(isAwait&&peviousStackTrace.length&&asyncStackTrace.callFrames.length){const lastPreviousFrame=peviousStackTrace[peviousStackTrace.length-1];const lastPreviousFrameName=UI.beautifyFunctionName(lastPreviousFrame.functionName);title=UI.asyncStackTraceLabel('await in '+lastPreviousFrameName);}else{title=UI.asyncStackTraceLabel(asyncStackTrace.description);}
  21. items.push(...Sources.CallStackSidebarPane.Item.createItemsForAsyncStack(title,debuggerModel,asyncStackTrace.callFrames,this._locationPool,this._refreshItem.bind(this)));--maxAsyncStackChainDepth;peviousStackTrace=asyncStackTrace.callFrames;if(asyncStackTrace.parent){asyncStackTrace=asyncStackTrace.parent;}else if(asyncStackTrace.parentId){if(asyncStackTrace.parentId.debuggerId){debuggerModel=SDK.DebuggerModel.modelForDebuggerId(asyncStackTrace.parentId.debuggerId);}
  22. asyncStackTrace=debuggerModel?await debuggerModel.fetchAsyncStackTrace(asyncStackTrace.parentId):null;}else{asyncStackTrace=null;}}
  23. this._showMoreMessageElement.classList.toggle('hidden',!asyncStackTrace);this._items.replaceAll(items);if(this._maxAsyncStackChainDepth===Sources.CallStackSidebarPane._defaultMaxAsyncStackChainDepth){this._list.selectNextItem(true,false);}
  24. this._updatedForTest();}
  25. _updatedForTest(){}
  26. _refreshItem(item){this._scheduledForUpdateItems.add(item);this._updateItemThrottler.schedule(innerUpdate.bind(this));function innerUpdate(){const items=Array.from(this._scheduledForUpdateItems);this._scheduledForUpdateItems.clear();this._muteActivateItem=true;if(!this._showBlackboxed&&this._items.every(item=>item.isBlackboxed)){this._showBlackboxed=true;for(let i=0;i<this._items.length;++i){this._list.refreshItemByIndex(i);}
  27. this._blackboxedMessageElement.classList.toggle('hidden',true);}else{const itemsSet=new Set(items);let hasBlackboxed=false;for(let i=0;i<this._items.length;++i){const item=this._items.at(i);if(itemsSet.has(item)){this._list.refreshItemByIndex(i);}
  28. hasBlackboxed=hasBlackboxed||item.isBlackboxed;}
  29. this._blackboxedMessageElement.classList.toggle('hidden',this._showBlackboxed||!hasBlackboxed);}
  30. delete this._muteActivateItem;return Promise.resolve();}}
  31. createElementForItem(item){const element=createElementWithClass('div','call-frame-item');const title=element.createChild('div','call-frame-item-title');title.createChild('div','call-frame-title-text').textContent=item.title;if(item.isAsyncHeader){element.classList.add('async-header');}else{const linkElement=element.createChild('div','call-frame-location');linkElement.textContent=item.linkText.trimMiddle(30);linkElement.title=item.linkText;element.classList.toggle('blackboxed-call-frame',item.isBlackboxed);}
  32. element.classList.toggle('hidden',!this._showBlackboxed&&item.isBlackboxed);element.appendChild(UI.Icon.create('smallicon-thick-right-arrow','selected-call-frame-icon'));return element;}
  33. heightForItem(item){console.assert(false);return 0;}
  34. isItemSelectable(item){return!!item[Sources.CallStackSidebarPane._debuggerCallFrameSymbol];}
  35. selectedItemChanged(from,to,fromElement,toElement){if(fromElement){fromElement.classList.remove('selected');}
  36. if(toElement){toElement.classList.add('selected');}
  37. if(to){this._activateItem(to);}}
  38. _createBlackboxedMessageElement(){const element=createElementWithClass('div','blackboxed-message');element.createChild('span');const showAllLink=element.createChild('span','link');showAllLink.textContent=Common.UIString('Show blackboxed frames');showAllLink.addEventListener('click',()=>{this._showBlackboxed=true;for(const item of this._items){this._refreshItem(item);}
  39. this._blackboxedMessageElement.classList.toggle('hidden',true);});return element;}
  40. _createShowMoreMessageElement(){const element=createElementWithClass('div','show-more-message');element.createChild('span');const showAllLink=element.createChild('span','link');showAllLink.textContent=Common.UIString('Show more');showAllLink.addEventListener('click',()=>{this._maxAsyncStackChainDepth+=Sources.CallStackSidebarPane._defaultMaxAsyncStackChainDepth;this._update();},false);return element;}
  41. _onContextMenu(event){const item=this._list.itemForNode((event.target));if(!item){return;}
  42. const contextMenu=new UI.ContextMenu(event);const debuggerCallFrame=item[Sources.CallStackSidebarPane._debuggerCallFrameSymbol];if(debuggerCallFrame){contextMenu.defaultSection().appendItem(Common.UIString('Restart frame'),()=>debuggerCallFrame.restart());}
  43. contextMenu.defaultSection().appendItem(Common.UIString('Copy stack trace'),this._copyStackTrace.bind(this));if(item.uiLocation){this.appendBlackboxURLContextMenuItems(contextMenu,item.uiLocation.uiSourceCode);}
  44. contextMenu.show();}
  45. _onClick(event){const item=this._list.itemForNode((event.target));if(item){this._activateItem(item);}}
  46. _activateItem(item){const uiLocation=item.uiLocation;if(this._muteActivateItem||!uiLocation){return;}
  47. const debuggerCallFrame=item[Sources.CallStackSidebarPane._debuggerCallFrameSymbol];if(debuggerCallFrame&&UI.context.flavor(SDK.DebuggerModel.CallFrame)!==debuggerCallFrame){debuggerCallFrame.debuggerModel.setSelectedCallFrame(debuggerCallFrame);UI.context.setFlavor(SDK.DebuggerModel.CallFrame,debuggerCallFrame);}else{Common.Revealer.reveal(uiLocation);}}
  48. appendBlackboxURLContextMenuItems(contextMenu,uiSourceCode){const binding=Persistence.persistence.binding(uiSourceCode);if(binding){uiSourceCode=binding.network;}
  49. if(uiSourceCode.project().type()===Workspace.projectTypes.FileSystem){return;}
  50. const canBlackbox=Bindings.blackboxManager.canBlackboxUISourceCode(uiSourceCode);const isBlackboxed=Bindings.blackboxManager.isBlackboxedUISourceCode(uiSourceCode);const isContentScript=uiSourceCode.project().type()===Workspace.projectTypes.ContentScripts;const manager=Bindings.blackboxManager;if(canBlackbox){if(isBlackboxed){contextMenu.defaultSection().appendItem(Common.UIString('Stop blackboxing'),manager.unblackboxUISourceCode.bind(manager,uiSourceCode));}else{contextMenu.defaultSection().appendItem(Common.UIString('Blackbox script'),manager.blackboxUISourceCode.bind(manager,uiSourceCode));}}
  51. if(isContentScript){if(isBlackboxed){contextMenu.defaultSection().appendItem(Common.UIString('Stop blackboxing all content scripts'),manager.blackboxContentScripts.bind(manager));}else{contextMenu.defaultSection().appendItem(Common.UIString('Blackbox all content scripts'),manager.unblackboxContentScripts.bind(manager));}}}
  52. _selectNextCallFrameOnStack(){return this._list.selectNextItem(false,false);}
  53. _selectPreviousCallFrameOnStack(){return this._list.selectPreviousItem(false,false);}
  54. _copyStackTrace(){const text=[];for(const item of this._items){let itemText=item.title;if(item.uiLocation){itemText+=' ('+item.uiLocation.linkText(true)+')';}
  55. text.push(itemText);}
  56. Host.InspectorFrontendHost.copyText(text.join('\n'));}};Sources.CallStackSidebarPane._debuggerCallFrameSymbol=Symbol('debuggerCallFrame');Sources.CallStackSidebarPane._elementSymbol=Symbol('element');Sources.CallStackSidebarPane._defaultMaxAsyncStackChainDepth=32;Sources.CallStackSidebarPane.ActionDelegate=class{handleAction(context,actionId){const callStackSidebarPane=self.runtime.sharedInstance(Sources.CallStackSidebarPane);switch(actionId){case'debugger.next-call-frame':callStackSidebarPane._selectNextCallFrameOnStack();return true;case'debugger.previous-call-frame':callStackSidebarPane._selectPreviousCallFrameOnStack();return true;}
  57. return false;}};Sources.CallStackSidebarPane.Item=class{static createForDebuggerCallFrame(frame,locationPool,updateDelegate){const item=new Sources.CallStackSidebarPane.Item(UI.beautifyFunctionName(frame.functionName),updateDelegate);Bindings.debuggerWorkspaceBinding.createCallFrameLiveLocation(frame.location(),item._update.bind(item),locationPool);return item;}
  58. static createItemsForAsyncStack(title,debuggerModel,frames,locationPool,updateDelegate){const whiteboxedItemsSymbol=Symbol('whiteboxedItems');const asyncHeaderItem=new Sources.CallStackSidebarPane.Item(title,updateDelegate);asyncHeaderItem[whiteboxedItemsSymbol]=new Set();asyncHeaderItem.isAsyncHeader=true;const asyncFrameItems=frames.map(frame=>{const item=new Sources.CallStackSidebarPane.Item(UI.beautifyFunctionName(frame.functionName),update);const rawLocation=debuggerModel?debuggerModel.createRawLocationByScriptId(frame.scriptId,frame.lineNumber,frame.columnNumber):null;if(!rawLocation){item.linkText=(frame.url||'<unknown>')+':'+(frame.lineNumber+1);item.updateDelegate(item);}else{Bindings.debuggerWorkspaceBinding.createCallFrameLiveLocation(rawLocation,item._update.bind(item),locationPool);}
  59. return item;});updateDelegate(asyncHeaderItem);return[asyncHeaderItem,...asyncFrameItems];function update(item){updateDelegate(item);let shouldUpdate=false;const items=asyncHeaderItem[whiteboxedItemsSymbol];if(item.isBlackboxed){items.delete(item);shouldUpdate=items.size===0;}else{shouldUpdate=items.size===0;items.add(item);}
  60. asyncHeaderItem.isBlackboxed=asyncHeaderItem[whiteboxedItemsSymbol].size===0;if(shouldUpdate){updateDelegate(asyncHeaderItem);}}}
  61. constructor(title,updateDelegate){this.isBlackboxed=false;this.title=title;this.linkText='';this.uiLocation=null;this.isAsyncHeader=false;this.updateDelegate=updateDelegate;}
  62. _update(liveLocation){const uiLocation=liveLocation.uiLocation();this.isBlackboxed=uiLocation?Bindings.blackboxManager.isBlackboxedUISourceCode(uiLocation.uiSourceCode):false;this.linkText=uiLocation?uiLocation.linkText():'';this.uiLocation=uiLocation;this.updateDelegate(this);}};;Sources.DebuggerPausedMessage=class{constructor(){this._element=createElementWithClass('div','paused-message flex-none');const root=UI.createShadowRootWithCoreStyles(this._element,'sources/debuggerPausedMessage.css');this._contentElement=root.createChild('div');UI.ARIAUtils.markAsPoliteLiveRegion(this._element);}
  63. element(){return this._element;}
  64. static _descriptionWithoutStack(description){const firstCallFrame=/^\s+at\s/m.exec(description);return firstCallFrame?description.substring(0,firstCallFrame.index-1):description.substring(0,description.lastIndexOf('\n'));}
  65. static async _createDOMBreakpointHitMessage(details){const messageWrapper=createElement('span');const domDebuggerModel=details.debuggerModel.target().model(SDK.DOMDebuggerModel);if(!details.auxData||!domDebuggerModel){return messageWrapper;}
  66. const data=domDebuggerModel.resolveDOMBreakpointData((details.auxData));if(!data){return messageWrapper;}
  67. const mainElement=messageWrapper.createChild('div','status-main');mainElement.appendChild(UI.Icon.create('smallicon-info','status-icon'));const breakpointType=Sources.DebuggerPausedMessage.BreakpointTypeNouns.get(data.type);mainElement.appendChild(createTextNode(ls`Paused on ${breakpointType}`));const subElement=messageWrapper.createChild('div','status-sub monospace');const linkifiedNode=await Common.Linkifier.linkify(data.node);subElement.appendChild(linkifiedNode);if(data.targetNode){const targetNodeLink=await Common.Linkifier.linkify(data.targetNode);let messageElement;if(data.insertion){if(data.targetNode===data.node){messageElement=UI.formatLocalized('Child %s added',[targetNodeLink]);}else{messageElement=UI.formatLocalized('Descendant %s added',[targetNodeLink]);}}else{messageElement=UI.formatLocalized('Descendant %s removed',[targetNodeLink]);}
  68. subElement.appendChild(createElement('br'));subElement.appendChild(messageElement);}
  69. return messageWrapper;}
  70. async render(details,debuggerWorkspaceBinding,breakpointManager){this._contentElement.removeChildren();this._contentElement.hidden=!details;if(!details){return;}
  71. const status=this._contentElement.createChild('div','paused-status');const errorLike=details.reason===SDK.DebuggerModel.BreakReason.Exception||details.reason===SDK.DebuggerModel.BreakReason.PromiseRejection||details.reason===SDK.DebuggerModel.BreakReason.Assert||details.reason===SDK.DebuggerModel.BreakReason.OOM;let messageWrapper;if(details.reason===SDK.DebuggerModel.BreakReason.DOM){messageWrapper=await Sources.DebuggerPausedMessage._createDOMBreakpointHitMessage(details);}else if(details.reason===SDK.DebuggerModel.BreakReason.EventListener){let eventNameForUI='';if(details.auxData){eventNameForUI=SDK.domDebuggerManager.resolveEventListenerBreakpointTitle((details.auxData));}
  72. messageWrapper=buildWrapper(Common.UIString('Paused on event listener'),eventNameForUI);}else if(details.reason===SDK.DebuggerModel.BreakReason.XHR){messageWrapper=buildWrapper(Common.UIString('Paused on XHR or fetch'),details.auxData['url']||'');}else if(details.reason===SDK.DebuggerModel.BreakReason.Exception){const description=details.auxData['description']||details.auxData['value']||'';const descriptionWithoutStack=Sources.DebuggerPausedMessage._descriptionWithoutStack(description);messageWrapper=buildWrapper(Common.UIString('Paused on exception'),descriptionWithoutStack,description);}else if(details.reason===SDK.DebuggerModel.BreakReason.PromiseRejection){const description=details.auxData['description']||details.auxData['value']||'';const descriptionWithoutStack=Sources.DebuggerPausedMessage._descriptionWithoutStack(description);messageWrapper=buildWrapper(Common.UIString('Paused on promise rejection'),descriptionWithoutStack,description);}else if(details.reason===SDK.DebuggerModel.BreakReason.Assert){messageWrapper=buildWrapper(Common.UIString('Paused on assertion'));}else if(details.reason===SDK.DebuggerModel.BreakReason.DebugCommand){messageWrapper=buildWrapper(Common.UIString('Paused on debugged function'));}else if(details.reason===SDK.DebuggerModel.BreakReason.OOM){messageWrapper=buildWrapper(Common.UIString('Paused before potential out-of-memory crash'));}else if(details.callFrames.length){const uiLocation=debuggerWorkspaceBinding.rawLocationToUILocation(details.callFrames[0].location());const breakpoint=uiLocation?breakpointManager.findBreakpoint(uiLocation):null;const defaultText=breakpoint?Common.UIString('Paused on breakpoint'):Common.UIString('Debugger paused');messageWrapper=buildWrapper(defaultText);}else{console.warn('ScriptsPanel paused, but callFrames.length is zero.');}
  73. status.classList.toggle('error-reason',errorLike);if(messageWrapper){status.appendChild(messageWrapper);}
  74. function buildWrapper(mainText,subText,title){const messageWrapper=createElement('span');const mainElement=messageWrapper.createChild('div','status-main');const icon=UI.Icon.create(errorLike?'smallicon-error':'smallicon-info','status-icon');mainElement.appendChild(icon);mainElement.appendChild(createTextNode(mainText));if(subText){const subElement=messageWrapper.createChild('div','status-sub monospace');subElement.textContent=subText;subElement.title=title||subText;}
  75. return messageWrapper;}}};Sources.DebuggerPausedMessage.BreakpointTypeNouns=new Map([[SDK.DOMDebuggerModel.DOMBreakpoint.Type.SubtreeModified,Common.UIString('subtree modifications')],[SDK.DOMDebuggerModel.DOMBreakpoint.Type.AttributeModified,Common.UIString('attribute modifications')],[SDK.DOMDebuggerModel.DOMBreakpoint.Type.NodeRemoved,Common.UIString('node removal')],]);;Sources.HistoryEntry=function(){};Sources.HistoryEntry.prototype={valid(){},reveal(){}};Sources.SimpleHistoryManager=class{constructor(historyDepth){this._entries=[];this._activeEntryIndex=-1;this._coalescingReadonly=0;this._historyDepth=historyDepth;}
  76. readOnlyLock(){++this._coalescingReadonly;}
  77. releaseReadOnlyLock(){--this._coalescingReadonly;}
  78. readOnly(){return!!this._coalescingReadonly;}
  79. filterOut(filterOutCallback){if(this.readOnly()){return;}
  80. const filteredEntries=[];let removedBeforeActiveEntry=0;for(let i=0;i<this._entries.length;++i){if(!filterOutCallback(this._entries[i])){filteredEntries.push(this._entries[i]);}else if(i<=this._activeEntryIndex){++removedBeforeActiveEntry;}}
  81. this._entries=filteredEntries;this._activeEntryIndex=Math.max(0,this._activeEntryIndex-removedBeforeActiveEntry);}
  82. empty(){return!this._entries.length;}
  83. active(){return this.empty()?null:this._entries[this._activeEntryIndex];}
  84. push(entry){if(this.readOnly()){return;}
  85. if(!this.empty()){this._entries.splice(this._activeEntryIndex+1);}
  86. this._entries.push(entry);if(this._entries.length>this._historyDepth){this._entries.shift();}
  87. this._activeEntryIndex=this._entries.length-1;}
  88. rollback(){if(this.empty()){return false;}
  89. let revealIndex=this._activeEntryIndex-1;while(revealIndex>=0&&!this._entries[revealIndex].valid()){--revealIndex;}
  90. if(revealIndex<0){return false;}
  91. this.readOnlyLock();this._entries[revealIndex].reveal();this.releaseReadOnlyLock();this._activeEntryIndex=revealIndex;return true;}
  92. rollover(){let revealIndex=this._activeEntryIndex+1;while(revealIndex<this._entries.length&&!this._entries[revealIndex].valid()){++revealIndex;}
  93. if(revealIndex>=this._entries.length){return false;}
  94. this.readOnlyLock();this._entries[revealIndex].reveal();this.releaseReadOnlyLock();this._activeEntryIndex=revealIndex;return true;}};;Sources.EditingLocationHistoryManager=class{constructor(sourcesView,currentSourceFrameCallback){this._sourcesView=sourcesView;this._historyManager=new Sources.SimpleHistoryManager(Sources.EditingLocationHistoryManager.HistoryDepth);this._currentSourceFrameCallback=currentSourceFrameCallback;}
  95. trackSourceFrameCursorJumps(sourceFrame){sourceFrame.textEditor.addEventListener(SourceFrame.SourcesTextEditor.Events.JumpHappened,this._onJumpHappened.bind(this));}
  96. _onJumpHappened(event){if(event.data.from){this._updateActiveState(event.data.from);}
  97. if(event.data.to){this._pushActiveState(event.data.to);}}
  98. rollback(){this._historyManager.rollback();}
  99. rollover(){this._historyManager.rollover();}
  100. updateCurrentState(){const sourceFrame=this._currentSourceFrameCallback();if(!sourceFrame){return;}
  101. this._updateActiveState(sourceFrame.textEditor.selection());}
  102. pushNewState(){const sourceFrame=this._currentSourceFrameCallback();if(!sourceFrame){return;}
  103. this._pushActiveState(sourceFrame.textEditor.selection());}
  104. _updateActiveState(selection){const active=this._historyManager.active();if(!active){return;}
  105. const sourceFrame=this._currentSourceFrameCallback();if(!sourceFrame){return;}
  106. const entry=new Sources.EditingLocationHistoryEntry(this._sourcesView,this,sourceFrame,selection);active.merge(entry);}
  107. _pushActiveState(selection){const sourceFrame=this._currentSourceFrameCallback();if(!sourceFrame){return;}
  108. const entry=new Sources.EditingLocationHistoryEntry(this._sourcesView,this,sourceFrame,selection);this._historyManager.push(entry);}
  109. removeHistoryForSourceCode(uiSourceCode){function filterOut(entry){return entry._projectId===uiSourceCode.project().id()&&entry._url===uiSourceCode.url();}
  110. this._historyManager.filterOut(filterOut);}};Sources.EditingLocationHistoryManager.HistoryDepth=20;Sources.EditingLocationHistoryEntry=class{constructor(sourcesView,editingLocationManager,sourceFrame,selection){this._sourcesView=sourcesView;this._editingLocationManager=editingLocationManager;const uiSourceCode=sourceFrame.uiSourceCode();this._projectId=uiSourceCode.project().id();this._url=uiSourceCode.url();const position=this._positionFromSelection(selection);this._positionHandle=sourceFrame.textEditor.textEditorPositionHandle(position.lineNumber,position.columnNumber);}
  111. merge(entry){if(this._projectId!==entry._projectId||this._url!==entry._url){return;}
  112. this._positionHandle=entry._positionHandle;}
  113. _positionFromSelection(selection){return{lineNumber:selection.endLine,columnNumber:selection.endColumn};}
  114. valid(){const position=this._positionHandle.resolve();const uiSourceCode=Workspace.workspace.uiSourceCode(this._projectId,this._url);return!!(position&&uiSourceCode);}
  115. reveal(){const position=this._positionHandle.resolve();const uiSourceCode=Workspace.workspace.uiSourceCode(this._projectId,this._url);if(!position||!uiSourceCode){return;}
  116. this._editingLocationManager.updateCurrentState();this._sourcesView.showSourceLocation(uiSourceCode,position.lineNumber,position.columnNumber);}};;Sources.FilePathScoreFunction=class{constructor(query){this._query=query;this._queryUpperCase=query.toUpperCase();this._score=new Int32Array(20*100);this._sequence=new Int32Array(20*100);this._dataUpperCase='';this._fileNameIndex=0;}
  117. score(data,matchIndexes){if(!data||!this._query){return 0;}
  118. const n=this._query.length;const m=data.length;if(!this._score||this._score.length<n*m){this._score=new Int32Array(n*m*2);this._sequence=new Int32Array(n*m*2);}
  119. const score=this._score;const sequence=(this._sequence);this._dataUpperCase=data.toUpperCase();this._fileNameIndex=data.lastIndexOf('/');for(let i=0;i<n;++i){for(let j=0;j<m;++j){const skipCharScore=j===0?0:score[i*m+j-1];const prevCharScore=i===0||j===0?0:score[(i-1)*m+j-1];const consecutiveMatch=i===0||j===0?0:sequence[(i-1)*m+j-1];const pickCharScore=this._match(this._query,data,i,j,consecutiveMatch);if(pickCharScore&&prevCharScore+pickCharScore>=skipCharScore){sequence[i*m+j]=consecutiveMatch+1;score[i*m+j]=(prevCharScore+pickCharScore);}else{sequence[i*m+j]=0;score[i*m+j]=skipCharScore;}}}
  120. if(matchIndexes){this._restoreMatchIndexes(sequence,n,m,matchIndexes);}
  121. const maxDataLength=256;return score[n*m-1]*maxDataLength+(maxDataLength-data.length);}
  122. _testWordStart(data,j){if(j===0){return true;}
  123. const prevChar=data.charAt(j-1);return prevChar==='_'||prevChar==='-'||prevChar==='/'||(data[j-1]!==this._dataUpperCase[j-1]&&data[j]===this._dataUpperCase[j]);}
  124. _restoreMatchIndexes(sequence,n,m,out){let i=n-1,j=m-1;while(i>=0&&j>=0){switch(sequence[i*m+j]){case 0:--j;break;default:out.push(j);--i;--j;break;}}
  125. out.reverse();}
  126. _singleCharScore(query,data,i,j){const isWordStart=this._testWordStart(data,j);const isFileName=j>this._fileNameIndex;const isPathTokenStart=j===0||data[j-1]==='/';const isCapsMatch=query[i]===data[j]&&query[i]===this._queryUpperCase[i];let score=10;if(isPathTokenStart){score+=4;}
  127. if(isWordStart){score+=2;}
  128. if(isCapsMatch){score+=6;}
  129. if(isFileName){score+=4;}
  130. if(j===this._fileNameIndex+1&&i===0){score+=5;}
  131. if(isFileName&&isWordStart){score+=3;}
  132. return score;}
  133. _sequenceCharScore(query,data,i,j,sequenceLength){const isFileName=j>this._fileNameIndex;const isPathTokenStart=j===0||data[j-1]==='/';let score=10;if(isFileName){score+=4;}
  134. if(isPathTokenStart){score+=5;}
  135. score+=sequenceLength*4;return score;}
  136. _match(query,data,i,j,consecutiveMatch){if(this._queryUpperCase[i]!==this._dataUpperCase[j]){return 0;}
  137. if(!consecutiveMatch){return this._singleCharScore(query,data,i,j);}else{return this._sequenceCharScore(query,data,i,j-consecutiveMatch,consecutiveMatch);}}};;Sources.FilteredUISourceCodeListProvider=class extends QuickOpen.FilteredListWidget.Provider{constructor(){super();this._queryLineNumberAndColumnNumber='';this._defaultScores=null;this._scorer=new Sources.FilePathScoreFunction('');}
  138. _projectRemoved(event){const project=(event.data);this._populate(project);this.refresh();}
  139. _populate(skipProject){this._uiSourceCodes=[];const projects=Workspace.workspace.projects().filter(this.filterProject.bind(this));for(let i=0;i<projects.length;++i){if(skipProject&&projects[i]===skipProject){continue;}
  140. const uiSourceCodes=projects[i].uiSourceCodes().filter(this._filterUISourceCode.bind(this));this._uiSourceCodes=this._uiSourceCodes.concat(uiSourceCodes);}}
  141. _filterUISourceCode(uiSourceCode){const binding=Persistence.persistence.binding(uiSourceCode);return!binding||binding.fileSystem===uiSourceCode;}
  142. uiSourceCodeSelected(uiSourceCode,lineNumber,columnNumber){}
  143. filterProject(project){return true;}
  144. itemCount(){return this._uiSourceCodes.length;}
  145. itemKeyAt(itemIndex){return this._uiSourceCodes[itemIndex].url();}
  146. setDefaultScores(defaultScores){this._defaultScores=defaultScores;}
  147. itemScoreAt(itemIndex,query){const uiSourceCode=this._uiSourceCodes[itemIndex];const score=this._defaultScores?(this._defaultScores.get(uiSourceCode)||0):0;if(!query||query.length<2){return score;}
  148. if(this._query!==query){this._query=query;this._scorer=new Sources.FilePathScoreFunction(query);}
  149. let multiplier=10;if(uiSourceCode.project().type()===Workspace.projectTypes.FileSystem&&!Persistence.persistence.binding(uiSourceCode)){multiplier=5;}
  150. const fullDisplayName=uiSourceCode.fullDisplayName();return score+multiplier*this._scorer.score(fullDisplayName,null);}
  151. renderItem(itemIndex,query,titleElement,subtitleElement){query=this.rewriteQuery(query);const uiSourceCode=this._uiSourceCodes[itemIndex];const fullDisplayName=uiSourceCode.fullDisplayName();const indexes=[];new Sources.FilePathScoreFunction(query).score(fullDisplayName,indexes);const fileNameIndex=fullDisplayName.lastIndexOf('/');titleElement.classList.add('monospace');subtitleElement.classList.add('monospace');titleElement.textContent=uiSourceCode.displayName()+(this._queryLineNumberAndColumnNumber||'');this._renderSubtitleElement(subtitleElement,fullDisplayName);subtitleElement.title=fullDisplayName;const ranges=[];for(let i=0;i<indexes.length;++i){ranges.push({offset:indexes[i],length:1});}
  152. if(indexes[0]>fileNameIndex){for(let i=0;i<ranges.length;++i){ranges[i].offset-=fileNameIndex+1;}
  153. UI.highlightRangesWithStyleClass(titleElement,ranges,'highlight');}else{UI.highlightRangesWithStyleClass(subtitleElement,ranges,'highlight');}}
  154. _renderSubtitleElement(element,text){element.removeChildren();let splitPosition=text.lastIndexOf('/');if(text.length>55){splitPosition=text.length-55;}
  155. const first=element.createChild('div','first-part');first.textContent=text.substring(0,splitPosition);const second=element.createChild('div','second-part');second.textContent=text.substring(splitPosition);element.title=text;}
  156. selectItem(itemIndex,promptValue){const parsedExpression=promptValue.trim().match(/^([^:]*)(:\d+)?(:\d+)?$/);if(!parsedExpression){return;}
  157. let lineNumber;let columnNumber;if(parsedExpression[2]){lineNumber=parseInt(parsedExpression[2].substr(1),10)-1;}
  158. if(parsedExpression[3]){columnNumber=parseInt(parsedExpression[3].substr(1),10)-1;}
  159. const uiSourceCode=itemIndex!==null?this._uiSourceCodes[itemIndex]:null;this.uiSourceCodeSelected(uiSourceCode,lineNumber,columnNumber);}
  160. rewriteQuery(query){query=query?query.trim():'';if(!query||query===':'){return'';}
  161. const lineNumberMatch=query.match(/^([^:]+)((?::[^:]*){0,2})$/);this._queryLineNumberAndColumnNumber=lineNumberMatch?lineNumberMatch[2]:'';return lineNumberMatch?lineNumberMatch[1]:query;}
  162. _uiSourceCodeAdded(event){const uiSourceCode=(event.data);if(!this._filterUISourceCode(uiSourceCode)||!this.filterProject(uiSourceCode.project())){return;}
  163. this._uiSourceCodes.push(uiSourceCode);this.refresh();}
  164. notFoundText(){return Common.UIString('No files found');}
  165. attach(){Workspace.workspace.addEventListener(Workspace.Workspace.Events.UISourceCodeAdded,this._uiSourceCodeAdded,this);Workspace.workspace.addEventListener(Workspace.Workspace.Events.ProjectRemoved,this._projectRemoved,this);this._populate();}
  166. detach(){Workspace.workspace.removeEventListener(Workspace.Workspace.Events.UISourceCodeAdded,this._uiSourceCodeAdded,this);Workspace.workspace.removeEventListener(Workspace.Workspace.Events.ProjectRemoved,this._projectRemoved,this);this._queryLineNumberAndColumnNumber='';this._defaultScores=null;}};;Sources.GoToLineQuickOpen=class extends QuickOpen.FilteredListWidget.Provider{selectItem(itemIndex,promptValue){const uiSourceCode=this._currentUISourceCode();if(!uiSourceCode){return;}
  167. const position=this._parsePosition(promptValue);if(!position){return;}
  168. Common.Revealer.reveal(uiSourceCode.uiLocation(position.line-1,position.column-1));}
  169. notFoundText(query){if(!this._currentUISourceCode()){return Common.UIString('No file selected.');}
  170. const position=this._parsePosition(query);if(!position){const sourceFrame=this._currentSourceFrame();if(!sourceFrame){return ls`Type a number to go to that line.`;}
  171. const currentLineNumber=sourceFrame.textEditor.currentLineNumber()+1;const linesCount=sourceFrame.textEditor.linesCount;return ls`Current line: ${currentLineNumber}. Type a line number between 1 and ${linesCount} to navigate to.`;}
  172. if(position.column&&position.column>1){return ls`Go to line ${position.line} and column ${position.column}.`;}
  173. return ls`Go to line ${position.line}.`;}
  174. _parsePosition(query){const parts=query.match(/([0-9]+)(\:[0-9]*)?/);if(!parts||!parts[0]||parts[0].length!==query.length){return null;}
  175. const line=parseInt(parts[1],10);let column;if(parts[2]){column=parseInt(parts[2].substring(1),10);}
  176. return{line:Math.max(line|0,1),column:Math.max(column|0,1)};}
  177. _currentUISourceCode(){const sourcesView=UI.context.flavor(Sources.SourcesView);if(!sourcesView){return null;}
  178. return sourcesView.currentUISourceCode();}
  179. _currentSourceFrame(){const sourcesView=UI.context.flavor(Sources.SourcesView);if(!sourcesView){return null;}
  180. return sourcesView.currentSourceFrame();}};;Sources.SourceMapNamesResolver={};Sources.SourceMapNamesResolver._cachedMapSymbol=Symbol('cache');Sources.SourceMapNamesResolver._cachedIdentifiersSymbol=Symbol('cachedIdentifiers');Sources.SourceMapNamesResolver.Identifier=class{constructor(name,lineNumber,columnNumber){this.name=name;this.lineNumber=lineNumber;this.columnNumber=columnNumber;}};Sources.SourceMapNamesResolver._scopeIdentifiers=function(scope){const startLocation=scope.startLocation();const endLocation=scope.endLocation();if(scope.type()===Protocol.Debugger.ScopeType.Global||!startLocation||!endLocation||!startLocation.script()||!startLocation.script().sourceMapURL||(startLocation.script()!==endLocation.script())){return Promise.resolve(([]));}
  181. const script=startLocation.script();return script.requestContent().then(onContent);function onContent(deferredContent){if(!deferredContent.content){return Promise.resolve(([]));}
  182. const content=deferredContent.content;const text=new TextUtils.Text(content);const scopeRange=new TextUtils.TextRange(startLocation.lineNumber,startLocation.columnNumber,endLocation.lineNumber,endLocation.columnNumber);const scopeText=text.extract(scopeRange);const scopeStart=text.toSourceRange(scopeRange).offset;const prefix='function fui';return Formatter.formatterWorkerPool().javaScriptIdentifiers(prefix+scopeText).then(onIdentifiers.bind(null,text,scopeStart,prefix));}
  183. function onIdentifiers(text,scopeStart,prefix,identifiers){const result=[];const cursor=new TextUtils.TextCursor(text.lineEndings());for(let i=0;i<identifiers.length;++i){const id=identifiers[i];if(id.offset<prefix.length){continue;}
  184. const start=scopeStart+id.offset-prefix.length;cursor.resetTo(start);result.push(new Sources.SourceMapNamesResolver.Identifier(id.name,cursor.lineNumber(),cursor.columnNumber()));}
  185. return result;}};Sources.SourceMapNamesResolver._resolveScope=function(scope){let identifiersPromise=scope[Sources.SourceMapNamesResolver._cachedIdentifiersSymbol];if(identifiersPromise){return identifiersPromise;}
  186. const script=scope.callFrame().script;const sourceMap=Bindings.debuggerWorkspaceBinding.sourceMapForScript(script);if(!sourceMap){return Promise.resolve(new Map());}
  187. const textCache=new Map();identifiersPromise=Sources.SourceMapNamesResolver._scopeIdentifiers(scope).then(onIdentifiers);scope[Sources.SourceMapNamesResolver._cachedIdentifiersSymbol]=identifiersPromise;return identifiersPromise;function onIdentifiers(identifiers){const namesMapping=new Map();for(let i=0;i<identifiers.length;++i){const id=identifiers[i];const entry=sourceMap.findEntry(id.lineNumber,id.columnNumber);if(entry&&entry.name){namesMapping.set(id.name,entry.name);}}
  188. const promises=[];for(let i=0;i<identifiers.length;++i){const id=identifiers[i];if(namesMapping.has(id.name)){continue;}
  189. const promise=resolveSourceName(id).then(onSourceNameResolved.bind(null,namesMapping,id));promises.push(promise);}
  190. return Promise.all(promises).then(()=>Sources.SourceMapNamesResolver._scopeResolvedForTest()).then(()=>namesMapping);}
  191. function onSourceNameResolved(namesMapping,id,sourceName){if(!sourceName){return;}
  192. namesMapping.set(id.name,sourceName);}
  193. function resolveSourceName(id){const startEntry=sourceMap.findEntry(id.lineNumber,id.columnNumber);const endEntry=sourceMap.findEntry(id.lineNumber,id.columnNumber+id.name.length);if(!startEntry||!endEntry||!startEntry.sourceURL||startEntry.sourceURL!==endEntry.sourceURL||!startEntry.sourceLineNumber||!startEntry.sourceColumnNumber||!endEntry.sourceLineNumber||!endEntry.sourceColumnNumber){return Promise.resolve((null));}
  194. const sourceTextRange=new TextUtils.TextRange(startEntry.sourceLineNumber,startEntry.sourceColumnNumber,endEntry.sourceLineNumber,endEntry.sourceColumnNumber);const uiSourceCode=Bindings.debuggerWorkspaceBinding.uiSourceCodeForSourceMapSourceURL(script.debuggerModel,startEntry.sourceURL,script.isContentScript());if(!uiSourceCode){return Promise.resolve((null));}
  195. return uiSourceCode.requestContent().then(deferredContent=>{const content=deferredContent.content;return onSourceContent(sourceTextRange,content);});}
  196. function onSourceContent(sourceTextRange,content){if(!content){return null;}
  197. let text=textCache.get(content);if(!text){text=new TextUtils.Text(content);textCache.set(content,text);}
  198. const originalIdentifier=text.extract(sourceTextRange).trim();return/[a-zA-Z0-9_$]+/.test(originalIdentifier)?originalIdentifier:null;}};Sources.SourceMapNamesResolver._scopeResolvedForTest=function(){};Sources.SourceMapNamesResolver._allVariablesInCallFrame=function(callFrame){const cached=callFrame[Sources.SourceMapNamesResolver._cachedMapSymbol];if(cached){return Promise.resolve(cached);}
  199. const promises=[];const scopeChain=callFrame.scopeChain();for(let i=0;i<scopeChain.length;++i){promises.push(Sources.SourceMapNamesResolver._resolveScope(scopeChain[i]));}
  200. return Promise.all(promises).then(mergeVariables);function mergeVariables(nameMappings){const reverseMapping=new Map();for(const map of nameMappings){for(const compiledName of map.keys()){const originalName=map.get(compiledName);if(!reverseMapping.has(originalName)){reverseMapping.set(originalName,compiledName);}}}
  201. callFrame[Sources.SourceMapNamesResolver._cachedMapSymbol]=reverseMapping;return reverseMapping;}};Sources.SourceMapNamesResolver.resolveExpression=function(callFrame,originalText,uiSourceCode,lineNumber,startColumnNumber,endColumnNumber){if(!uiSourceCode.contentType().isFromSourceMap()){return Promise.resolve('');}
  202. return Sources.SourceMapNamesResolver._allVariablesInCallFrame(callFrame).then(reverseMapping=>findCompiledName(callFrame.debuggerModel,reverseMapping));function findCompiledName(debuggerModel,reverseMapping){if(reverseMapping.has(originalText)){return Promise.resolve(reverseMapping.get(originalText)||'');}
  203. return Sources.SourceMapNamesResolver._resolveExpression(debuggerModel,uiSourceCode,lineNumber,startColumnNumber,endColumnNumber);}};Sources.SourceMapNamesResolver._resolveExpression=function(debuggerModel,uiSourceCode,lineNumber,startColumnNumber,endColumnNumber){const rawLocations=Bindings.debuggerWorkspaceBinding.uiLocationToRawLocations(uiSourceCode,lineNumber,startColumnNumber);const rawLocation=rawLocations.find(location=>location.debuggerModel===debuggerModel);if(!rawLocation){return Promise.resolve('');}
  204. const script=rawLocation.script();if(!script){return Promise.resolve('');}
  205. const sourceMap=(Bindings.debuggerWorkspaceBinding.sourceMapForScript(script));if(!sourceMap){return Promise.resolve('');}
  206. return script.requestContent().then(onContent);function onContent(deferredContent){const content=deferredContent.content;if(!content){return Promise.resolve('');}
  207. const text=new TextUtils.Text(content);const textRange=sourceMap.reverseMapTextRange(uiSourceCode.url(),new TextUtils.TextRange(lineNumber,startColumnNumber,lineNumber,endColumnNumber));const originalText=text.extract(textRange);if(!originalText){return Promise.resolve('');}
  208. return Formatter.formatterWorkerPool().evaluatableJavaScriptSubstring(originalText);}};Sources.SourceMapNamesResolver.resolveThisObject=function(callFrame){if(!callFrame){return Promise.resolve((null));}
  209. if(!callFrame.scopeChain().length){return Promise.resolve(callFrame.thisObject());}
  210. return Sources.SourceMapNamesResolver._resolveScope(callFrame.scopeChain()[0]).then(onScopeResolved);function onScopeResolved(namesMapping){const thisMappings=namesMapping.inverse().get('this');if(!thisMappings||thisMappings.size!==1){return Promise.resolve(callFrame.thisObject());}
  211. const thisMapping=thisMappings.valuesArray()[0];return callFrame.evaluate({expression:thisMapping,objectGroup:'backtrace',includeCommandLineAPI:false,silent:true,returnByValue:false,generatePreview:true}).then(onEvaluated);}
  212. function onEvaluated(result){return!result.exceptionDetails&&result.object?result.object:callFrame.thisObject();}};Sources.SourceMapNamesResolver.resolveScopeInObject=function(scope){const startLocation=scope.startLocation();const endLocation=scope.endLocation();if(scope.type()===Protocol.Debugger.ScopeType.Global||!startLocation||!endLocation||!startLocation.script()||!startLocation.script().sourceMapURL||startLocation.script()!==endLocation.script()){return scope.object();}
  213. return new Sources.SourceMapNamesResolver.RemoteObject(scope);};Sources.SourceMapNamesResolver.RemoteObject=class extends SDK.RemoteObject{constructor(scope){super();this._scope=scope;this._object=scope.object();}
  214. customPreview(){return this._object.customPreview();}
  215. get objectId(){return this._object.objectId;}
  216. get type(){return this._object.type;}
  217. get subtype(){return this._object.subtype;}
  218. get value(){return this._object.value;}
  219. get description(){return this._object.description;}
  220. get hasChildren(){return this._object.hasChildren;}
  221. get preview(){return this._object.preview;}
  222. arrayLength(){return this._object.arrayLength();}
  223. getOwnProperties(generatePreview){return this._object.getOwnProperties(generatePreview);}
  224. async getAllProperties(accessorPropertiesOnly,generatePreview){const allProperties=await this._object.getAllProperties(accessorPropertiesOnly,generatePreview);const namesMapping=await Sources.SourceMapNamesResolver._resolveScope(this._scope);const properties=allProperties.properties;const internalProperties=allProperties.internalProperties;const newProperties=[];if(properties){for(let i=0;i<properties.length;++i){const property=properties[i];const name=namesMapping.get(property.name)||properties[i].name;newProperties.push(new SDK.RemoteObjectProperty(name,property.value,property.enumerable,property.writable,property.isOwn,property.wasThrown,property.symbol,property.synthetic));}}
  225. return{properties:newProperties,internalProperties:internalProperties};}
  226. async setPropertyValue(argumentName,value){const namesMapping=await Sources.SourceMapNamesResolver._resolveScope(this._scope);let name;if(typeof argumentName==='string'){name=argumentName;}else{name=(argumentName.value);}
  227. let actualName=name;for(const compiledName of namesMapping.keys()){if(namesMapping.get(compiledName)===name){actualName=compiledName;break;}}
  228. return this._object.setPropertyValue(actualName,value);}
  229. async deleteProperty(name){return this._object.deleteProperty(name);}
  230. callFunction(functionDeclaration,args){return this._object.callFunction(functionDeclaration,args);}
  231. callFunctionJSON(functionDeclaration,args){return this._object.callFunctionJSON(functionDeclaration,args);}
  232. release(){this._object.release();}
  233. debuggerModel(){return this._object.debuggerModel();}
  234. runtimeModel(){return this._object.runtimeModel();}
  235. isNode(){return this._object.isNode();}};;Sources.JavaScriptBreakpointsSidebarPane=class extends UI.ThrottledWidget{constructor(){super(true);this.registerRequiredCSS('sources/javaScriptBreakpointsSidebarPane.css');this._breakpointManager=Bindings.breakpointManager;this._breakpointManager.addEventListener(Bindings.BreakpointManager.Events.BreakpointAdded,this.update,this);this._breakpointManager.addEventListener(Bindings.BreakpointManager.Events.BreakpointRemoved,this.update,this);Common.moduleSetting('breakpointsActive').addChangeListener(this.update,this);this._listElement=null;this.update();}
  236. doUpdate(){const breakpointLocations=this._breakpointManager.allBreakpointLocations().filter(breakpointLocation=>breakpointLocation.uiLocation.uiSourceCode.project().type()!==Workspace.projectTypes.Debugger);if(!breakpointLocations.length){this._listElement=null;this.contentElement.removeChildren();const emptyElement=this.contentElement.createChild('div','gray-info-message');emptyElement.textContent=Common.UIString('No breakpoints');this.contentElement.appendChild(emptyElement);this._didUpdateForTest();return Promise.resolve();}
  237. if(!this._listElement){this.contentElement.removeChildren();this._listElement=this.contentElement.createChild('div');this.contentElement.appendChild(this._listElement);}
  238. breakpointLocations.sort((item1,item2)=>item1.uiLocation.compareTo(item2.uiLocation));const breakpointEntriesForLine=new Platform.Multimap();const locationForEntry=new Platform.Multimap();for(const breakpointLocation of breakpointLocations){const uiLocation=breakpointLocation.uiLocation;const entryDescriptor=`${uiLocation.uiSourceCode.url()}:${uiLocation.lineNumber}:${uiLocation.columnNumber}`;locationForEntry.set(entryDescriptor,breakpointLocation);const lineDescriptor=`${uiLocation.uiSourceCode.url()}:${uiLocation.lineNumber}`;breakpointEntriesForLine.set(lineDescriptor,entryDescriptor);}
  239. const details=UI.context.flavor(SDK.DebuggerPausedDetails);const selectedUILocation=details&&details.callFrames.length?Bindings.debuggerWorkspaceBinding.rawLocationToUILocation(details.callFrames[0].location()):null;let shouldShowView=false;let entry=this._listElement.firstChild;const promises=[];for(const descriptor of locationForEntry.keysArray()){if(!entry){entry=this._listElement.createChild('div','breakpoint-entry');entry.addEventListener('contextmenu',this._breakpointContextMenu.bind(this),true);entry.addEventListener('click',this._revealLocation.bind(this),false);const checkboxLabel=UI.CheckboxLabel.create('');checkboxLabel.addEventListener('click',this._breakpointCheckboxClicked.bind(this),false);entry.appendChild(checkboxLabel);entry[Sources.JavaScriptBreakpointsSidebarPane._checkboxLabelSymbol]=checkboxLabel;const snippetElement=entry.createChild('div','source-text monospace');entry[Sources.JavaScriptBreakpointsSidebarPane._snippetElementSymbol]=snippetElement;}
  240. const locations=Array.from(locationForEntry.get(descriptor));const uiLocation=locations[0].uiLocation;const isSelected=!!selectedUILocation&&locations.some(location=>location.uiLocation.id()===selectedUILocation.id());const hasEnabled=locations.some(location=>location.breakpoint.enabled());const hasDisabled=locations.some(location=>!location.breakpoint.enabled());const showCoumn=breakpointEntriesForLine.get(`${uiLocation.uiSourceCode.url()}:${uiLocation.lineNumber}`).size>1;promises.push(this._resetEntry((entry),uiLocation,isSelected,hasEnabled,hasDisabled,showCoumn));entry[Sources.JavaScriptBreakpointsSidebarPane._breakpointLocationsSymbol]=locations;if(isSelected){shouldShowView=true;}
  241. entry=entry.nextSibling;}
  242. while(entry){const next=entry.nextSibling;entry.remove();entry=next;}
  243. if(shouldShowView){UI.viewManager.showView('sources.jsBreakpoints');}
  244. this._listElement.classList.toggle('breakpoints-list-deactivated',!Common.moduleSetting('breakpointsActive').get());return Promise.all(promises).then(()=>this._didUpdateForTest());}
  245. async _resetEntry(element,uiLocation,isSelected,hasEnabled,hasDisabled,showColumn){element[Sources.JavaScriptBreakpointsSidebarPane._locationSymbol]=uiLocation;element.classList.toggle('breakpoint-hit',isSelected);const checkboxLabel=element[Sources.JavaScriptBreakpointsSidebarPane._checkboxLabelSymbol];checkboxLabel.textElement.textContent=uiLocation.linkText()+(showColumn?':'+(uiLocation.columnNumber+1):'');checkboxLabel.checkboxElement.checked=hasEnabled;checkboxLabel.checkboxElement.indeterminate=hasEnabled&&hasDisabled;const snippetElement=element[Sources.JavaScriptBreakpointsSidebarPane._snippetElementSymbol];const{content}=await uiLocation.uiSourceCode.requestContent();const lineNumber=uiLocation.lineNumber;const text=new TextUtils.Text(content||'');if(lineNumber<text.lineCount()){const lineText=text.lineAt(lineNumber);const maxSnippetLength=200;snippetElement.textContent=lineText.substring(showColumn?uiLocation.columnNumber:0).trimEndWithMaxLength(maxSnippetLength);}}
  246. _breakpointLocations(event){const node=event.target.enclosingNodeOrSelfWithClass('breakpoint-entry');if(!node){return[];}
  247. return node[Sources.JavaScriptBreakpointsSidebarPane._breakpointLocationsSymbol]||[];}
  248. _breakpointCheckboxClicked(event){const breakpoints=this._breakpointLocations(event).map(breakpointLocation=>breakpointLocation.breakpoint);const newState=event.target.checkboxElement.checked;for(const breakpoint of breakpoints){breakpoint.setEnabled(newState);}
  249. event.consume();}
  250. _revealLocation(event){const uiLocations=this._breakpointLocations(event).map(breakpointLocation=>breakpointLocation.uiLocation);let uiLocation=null;for(const uiLocationCandidate of uiLocations){if(!uiLocation||uiLocationCandidate.columnNumber<uiLocation.columnNumber){uiLocation=uiLocationCandidate;}}
  251. if(uiLocation){Common.Revealer.reveal(uiLocation);}}
  252. _breakpointContextMenu(event){const breakpoints=this._breakpointLocations(event).map(breakpointLocation=>breakpointLocation.breakpoint);const contextMenu=new UI.ContextMenu(event);const removeEntryTitle=breakpoints.length>1?Common.UIString('Remove all breakpoints in line'):Common.UIString('Remove breakpoint');contextMenu.defaultSection().appendItem(removeEntryTitle,()=>breakpoints.map(breakpoint=>breakpoint.remove(false)));const breakpointActive=Common.moduleSetting('breakpointsActive').get();const breakpointActiveTitle=breakpointActive?Common.UIString('Deactivate breakpoints'):Common.UIString('Activate breakpoints');contextMenu.defaultSection().appendItem(breakpointActiveTitle,()=>Common.moduleSetting('breakpointsActive').set(!breakpointActive));if(breakpoints.some(breakpoint=>!breakpoint.enabled())){const enableTitle=Common.UIString('Enable all breakpoints');contextMenu.defaultSection().appendItem(enableTitle,this._toggleAllBreakpoints.bind(this,true));}
  253. if(breakpoints.some(breakpoint=>breakpoint.enabled())){const disableTitle=Common.UIString('Disable all breakpoints');contextMenu.defaultSection().appendItem(disableTitle,this._toggleAllBreakpoints.bind(this,false));}
  254. const removeAllTitle=Common.UIString('Remove all breakpoints');contextMenu.defaultSection().appendItem(removeAllTitle,this._removeAllBreakpoints.bind(this));const removeOtherTitle=Common.UIString('Remove other breakpoints');contextMenu.defaultSection().appendItem(removeOtherTitle,this._removeOtherBreakpoints.bind(this,new Set(breakpoints)));contextMenu.show();}
  255. _toggleAllBreakpoints(toggleState){for(const breakpointLocation of this._breakpointManager.allBreakpointLocations()){breakpointLocation.breakpoint.setEnabled(toggleState);}}
  256. _removeAllBreakpoints(){for(const breakpointLocation of this._breakpointManager.allBreakpointLocations()){breakpointLocation.breakpoint.remove(false);}}
  257. _removeOtherBreakpoints(selectedBreakpoints){for(const breakpointLocation of this._breakpointManager.allBreakpointLocations()){if(!selectedBreakpoints.has(breakpointLocation.breakpoint)){breakpointLocation.breakpoint.remove(false);}}}
  258. flavorChanged(object){this.update();}
  259. _didUpdateForTest(){}};Sources.JavaScriptBreakpointsSidebarPane._locationSymbol=Symbol('location');Sources.JavaScriptBreakpointsSidebarPane._checkboxLabelSymbol=Symbol('checkbox-label');Sources.JavaScriptBreakpointsSidebarPane._snippetElementSymbol=Symbol('snippet-element');Sources.JavaScriptBreakpointsSidebarPane._breakpointLocationsSymbol=Symbol('locations');;Sources.UISourceCodeFrame=class extends SourceFrame.SourceFrame{constructor(uiSourceCode){super(workingCopy);this._uiSourceCode=uiSourceCode;if(Root.Runtime.experiments.isEnabled('sourceDiff')){this._diff=new SourceFrame.SourceCodeDiff(this.textEditor);}
  260. this._muteSourceCodeEvents=false;this._isSettingContent=false;this._persistenceBinding=Persistence.persistence.binding(uiSourceCode);this._rowMessageBuckets=new Map();this._typeDecorationsPending=new Set();this._uiSourceCodeEventListeners=[];this._messageAndDecorationListeners=[];this._boundOnBindingChanged=this._onBindingChanged.bind(this);this.textEditor.addEventListener(SourceFrame.SourcesTextEditor.Events.EditorBlurred,()=>UI.context.setFlavor(Sources.UISourceCodeFrame,null));this.textEditor.addEventListener(SourceFrame.SourcesTextEditor.Events.EditorFocused,()=>UI.context.setFlavor(Sources.UISourceCodeFrame,this));Common.settings.moduleSetting('persistenceNetworkOverridesEnabled').addChangeListener(this._onNetworkPersistenceChanged,this);this._errorPopoverHelper=new UI.PopoverHelper(this.element,this._getErrorPopoverContent.bind(this));this._errorPopoverHelper.setHasPadding(true);this._errorPopoverHelper.setTimeout(100,100);this._plugins=[];this._initializeUISourceCode();function workingCopy(){if(uiSourceCode.isDirty()){return Promise.resolve({content:uiSourceCode.workingCopy(),isEncoded:false});}
  261. return uiSourceCode.requestContent();}}
  262. _installMessageAndDecorationListeners(){if(this._persistenceBinding){const networkSourceCode=this._persistenceBinding.network;const fileSystemSourceCode=this._persistenceBinding.fileSystem;this._messageAndDecorationListeners=[networkSourceCode.addEventListener(Workspace.UISourceCode.Events.MessageAdded,this._onMessageAdded,this),networkSourceCode.addEventListener(Workspace.UISourceCode.Events.MessageRemoved,this._onMessageRemoved,this),networkSourceCode.addEventListener(Workspace.UISourceCode.Events.LineDecorationAdded,this._onLineDecorationAdded,this),networkSourceCode.addEventListener(Workspace.UISourceCode.Events.LineDecorationRemoved,this._onLineDecorationRemoved,this),fileSystemSourceCode.addEventListener(Workspace.UISourceCode.Events.MessageAdded,this._onMessageAdded,this),fileSystemSourceCode.addEventListener(Workspace.UISourceCode.Events.MessageRemoved,this._onMessageRemoved,this),];}else{this._messageAndDecorationListeners=[this._uiSourceCode.addEventListener(Workspace.UISourceCode.Events.MessageAdded,this._onMessageAdded,this),this._uiSourceCode.addEventListener(Workspace.UISourceCode.Events.MessageRemoved,this._onMessageRemoved,this),this._uiSourceCode.addEventListener(Workspace.UISourceCode.Events.LineDecorationAdded,this._onLineDecorationAdded,this),this._uiSourceCode.addEventListener(Workspace.UISourceCode.Events.LineDecorationRemoved,this._onLineDecorationRemoved,this)];}}
  263. uiSourceCode(){return this._uiSourceCode;}
  264. setUISourceCode(uiSourceCode){this._unloadUISourceCode();this._uiSourceCode=uiSourceCode;if(uiSourceCode.contentLoaded()){if(uiSourceCode.workingCopy()!==this.textEditor.text()){this._innerSetContent(uiSourceCode.workingCopy());}}else{uiSourceCode.requestContent().then(()=>{if(this._uiSourceCode!==uiSourceCode){return;}
  265. if(uiSourceCode.workingCopy()!==this.textEditor.text()){this._innerSetContent(uiSourceCode.workingCopy());}});}
  266. this._initializeUISourceCode();}
  267. _unloadUISourceCode(){this._disposePlugins();for(const message of this._allMessages()){this._removeMessageFromSource(message);}
  268. Common.EventTarget.removeEventListeners(this._messageAndDecorationListeners);Common.EventTarget.removeEventListeners(this._uiSourceCodeEventListeners);this._uiSourceCode.removeWorkingCopyGetter();Persistence.persistence.unsubscribeFromBindingEvent(this._uiSourceCode,this._boundOnBindingChanged);}
  269. _initializeUISourceCode(){this._uiSourceCodeEventListeners=[this._uiSourceCode.addEventListener(Workspace.UISourceCode.Events.WorkingCopyChanged,this._onWorkingCopyChanged,this),this._uiSourceCode.addEventListener(Workspace.UISourceCode.Events.WorkingCopyCommitted,this._onWorkingCopyCommitted,this),this._uiSourceCode.addEventListener(Workspace.UISourceCode.Events.TitleChanged,this._refreshHighlighterType,this)];Persistence.persistence.subscribeForBindingEvent(this._uiSourceCode,this._boundOnBindingChanged);for(const message of this._allMessages()){this._addMessageToSource(message);}
  270. this._installMessageAndDecorationListeners();this._updateStyle();this._decorateAllTypes();this._refreshHighlighterType();if(Root.Runtime.experiments.isEnabled('sourcesPrettyPrint')){const supportedPrettyTypes=new Set(['text/html','text/css','text/javascript']);this.setCanPrettyPrint(supportedPrettyTypes.has(this.highlighterType()),true);}
  271. this._ensurePluginsLoaded();}
  272. wasShown(){super.wasShown();setImmediate(this._updateBucketDecorations.bind(this));this.setEditable(this._canEditSource());for(const plugin of this._plugins){plugin.wasShown();}}
  273. willHide(){for(const plugin of this._plugins){plugin.willHide();}
  274. super.willHide();UI.context.setFlavor(Sources.UISourceCodeFrame,null);this._uiSourceCode.removeWorkingCopyGetter();}
  275. _refreshHighlighterType(){const binding=Persistence.persistence.binding(this._uiSourceCode);const highlighterType=binding?binding.network.mimeType():this._uiSourceCode.mimeType();if(this.highlighterType()===highlighterType){return;}
  276. this._disposePlugins();this.setHighlighterType(highlighterType);this._ensurePluginsLoaded();}
  277. _canEditSource(){if(this.hasLoadError()){return false;}
  278. if(Persistence.persistence.binding(this._uiSourceCode)){return true;}
  279. if(this._uiSourceCode.project().canSetFileContent()){return true;}
  280. if(this._uiSourceCode.project().isServiceProject()){return false;}
  281. if(this._uiSourceCode.project().type()===Workspace.projectTypes.Network&&Persistence.networkPersistenceManager.active()){return true;}
  282. if(this.pretty&&this._uiSourceCode.contentType().hasScripts()){return false;}
  283. return this._uiSourceCode.contentType()!==Common.resourceTypes.Document;}
  284. _onNetworkPersistenceChanged(){this.setEditable(this._canEditSource());}
  285. commitEditing(){if(!this._uiSourceCode.isDirty()){return;}
  286. this._muteSourceCodeEvents=true;this._uiSourceCode.commitWorkingCopy();this._muteSourceCodeEvents=false;}
  287. setContent(content,loadError){this._disposePlugins();this._rowMessageBuckets.clear();super.setContent(content,loadError);for(const message of this._allMessages()){this._addMessageToSource(message);}
  288. this._decorateAllTypes();this._ensurePluginsLoaded();}
  289. _allMessages(){if(this._persistenceBinding){const combinedSet=this._persistenceBinding.network.messages();combinedSet.addAll(this._persistenceBinding.fileSystem.messages());return combinedSet;}
  290. return this._uiSourceCode.messages();}
  291. onTextChanged(oldRange,newRange){const wasPretty=this.pretty;super.onTextChanged(oldRange,newRange);this._errorPopoverHelper.hidePopover();if(this._isSettingContent){return;}
  292. Sources.SourcesPanel.instance().updateLastModificationTime();this._muteSourceCodeEvents=true;if(this.isClean()){this._uiSourceCode.resetWorkingCopy();}else{this._uiSourceCode.setWorkingCopyGetter(this.textEditor.text.bind(this.textEditor));}
  293. this._muteSourceCodeEvents=false;if(wasPretty!==this.pretty){this._updateStyle();this._disposePlugins();this._ensurePluginsLoaded();}}
  294. _onWorkingCopyChanged(event){if(this._muteSourceCodeEvents){return;}
  295. this._innerSetContent(this._uiSourceCode.workingCopy());}
  296. _onWorkingCopyCommitted(event){if(!this._muteSourceCodeEvents){this._innerSetContent(this._uiSourceCode.workingCopy());}
  297. this.contentCommitted();this._updateStyle();}
  298. _ensurePluginsLoaded(){if(!this.loaded||this._plugins.length){return;}
  299. const binding=Persistence.persistence.binding(this._uiSourceCode);const pluginUISourceCode=binding?binding.network:this._uiSourceCode;if(Sources.DebuggerPlugin.accepts(pluginUISourceCode)){this._plugins.push(new Sources.DebuggerPlugin(this.textEditor,pluginUISourceCode,this.transformer()));}
  300. if(Sources.CSSPlugin.accepts(pluginUISourceCode)){this._plugins.push(new Sources.CSSPlugin(this.textEditor));}
  301. if(!this.pretty&&Sources.JavaScriptCompilerPlugin.accepts(pluginUISourceCode)){this._plugins.push(new Sources.JavaScriptCompilerPlugin(this.textEditor,pluginUISourceCode));}
  302. if(Sources.SnippetsPlugin.accepts(pluginUISourceCode)){this._plugins.push(new Sources.SnippetsPlugin(this.textEditor,pluginUISourceCode));}
  303. if(Sources.ScriptOriginPlugin.accepts(pluginUISourceCode)){this._plugins.push(new Sources.ScriptOriginPlugin(this.textEditor,pluginUISourceCode));}
  304. if(!this.pretty&&Root.Runtime.experiments.isEnabled('sourceDiff')&&Sources.GutterDiffPlugin.accepts(pluginUISourceCode)){this._plugins.push(new Sources.GutterDiffPlugin(this.textEditor,pluginUISourceCode));}
  305. this.dispatchEventToListeners(Sources.UISourceCodeFrame.Events.ToolbarItemsChanged);for(const plugin of this._plugins){plugin.wasShown();}}
  306. _disposePlugins(){this.textEditor.operation(()=>{for(const plugin of this._plugins){plugin.dispose();}});this._plugins=[];}
  307. _onBindingChanged(){const binding=Persistence.persistence.binding(this._uiSourceCode);if(binding===this._persistenceBinding){return;}
  308. this._unloadUISourceCode();this._persistenceBinding=binding;this._initializeUISourceCode();}
  309. _updateStyle(){this.setEditable(this._canEditSource());}
  310. _innerSetContent(content){this._isSettingContent=true;const oldContent=this.textEditor.text();if(this._diff){this._diff.highlightModifiedLines(oldContent,content);}
  311. if(oldContent!==content){this.setContent(content,null);}
  312. this._isSettingContent=false;}
  313. async populateTextAreaContextMenu(contextMenu,editorLineNumber,editorColumnNumber){await super.populateTextAreaContextMenu(contextMenu,editorLineNumber,editorColumnNumber);contextMenu.appendApplicableItems(this._uiSourceCode);const location=this.transformer().editorToRawLocation(editorLineNumber,editorColumnNumber);contextMenu.appendApplicableItems(new Workspace.UILocation(this._uiSourceCode,location[0],location[1]));contextMenu.appendApplicableItems(this);for(const plugin of this._plugins){await plugin.populateTextAreaContextMenu(contextMenu,editorLineNumber,editorColumnNumber);}}
  314. dispose(){this._errorPopoverHelper.dispose();this._unloadUISourceCode();this.textEditor.dispose();this.detach();Common.settings.moduleSetting('persistenceNetworkOverridesEnabled').removeChangeListener(this._onNetworkPersistenceChanged,this);}
  315. _onMessageAdded(event){const message=(event.data);this._addMessageToSource(message);}
  316. _addMessageToSource(message){if(!this.loaded){return;}
  317. const editorLocation=this.transformer().rawToEditorLocation(message.lineNumber(),message.columnNumber());let editorLineNumber=editorLocation[0];if(editorLineNumber>=this.textEditor.linesCount){editorLineNumber=this.textEditor.linesCount-1;}
  318. if(editorLineNumber<0){editorLineNumber=0;}
  319. let messageBucket=this._rowMessageBuckets.get(editorLineNumber);if(!messageBucket){messageBucket=new Sources.UISourceCodeFrame.RowMessageBucket(this,this.textEditor,editorLineNumber);this._rowMessageBuckets.set(editorLineNumber,messageBucket);}
  320. messageBucket.addMessage(message);}
  321. _onMessageRemoved(event){const message=(event.data);this._removeMessageFromSource(message);}
  322. _removeMessageFromSource(message){if(!this.loaded){return;}
  323. const editorLocation=this.transformer().rawToEditorLocation(message.lineNumber(),message.columnNumber());let editorLineNumber=editorLocation[0];if(editorLineNumber>=this.textEditor.linesCount){editorLineNumber=this.textEditor.linesCount-1;}
  324. if(editorLineNumber<0){editorLineNumber=0;}
  325. const messageBucket=this._rowMessageBuckets.get(editorLineNumber);if(!messageBucket){return;}
  326. messageBucket.removeMessage(message);if(!messageBucket.uniqueMessagesCount()){messageBucket.detachFromEditor();this._rowMessageBuckets.delete(editorLineNumber);}}
  327. _getErrorPopoverContent(event){const element=event.target.enclosingNodeOrSelfWithClass('text-editor-line-decoration-icon')||event.target.enclosingNodeOrSelfWithClass('text-editor-line-decoration-wave');if(!element){return null;}
  328. const anchor=element.enclosingNodeOrSelfWithClass('text-editor-line-decoration-icon')?element.boxInWindow():new AnchorBox(event.clientX,event.clientY,1,1);return{box:anchor,show:popover=>{const messageBucket=element.enclosingNodeOrSelfWithClass('text-editor-line-decoration')._messageBucket;const messagesOutline=messageBucket.messagesDescription();popover.contentElement.appendChild(messagesOutline);return Promise.resolve(true);}};}
  329. _updateBucketDecorations(){for(const bucket of this._rowMessageBuckets.values()){bucket._updateDecoration();}}
  330. _onLineDecorationAdded(event){const marker=(event.data);this._decorateTypeThrottled(marker.type());}
  331. _onLineDecorationRemoved(event){const marker=(event.data);this._decorateTypeThrottled(marker.type());}
  332. async _decorateTypeThrottled(type){if(this._typeDecorationsPending.has(type)){return;}
  333. this._typeDecorationsPending.add(type);const decorator=await self.runtime.extensions(SourceFrame.LineDecorator).find(extension=>extension.descriptor()['decoratorType']===type).instance();this._typeDecorationsPending.delete(type);this.textEditor.codeMirror().operation(()=>{decorator.decorate(this._persistenceBinding?this._persistenceBinding.network:this.uiSourceCode(),this.textEditor,type);});}
  334. _decorateAllTypes(){if(!this.loaded){return;}
  335. for(const extension of self.runtime.extensions(SourceFrame.LineDecorator)){const type=extension.descriptor()['decoratorType'];if(this._uiSourceCode.decorationsForType(type)){this._decorateTypeThrottled(type);}}}
  336. syncToolbarItems(){const leftToolbarItems=super.syncToolbarItems();const rightToolbarItems=[];for(const plugin of this._plugins){leftToolbarItems.pushAll(plugin.leftToolbarItems());rightToolbarItems.pushAll(plugin.rightToolbarItems());}
  337. if(!rightToolbarItems.length){return leftToolbarItems;}
  338. return[...leftToolbarItems,new UI.ToolbarSeparator(true),...rightToolbarItems];}
  339. async populateLineGutterContextMenu(contextMenu,lineNumber){await super.populateLineGutterContextMenu(contextMenu,lineNumber);for(const plugin of this._plugins){await plugin.populateLineGutterContextMenu(contextMenu,lineNumber);}}};Sources.UISourceCodeFrame._iconClassPerLevel={};Sources.UISourceCodeFrame._iconClassPerLevel[Workspace.UISourceCode.Message.Level.Error]='smallicon-error';Sources.UISourceCodeFrame._iconClassPerLevel[Workspace.UISourceCode.Message.Level.Warning]='smallicon-warning';Sources.UISourceCodeFrame._bubbleTypePerLevel={};Sources.UISourceCodeFrame._bubbleTypePerLevel[Workspace.UISourceCode.Message.Level.Error]='error';Sources.UISourceCodeFrame._bubbleTypePerLevel[Workspace.UISourceCode.Message.Level.Warning]='warning';Sources.UISourceCodeFrame._lineClassPerLevel={};Sources.UISourceCodeFrame._lineClassPerLevel[Workspace.UISourceCode.Message.Level.Error]='text-editor-line-with-error';Sources.UISourceCodeFrame._lineClassPerLevel[Workspace.UISourceCode.Message.Level.Warning]='text-editor-line-with-warning';Sources.UISourceCodeFrame.RowMessage=class{constructor(message){this._message=message;this._repeatCount=1;this.element=createElementWithClass('div','text-editor-row-message');this._icon=this.element.createChild('label','','dt-icon-label');this._icon.type=Sources.UISourceCodeFrame._iconClassPerLevel[message.level()];this._repeatCountElement=this.element.createChild('span','text-editor-row-message-repeat-count hidden','dt-small-bubble');this._repeatCountElement.type=Sources.UISourceCodeFrame._bubbleTypePerLevel[message.level()];const linesContainer=this.element.createChild('div');const lines=this._message.text().split('\n');for(let i=0;i<lines.length;++i){const messageLine=linesContainer.createChild('div');messageLine.textContent=lines[i];}}
  340. message(){return this._message;}
  341. repeatCount(){return this._repeatCount;}
  342. setRepeatCount(repeatCount){if(this._repeatCount===repeatCount){return;}
  343. this._repeatCount=repeatCount;this._updateMessageRepeatCount();}
  344. _updateMessageRepeatCount(){this._repeatCountElement.textContent=this._repeatCount;const showRepeatCount=this._repeatCount>1;this._repeatCountElement.classList.toggle('hidden',!showRepeatCount);this._icon.classList.toggle('hidden',showRepeatCount);}};Sources.UISourceCodeFrame.RowMessageBucket=class{constructor(sourceFrame,textEditor,editorLineNumber){this._sourceFrame=sourceFrame;this.textEditor=textEditor;this._lineHandle=textEditor.textEditorPositionHandle(editorLineNumber,0);this._decoration=createElementWithClass('div','text-editor-line-decoration');this._decoration._messageBucket=this;this._wave=this._decoration.createChild('div','text-editor-line-decoration-wave');this._icon=this._wave.createChild('span','text-editor-line-decoration-icon','dt-icon-label');this._decorationStartColumn=null;this._messagesDescriptionElement=createElementWithClass('div','text-editor-messages-description-container');this._messages=[];this._level=null;}
  345. _updateWavePosition(editorLineNumber,columnNumber){editorLineNumber=Math.min(editorLineNumber,this.textEditor.linesCount-1);const lineText=this.textEditor.line(editorLineNumber);columnNumber=Math.min(columnNumber,lineText.length);const lineIndent=TextUtils.TextUtils.lineIndent(lineText).length;const startColumn=Math.max(columnNumber-1,lineIndent);if(this._decorationStartColumn===startColumn){return;}
  346. if(this._decorationStartColumn!==null){this.textEditor.removeDecoration(this._decoration,editorLineNumber);}
  347. this.textEditor.addDecoration(this._decoration,editorLineNumber,startColumn);this._decorationStartColumn=startColumn;}
  348. messagesDescription(){this._messagesDescriptionElement.removeChildren();UI.appendStyle(this._messagesDescriptionElement,'source_frame/messagesPopover.css');for(let i=0;i<this._messages.length;++i){this._messagesDescriptionElement.appendChild(this._messages[i].element);}
  349. return this._messagesDescriptionElement;}
  350. detachFromEditor(){const position=this._lineHandle.resolve();if(!position){return;}
  351. const editorLineNumber=position.lineNumber;if(this._level){this.textEditor.toggleLineClass(editorLineNumber,Sources.UISourceCodeFrame._lineClassPerLevel[this._level],false);}
  352. if(this._decorationStartColumn!==null){this.textEditor.removeDecoration(this._decoration,editorLineNumber);this._decorationStartColumn=null;}}
  353. uniqueMessagesCount(){return this._messages.length;}
  354. addMessage(message){for(let i=0;i<this._messages.length;++i){const rowMessage=this._messages[i];if(rowMessage.message().isEqual(message)){rowMessage.setRepeatCount(rowMessage.repeatCount()+1);return;}}
  355. const rowMessage=new Sources.UISourceCodeFrame.RowMessage(message);this._messages.push(rowMessage);this._updateDecoration();}
  356. removeMessage(message){for(let i=0;i<this._messages.length;++i){const rowMessage=this._messages[i];if(!rowMessage.message().isEqual(message)){continue;}
  357. rowMessage.setRepeatCount(rowMessage.repeatCount()-1);if(!rowMessage.repeatCount()){this._messages.splice(i,1);}
  358. this._updateDecoration();return;}}
  359. _updateDecoration(){if(!this._sourceFrame.isShowing()){return;}
  360. if(!this._messages.length){return;}
  361. const position=this._lineHandle.resolve();if(!position){return;}
  362. const editorLineNumber=position.lineNumber;let columnNumber=Number.MAX_VALUE;let maxMessage=null;for(let i=0;i<this._messages.length;++i){const message=this._messages[i].message();const editorLocation=this._sourceFrame.transformer().rawToEditorLocation(editorLineNumber,message.columnNumber());columnNumber=Math.min(columnNumber,editorLocation[1]);if(!maxMessage||Workspace.UISourceCode.Message.messageLevelComparator(maxMessage,message)<0){maxMessage=message;}}
  363. this._updateWavePosition(editorLineNumber,columnNumber);if(this._level===maxMessage.level()){return;}
  364. if(this._level){this.textEditor.toggleLineClass(editorLineNumber,Sources.UISourceCodeFrame._lineClassPerLevel[this._level],false);this._icon.type='';}
  365. this._level=maxMessage.level();if(!this._level){return;}
  366. this.textEditor.toggleLineClass(editorLineNumber,Sources.UISourceCodeFrame._lineClassPerLevel[this._level],true);this._icon.type=Sources.UISourceCodeFrame._iconClassPerLevel[this._level];}};Workspace.UISourceCode.Message._messageLevelPriority={'Warning':3,'Error':4};Workspace.UISourceCode.Message.messageLevelComparator=function(a,b){return Workspace.UISourceCode.Message._messageLevelPriority[a.level()]-
  367. Workspace.UISourceCode.Message._messageLevelPriority[b.level()];};Sources.UISourceCodeFrame.Plugin=class{static accepts(uiSourceCode){return false;}
  368. wasShown(){}
  369. willHide(){}
  370. rightToolbarItems(){return[];}
  371. leftToolbarItems(){return[];}
  372. populateLineGutterContextMenu(contextMenu,lineNumber){return Promise.resolve();}
  373. populateTextAreaContextMenu(contextMenu,lineNumber,columnNumber){return Promise.resolve();}
  374. dispose(){}};Sources.UISourceCodeFrame.Events={ToolbarItemsChanged:Symbol('ToolbarItemsChanged')};;Sources.DebuggerPlugin=class extends Sources.UISourceCodeFrame.Plugin{constructor(textEditor,uiSourceCode,transformer){super();this._textEditor=textEditor;this._uiSourceCode=uiSourceCode;this._transformer=transformer;this._executionLocation=null;this._controlDown=false;this._asyncStepInHoveredLine=0;this._asyncStepInHovered=false;this._clearValueWidgetsTimer=null;this._sourceMapInfobar=null;this._controlTimeout=null;this._scriptsPanel=Sources.SourcesPanel.instance();this._breakpointManager=Bindings.breakpointManager;if(uiSourceCode.project().type()===Workspace.projectTypes.Debugger){this._textEditor.element.classList.add('source-frame-debugger-script');}
  375. this._popoverHelper=new UI.PopoverHelper(this._scriptsPanel.element,this._getPopoverRequest.bind(this));this._popoverHelper.setDisableOnClick(true);this._popoverHelper.setTimeout(250,250);this._popoverHelper.setHasPadding(true);this._boundPopoverHelperHide=this._popoverHelper.hidePopover.bind(this._popoverHelper);this._scriptsPanel.element.addEventListener('scroll',this._boundPopoverHelperHide,true);this._boundKeyDown=(this._onKeyDown.bind(this));this._textEditor.element.addEventListener('keydown',this._boundKeyDown,true);this._boundKeyUp=(this._onKeyUp.bind(this));this._textEditor.element.addEventListener('keyup',this._boundKeyUp,true);this._boundMouseMove=(this._onMouseMove.bind(this));this._textEditor.element.addEventListener('mousemove',this._boundMouseMove,false);this._boundMouseDown=(this._onMouseDown.bind(this));this._textEditor.element.addEventListener('mousedown',this._boundMouseDown,true);this._boundBlur=this._onBlur.bind(this);this._textEditor.element.addEventListener('focusout',this._boundBlur,false);this._boundWheel=event=>{if(this._executionLocation&&UI.KeyboardShortcut.eventHasCtrlOrMeta(event)){event.preventDefault();}};this._textEditor.element.addEventListener('wheel',this._boundWheel,true);this._textEditor.addEventListener(SourceFrame.SourcesTextEditor.Events.GutterClick,this._handleGutterClick,this);this._breakpointManager.addEventListener(Bindings.BreakpointManager.Events.BreakpointAdded,this._breakpointAdded,this);this._breakpointManager.addEventListener(Bindings.BreakpointManager.Events.BreakpointRemoved,this._breakpointRemoved,this);this._uiSourceCode.addEventListener(Workspace.UISourceCode.Events.WorkingCopyChanged,this._workingCopyChanged,this);this._uiSourceCode.addEventListener(Workspace.UISourceCode.Events.WorkingCopyCommitted,this._workingCopyCommitted,this);this._breakpointDecorations=new Set();this._decorationByBreakpoint=new Map();this._possibleBreakpointsRequested=new Set();this._scriptFileForDebuggerModel=new Map();Common.moduleSetting('skipStackFramesPattern').addChangeListener(this._showBlackboxInfobarIfNeeded,this);Common.moduleSetting('skipContentScripts').addChangeListener(this._showBlackboxInfobarIfNeeded,this);this._valueWidgets=new Map();this._continueToLocationDecorations=null;UI.context.addFlavorChangeListener(SDK.DebuggerModel.CallFrame,this._callFrameChanged,this);this._liveLocationPool=new Bindings.LiveLocationPool();this._callFrameChanged();this._updateScriptFiles();if(this._uiSourceCode.isDirty()){this._muted=true;this._mutedFromStart=true;}else{this._muted=false;this._mutedFromStart=false;this._initializeBreakpoints();}
  376. this._blackboxInfobar=null;this._showBlackboxInfobarIfNeeded();const scriptFiles=this._scriptFileForDebuggerModel.valuesArray();for(let i=0;i<scriptFiles.length;++i){scriptFiles[i].checkMapping();}
  377. this._hasLineWithoutMapping=false;this._updateLinesWithoutMappingHighlight();if(!Root.Runtime.experiments.isEnabled('sourcesPrettyPrint')){this._prettyPrintInfobar=null;this._detectMinified();}}
  378. static accepts(uiSourceCode){return uiSourceCode.contentType().hasScripts();}
  379. _showBlackboxInfobarIfNeeded(){const uiSourceCode=this._uiSourceCode;if(!uiSourceCode.contentType().hasScripts()){return;}
  380. const projectType=uiSourceCode.project().type();if(!Bindings.blackboxManager.isBlackboxedUISourceCode(uiSourceCode)){this._hideBlackboxInfobar();return;}
  381. if(this._blackboxInfobar){this._blackboxInfobar.dispose();}
  382. const infobar=new UI.Infobar(UI.Infobar.Type.Warning,Common.UIString('This script is blackboxed in debugger'));this._blackboxInfobar=infobar;infobar.createDetailsRowMessage(Common.UIString('Debugger will skip stepping through this script, and will not stop on exceptions'));const scriptFile=this._scriptFileForDebuggerModel.size?this._scriptFileForDebuggerModel.valuesArray()[0]:null;if(scriptFile&&scriptFile.hasSourceMapURL()){infobar.createDetailsRowMessage(Common.UIString('Source map found, but ignored for blackboxed file.'));}
  383. infobar.createDetailsRowMessage();infobar.createDetailsRowMessage(Common.UIString('Possible ways to cancel this behavior are:'));infobar.createDetailsRowMessage(' - ').createTextChild(Common.UIString('Go to "%s" tab in settings',Common.UIString('Blackboxing')));const unblackboxLink=infobar.createDetailsRowMessage(' - ').createChild('span','link');unblackboxLink.textContent=Common.UIString('Unblackbox this script');unblackboxLink.addEventListener('click',unblackbox,false);function unblackbox(){Bindings.blackboxManager.unblackboxUISourceCode(uiSourceCode);if(projectType===Workspace.projectTypes.ContentScripts){Bindings.blackboxManager.unblackboxContentScripts();}}
  384. this._textEditor.attachInfobar(this._blackboxInfobar);}
  385. _hideBlackboxInfobar(){if(!this._blackboxInfobar){return;}
  386. this._blackboxInfobar.dispose();this._blackboxInfobar=null;}
  387. wasShown(){if(this._executionLocation){setImmediate(()=>{this._generateValuesInSource();});}}
  388. willHide(){this._popoverHelper.hidePopover();}
  389. populateLineGutterContextMenu(contextMenu,editorLineNumber){function populate(resolve,reject){const uiLocation=new Workspace.UILocation(this._uiSourceCode,editorLineNumber,0);this._scriptsPanel.appendUILocationItems(contextMenu,uiLocation);const breakpoints=this._lineBreakpointDecorations(editorLineNumber).map(decoration=>decoration.breakpoint).filter(breakpoint=>!!breakpoint);if(!breakpoints.length){contextMenu.debugSection().appendItem(Common.UIString('Add breakpoint'),this._createNewBreakpoint.bind(this,editorLineNumber,'',true));contextMenu.debugSection().appendItem(Common.UIString('Add conditional breakpoint\u2026'),this._editBreakpointCondition.bind(this,editorLineNumber,null,null));contextMenu.debugSection().appendItem(ls`Add logpoint\u2026`,this._editBreakpointCondition.bind(this,editorLineNumber,null,null,true));contextMenu.debugSection().appendItem(Common.UIString('Never pause here'),this._createNewBreakpoint.bind(this,editorLineNumber,'false',true));}else{const hasOneBreakpoint=breakpoints.length===1;const removeTitle=hasOneBreakpoint?Common.UIString('Remove breakpoint'):Common.UIString('Remove all breakpoints in line');contextMenu.debugSection().appendItem(removeTitle,()=>breakpoints.map(breakpoint=>breakpoint.remove()));if(hasOneBreakpoint){contextMenu.debugSection().appendItem(Common.UIString('Edit breakpoint\u2026'),this._editBreakpointCondition.bind(this,editorLineNumber,breakpoints[0],null));}
  390. const hasEnabled=breakpoints.some(breakpoint=>breakpoint.enabled());if(hasEnabled){const title=hasOneBreakpoint?Common.UIString('Disable breakpoint'):Common.UIString('Disable all breakpoints in line');contextMenu.debugSection().appendItem(title,()=>breakpoints.map(breakpoint=>breakpoint.setEnabled(false)));}
  391. const hasDisabled=breakpoints.some(breakpoint=>!breakpoint.enabled());if(hasDisabled){const title=hasOneBreakpoint?Common.UIString('Enable breakpoint'):Common.UIString('Enabled all breakpoints in line');contextMenu.debugSection().appendItem(title,()=>breakpoints.map(breakpoint=>breakpoint.setEnabled(true)));}}
  392. resolve();}
  393. return new Promise(populate.bind(this));}
  394. populateTextAreaContextMenu(contextMenu,editorLineNumber,editorColumnNumber){function addSourceMapURL(scriptFile){const dialog=new Sources.AddSourceMapURLDialog(addSourceMapURLDialogCallback.bind(null,scriptFile));dialog.show();}
  395. function addSourceMapURLDialogCallback(scriptFile,url){if(!url){return;}
  396. scriptFile.addSourceMapURL(url);}
  397. function populateSourceMapMembers(){if(this._uiSourceCode.project().type()===Workspace.projectTypes.Network&&Common.moduleSetting('jsSourceMapsEnabled').get()&&!Bindings.blackboxManager.isBlackboxedUISourceCode(this._uiSourceCode)){if(this._scriptFileForDebuggerModel.size){const scriptFile=this._scriptFileForDebuggerModel.valuesArray()[0];const addSourceMapURLLabel=Common.UIString('Add source map\u2026');contextMenu.debugSection().appendItem(addSourceMapURLLabel,addSourceMapURL.bind(null,scriptFile));}}}
  398. return super.populateTextAreaContextMenu(contextMenu,editorLineNumber,editorColumnNumber).then(populateSourceMapMembers.bind(this));}
  399. _workingCopyChanged(){if(this._scriptFileForDebuggerModel.size){return;}
  400. if(this._uiSourceCode.isDirty()){this._muteBreakpointsWhileEditing();}else{this._restoreBreakpointsAfterEditing();}}
  401. _workingCopyCommitted(event){this._scriptsPanel.updateLastModificationTime();if(!this._scriptFileForDebuggerModel.size){this._restoreBreakpointsAfterEditing();}}
  402. _didMergeToVM(){this._restoreBreakpointsIfConsistentScripts();}
  403. _didDivergeFromVM(){this._muteBreakpointsWhileEditing();}
  404. _muteBreakpointsWhileEditing(){if(this._muted){return;}
  405. for(const decoration of this._breakpointDecorations){this._updateBreakpointDecoration(decoration);}
  406. this._muted=true;}
  407. _restoreBreakpointsIfConsistentScripts(){const scriptFiles=this._scriptFileForDebuggerModel.valuesArray();for(let i=0;i<scriptFiles.length;++i){if(scriptFiles[i].hasDivergedFromVM()||scriptFiles[i].isMergingToVM()){return;}}
  408. this._restoreBreakpointsAfterEditing();}
  409. _restoreBreakpointsAfterEditing(){this._muted=false;if(this._mutedFromStart){this._mutedFromStart=false;this._initializeBreakpoints();return;}
  410. const decorations=Array.from(this._breakpointDecorations);this._breakpointDecorations.clear();this._textEditor.operation(()=>decorations.map(decoration=>decoration.hide()));for(const decoration of decorations){if(!decoration.breakpoint){continue;}
  411. const enabled=decoration.enabled;decoration.breakpoint.remove();const location=decoration.handle.resolve();if(location){this._setBreakpoint(location.lineNumber,location.columnNumber,decoration.condition,enabled);}}}
  412. _isIdentifier(tokenType){return tokenType.startsWith('js-variable')||tokenType.startsWith('js-property')||tokenType==='js-def';}
  413. _getPopoverRequest(event){if(UI.KeyboardShortcut.eventHasCtrlOrMeta(event)){return null;}
  414. const target=UI.context.flavor(SDK.Target);const debuggerModel=target?target.model(SDK.DebuggerModel):null;if(!debuggerModel||!debuggerModel.isPaused()){return null;}
  415. const textPosition=this._textEditor.coordinatesToCursorPosition(event.x,event.y);if(!textPosition){return null;}
  416. const mouseLine=textPosition.startLine;const mouseColumn=textPosition.startColumn;const textSelection=this._textEditor.selection().normalize();let anchorBox;let editorLineNumber;let startHighlight;let endHighlight;const selectedCallFrame=(UI.context.flavor(SDK.DebuggerModel.CallFrame));if(!selectedCallFrame){return null;}
  417. if(textSelection&&!textSelection.isEmpty()){if(textSelection.startLine!==textSelection.endLine||textSelection.startLine!==mouseLine||mouseColumn<textSelection.startColumn||mouseColumn>textSelection.endColumn){return null;}
  418. const leftCorner=this._textEditor.cursorPositionToCoordinates(textSelection.startLine,textSelection.startColumn);const rightCorner=this._textEditor.cursorPositionToCoordinates(textSelection.endLine,textSelection.endColumn);anchorBox=new AnchorBox(leftCorner.x,leftCorner.y,rightCorner.x-leftCorner.x,leftCorner.height);editorLineNumber=textSelection.startLine;startHighlight=textSelection.startColumn;endHighlight=textSelection.endColumn-1;}else{const token=this._textEditor.tokenAtTextPosition(textPosition.startLine,textPosition.startColumn);if(!token||!token.type){return null;}
  419. editorLineNumber=textPosition.startLine;const line=this._textEditor.line(editorLineNumber);const tokenContent=line.substring(token.startColumn,token.endColumn);const isIdentifier=this._isIdentifier(token.type);if(!isIdentifier&&(token.type!=='js-keyword'||tokenContent!=='this')){return null;}
  420. const leftCorner=this._textEditor.cursorPositionToCoordinates(editorLineNumber,token.startColumn);const rightCorner=this._textEditor.cursorPositionToCoordinates(editorLineNumber,token.endColumn-1);anchorBox=new AnchorBox(leftCorner.x,leftCorner.y,rightCorner.x-leftCorner.x,leftCorner.height);startHighlight=token.startColumn;endHighlight=token.endColumn-1;while(startHighlight>1&&line.charAt(startHighlight-1)==='.'){const tokenBefore=this._textEditor.tokenAtTextPosition(editorLineNumber,startHighlight-2);if(!tokenBefore||!tokenBefore.type){return null;}
  421. if(tokenBefore.type==='js-meta'){break;}
  422. if(tokenBefore.type==='js-string-2'){if(tokenBefore.endColumn<2){return null;}
  423. startHighlight=line.lastIndexOf('`',tokenBefore.endColumn-2);if(startHighlight<0){return null;}
  424. break;}
  425. startHighlight=tokenBefore.startColumn;}}
  426. const[scope]=selectedCallFrame.scopeChain();const scopeStartLocation=scope&&scope.startLocation();const scopeEndLocation=scope&&scope.endLocation();if(scopeStartLocation&&scopeEndLocation){let{lineNumber:scopeStartLineNumber,columnNumber:scopeStartColNumber}=scopeStartLocation;let{lineNumber:scopeEndLineNumber,columnNumber:scopeEndColNumber}=scopeEndLocation;const scopeUIStartLocation=Bindings.debuggerWorkspaceBinding.rawLocationToUILocation(scopeStartLocation);const scopeUIEndLocation=Bindings.debuggerWorkspaceBinding.rawLocationToUILocation(scopeEndLocation);if(scopeUIStartLocation&&scopeUIEndLocation){({lineNumber:scopeStartLineNumber,columnNumber:scopeStartColNumber}=scopeUIStartLocation);({lineNumber:scopeEndLineNumber,columnNumber:scopeEndColNumber}=scopeUIEndLocation);}
  427. if(editorLineNumber<scopeStartLineNumber){return null;}
  428. if(editorLineNumber===scopeStartLineNumber&&startHighlight<scopeStartColNumber){return null;}
  429. if(editorLineNumber>scopeEndLineNumber){return null;}
  430. if(editorLineNumber===scopeEndLineNumber&&endHighlight>scopeEndColNumber){return null;}}
  431. let objectPopoverHelper;let highlightDescriptor;return{box:anchorBox,show:async popover=>{const evaluationText=this._textEditor.line(editorLineNumber).substring(startHighlight,endHighlight+1);const resolvedText=await Sources.SourceMapNamesResolver.resolveExpression(selectedCallFrame,evaluationText,this._uiSourceCode,editorLineNumber,startHighlight,endHighlight);const result=await selectedCallFrame.evaluate({expression:resolvedText||evaluationText,objectGroup:'popover',includeCommandLineAPI:false,silent:true,returnByValue:false,generatePreview:false});if(!result.object||(result.object.type==='object'&&result.object.subtype==='error')){return false;}
  432. objectPopoverHelper=await ObjectUI.ObjectPopoverHelper.buildObjectPopover(result.object,popover);const potentiallyUpdatedCallFrame=UI.context.flavor(SDK.DebuggerModel.CallFrame);if(!objectPopoverHelper||selectedCallFrame!==potentiallyUpdatedCallFrame){debuggerModel.runtimeModel().releaseObjectGroup('popover');if(objectPopoverHelper){objectPopoverHelper.dispose();}
  433. return false;}
  434. const highlightRange=new TextUtils.TextRange(editorLineNumber,startHighlight,editorLineNumber,endHighlight);highlightDescriptor=this._textEditor.highlightRange(highlightRange,'source-frame-eval-expression');return true;},hide:()=>{objectPopoverHelper.dispose();debuggerModel.runtimeModel().releaseObjectGroup('popover');this._textEditor.removeHighlight(highlightDescriptor);}};}
  435. _onKeyDown(event){this._clearControlDown();if(event.key==='Escape'){if(this._popoverHelper.isPopoverVisible()){this._popoverHelper.hidePopover();event.consume();}
  436. return;}
  437. if(UI.shortcutRegistry.eventMatchesAction(event,'debugger.toggle-breakpoint')){const selection=this._textEditor.selection();if(!selection){return;}
  438. this._toggleBreakpoint(selection.startLine,false);event.consume(true);return;}
  439. if(UI.shortcutRegistry.eventMatchesAction(event,'debugger.toggle-breakpoint-enabled')){const selection=this._textEditor.selection();if(!selection){return;}
  440. this._toggleBreakpoint(selection.startLine,true);event.consume(true);return;}
  441. if(UI.shortcutRegistry.eventMatchesAction(event,'debugger.breakpoint-input-window')){const selection=this._textEditor.selection();if(!selection){return;}
  442. const breakpoints=this._lineBreakpointDecorations(selection.startLine).map(decoration=>decoration.breakpoint).filter(breakpoint=>!!breakpoint);let breakpoint;if(breakpoints.length){breakpoint=breakpoints[0];}
  443. const isLogpoint=breakpoint?breakpoint.condition().includes(Sources.BreakpointEditDialog.LogpointPrefix):false;this._editBreakpointCondition(selection.startLine,breakpoint,null,isLogpoint);event.consume(true);return;}
  444. if(UI.KeyboardShortcut.eventHasCtrlOrMeta(event)&&this._executionLocation){this._controlDown=true;if(event.key===(Host.isMac()?'Meta':'Control')){this._controlTimeout=setTimeout(()=>{if(this._executionLocation&&this._controlDown){this._showContinueToLocations();}},150);}}}
  445. _onMouseMove(event){if(this._executionLocation&&this._controlDown&&UI.KeyboardShortcut.eventHasCtrlOrMeta(event)){if(!this._continueToLocationDecorations){this._showContinueToLocations();}}
  446. if(this._continueToLocationDecorations){const textPosition=this._textEditor.coordinatesToCursorPosition(event.x,event.y);const hovering=!!event.target.enclosingNodeOrSelfWithClass('source-frame-async-step-in');this._setAsyncStepInHoveredLine(textPosition?textPosition.startLine:null,hovering);}}
  447. _setAsyncStepInHoveredLine(editorLineNumber,hovered){if(this._asyncStepInHoveredLine===editorLineNumber&&this._asyncStepInHovered===hovered){return;}
  448. if(this._asyncStepInHovered&&this._asyncStepInHoveredLine){this._textEditor.toggleLineClass(this._asyncStepInHoveredLine,'source-frame-async-step-in-hovered',false);}
  449. this._asyncStepInHoveredLine=editorLineNumber;this._asyncStepInHovered=hovered;if(this._asyncStepInHovered&&this._asyncStepInHoveredLine){this._textEditor.toggleLineClass(this._asyncStepInHoveredLine,'source-frame-async-step-in-hovered',true);}}
  450. _onMouseDown(event){if(!this._executionLocation||!UI.KeyboardShortcut.eventHasCtrlOrMeta(event)){return;}
  451. if(!this._continueToLocationDecorations){return;}
  452. event.consume();const textPosition=this._textEditor.coordinatesToCursorPosition(event.x,event.y);if(!textPosition){return;}
  453. for(const decoration of this._continueToLocationDecorations.keys()){const range=decoration.find();if(range.from.line!==textPosition.startLine||range.to.line!==textPosition.startLine){continue;}
  454. if(range.from.ch<=textPosition.startColumn&&textPosition.startColumn<=range.to.ch){this._continueToLocationDecorations.get(decoration)();break;}}}
  455. _onBlur(event){if(this._textEditor.element.isAncestor((event.target))){return;}
  456. this._clearControlDown();}
  457. _onKeyUp(event){this._clearControlDown();}
  458. _clearControlDown(){this._controlDown=false;this._clearContinueToLocations();clearTimeout(this._controlTimeout);}
  459. async _editBreakpointCondition(editorLineNumber,breakpoint,location,preferLogpoint){const oldCondition=breakpoint?breakpoint.condition():'';const decorationElement=createElement('div');const dialog=new Sources.BreakpointEditDialog(editorLineNumber,oldCondition,!!preferLogpoint,result=>{dialog.detach();this._textEditor.removeDecoration(decorationElement,editorLineNumber);if(!result.committed){return;}
  460. if(breakpoint){breakpoint.setCondition(result.condition);}else if(location){this._setBreakpoint(location.lineNumber,location.columnNumber,result.condition,true);}else{this._createNewBreakpoint(editorLineNumber,result.condition,true);}});this._textEditor.addDecoration(decorationElement,editorLineNumber);dialog.markAsExternallyManaged();dialog.show(decorationElement);}
  461. _executionLineChanged(liveLocation){this._clearExecutionLine();const uiLocation=liveLocation.uiLocation();if(!uiLocation||uiLocation.uiSourceCode!==this._uiSourceCode){this._executionLocation=null;return;}
  462. this._executionLocation=uiLocation;const editorLocation=this._transformer.rawToEditorLocation(uiLocation.lineNumber,uiLocation.columnNumber);this._textEditor.setExecutionLocation(editorLocation[0],editorLocation[1]);if(this._textEditor.isShowing()){setImmediate(()=>{if(this._controlDown){this._showContinueToLocations();}else{this._generateValuesInSource();}});}}
  463. _generateValuesInSource(){if(!Common.moduleSetting('inlineVariableValues').get()){return;}
  464. const executionContext=UI.context.flavor(SDK.ExecutionContext);if(!executionContext){return;}
  465. const callFrame=UI.context.flavor(SDK.DebuggerModel.CallFrame);if(!callFrame){return;}
  466. const localScope=callFrame.localScope();const functionLocation=callFrame.functionLocation();if(localScope&&functionLocation){Sources.SourceMapNamesResolver.resolveScopeInObject(localScope).getAllProperties(false,false).then(this._prepareScopeVariables.bind(this,callFrame));}}
  467. _showContinueToLocations(){this._popoverHelper.hidePopover();const executionContext=UI.context.flavor(SDK.ExecutionContext);if(!executionContext){return;}
  468. const callFrame=UI.context.flavor(SDK.DebuggerModel.CallFrame);if(!callFrame){return;}
  469. const start=callFrame.functionLocation()||callFrame.location();const debuggerModel=callFrame.debuggerModel;debuggerModel.getPossibleBreakpoints(start,null,true).then(locations=>this._textEditor.operation(renderLocations.bind(this,locations)));function renderLocations(locations){this._clearContinueToLocationsNoRestore();this._textEditor.hideExecutionLineBackground();this._clearValueWidgets();this._continueToLocationDecorations=new Map();locations=locations.reverse();let previousCallLine=-1;for(const location of locations){const editorLocation=this._transformer.rawToEditorLocation(location.lineNumber,location.columnNumber);let token=this._textEditor.tokenAtTextPosition(editorLocation[0],editorLocation[1]);if(!token){continue;}
  470. const line=this._textEditor.line(editorLocation[0]);let tokenContent=line.substring(token.startColumn,token.endColumn);if(!token.type&&tokenContent==='.'){token=this._textEditor.tokenAtTextPosition(editorLocation[0],token.endColumn+1);tokenContent=line.substring(token.startColumn,token.endColumn);}
  471. if(!token.type){continue;}
  472. const validKeyword=token.type==='js-keyword'&&(tokenContent==='this'||tokenContent==='return'||tokenContent==='new'||tokenContent==='continue'||tokenContent==='break');if(!validKeyword&&!this._isIdentifier(token.type)){continue;}
  473. if(previousCallLine===editorLocation[0]&&location.type!==Protocol.Debugger.BreakLocationType.Call){continue;}
  474. let highlightRange=new TextUtils.TextRange(editorLocation[0],token.startColumn,editorLocation[0],token.endColumn-1);let decoration=this._textEditor.highlightRange(highlightRange,'source-frame-continue-to-location');this._continueToLocationDecorations.set(decoration,location.continueToLocation.bind(location));if(location.type===Protocol.Debugger.BreakLocationType.Call){previousCallLine=editorLocation[0];}
  475. let isAsyncCall=(line[token.startColumn-1]==='.'&&tokenContent==='then')||tokenContent==='setTimeout'||tokenContent==='setInterval'||tokenContent==='postMessage';if(tokenContent==='new'){token=this._textEditor.tokenAtTextPosition(editorLocation[0],token.endColumn+1);tokenContent=line.substring(token.startColumn,token.endColumn);isAsyncCall=tokenContent==='Worker';}
  476. const isCurrentPosition=this._executionLocation&&location.lineNumber===this._executionLocation.lineNumber&&location.columnNumber===this._executionLocation.columnNumber;if(location.type===Protocol.Debugger.BreakLocationType.Call&&isAsyncCall){const asyncStepInRange=this._findAsyncStepInRange(this._textEditor,editorLocation[0],line,token.endColumn);if(asyncStepInRange){highlightRange=new TextUtils.TextRange(editorLocation[0],asyncStepInRange.from,editorLocation[0],asyncStepInRange.to-1);decoration=this._textEditor.highlightRange(highlightRange,'source-frame-async-step-in');this._continueToLocationDecorations.set(decoration,this._asyncStepIn.bind(this,location,!!isCurrentPosition));}}}
  477. this._continueToLocationRenderedForTest();}}
  478. _continueToLocationRenderedForTest(){}
  479. _findAsyncStepInRange(textEditor,editorLineNumber,line,column){let token;let tokenText;let from=column;let to=line.length;let position=line.indexOf('(',column);const argumentsStart=position;if(position===-1){return null;}
  480. position++;skipWhitespace();if(position>=line.length){return null;}
  481. nextToken();if(!token){return null;}
  482. from=token.startColumn;if(token.type==='js-keyword'&&tokenText==='async'){skipWhitespace();if(position>=line.length){return{from:from,to:to};}
  483. nextToken();if(!token){return{from:from,to:to};}}
  484. if(token.type==='js-keyword'&&tokenText==='function'){return{from:from,to:to};}
  485. if(token.type==='js-string'){return{from:argumentsStart,to:to};}
  486. if(token.type&&this._isIdentifier(token.type)){return{from:from,to:to};}
  487. if(tokenText!=='('){return null;}
  488. const closeParen=line.indexOf(')',position);if(closeParen===-1||line.substring(position,closeParen).indexOf('(')!==-1){return{from:from,to:to};}
  489. return{from:from,to:closeParen+1};function nextToken(){token=textEditor.tokenAtTextPosition(editorLineNumber,position);if(token){position=token.endColumn;to=token.endColumn;tokenText=line.substring(token.startColumn,token.endColumn);}}
  490. function skipWhitespace(){while(position<line.length){if(line[position]===' '){position++;continue;}
  491. const token=textEditor.tokenAtTextPosition(editorLineNumber,position);if(token.type==='js-comment'){position=token.endColumn;continue;}
  492. break;}}}
  493. _asyncStepIn(location,isCurrentPosition){if(!isCurrentPosition){location.continueToLocation(asyncStepIn);}else{asyncStepIn();}
  494. function asyncStepIn(){location.debuggerModel.scheduleStepIntoAsync();}}
  495. _prepareScopeVariables(callFrame,allProperties){const properties=allProperties.properties;this._clearValueWidgets();if(!properties||!properties.length||properties.length>500||!this._textEditor.isShowing()){return;}
  496. const functionUILocation=Bindings.debuggerWorkspaceBinding.rawLocationToUILocation((callFrame.functionLocation()));const executionUILocation=Bindings.debuggerWorkspaceBinding.rawLocationToUILocation(callFrame.location());if(!functionUILocation||!executionUILocation||functionUILocation.uiSourceCode!==this._uiSourceCode||executionUILocation.uiSourceCode!==this._uiSourceCode){return;}
  497. const functionEditorLocation=this._transformer.rawToEditorLocation(functionUILocation.lineNumber,functionUILocation.columnNumber);const executionEditorLocation=this._transformer.rawToEditorLocation(executionUILocation.lineNumber,executionUILocation.columnNumber);const fromLine=functionEditorLocation[0];const fromColumn=functionEditorLocation[1];const toLine=executionEditorLocation[0];if(fromLine>=toLine||toLine-fromLine>500||fromLine<0||toLine>=this._textEditor.linesCount){return;}
  498. const valuesMap=new Map();for(const property of properties){valuesMap.set(property.name,property.value);}
  499. const namesPerLine=new Map();let skipObjectProperty=false;const tokenizer=new TextEditor.CodeMirrorUtils.TokenizerFactory().createTokenizer('text/javascript');tokenizer(this._textEditor.line(fromLine).substring(fromColumn),processToken.bind(this,fromLine));for(let i=fromLine+1;i<toLine;++i){tokenizer(this._textEditor.line(i),processToken.bind(this,i));}
  500. function processToken(editorLineNumber,tokenValue,tokenType,column,newColumn){if(!skipObjectProperty&&tokenType&&this._isIdentifier(tokenType)&&valuesMap.get(tokenValue)){let names=namesPerLine.get(editorLineNumber);if(!names){names=new Set();namesPerLine.set(editorLineNumber,names);}
  501. names.add(tokenValue);}
  502. skipObjectProperty=tokenValue==='.';}
  503. this._textEditor.operation(this._renderDecorations.bind(this,valuesMap,namesPerLine,fromLine,toLine));}
  504. _renderDecorations(valuesMap,namesPerLine,fromLine,toLine){const formatter=new ObjectUI.RemoteObjectPreviewFormatter();for(let i=fromLine;i<toLine;++i){const names=namesPerLine.get(i);const oldWidget=this._valueWidgets.get(i);if(!names){if(oldWidget){this._valueWidgets.delete(i);this._textEditor.removeDecoration(oldWidget,i);}
  505. continue;}
  506. const widget=createElementWithClass('div','text-editor-value-decoration');const base=this._textEditor.cursorPositionToCoordinates(i,0);const offset=this._textEditor.cursorPositionToCoordinates(i,this._textEditor.line(i).length);const codeMirrorLinesLeftPadding=4;const left=offset.x-base.x+codeMirrorLinesLeftPadding;widget.style.left=left+'px';widget.__nameToToken=new Map();let renderedNameCount=0;for(const name of names){if(renderedNameCount>10){break;}
  507. if(namesPerLine.get(i-1)&&namesPerLine.get(i-1).has(name)){continue;}
  508. if(renderedNameCount){widget.createTextChild(', ');}
  509. const nameValuePair=widget.createChild('span');widget.__nameToToken.set(name,nameValuePair);nameValuePair.createTextChild(name+' = ');const value=valuesMap.get(name);const propertyCount=value.preview?value.preview.properties.length:0;const entryCount=value.preview&&value.preview.entries?value.preview.entries.length:0;if(value.preview&&propertyCount+entryCount<10){formatter.appendObjectPreview(nameValuePair,value.preview,false);}else{nameValuePair.appendChild(ObjectUI.ObjectPropertiesSection.createValueElement(value,false,false));}
  510. ++renderedNameCount;}
  511. let widgetChanged=true;if(oldWidget){widgetChanged=false;for(const name of widget.__nameToToken.keys()){const oldText=oldWidget.__nameToToken.get(name)?oldWidget.__nameToToken.get(name).textContent:'';const newText=widget.__nameToToken.get(name)?widget.__nameToToken.get(name).textContent:'';if(newText!==oldText){widgetChanged=true;UI.runCSSAnimationOnce((widget.__nameToToken.get(name)),'source-frame-value-update-highlight');}}
  512. if(widgetChanged){this._valueWidgets.delete(i);this._textEditor.removeDecoration(oldWidget,i);}}
  513. if(widgetChanged){this._valueWidgets.set(i,widget);this._textEditor.addDecoration(widget,i);}}}
  514. _clearExecutionLine(){this._textEditor.operation(()=>{if(this._executionLocation){this._textEditor.clearExecutionLine();}
  515. this._executionLocation=null;if(this._clearValueWidgetsTimer){clearTimeout(this._clearValueWidgetsTimer);this._clearValueWidgetsTimer=null;}
  516. this._clearValueWidgetsTimer=setTimeout(this._clearValueWidgets.bind(this),1000);this._clearContinueToLocationsNoRestore();});}
  517. _clearValueWidgets(){clearTimeout(this._clearValueWidgetsTimer);this._clearValueWidgetsTimer=null;this._textEditor.operation(()=>{for(const line of this._valueWidgets.keys()){this._textEditor.removeDecoration(this._valueWidgets.get(line),line);}
  518. this._valueWidgets.clear();});}
  519. _clearContinueToLocationsNoRestore(){if(!this._continueToLocationDecorations){return;}
  520. this._textEditor.operation(()=>{for(const decoration of this._continueToLocationDecorations.keys()){this._textEditor.removeHighlight(decoration);}
  521. this._continueToLocationDecorations=null;this._setAsyncStepInHoveredLine(null,false);});}
  522. _clearContinueToLocations(){if(!this._continueToLocationDecorations){return;}
  523. this._textEditor.operation(()=>{this._textEditor.showExecutionLineBackground();this._generateValuesInSource();this._clearContinueToLocationsNoRestore();});}
  524. _lineBreakpointDecorations(lineNumber){return Array.from(this._breakpointDecorations).filter(decoration=>(decoration.handle.resolve()||{}).lineNumber===lineNumber);}
  525. _breakpointDecoration(editorLineNumber,editorColumnNumber){for(const decoration of this._breakpointDecorations){const location=decoration.handle.resolve();if(!location){continue;}
  526. if(location.lineNumber===editorLineNumber&&location.columnNumber===editorColumnNumber){return decoration;}}
  527. return null;}
  528. _updateBreakpointDecoration(decoration){if(!this._scheduledBreakpointDecorationUpdates){this._scheduledBreakpointDecorationUpdates=new Set();setImmediate(()=>this._textEditor.operation(update.bind(this)));}
  529. this._scheduledBreakpointDecorationUpdates.add(decoration);function update(){if(!this._scheduledBreakpointDecorationUpdates){return;}
  530. const editorLineNumbers=new Set();for(const decoration of this._scheduledBreakpointDecorationUpdates){const location=decoration.handle.resolve();if(!location){continue;}
  531. editorLineNumbers.add(location.lineNumber);}
  532. this._scheduledBreakpointDecorationUpdates=null;let waitingForInlineDecorations=false;for(const lineNumber of editorLineNumbers){const decorations=this._lineBreakpointDecorations(lineNumber);updateGutter.call(this,lineNumber,decorations);if(this._possibleBreakpointsRequested.has(lineNumber)){waitingForInlineDecorations=true;continue;}
  533. updateInlineDecorations.call(this,lineNumber,decorations);}
  534. if(!waitingForInlineDecorations){this._breakpointDecorationsUpdatedForTest();}}
  535. function updateGutter(editorLineNumber,decorations){this._textEditor.toggleLineClass(editorLineNumber,'cm-breakpoint',false);this._textEditor.toggleLineClass(editorLineNumber,'cm-breakpoint-disabled',false);this._textEditor.toggleLineClass(editorLineNumber,'cm-breakpoint-conditional',false);if(decorations.length){decorations.sort(Sources.DebuggerPlugin.BreakpointDecoration.mostSpecificFirst);this._textEditor.toggleLineClass(editorLineNumber,'cm-breakpoint',true);this._textEditor.toggleLineClass(editorLineNumber,'cm-breakpoint-disabled',!decorations[0].enabled||this._muted);this._textEditor.toggleLineClass(editorLineNumber,'cm-breakpoint-conditional',!!decorations[0].condition);}}
  536. function updateInlineDecorations(editorLineNumber,decorations){const actualBookmarks=new Set(decorations.map(decoration=>decoration.bookmark).filter(bookmark=>!!bookmark));const lineEnd=this._textEditor.line(editorLineNumber).length;const bookmarks=this._textEditor.bookmarks(new TextUtils.TextRange(editorLineNumber,0,editorLineNumber,lineEnd),Sources.DebuggerPlugin.BreakpointDecoration.bookmarkSymbol);for(const bookmark of bookmarks){if(!actualBookmarks.has(bookmark)){bookmark.clear();}}
  537. if(!decorations.length){return;}
  538. if(decorations.length>1){for(const decoration of decorations){decoration.update();if(!this._muted){decoration.show();}else{decoration.hide();}}}else{decorations[0].update();decorations[0].hide();}}}
  539. _breakpointDecorationsUpdatedForTest(){}
  540. _inlineBreakpointClick(decoration,event){event.consume(true);if(decoration.breakpoint){if(event.shiftKey){decoration.breakpoint.setEnabled(!decoration.breakpoint.enabled());}else{decoration.breakpoint.remove();}}else{const editorLocation=decoration.handle.resolve();if(!editorLocation){return;}
  541. const location=this._transformer.editorToRawLocation(editorLocation.lineNumber,editorLocation.columnNumber);this._setBreakpoint(location[0],location[1],decoration.condition,true);}}
  542. _inlineBreakpointContextMenu(decoration,event){event.consume(true);const editorLocation=decoration.handle.resolve();if(!editorLocation){return;}
  543. const location=this._transformer.editorToRawLocation(editorLocation[0],editorLocation[1]);const contextMenu=new UI.ContextMenu(event);if(decoration.breakpoint){contextMenu.debugSection().appendItem(Common.UIString('Edit breakpoint\u2026'),this._editBreakpointCondition.bind(this,editorLocation.lineNumber,decoration.breakpoint,null));}else{contextMenu.debugSection().appendItem(Common.UIString('Add conditional breakpoint\u2026'),this._editBreakpointCondition.bind(this,editorLocation.lineNumber,null,editorLocation));contextMenu.debugSection().appendItem(ls`Add logpoint\u2026`,this._editBreakpointCondition.bind(this,editorLocation.lineNumber,null,editorLocation,true));contextMenu.debugSection().appendItem(Common.UIString('Never pause here'),this._setBreakpoint.bind(this,location[0],location[1],'false',true));}
  544. contextMenu.show();}
  545. _shouldIgnoreExternalBreakpointEvents(event){const uiLocation=(event.data.uiLocation);if(uiLocation.uiSourceCode!==this._uiSourceCode){return true;}
  546. if(this._muted){return true;}
  547. const scriptFiles=this._scriptFileForDebuggerModel.valuesArray();for(let i=0;i<scriptFiles.length;++i){if(scriptFiles[i].isDivergingFromVM()||scriptFiles[i].isMergingToVM()){return true;}}
  548. return false;}
  549. _breakpointAdded(event){if(this._shouldIgnoreExternalBreakpointEvents(event)){return;}
  550. const uiLocation=(event.data.uiLocation);const breakpoint=(event.data.breakpoint);this._addBreakpoint(uiLocation,breakpoint);}
  551. _addBreakpoint(uiLocation,breakpoint){const editorLocation=this._transformer.rawToEditorLocation(uiLocation.lineNumber,uiLocation.columnNumber);const lineDecorations=this._lineBreakpointDecorations(uiLocation.lineNumber);let decoration=this._breakpointDecoration(editorLocation[0],editorLocation[1]);if(decoration){decoration.breakpoint=breakpoint;decoration.condition=breakpoint.condition();decoration.enabled=breakpoint.enabled();}else{const handle=this._textEditor.textEditorPositionHandle(editorLocation[0],editorLocation[1]);decoration=new Sources.DebuggerPlugin.BreakpointDecoration(this._textEditor,handle,breakpoint.condition(),breakpoint.enabled(),breakpoint);decoration.element.addEventListener('click',this._inlineBreakpointClick.bind(this,decoration),true);decoration.element.addEventListener('contextmenu',this._inlineBreakpointContextMenu.bind(this,decoration),true);this._breakpointDecorations.add(decoration);}
  552. this._decorationByBreakpoint.set(breakpoint,decoration);this._updateBreakpointDecoration(decoration);if(breakpoint.enabled()&&!lineDecorations.length){this._possibleBreakpointsRequested.add(editorLocation[0]);const start=this._transformer.editorToRawLocation(editorLocation[0],0);const end=this._transformer.editorToRawLocation(editorLocation[0]+1,0);this._breakpointManager.possibleBreakpoints(this._uiSourceCode,new TextUtils.TextRange(start[0],start[1],end[0],end[1])).then(addInlineDecorations.bind(this,editorLocation[0]));}
  553. function addInlineDecorations(editorLineNumber,possibleLocations){this._possibleBreakpointsRequested.delete(editorLineNumber);const decorations=this._lineBreakpointDecorations(editorLineNumber);for(const decoration of decorations){this._updateBreakpointDecoration(decoration);}
  554. if(!decorations.some(decoration=>!!decoration.breakpoint)){return;}
  555. const columns=new Set();for(const decoration of decorations){const editorLocation=decoration.handle.resolve();if(!editorLocation){continue;}
  556. columns.add(editorLocation.columnNumber);}
  557. for(const location of possibleLocations){const editorLocation=this._transformer.rawToEditorLocation(location.lineNumber,location.columnNumber);if(columns.has(editorLocation[1])){continue;}
  558. const handle=this._textEditor.textEditorPositionHandle(editorLocation[0],editorLocation[1]);const decoration=new Sources.DebuggerPlugin.BreakpointDecoration(this._textEditor,handle,'',false,null);decoration.element.addEventListener('click',this._inlineBreakpointClick.bind(this,decoration),true);decoration.element.addEventListener('contextmenu',this._inlineBreakpointContextMenu.bind(this,decoration),true);this._breakpointDecorations.add(decoration);this._updateBreakpointDecoration(decoration);}}}
  559. _breakpointRemoved(event){if(this._shouldIgnoreExternalBreakpointEvents(event)){return;}
  560. const uiLocation=(event.data.uiLocation);const breakpoint=(event.data.breakpoint);const decoration=this._decorationByBreakpoint.get(breakpoint);if(!decoration){return;}
  561. this._decorationByBreakpoint.delete(breakpoint);const editorLocation=this._transformer.rawToEditorLocation(uiLocation.lineNumber,uiLocation.columnNumber);decoration.breakpoint=null;decoration.enabled=false;const lineDecorations=this._lineBreakpointDecorations(editorLocation[0]);if(!lineDecorations.some(decoration=>!!decoration.breakpoint)){for(const lineDecoration of lineDecorations){this._breakpointDecorations.delete(lineDecoration);this._updateBreakpointDecoration(lineDecoration);}}else{this._updateBreakpointDecoration(decoration);}}
  562. _initializeBreakpoints(){const breakpointLocations=this._breakpointManager.breakpointLocationsForUISourceCode(this._uiSourceCode);for(const breakpointLocation of breakpointLocations){this._addBreakpoint(breakpointLocation.uiLocation,breakpointLocation.breakpoint);}}
  563. _updateLinesWithoutMappingHighlight(){const isSourceMapSource=!!Bindings.CompilerScriptMapping.uiSourceCodeOrigin(this._uiSourceCode);if(!isSourceMapSource){return;}
  564. const linesCount=this._textEditor.linesCount;for(let i=0;i<linesCount;++i){const lineHasMapping=Bindings.CompilerScriptMapping.uiLineHasMapping(this._uiSourceCode,i);if(!lineHasMapping){this._hasLineWithoutMapping=true;}
  565. if(this._hasLineWithoutMapping){this._textEditor.toggleLineClass(i,'cm-line-without-source-mapping',!lineHasMapping);}}}
  566. _updateScriptFiles(){for(const debuggerModel of SDK.targetManager.models(SDK.DebuggerModel)){const scriptFile=Bindings.debuggerWorkspaceBinding.scriptFile(this._uiSourceCode,debuggerModel);if(scriptFile){this._updateScriptFile(debuggerModel);}}}
  567. _updateScriptFile(debuggerModel){const oldScriptFile=this._scriptFileForDebuggerModel.get(debuggerModel);const newScriptFile=Bindings.debuggerWorkspaceBinding.scriptFile(this._uiSourceCode,debuggerModel);this._scriptFileForDebuggerModel.delete(debuggerModel);if(oldScriptFile){oldScriptFile.removeEventListener(Bindings.ResourceScriptFile.Events.DidMergeToVM,this._didMergeToVM,this);oldScriptFile.removeEventListener(Bindings.ResourceScriptFile.Events.DidDivergeFromVM,this._didDivergeFromVM,this);if(this._muted&&!this._uiSourceCode.isDirty()){this._restoreBreakpointsIfConsistentScripts();}}
  568. if(!newScriptFile){return;}
  569. this._scriptFileForDebuggerModel.set(debuggerModel,newScriptFile);newScriptFile.addEventListener(Bindings.ResourceScriptFile.Events.DidMergeToVM,this._didMergeToVM,this);newScriptFile.addEventListener(Bindings.ResourceScriptFile.Events.DidDivergeFromVM,this._didDivergeFromVM,this);newScriptFile.checkMapping();if(newScriptFile.hasSourceMapURL()){this._showSourceMapInfobar();}}
  570. _showSourceMapInfobar(){if(this._sourceMapInfobar){return;}
  571. this._sourceMapInfobar=UI.Infobar.create(UI.Infobar.Type.Info,Common.UIString('Source Map detected.'),Common.settings.createSetting('sourceMapInfobarDisabled',false));if(!this._sourceMapInfobar){return;}
  572. this._sourceMapInfobar.createDetailsRowMessage(Common.UIString('Associated files should be added to the file tree. You can debug these resolved source files as regular JavaScript files.'));this._sourceMapInfobar.createDetailsRowMessage(Common.UIString('Associated files are available via file tree or %s.',UI.shortcutRegistry.shortcutTitleForAction('quickOpen.show')));this._sourceMapInfobar.setCloseCallback(()=>this._sourceMapInfobar=null);this._textEditor.attachInfobar(this._sourceMapInfobar);}
  573. _detectMinified(){const content=this._uiSourceCode.content();if(!content||!TextUtils.isMinified(content)){return;}
  574. this._prettyPrintInfobar=UI.Infobar.create(UI.Infobar.Type.Info,Common.UIString('Pretty-print this minified file?'),Common.settings.createSetting('prettyPrintInfobarDisabled',false));if(!this._prettyPrintInfobar){return;}
  575. this._prettyPrintInfobar.setCloseCallback(()=>this._prettyPrintInfobar=null);const toolbar=new UI.Toolbar('');const button=new UI.ToolbarButton('','largeicon-pretty-print');toolbar.appendToolbarItem(button);toolbar.element.style.display='inline-block';toolbar.element.style.verticalAlign='middle';toolbar.element.style.marginBottom='3px';toolbar.element.style.pointerEvents='none';toolbar.element.tabIndex=-1;const element=this._prettyPrintInfobar.createDetailsRowMessage();element.appendChild(UI.formatLocalized('You can click the %s button on the bottom status bar, and continue debugging with the new formatted source.',[toolbar.element]));this._textEditor.attachInfobar(this._prettyPrintInfobar);}
  576. _handleGutterClick(event){if(this._muted){return;}
  577. const eventData=(event.data);if(eventData.gutterType!==SourceFrame.SourcesTextEditor.lineNumbersGutterType){return;}
  578. const editorLineNumber=eventData.lineNumber;const eventObject=eventData.event;if(eventObject.button!==0||eventObject.altKey||eventObject.ctrlKey||eventObject.metaKey){return;}
  579. this._toggleBreakpoint(editorLineNumber,eventObject.shiftKey);eventObject.consume(true);}
  580. _toggleBreakpoint(editorLineNumber,onlyDisable){const decorations=this._lineBreakpointDecorations(editorLineNumber);if(!decorations.length){this._createNewBreakpoint(editorLineNumber,'',true);return;}
  581. const hasDisabled=this._textEditor.hasLineClass(editorLineNumber,'cm-breakpoint-disabled');const breakpoints=decorations.map(decoration=>decoration.breakpoint).filter(breakpoint=>!!breakpoint);for(const breakpoint of breakpoints){if(onlyDisable){breakpoint.setEnabled(hasDisabled);}else{breakpoint.remove();}}}
  582. async _createNewBreakpoint(editorLineNumber,condition,enabled){Host.userMetrics.actionTaken(Host.UserMetrics.Action.ScriptsBreakpointSet);if(editorLineNumber<this._textEditor.linesCount){const lineLength=Math.min(this._textEditor.line(editorLineNumber).length,1024);const start=this._transformer.editorToRawLocation(editorLineNumber,0);const end=this._transformer.editorToRawLocation(editorLineNumber,lineLength);const locations=await this._breakpointManager.possibleBreakpoints(this._uiSourceCode,new TextUtils.TextRange(start[0],start[1],end[0],end[1]));if(locations&&locations.length){this._setBreakpoint(locations[0].lineNumber,locations[0].columnNumber,condition,enabled);return;}}
  583. const origin=this._transformer.editorToRawLocation(editorLineNumber,0);await this._setBreakpoint(origin[0],origin[1],condition,enabled);}
  584. toggleBreakpointOnCurrentLine(onlyDisable){if(this._muted){return;}
  585. const selection=this._textEditor.selection();if(!selection){return;}
  586. this._toggleBreakpoint(selection.startLine,onlyDisable);}
  587. _setBreakpoint(lineNumber,columnNumber,condition,enabled){if(!Bindings.CompilerScriptMapping.uiLineHasMapping(this._uiSourceCode,lineNumber)){return;}
  588. Common.moduleSetting('breakpointsActive').set(true);this._breakpointManager.setBreakpoint(this._uiSourceCode,lineNumber,columnNumber,condition,enabled);this._breakpointWasSetForTest(lineNumber,columnNumber,condition,enabled);}
  589. _breakpointWasSetForTest(lineNumber,columnNumber,condition,enabled){}
  590. _callFrameChanged(){this._liveLocationPool.disposeAll();const callFrame=UI.context.flavor(SDK.DebuggerModel.CallFrame);if(!callFrame){this._clearExecutionLine();return;}
  591. Bindings.debuggerWorkspaceBinding.createCallFrameLiveLocation(callFrame.location(),this._executionLineChanged.bind(this),this._liveLocationPool);}
  592. dispose(){for(const decoration of this._breakpointDecorations){decoration.dispose();}
  593. this._breakpointDecorations.clear();if(this._scheduledBreakpointDecorationUpdates){for(const decoration of this._scheduledBreakpointDecorationUpdates){decoration.dispose();}
  594. this._scheduledBreakpointDecorationUpdates.clear();}
  595. this._hideBlackboxInfobar();if(this._sourceMapInfobar){this._sourceMapInfobar.dispose();}
  596. if(this._prettyPrintInfobar){this._prettyPrintInfobar.dispose();}
  597. this._scriptsPanel.element.removeEventListener('scroll',this._boundPopoverHelperHide,true);for(const script of this._scriptFileForDebuggerModel.values()){script.removeEventListener(Bindings.ResourceScriptFile.Events.DidMergeToVM,this._didMergeToVM,this);script.removeEventListener(Bindings.ResourceScriptFile.Events.DidDivergeFromVM,this._didDivergeFromVM,this);}
  598. this._scriptFileForDebuggerModel.clear();this._textEditor.element.removeEventListener('keydown',this._boundKeyDown,true);this._textEditor.element.removeEventListener('keyup',this._boundKeyUp,true);this._textEditor.element.removeEventListener('mousemove',this._boundMouseMove,false);this._textEditor.element.removeEventListener('mousedown',this._boundMouseDown,true);this._textEditor.element.removeEventListener('focusout',this._boundBlur,false);this._textEditor.element.removeEventListener('wheel',this._boundWheel,true);this._textEditor.removeEventListener(SourceFrame.SourcesTextEditor.Events.GutterClick,this._handleGutterClick,this);this._popoverHelper.hidePopover();this._popoverHelper.dispose();this._breakpointManager.removeEventListener(Bindings.BreakpointManager.Events.BreakpointAdded,this._breakpointAdded,this);this._breakpointManager.removeEventListener(Bindings.BreakpointManager.Events.BreakpointRemoved,this._breakpointRemoved,this);this._uiSourceCode.removeEventListener(Workspace.UISourceCode.Events.WorkingCopyChanged,this._workingCopyChanged,this);this._uiSourceCode.removeEventListener(Workspace.UISourceCode.Events.WorkingCopyCommitted,this._workingCopyCommitted,this);Common.moduleSetting('skipStackFramesPattern').removeChangeListener(this._showBlackboxInfobarIfNeeded,this);Common.moduleSetting('skipContentScripts').removeChangeListener(this._showBlackboxInfobarIfNeeded,this);super.dispose();this._clearExecutionLine();UI.context.removeFlavorChangeListener(SDK.DebuggerModel.CallFrame,this._callFrameChanged,this);this._liveLocationPool.disposeAll();}};Sources.DebuggerPlugin.BreakpointDecoration=class{constructor(textEditor,handle,condition,enabled,breakpoint){this._textEditor=textEditor;this.handle=handle;this.condition=condition;this.enabled=enabled;this.breakpoint=breakpoint;this.element=UI.Icon.create('smallicon-inline-breakpoint');this.element.classList.toggle('cm-inline-breakpoint',true);this.bookmark=null;}
  599. static mostSpecificFirst(decoration1,decoration2){if(decoration1.enabled!==decoration2.enabled){return decoration1.enabled?-1:1;}
  600. if(!!decoration1.condition!==!!decoration2.condition){return!!decoration1.condition?-1:1;}
  601. return 0;}
  602. update(){if(!this.condition){this.element.setIconType('smallicon-inline-breakpoint');}else{this.element.setIconType('smallicon-inline-breakpoint-conditional');}
  603. this.element.classList.toggle('cm-inline-disabled',!this.enabled);}
  604. show(){if(this.bookmark){return;}
  605. const editorLocation=this.handle.resolve();if(!editorLocation){return;}
  606. this.bookmark=this._textEditor.addBookmark(editorLocation.lineNumber,editorLocation.columnNumber,this.element,Sources.DebuggerPlugin.BreakpointDecoration.bookmarkSymbol);this.bookmark[Sources.DebuggerPlugin.BreakpointDecoration._elementSymbolForTest]=this.element;}
  607. hide(){if(!this.bookmark){return;}
  608. this.bookmark.clear();this.bookmark=null;}
  609. dispose(){const location=this.handle.resolve();if(location){this._textEditor.toggleLineClass(location.lineNumber,'cm-breakpoint',false);this._textEditor.toggleLineClass(location.lineNumber,'cm-breakpoint-disabled',false);this._textEditor.toggleLineClass(location.lineNumber,'cm-breakpoint-conditional',false);}
  610. this.hide();}};Sources.DebuggerPlugin.BreakpointDecoration.bookmarkSymbol=Symbol('bookmark');Sources.DebuggerPlugin.BreakpointDecoration._elementSymbolForTest=Symbol('element');Sources.DebuggerPlugin.continueToLocationDecorationSymbol=Symbol('bookmark');;Sources.CSSPlugin=class extends Sources.UISourceCodeFrame.Plugin{constructor(textEditor){super();this._textEditor=textEditor;this._swatchPopoverHelper=new InlineEditor.SwatchPopoverHelper();this._muteSwatchProcessing=false;this._hadSwatchChange=false;this._bezierEditor=null;this._editedSwatchTextRange=null;this._spectrum=null;this._currentSwatch=null;this._textEditor.configureAutocomplete({suggestionsCallback:this._cssSuggestions.bind(this),isWordChar:this._isWordChar.bind(this)});this._textEditor.addEventListener(SourceFrame.SourcesTextEditor.Events.ScrollChanged,this._textEditorScrolled,this);this._textEditor.addEventListener(UI.TextEditor.Events.TextChanged,this._onTextChanged,this);this._updateSwatches(0,this._textEditor.linesCount-1);this._shortcuts={};this._registerShortcuts();this._boundHandleKeyDown=this._handleKeyDown.bind(this);this._textEditor.element.addEventListener('keydown',this._boundHandleKeyDown,false);}
  611. static accepts(uiSourceCode){return uiSourceCode.contentType().isStyleSheet();}
  612. _registerShortcuts(){const shortcutKeys=UI.ShortcutsScreen.SourcesPanelShortcuts;for(const descriptor of shortcutKeys.IncreaseCSSUnitByOne){this._shortcuts[descriptor.key]=this._handleUnitModification.bind(this,1);}
  613. for(const descriptor of shortcutKeys.DecreaseCSSUnitByOne){this._shortcuts[descriptor.key]=this._handleUnitModification.bind(this,-1);}
  614. for(const descriptor of shortcutKeys.IncreaseCSSUnitByTen){this._shortcuts[descriptor.key]=this._handleUnitModification.bind(this,10);}
  615. for(const descriptor of shortcutKeys.DecreaseCSSUnitByTen){this._shortcuts[descriptor.key]=this._handleUnitModification.bind(this,-10);}}
  616. _handleKeyDown(event){const shortcutKey=UI.KeyboardShortcut.makeKeyFromEvent((event));const handler=this._shortcuts[shortcutKey];if(handler&&handler()){event.consume(true);}}
  617. _textEditorScrolled(){if(this._swatchPopoverHelper.isShowing()){this._swatchPopoverHelper.hide(true);}}
  618. _modifyUnit(unit,change){const unitValue=parseInt(unit,10);if(isNaN(unitValue)){return null;}
  619. const tail=unit.substring((unitValue).toString().length);return String.sprintf('%d%s',unitValue+change,tail);}
  620. _handleUnitModification(change){const selection=this._textEditor.selection().normalize();let token=this._textEditor.tokenAtTextPosition(selection.startLine,selection.startColumn);if(!token){if(selection.startColumn>0){token=this._textEditor.tokenAtTextPosition(selection.startLine,selection.startColumn-1);}
  621. if(!token){return false;}}
  622. if(token.type!=='css-number'){return false;}
  623. const cssUnitRange=new TextUtils.TextRange(selection.startLine,token.startColumn,selection.startLine,token.endColumn);const cssUnitText=this._textEditor.text(cssUnitRange);const newUnitText=this._modifyUnit(cssUnitText,change);if(!newUnitText){return false;}
  624. this._textEditor.editRange(cssUnitRange,newUnitText);selection.startColumn=token.startColumn;selection.endColumn=selection.startColumn+newUnitText.length;this._textEditor.setSelection(selection);return true;}
  625. _updateSwatches(startLine,endLine){const swatches=[];const swatchPositions=[];const regexes=[SDK.CSSMetadata.VariableRegex,SDK.CSSMetadata.URLRegex,UI.Geometry.CubicBezier.Regex,Common.Color.Regex];const handlers=new Map();handlers.set(Common.Color.Regex,this._createColorSwatch.bind(this));handlers.set(UI.Geometry.CubicBezier.Regex,this._createBezierSwatch.bind(this));for(let lineNumber=startLine;lineNumber<=endLine;lineNumber++){const line=this._textEditor.line(lineNumber).substring(0,Sources.CSSPlugin.maxSwatchProcessingLength);const results=TextUtils.TextUtils.splitStringByRegexes(line,regexes);for(let i=0;i<results.length;i++){const result=results[i];if(result.regexIndex===-1||!handlers.has(regexes[result.regexIndex])){continue;}
  626. const delimiters=/[\s:;,(){}]/;const positionBefore=result.position-1;const positionAfter=result.position+result.value.length;if(positionBefore>=0&&!delimiters.test(line.charAt(positionBefore))||positionAfter<line.length&&!delimiters.test(line.charAt(positionAfter))){continue;}
  627. const swatch=handlers.get(regexes[result.regexIndex])(result.value);if(!swatch){continue;}
  628. swatches.push(swatch);swatchPositions.push(TextUtils.TextRange.createFromLocation(lineNumber,result.position));}}
  629. this._textEditor.operation(putSwatchesInline.bind(this));function putSwatchesInline(){const clearRange=new TextUtils.TextRange(startLine,0,endLine,this._textEditor.line(endLine).length);this._textEditor.bookmarks(clearRange,Sources.CSSPlugin.SwatchBookmark).forEach(marker=>marker.clear());for(let i=0;i<swatches.length;i++){const swatch=swatches[i];const swatchPosition=swatchPositions[i];const bookmark=this._textEditor.addBookmark(swatchPosition.startLine,swatchPosition.startColumn,swatch,Sources.CSSPlugin.SwatchBookmark);swatch[Sources.CSSPlugin.SwatchBookmark]=bookmark;}}}
  630. _createColorSwatch(text){const color=Common.Color.parse(text);if(!color){return null;}
  631. const swatch=InlineEditor.ColorSwatch.create();swatch.setColor(color);swatch.iconElement().title=Common.UIString('Open color picker.');swatch.iconElement().addEventListener('click',this._swatchIconClicked.bind(this,swatch),false);swatch.hideText(true);return swatch;}
  632. _createBezierSwatch(text){if(!UI.Geometry.CubicBezier.parse(text)){return null;}
  633. const swatch=InlineEditor.BezierSwatch.create();swatch.setBezierText(text);swatch.iconElement().title=Common.UIString('Open cubic bezier editor.');swatch.iconElement().addEventListener('click',this._swatchIconClicked.bind(this,swatch),false);swatch.hideText(true);return swatch;}
  634. _swatchIconClicked(swatch,event){event.consume(true);this._hadSwatchChange=false;this._muteSwatchProcessing=true;const swatchPosition=swatch[Sources.CSSPlugin.SwatchBookmark].position();this._textEditor.setSelection(swatchPosition);this._editedSwatchTextRange=swatchPosition.clone();this._editedSwatchTextRange.endColumn+=swatch.textContent.length;this._currentSwatch=swatch;if(swatch instanceof InlineEditor.ColorSwatch){this._showSpectrum(swatch);}else if(swatch instanceof InlineEditor.BezierSwatch){this._showBezierEditor(swatch);}}
  635. _showSpectrum(swatch){if(!this._spectrum){this._spectrum=new ColorPicker.Spectrum();this._spectrum.addEventListener(ColorPicker.Spectrum.Events.SizeChanged,this._spectrumResized,this);this._spectrum.addEventListener(ColorPicker.Spectrum.Events.ColorChanged,this._spectrumChanged,this);}
  636. this._spectrum.setColor(swatch.color(),swatch.format());this._swatchPopoverHelper.show(this._spectrum,swatch.iconElement(),this._swatchPopoverHidden.bind(this));}
  637. _spectrumResized(event){this._swatchPopoverHelper.reposition();}
  638. _spectrumChanged(event){const colorString=(event.data);const color=Common.Color.parse(colorString);if(!color){return;}
  639. this._currentSwatch.setColor(color);this._changeSwatchText(colorString);}
  640. _showBezierEditor(swatch){if(!this._bezierEditor){this._bezierEditor=new InlineEditor.BezierEditor();this._bezierEditor.addEventListener(InlineEditor.BezierEditor.Events.BezierChanged,this._bezierChanged,this);}
  641. let cubicBezier=UI.Geometry.CubicBezier.parse(swatch.bezierText());if(!cubicBezier){cubicBezier=(UI.Geometry.CubicBezier.parse('linear'));}
  642. this._bezierEditor.setBezier(cubicBezier);this._swatchPopoverHelper.show(this._bezierEditor,swatch.iconElement(),this._swatchPopoverHidden.bind(this));}
  643. _bezierChanged(event){const bezierString=(event.data);this._currentSwatch.setBezierText(bezierString);this._changeSwatchText(bezierString);}
  644. _changeSwatchText(text){this._hadSwatchChange=true;this._textEditor.editRange((this._editedSwatchTextRange),text,'*swatch-text-changed');this._editedSwatchTextRange.endColumn=this._editedSwatchTextRange.startColumn+text.length;}
  645. _swatchPopoverHidden(commitEdit){this._muteSwatchProcessing=false;if(!commitEdit&&this._hadSwatchChange){this._textEditor.undo();}}
  646. _onTextChanged(event){if(!this._muteSwatchProcessing){this._updateSwatches(event.data.newRange.startLine,event.data.newRange.endLine);}}
  647. _isWordChar(char){return TextUtils.TextUtils.isWordChar(char)||char==='.'||char==='-'||char==='$';}
  648. _cssSuggestions(prefixRange,substituteRange){const prefix=this._textEditor.text(prefixRange);if(prefix.startsWith('$')){return null;}
  649. const propertyToken=this._backtrackPropertyToken(prefixRange.startLine,prefixRange.startColumn-1);if(!propertyToken){return null;}
  650. const line=this._textEditor.line(prefixRange.startLine);const tokenContent=line.substring(propertyToken.startColumn,propertyToken.endColumn);const propertyValues=SDK.cssMetadata().propertyValues(tokenContent);return Promise.resolve(propertyValues.filter(value=>value.startsWith(prefix)).map(value=>({text:value})));}
  651. _backtrackPropertyToken(lineNumber,columnNumber){const backtrackDepth=10;let tokenPosition=columnNumber;const line=this._textEditor.line(lineNumber);let seenColon=false;for(let i=0;i<backtrackDepth&&tokenPosition>=0;++i){const token=this._textEditor.tokenAtTextPosition(lineNumber,tokenPosition);if(!token){return null;}
  652. if(token.type==='css-property'){return seenColon?token:null;}
  653. if(token.type&&!(token.type.indexOf('whitespace')!==-1||token.type.startsWith('css-comment'))){return null;}
  654. if(!token.type&&line.substring(token.startColumn,token.endColumn)===':'){if(!seenColon){seenColon=true;}else{return null;}}
  655. tokenPosition=token.startColumn-1;}
  656. return null;}
  657. dispose(){if(this._swatchPopoverHelper.isShowing()){this._swatchPopoverHelper.hide(true);}
  658. this._textEditor.removeEventListener(SourceFrame.SourcesTextEditor.Events.ScrollChanged,this._textEditorScrolled,this);this._textEditor.removeEventListener(UI.TextEditor.Events.TextChanged,this._onTextChanged,this);this._textEditor.bookmarks(this._textEditor.fullRange(),Sources.CSSPlugin.SwatchBookmark).forEach(marker=>marker.clear());this._textEditor.element.removeEventListener('keydown',this._boundHandleKeyDown,false);}};Sources.CSSPlugin.maxSwatchProcessingLength=300;Sources.CSSPlugin.SwatchBookmark=Symbol('swatch');;Sources.GutterDiffPlugin=class extends Sources.UISourceCodeFrame.Plugin{constructor(textEditor,uiSourceCode){super();this._textEditor=textEditor;this._uiSourceCode=uiSourceCode;this._decorations=[];this._textEditor.installGutter(Sources.GutterDiffPlugin.DiffGutterType,true);this._workspaceDiff=WorkspaceDiff.workspaceDiff();this._workspaceDiff.subscribeToDiffChange(this._uiSourceCode,this._update,this);this._update();}
  659. static accepts(uiSourceCode){return uiSourceCode.project().type()===Workspace.projectTypes.Network;}
  660. _updateDecorations(removed,added){this._textEditor.operation(operation);function operation(){for(const decoration of removed){decoration.remove();}
  661. for(const decoration of added){decoration.install();}}}
  662. _update(){if(this._uiSourceCode){this._workspaceDiff.requestDiff(this._uiSourceCode).then(this._innerUpdate.bind(this));}else{this._innerUpdate(null);}}
  663. _innerUpdate(lineDiff){if(!lineDiff){this._updateDecorations(this._decorations,[]);this._decorations=[];return;}
  664. const oldDecorations=new Map();for(let i=0;i<this._decorations.length;++i){const decoration=this._decorations[i];const lineNumber=decoration.lineNumber();if(lineNumber===-1){continue;}
  665. oldDecorations.set(lineNumber,decoration);}
  666. const diff=SourceFrame.SourceCodeDiff.computeDiff(lineDiff);const newDecorations=new Map();for(let i=0;i<diff.length;++i){const diffEntry=diff[i];for(let lineNumber=diffEntry.from;lineNumber<diffEntry.to;++lineNumber){newDecorations.set(lineNumber,{lineNumber:lineNumber,type:diffEntry.type});}}
  667. const decorationDiff=oldDecorations.diff(newDecorations,(e1,e2)=>e1.type===e2.type);const addedDecorations=decorationDiff.added.map(entry=>new Sources.GutterDiffPlugin.GutterDecoration(this._textEditor,entry.lineNumber,entry.type));this._decorations=decorationDiff.equal.concat(addedDecorations);this._updateDecorations(decorationDiff.removed,addedDecorations);this._decorationsSetForTest(newDecorations);}
  668. _decorationsSetForTest(decorations){}
  669. async populateLineGutterContextMenu(contextMenu,lineNumber){Sources.GutterDiffPlugin._appendRevealDiffContextMenu(contextMenu,this._uiSourceCode);}
  670. async populateTextAreaContextMenu(contextMenu,lineNumber,columnNumber){Sources.GutterDiffPlugin._appendRevealDiffContextMenu(contextMenu,this._uiSourceCode);}
  671. static _appendRevealDiffContextMenu(contextMenu,uiSourceCode){if(!WorkspaceDiff.workspaceDiff().isUISourceCodeModified(uiSourceCode)){return;}
  672. contextMenu.revealSection().appendItem(ls`Local Modifications...`,()=>{Common.Revealer.reveal(new WorkspaceDiff.DiffUILocation(uiSourceCode));});}
  673. dispose(){for(const decoration of this._decorations){decoration.remove();}
  674. WorkspaceDiff.workspaceDiff().unsubscribeFromDiffChange(this._uiSourceCode,this._update,this);}};Sources.GutterDiffPlugin.GutterDecoration=class{constructor(textEditor,lineNumber,type){this._textEditor=textEditor;this._position=this._textEditor.textEditorPositionHandle(lineNumber,0);this._className='';if(type===SourceFrame.SourceCodeDiff.EditType.Insert){this._className='diff-entry-insert';}else if(type===SourceFrame.SourceCodeDiff.EditType.Delete){this._className='diff-entry-delete';}else if(type===SourceFrame.SourceCodeDiff.EditType.Modify){this._className='diff-entry-modify';}
  675. this.type=type;}
  676. lineNumber(){const location=this._position.resolve();if(!location){return-1;}
  677. return location.lineNumber;}
  678. install(){const location=this._position.resolve();if(!location){return;}
  679. const element=createElementWithClass('div','diff-marker');element.textContent='\xA0';this._textEditor.setGutterDecoration(location.lineNumber,Sources.GutterDiffPlugin.DiffGutterType,element);this._textEditor.toggleLineClass(location.lineNumber,this._className,true);}
  680. remove(){const location=this._position.resolve();if(!location){return;}
  681. this._textEditor.setGutterDecoration(location.lineNumber,Sources.GutterDiffPlugin.DiffGutterType,null);this._textEditor.toggleLineClass(location.lineNumber,this._className,false);}};Sources.GutterDiffPlugin.DiffGutterType='CodeMirror-gutter-diff';Sources.GutterDiffPlugin.ContextMenuProvider=class{appendApplicableItems(event,contextMenu,target){let uiSourceCode=(target);const binding=Persistence.persistence.binding(uiSourceCode);if(binding){uiSourceCode=binding.network;}
  682. Sources.GutterDiffPlugin._appendRevealDiffContextMenu(contextMenu,uiSourceCode);}};;Sources.SearchSourcesView=class extends Search.SearchView{constructor(){super('sources');}
  683. static async openSearch(query,searchImmediately){const view=UI.viewManager.view('sources.search-sources-tab');const location=await UI.viewManager.resolveLocation('drawer-view');location.appendView(view);await UI.viewManager.revealView((view));const widget=(await view.widget());widget.toggle(query,!!searchImmediately);return widget;}
  684. createScope(){return new Sources.SourcesSearchScope();}};Sources.SearchSourcesView.ActionDelegate=class{handleAction(context,actionId){this._showSearch();return true;}
  685. _showSearch(){const selection=UI.inspectorView.element.window().getSelection();let queryCandidate='';if(selection.rangeCount){queryCandidate=selection.toString().replace(/\r?\n.*/,'');}
  686. return Sources.SearchSourcesView.openSearch(queryCandidate);}};;Sources.NavigatorView=class extends UI.VBox{constructor(){super(true);this.registerRequiredCSS('sources/navigatorView.css');this._placeholder=null;this._scriptsTree=new UI.TreeOutlineInShadow();this._scriptsTree.registerRequiredCSS('sources/navigatorTree.css');this._scriptsTree.setComparator(Sources.NavigatorView._treeElementsCompare);this.contentElement.appendChild(this._scriptsTree.element);this.setDefaultFocusedElement(this._scriptsTree.element);this._uiSourceCodeNodes=new Platform.Multimap();this._subfolderNodes=new Map();this._rootNode=new Sources.NavigatorRootTreeNode(this);this._rootNode.populate();this._frameNodes=new Map();this.contentElement.addEventListener('contextmenu',this.handleContextMenu.bind(this),false);UI.shortcutRegistry.addShortcutListener(this.contentElement,'sources.rename',this._renameShortcut.bind(this),true);this._navigatorGroupByFolderSetting=Common.moduleSetting('navigatorGroupByFolder');this._navigatorGroupByFolderSetting.addChangeListener(this._groupingChanged.bind(this));this._initGrouping();Persistence.persistence.addEventListener(Persistence.Persistence.Events.BindingCreated,this._onBindingChanged,this);Persistence.persistence.addEventListener(Persistence.Persistence.Events.BindingRemoved,this._onBindingChanged,this);SDK.targetManager.addEventListener(SDK.TargetManager.Events.NameChanged,this._targetNameChanged,this);SDK.targetManager.observeTargets(this);this._resetWorkspace(Workspace.workspace);this._workspace.uiSourceCodes().forEach(this._addUISourceCode.bind(this));Bindings.networkProjectManager.addEventListener(Bindings.NetworkProjectManager.Events.FrameAttributionAdded,this._frameAttributionAdded,this);Bindings.networkProjectManager.addEventListener(Bindings.NetworkProjectManager.Events.FrameAttributionRemoved,this._frameAttributionRemoved,this);}
  687. static _treeElementOrder(treeElement){if(treeElement._boostOrder){return 0;}
  688. if(!Sources.NavigatorView._typeOrders){const weights={};const types=Sources.NavigatorView.Types;weights[types.Root]=1;weights[types.Domain]=10;weights[types.FileSystemFolder]=1;weights[types.NetworkFolder]=1;weights[types.SourceMapFolder]=2;weights[types.File]=10;weights[types.Frame]=70;weights[types.Worker]=90;weights[types.FileSystem]=100;Sources.NavigatorView._typeOrders=weights;}
  689. let order=Sources.NavigatorView._typeOrders[treeElement._nodeType];if(treeElement._uiSourceCode){const contentType=treeElement._uiSourceCode.contentType();if(contentType.isDocument()){order+=3;}else if(contentType.isScript()){order+=5;}else if(contentType.isStyleSheet()){order+=10;}else{order+=15;}}
  690. return order;}
  691. static appendSearchItem(contextMenu,path){function searchPath(){Sources.SearchSourcesView.openSearch(`file:${path.trim()}`);}
  692. let searchLabel=Common.UIString('Search in folder');if(!path||!path.trim()){path='*';searchLabel=Common.UIString('Search in all files');}
  693. contextMenu.viewSection().appendItem(searchLabel,searchPath);}
  694. static _treeElementsCompare(treeElement1,treeElement2){const typeWeight1=Sources.NavigatorView._treeElementOrder(treeElement1);const typeWeight2=Sources.NavigatorView._treeElementOrder(treeElement2);if(typeWeight1>typeWeight2){return 1;}
  695. if(typeWeight1<typeWeight2){return-1;}
  696. return treeElement1.titleAsText().compareTo(treeElement2.titleAsText());}
  697. setPlaceholder(placeholder){console.assert(!this._placeholder,'A placeholder widget was already set');this._placeholder=placeholder;placeholder.show(this.contentElement,this.contentElement.firstChild);updateVisibility.call(this);this._scriptsTree.addEventListener(UI.TreeOutline.Events.ElementAttached,updateVisibility.bind(this));this._scriptsTree.addEventListener(UI.TreeOutline.Events.ElementsDetached,updateVisibility.bind(this));function updateVisibility(){const showTree=this._scriptsTree.firstChild();if(showTree){placeholder.hideWidget();}else{placeholder.showWidget();}
  698. this._scriptsTree.element.classList.toggle('hidden',!showTree);}}
  699. _onBindingChanged(event){const binding=(event.data);const networkNodes=this._uiSourceCodeNodes.get(binding.network);for(const networkNode of networkNodes){networkNode.updateTitle();}
  700. const fileSystemNodes=this._uiSourceCodeNodes.get(binding.fileSystem);for(const fileSystemNode of fileSystemNodes){fileSystemNode.updateTitle();}
  701. const pathTokens=Persistence.FileSystemWorkspaceBinding.relativePath(binding.fileSystem);let folderPath='';for(let i=0;i<pathTokens.length-1;++i){folderPath+=pathTokens[i];const folderId=this._folderNodeId(binding.fileSystem.project(),null,null,binding.fileSystem.origin(),folderPath);const folderNode=this._subfolderNodes.get(folderId);if(folderNode){folderNode.updateTitle();}
  702. folderPath+='/';}
  703. const fileSystemRoot=this._rootNode.child(binding.fileSystem.project().id());if(fileSystemRoot){fileSystemRoot.updateTitle();}}
  704. focus(){this._scriptsTree.focus();}
  705. _resetWorkspace(workspace){this._workspace=workspace;this._workspace.addEventListener(Workspace.Workspace.Events.UISourceCodeAdded,this._uiSourceCodeAdded,this);this._workspace.addEventListener(Workspace.Workspace.Events.UISourceCodeRemoved,this._uiSourceCodeRemoved,this);this._workspace.addEventListener(Workspace.Workspace.Events.ProjectAdded,event=>{const project=(event.data);this._projectAdded(project);if(project.type()===Workspace.projectTypes.FileSystem){this._computeUniqueFileSystemProjectNames();}});this._workspace.addEventListener(Workspace.Workspace.Events.ProjectRemoved,event=>{const project=(event.data);this._removeProject(project);if(project.type()===Workspace.projectTypes.FileSystem){this._computeUniqueFileSystemProjectNames();}});this._workspace.projects().forEach(this._projectAdded.bind(this));this._computeUniqueFileSystemProjectNames();}
  706. workspace(){return this._workspace;}
  707. acceptProject(project){return!project.isServiceProject();}
  708. _frameAttributionAdded(event){const uiSourceCode=(event.data.uiSourceCode);if(!this._acceptsUISourceCode(uiSourceCode)){return;}
  709. const addedFrame=(event.data.frame);this._addUISourceCodeNode(uiSourceCode,addedFrame);}
  710. _frameAttributionRemoved(event){const uiSourceCode=(event.data.uiSourceCode);if(!this._acceptsUISourceCode(uiSourceCode)){return;}
  711. const removedFrame=(event.data.frame);const node=Array.from(this._uiSourceCodeNodes.get(uiSourceCode)).find(node=>node.frame()===removedFrame);this._removeUISourceCodeNode(node);}
  712. _acceptsUISourceCode(uiSourceCode){return this.acceptProject(uiSourceCode.project());}
  713. _addUISourceCode(uiSourceCode){if(!this._acceptsUISourceCode(uiSourceCode)){return;}
  714. const frames=Bindings.NetworkProject.framesForUISourceCode(uiSourceCode);if(frames.length){for(const frame of frames){this._addUISourceCodeNode(uiSourceCode,frame);}}else{this._addUISourceCodeNode(uiSourceCode,null);}
  715. this.uiSourceCodeAdded(uiSourceCode);}
  716. _addUISourceCodeNode(uiSourceCode,frame){const isFromSourceMap=uiSourceCode.contentType().isFromSourceMap();let path;if(uiSourceCode.project().type()===Workspace.projectTypes.FileSystem){path=Persistence.FileSystemWorkspaceBinding.relativePath(uiSourceCode).slice(0,-1);}else{path=Common.ParsedURL.extractPath(uiSourceCode.url()).split('/').slice(1,-1);}
  717. const project=uiSourceCode.project();const target=Bindings.NetworkProject.targetForUISourceCode(uiSourceCode);const folderNode=this._folderNode(uiSourceCode,project,target,frame,uiSourceCode.origin(),path,isFromSourceMap);const uiSourceCodeNode=new Sources.NavigatorUISourceCodeTreeNode(this,uiSourceCode,frame);folderNode.appendChild(uiSourceCodeNode);this._uiSourceCodeNodes.set(uiSourceCode,uiSourceCodeNode);this._selectDefaultTreeNode();}
  718. uiSourceCodeAdded(uiSourceCode){}
  719. _uiSourceCodeAdded(event){const uiSourceCode=(event.data);this._addUISourceCode(uiSourceCode);}
  720. _uiSourceCodeRemoved(event){const uiSourceCode=(event.data);this._removeUISourceCode(uiSourceCode);}
  721. tryAddProject(project){this._projectAdded(project);project.uiSourceCodes().forEach(this._addUISourceCode.bind(this));}
  722. _projectAdded(project){if(!this.acceptProject(project)||project.type()!==Workspace.projectTypes.FileSystem||Snippets.isSnippetsProject(project)||this._rootNode.child(project.id())){return;}
  723. this._rootNode.appendChild(new Sources.NavigatorGroupTreeNode(this,project,project.id(),Sources.NavigatorView.Types.FileSystem,project.displayName()));this._selectDefaultTreeNode();}
  724. _selectDefaultTreeNode(){const children=this._rootNode.children();if(children.length&&!this._scriptsTree.selectedTreeElement){children[0].treeNode().select(true,false);}}
  725. _computeUniqueFileSystemProjectNames(){const fileSystemProjects=this._workspace.projectsForType(Workspace.projectTypes.FileSystem);if(!fileSystemProjects.length){return;}
  726. const encoder=new Persistence.PathEncoder();const reversedPaths=fileSystemProjects.map(project=>{const fileSystem=(project);return encoder.encode(fileSystem.fileSystemPath()).reverse();});const reversedIndex=new Common.Trie();for(const reversedPath of reversedPaths){reversedIndex.add(reversedPath);}
  727. for(let i=0;i<fileSystemProjects.length;++i){const reversedPath=reversedPaths[i];const project=fileSystemProjects[i];reversedIndex.remove(reversedPath);const commonPrefix=reversedIndex.longestPrefix(reversedPath,false);reversedIndex.add(reversedPath);const path=encoder.decode(reversedPath.substring(0,commonPrefix.length+1).reverse());const fileSystemNode=this._rootNode.child(project.id());if(fileSystemNode){fileSystemNode.setTitle(path);}}}
  728. _removeProject(project){const uiSourceCodes=project.uiSourceCodes();for(let i=0;i<uiSourceCodes.length;++i){this._removeUISourceCode(uiSourceCodes[i]);}
  729. if(project.type()!==Workspace.projectTypes.FileSystem){return;}
  730. const fileSystemNode=this._rootNode.child(project.id());if(!fileSystemNode){return;}
  731. this._rootNode.removeChild(fileSystemNode);}
  732. _folderNodeId(project,target,frame,projectOrigin,path){const targetId=target?target.id():'';const projectId=project.type()===Workspace.projectTypes.FileSystem?project.id():'';const frameId=this._groupByFrame&&frame?frame.id:'';return targetId+':'+projectId+':'+frameId+':'+projectOrigin+':'+path;}
  733. _folderNode(uiSourceCode,project,target,frame,projectOrigin,path,fromSourceMap){if(Snippets.isSnippetsUISourceCode(uiSourceCode)){return this._rootNode;}
  734. if(target&&!this._groupByFolder&&!fromSourceMap){return this._domainNode(uiSourceCode,project,target,frame,projectOrigin);}
  735. const folderPath=path.join('/');const folderId=this._folderNodeId(project,target,frame,projectOrigin,folderPath);let folderNode=this._subfolderNodes.get(folderId);if(folderNode){return folderNode;}
  736. if(!path.length){if(target){return this._domainNode(uiSourceCode,project,target,frame,projectOrigin);}
  737. return(this._rootNode.child(project.id()));}
  738. const parentNode=this._folderNode(uiSourceCode,project,target,frame,projectOrigin,path.slice(0,-1),fromSourceMap);let type=fromSourceMap?Sources.NavigatorView.Types.SourceMapFolder:Sources.NavigatorView.Types.NetworkFolder;if(project.type()===Workspace.projectTypes.FileSystem){type=Sources.NavigatorView.Types.FileSystemFolder;}
  739. const name=path[path.length-1];folderNode=new Sources.NavigatorFolderTreeNode(this,project,folderId,type,folderPath,name);this._subfolderNodes.set(folderId,folderNode);parentNode.appendChild(folderNode);return folderNode;}
  740. _domainNode(uiSourceCode,project,target,frame,projectOrigin){const frameNode=this._frameNode(project,target,frame);if(!this._groupByDomain){return frameNode;}
  741. let domainNode=frameNode.child(projectOrigin);if(domainNode){return domainNode;}
  742. domainNode=new Sources.NavigatorGroupTreeNode(this,project,projectOrigin,Sources.NavigatorView.Types.Domain,this._computeProjectDisplayName(target,projectOrigin));if(frame&&projectOrigin===Common.ParsedURL.extractOrigin(frame.url)){domainNode.treeNode()._boostOrder=true;}
  743. frameNode.appendChild(domainNode);return domainNode;}
  744. _frameNode(project,target,frame){if(!this._groupByFrame||!frame){return this._targetNode(project,target);}
  745. let frameNode=this._frameNodes.get(frame);if(frameNode){return frameNode;}
  746. frameNode=new Sources.NavigatorGroupTreeNode(this,project,target.id()+':'+frame.id,Sources.NavigatorView.Types.Frame,frame.displayName());frameNode.setHoverCallback(hoverCallback);this._frameNodes.set(frame,frameNode);const parentFrame=frame.parentFrame||frame.crossTargetParentFrame();this._frameNode(project,parentFrame?parentFrame.resourceTreeModel().target():target,parentFrame).appendChild(frameNode);if(!parentFrame){frameNode.treeNode()._boostOrder=true;frameNode.treeNode().expand();}
  747. function hoverCallback(hovered){if(hovered){const overlayModel=target.model(SDK.OverlayModel);if(overlayModel){overlayModel.highlightFrame(frame.id);}}else{SDK.OverlayModel.hideDOMNodeHighlight();}}
  748. return frameNode;}
  749. _targetNode(project,target){if(target===SDK.targetManager.mainTarget()){return this._rootNode;}
  750. let targetNode=this._rootNode.child('target:'+target.id());if(!targetNode){targetNode=new Sources.NavigatorGroupTreeNode(this,project,'target:'+target.id(),target.type()===SDK.Target.Type.Frame?Sources.NavigatorView.Types.Frame:Sources.NavigatorView.Types.Worker,target.name());this._rootNode.appendChild(targetNode);}
  751. return targetNode;}
  752. _computeProjectDisplayName(target,projectOrigin){const runtimeModel=target.model(SDK.RuntimeModel);const executionContexts=runtimeModel?runtimeModel.executionContexts():[];for(const context of executionContexts){if(context.name&&context.origin&&projectOrigin.startsWith(context.origin)){return context.name;}}
  753. if(!projectOrigin){return Common.UIString('(no domain)');}
  754. const parsedURL=new Common.ParsedURL(projectOrigin);const prettyURL=parsedURL.isValid?parsedURL.host+(parsedURL.port?(':'+parsedURL.port):''):'';return(prettyURL||projectOrigin);}
  755. revealUISourceCode(uiSourceCode,select){const nodes=this._uiSourceCodeNodes.get(uiSourceCode);const node=nodes.firstValue();if(!node){return null;}
  756. if(this._scriptsTree.selectedTreeElement){this._scriptsTree.selectedTreeElement.deselect();}
  757. this._lastSelectedUISourceCode=uiSourceCode;node.reveal(select);return node;}
  758. _sourceSelected(uiSourceCode,focusSource){this._lastSelectedUISourceCode=uiSourceCode;Common.Revealer.reveal(uiSourceCode,!focusSource);}
  759. _removeUISourceCode(uiSourceCode){const nodes=this._uiSourceCodeNodes.get(uiSourceCode);for(const node of nodes){this._removeUISourceCodeNode(node);}}
  760. _removeUISourceCodeNode(node){const uiSourceCode=node.uiSourceCode();this._uiSourceCodeNodes.delete(uiSourceCode,node);const project=uiSourceCode.project();const target=Bindings.NetworkProject.targetForUISourceCode(uiSourceCode);const frame=node.frame();let parentNode=node.parent;parentNode.removeChild(node);node=parentNode;while(node){parentNode=node.parent;if(!parentNode||!node.isEmpty()){break;}
  761. if(parentNode===this._rootNode&&project.type()===Workspace.projectTypes.FileSystem){break;}
  762. if(!(node instanceof Sources.NavigatorGroupTreeNode||node instanceof Sources.NavigatorFolderTreeNode)){break;}
  763. if(node._type===Sources.NavigatorView.Types.Frame){this._discardFrame((frame));break;}
  764. const folderId=this._folderNodeId(project,target,frame,uiSourceCode.origin(),node._folderPath);this._subfolderNodes.delete(folderId);parentNode.removeChild(node);node=parentNode;}}
  765. reset(){for(const node of this._uiSourceCodeNodes.valuesArray()){node.dispose();}
  766. this._scriptsTree.removeChildren();this._uiSourceCodeNodes.clear();this._subfolderNodes.clear();this._frameNodes.clear();this._rootNode.reset();}
  767. handleContextMenu(event){}
  768. _renameShortcut(){const node=this._scriptsTree.selectedTreeElement&&this._scriptsTree.selectedTreeElement._node;if(!node||!node._uiSourceCode||!node._uiSourceCode.canRename()){return false;}
  769. this.rename(node,false);return true;}
  770. _handleContextMenuCreate(project,path,uiSourceCode){if(uiSourceCode){const relativePath=Persistence.FileSystemWorkspaceBinding.relativePath(uiSourceCode);relativePath.pop();path=relativePath.join('/');}
  771. this.create(project,path,uiSourceCode);}
  772. _handleContextMenuRename(node){this.rename(node,false);}
  773. _handleContextMenuExclude(project,path){const shouldExclude=window.confirm(Common.UIString('Are you sure you want to exclude this folder?'));if(shouldExclude){UI.startBatchUpdate();project.excludeFolder(Persistence.FileSystemWorkspaceBinding.completeURL(project,path));UI.endBatchUpdate();}}
  774. _handleContextMenuDelete(uiSourceCode){const shouldDelete=window.confirm(Common.UIString('Are you sure you want to delete this file?'));if(shouldDelete){uiSourceCode.project().deleteFile(uiSourceCode);}}
  775. handleFileContextMenu(event,node){const uiSourceCode=node.uiSourceCode();const contextMenu=new UI.ContextMenu(event);contextMenu.appendApplicableItems(uiSourceCode);const project=uiSourceCode.project();if(project.type()===Workspace.projectTypes.FileSystem){contextMenu.editSection().appendItem(Common.UIString('Rename\u2026'),this._handleContextMenuRename.bind(this,node));contextMenu.editSection().appendItem(Common.UIString('Make a copy\u2026'),this._handleContextMenuCreate.bind(this,project,'',uiSourceCode));contextMenu.editSection().appendItem(Common.UIString('Delete'),this._handleContextMenuDelete.bind(this,uiSourceCode));}
  776. contextMenu.show();}
  777. handleFolderContextMenu(event,node){const path=node._folderPath||'';const project=node._project;const contextMenu=new UI.ContextMenu(event);if(project.type()===Workspace.projectTypes.FileSystem){Sources.NavigatorView.appendSearchItem(contextMenu,path);const folderPath=Common.ParsedURL.urlToPlatformPath(Persistence.FileSystemWorkspaceBinding.completeURL(project,path),Host.isWin());contextMenu.revealSection().appendItem(Common.UIString('Open folder'),()=>Host.InspectorFrontendHost.showItemInFolder(folderPath));if(project.canCreateFile()){contextMenu.defaultSection().appendItem(Common.UIString('New file'),this._handleContextMenuCreate.bind(this,project,path));}}
  778. if(project.canExcludeFolder(path)){contextMenu.defaultSection().appendItem(Common.UIString('Exclude folder'),this._handleContextMenuExclude.bind(this,project,path));}
  779. function removeFolder(){const shouldRemove=window.confirm(Common.UIString('Are you sure you want to remove this folder?'));if(shouldRemove){project.remove();}}
  780. if(project.type()===Workspace.projectTypes.FileSystem){contextMenu.defaultSection().appendAction('sources.add-folder-to-workspace',undefined,true);if(node instanceof Sources.NavigatorGroupTreeNode){contextMenu.defaultSection().appendItem(Common.UIString('Remove folder from workspace'),removeFolder);}}
  781. contextMenu.show();}
  782. rename(node,creatingNewUISourceCode){const uiSourceCode=node.uiSourceCode();node.rename(callback.bind(this));function callback(committed){if(!creatingNewUISourceCode){return;}
  783. if(!committed){uiSourceCode.remove();}else if(node._treeElement.listItemElement.hasFocus()){this._sourceSelected(uiSourceCode,true);}}}
  784. async create(project,path,uiSourceCodeToCopy){let content='';if(uiSourceCodeToCopy){content=(await uiSourceCodeToCopy.requestContent()).content||'';}
  785. const uiSourceCode=await project.createFile(path,null,content);if(!uiSourceCode){return;}
  786. this._sourceSelected(uiSourceCode,false);const node=this.revealUISourceCode(uiSourceCode,true);if(node){this.rename(node,true);}}
  787. _groupingChanged(){this.reset();this._initGrouping();this._workspace.uiSourceCodes().forEach(this._addUISourceCode.bind(this));}
  788. _initGrouping(){this._groupByFrame=true;this._groupByDomain=this._navigatorGroupByFolderSetting.get();this._groupByFolder=this._groupByDomain;}
  789. _resetForTest(){this.reset();this._workspace.uiSourceCodes().forEach(this._addUISourceCode.bind(this));}
  790. _discardFrame(frame){const node=this._frameNodes.get(frame);if(!node){return;}
  791. if(node.parent){node.parent.removeChild(node);}
  792. this._frameNodes.delete(frame);for(const child of frame.childFrames){this._discardFrame(child);}}
  793. targetAdded(target){}
  794. targetRemoved(target){const targetNode=this._rootNode.child('target:'+target.id());if(targetNode){this._rootNode.removeChild(targetNode);}}
  795. _targetNameChanged(event){const target=(event.data);const targetNode=this._rootNode.child('target:'+target.id());if(targetNode){targetNode.setTitle(target.name());}}};Sources.NavigatorView.Types={Domain:'domain',File:'file',FileSystem:'fs',FileSystemFolder:'fs-folder',Frame:'frame',NetworkFolder:'nw-folder',Root:'root',SourceMapFolder:'sm-folder',Worker:'worker'};Sources.NavigatorFolderTreeElement=class extends UI.TreeElement{constructor(navigatorView,type,title,hoverCallback){super('',true);this.listItemElement.classList.add('navigator-'+type+'-tree-item','navigator-folder-tree-item');this._nodeType=type;this.title=title;this.tooltip=title;this._navigatorView=navigatorView;this._hoverCallback=hoverCallback;let iconType='largeicon-navigator-folder';if(type===Sources.NavigatorView.Types.Domain){iconType='largeicon-navigator-domain';}else if(type===Sources.NavigatorView.Types.Frame){iconType='largeicon-navigator-frame';}else if(type===Sources.NavigatorView.Types.Worker){iconType='largeicon-navigator-worker';}
  796. this.setLeadingIcons([UI.Icon.create(iconType,'icon')]);}
  797. async onpopulate(){this._node.populate();}
  798. onattach(){this.collapse();this._node.onattach();this.listItemElement.addEventListener('contextmenu',this._handleContextMenuEvent.bind(this),false);this.listItemElement.addEventListener('mousemove',this._mouseMove.bind(this),false);this.listItemElement.addEventListener('mouseleave',this._mouseLeave.bind(this),false);}
  799. setNode(node){this._node=node;const paths=[];while(node&&!node.isRoot()){paths.push(node._title);node=node.parent;}
  800. paths.reverse();this.tooltip=paths.join('/');}
  801. _handleContextMenuEvent(event){if(!this._node){return;}
  802. this.select();this._navigatorView.handleFolderContextMenu(event,this._node);}
  803. _mouseMove(event){if(this._hovered||!this._hoverCallback){return;}
  804. this._hovered=true;this._hoverCallback(true);}
  805. _mouseLeave(event){if(!this._hoverCallback){return;}
  806. this._hovered=false;this._hoverCallback(false);}};Sources.NavigatorSourceTreeElement=class extends UI.TreeElement{constructor(navigatorView,uiSourceCode,title,node){super('',false);this._nodeType=Sources.NavigatorView.Types.File;this._node=node;this.title=title;this.listItemElement.classList.add('navigator-'+uiSourceCode.contentType().name()+'-tree-item','navigator-file-tree-item');this.tooltip=uiSourceCode.url();this._navigatorView=navigatorView;this._uiSourceCode=uiSourceCode;this.updateIcon();}
  807. updateIcon(){const binding=Persistence.persistence.binding(this._uiSourceCode);if(binding){const container=createElementWithClass('span','icon-stack');let iconType='largeicon-navigator-file-sync';if(Snippets.isSnippetsUISourceCode(binding.fileSystem)){iconType='largeicon-navigator-snippet';}
  808. const icon=UI.Icon.create(iconType,'icon');const badge=UI.Icon.create('badge-navigator-file-sync','icon-badge');if(Persistence.networkPersistenceManager.project()===binding.fileSystem.project()){badge.style.filter='hue-rotate(160deg)';}
  809. container.appendChild(icon);container.appendChild(badge);container.title=Persistence.PersistenceUtils.tooltipForUISourceCode(this._uiSourceCode);this.setLeadingIcons([container]);}else{let iconType='largeicon-navigator-file';if(Snippets.isSnippetsUISourceCode(this._uiSourceCode)){iconType='largeicon-navigator-snippet';}
  810. const defaultIcon=UI.Icon.create(iconType,'icon');this.setLeadingIcons([defaultIcon]);}}
  811. get uiSourceCode(){return this._uiSourceCode;}
  812. onattach(){this.listItemElement.draggable=true;this.listItemElement.addEventListener('click',this._onclick.bind(this),false);this.listItemElement.addEventListener('contextmenu',this._handleContextMenuEvent.bind(this),false);this.listItemElement.addEventListener('dragstart',this._ondragstart.bind(this),false);}
  813. _shouldRenameOnMouseDown(){if(!this._uiSourceCode.canRename()){return false;}
  814. const isSelected=this===this.treeOutline.selectedTreeElement;return isSelected&&this.treeOutline.element.hasFocus()&&!UI.isBeingEdited(this.treeOutline.element);}
  815. selectOnMouseDown(event){if(event.which!==1||!this._shouldRenameOnMouseDown()){super.selectOnMouseDown(event);return;}
  816. setTimeout(rename.bind(this),300);function rename(){if(this._shouldRenameOnMouseDown()){this._navigatorView.rename(this._node,false);}}}
  817. _ondragstart(event){event.dataTransfer.setData('text/plain',this._uiSourceCode.url());event.dataTransfer.effectAllowed='copy';}
  818. onspace(){this._navigatorView._sourceSelected(this.uiSourceCode,true);return true;}
  819. _onclick(event){this._navigatorView._sourceSelected(this.uiSourceCode,false);}
  820. ondblclick(event){const middleClick=event.button===1;this._navigatorView._sourceSelected(this.uiSourceCode,!middleClick);return false;}
  821. onenter(){this._navigatorView._sourceSelected(this.uiSourceCode,true);return true;}
  822. ondelete(){return true;}
  823. _handleContextMenuEvent(event){this.select();this._navigatorView.handleFileContextMenu(event,this._node);}};Sources.NavigatorTreeNode=class{constructor(id,type){this.id=id;this._type=type;this._children=new Map();}
  824. treeNode(){throw'Not implemented';}
  825. dispose(){}
  826. isRoot(){return false;}
  827. hasChildren(){return true;}
  828. onattach(){}
  829. setTitle(title){throw'Not implemented';}
  830. populate(){if(this.isPopulated()){return;}
  831. if(this.parent){this.parent.populate();}
  832. this._populated=true;this.wasPopulated();}
  833. wasPopulated(){const children=this.children();for(let i=0;i<children.length;++i){this.treeNode().appendChild((children[i].treeNode()));}}
  834. didAddChild(node){if(this.isPopulated()){this.treeNode().appendChild((node.treeNode()));}}
  835. willRemoveChild(node){if(this.isPopulated()){this.treeNode().removeChild((node.treeNode()));}}
  836. isPopulated(){return this._populated;}
  837. isEmpty(){return!this._children.size;}
  838. children(){return this._children.valuesArray();}
  839. child(id){return this._children.get(id)||null;}
  840. appendChild(node){this._children.set(node.id,node);node.parent=this;this.didAddChild(node);}
  841. removeChild(node){this.willRemoveChild(node);this._children.remove(node.id);delete node.parent;node.dispose();}
  842. reset(){this._children.clear();}};Sources.NavigatorRootTreeNode=class extends Sources.NavigatorTreeNode{constructor(navigatorView){super('',Sources.NavigatorView.Types.Root);this._navigatorView=navigatorView;}
  843. isRoot(){return true;}
  844. treeNode(){return this._navigatorView._scriptsTree.rootElement();}};Sources.NavigatorUISourceCodeTreeNode=class extends Sources.NavigatorTreeNode{constructor(navigatorView,uiSourceCode,frame){super(uiSourceCode.project().id()+':'+uiSourceCode.url(),Sources.NavigatorView.Types.File);this._navigatorView=navigatorView;this._uiSourceCode=uiSourceCode;this._treeElement=null;this._eventListeners=[];this._frame=frame;}
  845. frame(){return this._frame;}
  846. uiSourceCode(){return this._uiSourceCode;}
  847. treeNode(){if(this._treeElement){return this._treeElement;}
  848. this._treeElement=new Sources.NavigatorSourceTreeElement(this._navigatorView,this._uiSourceCode,'',this);this.updateTitle();const updateTitleBound=this.updateTitle.bind(this,undefined);this._eventListeners=[this._uiSourceCode.addEventListener(Workspace.UISourceCode.Events.TitleChanged,updateTitleBound),this._uiSourceCode.addEventListener(Workspace.UISourceCode.Events.WorkingCopyChanged,updateTitleBound),this._uiSourceCode.addEventListener(Workspace.UISourceCode.Events.WorkingCopyCommitted,updateTitleBound)];return this._treeElement;}
  849. updateTitle(ignoreIsDirty){if(!this._treeElement){return;}
  850. let titleText=this._uiSourceCode.displayName();if(!ignoreIsDirty&&this._uiSourceCode.isDirty()){titleText='*'+titleText;}
  851. this._treeElement.title=titleText;this._treeElement.updateIcon();let tooltip=this._uiSourceCode.url();if(this._uiSourceCode.contentType().isFromSourceMap()){tooltip=Common.UIString('%s (from source map)',this._uiSourceCode.displayName());}
  852. this._treeElement.tooltip=tooltip;}
  853. hasChildren(){return false;}
  854. dispose(){Common.EventTarget.removeEventListeners(this._eventListeners);}
  855. reveal(select){this.parent.populate();this.parent.treeNode().expand();this._treeElement.reveal(true);if(select){this._treeElement.select(true);}}
  856. rename(callback){if(!this._treeElement){return;}
  857. this._treeElement.listItemElement.focus();const treeOutlineElement=this._treeElement.treeOutline.element;UI.markBeingEdited(treeOutlineElement,true);function commitHandler(element,newTitle,oldTitle){if(newTitle!==oldTitle){this._treeElement.title=newTitle;this._uiSourceCode.rename(newTitle).then(renameCallback.bind(this));return;}
  858. afterEditing.call(this,true);}
  859. function renameCallback(success){if(!success){UI.markBeingEdited(treeOutlineElement,false);this.updateTitle();this.rename(callback);return;}
  860. afterEditing.call(this,true);}
  861. function afterEditing(committed){UI.markBeingEdited(treeOutlineElement,false);this.updateTitle();if(callback){callback(committed);}}
  862. this.updateTitle(true);this._treeElement.startEditingTitle(new UI.InplaceEditor.Config(commitHandler.bind(this),afterEditing.bind(this,false)));}};Sources.NavigatorFolderTreeNode=class extends Sources.NavigatorTreeNode{constructor(navigatorView,project,id,type,folderPath,title){super(id,type);this._navigatorView=navigatorView;this._project=project;this._folderPath=folderPath;this._title=title;}
  863. treeNode(){if(this._treeElement){return this._treeElement;}
  864. this._treeElement=this._createTreeElement(this._title,this);this.updateTitle();return this._treeElement;}
  865. updateTitle(){if(!this._treeElement||this._project.type()!==Workspace.projectTypes.FileSystem){return;}
  866. const absoluteFileSystemPath=Persistence.FileSystemWorkspaceBinding.fileSystemPath(this._project.id())+'/'+this._folderPath;const hasMappedFiles=Persistence.persistence.filePathHasBindings(absoluteFileSystemPath);this._treeElement.listItemElement.classList.toggle('has-mapped-files',hasMappedFiles);}
  867. _createTreeElement(title,node){if(this._project.type()!==Workspace.projectTypes.FileSystem){try{title=decodeURI(title);}catch(e){}}
  868. const treeElement=new Sources.NavigatorFolderTreeElement(this._navigatorView,this._type,title);treeElement.setNode(node);return treeElement;}
  869. wasPopulated(){if(!this._treeElement||this._treeElement._node!==this){return;}
  870. this._addChildrenRecursive();}
  871. _addChildrenRecursive(){const children=this.children();for(let i=0;i<children.length;++i){const child=children[i];this.didAddChild(child);if(child instanceof Sources.NavigatorFolderTreeNode){child._addChildrenRecursive();}}}
  872. _shouldMerge(node){return this._type!==Sources.NavigatorView.Types.Domain&&node instanceof Sources.NavigatorFolderTreeNode;}
  873. didAddChild(node){function titleForNode(node){return node._title;}
  874. if(!this._treeElement){return;}
  875. let children=this.children();if(children.length===1&&this._shouldMerge(node)){node._isMerged=true;this._treeElement.title=this._treeElement.title+'/'+node._title;node._treeElement=this._treeElement;this._treeElement.setNode(node);return;}
  876. let oldNode;if(children.length===2){oldNode=children[0]!==node?children[0]:children[1];}
  877. if(oldNode&&oldNode._isMerged){delete oldNode._isMerged;const mergedToNodes=[];mergedToNodes.push(this);let treeNode=this;while(treeNode._isMerged){treeNode=treeNode.parent;mergedToNodes.push(treeNode);}
  878. mergedToNodes.reverse();const titleText=mergedToNodes.map(titleForNode).join('/');const nodes=[];treeNode=oldNode;do{nodes.push(treeNode);children=treeNode.children();treeNode=children.length===1?children[0]:null;}while(treeNode&&treeNode._isMerged);if(!this.isPopulated()){this._treeElement.title=titleText;this._treeElement.setNode(this);for(let i=0;i<nodes.length;++i){delete nodes[i]._treeElement;delete nodes[i]._isMerged;}
  879. return;}
  880. const oldTreeElement=this._treeElement;const treeElement=this._createTreeElement(titleText,this);for(let i=0;i<mergedToNodes.length;++i){mergedToNodes[i]._treeElement=treeElement;}
  881. oldTreeElement.parent.appendChild(treeElement);oldTreeElement.setNode(nodes[nodes.length-1]);oldTreeElement.title=nodes.map(titleForNode).join('/');oldTreeElement.parent.removeChild(oldTreeElement);this._treeElement.appendChild(oldTreeElement);if(oldTreeElement.expanded){treeElement.expand();}}
  882. if(this.isPopulated()){this._treeElement.appendChild(node.treeNode());}}
  883. willRemoveChild(node){if(node._isMerged||!this.isPopulated()){return;}
  884. this._treeElement.removeChild(node._treeElement);}};Sources.NavigatorGroupTreeNode=class extends Sources.NavigatorTreeNode{constructor(navigatorView,project,id,type,title){super(id,type);this._project=project;this._navigatorView=navigatorView;this._title=title;this.populate();}
  885. setHoverCallback(hoverCallback){this._hoverCallback=hoverCallback;}
  886. treeNode(){if(this._treeElement){return this._treeElement;}
  887. this._treeElement=new Sources.NavigatorFolderTreeElement(this._navigatorView,this._type,this._title,this._hoverCallback);this._treeElement.setNode(this);return this._treeElement;}
  888. onattach(){this.updateTitle();}
  889. updateTitle(){if(!this._treeElement||this._project.type()!==Workspace.projectTypes.FileSystem){return;}
  890. const fileSystemPath=Persistence.FileSystemWorkspaceBinding.fileSystemPath(this._project.id());const wasActive=this._treeElement.listItemElement.classList.contains('has-mapped-files');const isActive=Persistence.persistence.filePathHasBindings(fileSystemPath);if(wasActive===isActive){return;}
  891. this._treeElement.listItemElement.classList.toggle('has-mapped-files',isActive);if(this._treeElement.childrenListElement.hasFocus()){return;}
  892. if(isActive){this._treeElement.expand();}else{this._treeElement.collapse();}}
  893. setTitle(title){this._title=title;if(this._treeElement){this._treeElement.title=this._title;}}};;Sources.ScopeChainSidebarPane=class extends UI.VBox{constructor(){super(true);this.registerRequiredCSS('sources/scopeChainSidebarPane.css');this._treeOutline=new ObjectUI.ObjectPropertiesSectionsTreeOutline();this._treeOutline.registerRequiredCSS('sources/scopeChainSidebarPane.css');this._treeOutline.setShowSelectionOnKeyboardFocus(true);this._expandController=new ObjectUI.ObjectPropertiesSectionsTreeExpandController(this._treeOutline);this._linkifier=new Components.Linkifier();this._infoElement=createElement('div');this._infoElement.className='gray-info-message';this._infoElement.textContent=ls`Not paused`;this._infoElement.tabIndex=-1;this._update();}
  894. flavorChanged(object){this._update();}
  895. focus(){if(this.hasFocus()){return;}
  896. if(UI.context.flavor(SDK.DebuggerPausedDetails)){this._treeOutline.forceSelect();}}
  897. _update(){const callFrame=UI.context.flavor(SDK.DebuggerModel.CallFrame);const details=UI.context.flavor(SDK.DebuggerPausedDetails);this._linkifier.reset();Sources.SourceMapNamesResolver.resolveThisObject(callFrame).then(this._innerUpdate.bind(this,details,callFrame));}
  898. _innerUpdate(details,callFrame,thisObject){this._treeOutline.removeChildren();this.contentElement.removeChildren();if(!details||!callFrame){this.contentElement.appendChild(this._infoElement);return;}
  899. this.contentElement.appendChild(this._treeOutline.element);let foundLocalScope=false;const scopeChain=callFrame.scopeChain();for(let i=0;i<scopeChain.length;++i){const scope=scopeChain[i];const extraProperties=this._extraPropertiesForScope(scope,details,callFrame,thisObject,i===0);if(scope.type()===Protocol.Debugger.ScopeType.Local){foundLocalScope=true;}
  900. const section=this._createScopeSectionTreeElement(scope,extraProperties);if(scope.type()===Protocol.Debugger.ScopeType.Global){section.collapse();}else if(!foundLocalScope||scope.type()===Protocol.Debugger.ScopeType.Local){section.expand();}
  901. this._treeOutline.appendChild(section);if(i===0){section.select(true);}}
  902. this._sidebarPaneUpdatedForTest();}
  903. _createScopeSectionTreeElement(scope,extraProperties){let emptyPlaceholder=null;if(scope.type()===Protocol.Debugger.ScopeType.Local||Protocol.Debugger.ScopeType.Closure){emptyPlaceholder=ls`No variables`;}
  904. let title=scope.typeName();if(scope.type()===Protocol.Debugger.ScopeType.Closure){const scopeName=scope.name();if(scopeName){title=ls`Closure (${UI.beautifyFunctionName(scopeName)})`;}else{title=ls`Closure`;}}
  905. let subtitle=scope.description();if(!title||title===subtitle){subtitle=undefined;}
  906. const titleElement=createElementWithClass('div','scope-chain-sidebar-pane-section-header tree-element-title');titleElement.createChild('div','scope-chain-sidebar-pane-section-subtitle').textContent=subtitle;titleElement.createChild('div','scope-chain-sidebar-pane-section-title').textContent=title;const section=new ObjectUI.ObjectPropertiesSection.RootElement(Sources.SourceMapNamesResolver.resolveScopeInObject(scope),this._linkifier,emptyPlaceholder,true,extraProperties);section.title=titleElement;section.listItemElement.classList.add('scope-chain-sidebar-pane-section');this._expandController.watchSection(title+(subtitle?':'+subtitle:''),section);return section;}
  907. _extraPropertiesForScope(scope,details,callFrame,thisObject,isFirstScope){if(scope.type()!==Protocol.Debugger.ScopeType.Local){return[];}
  908. const extraProperties=[];if(thisObject){extraProperties.push(new SDK.RemoteObjectProperty('this',thisObject));}
  909. if(isFirstScope){const exception=details.exception();if(exception){extraProperties.push(new SDK.RemoteObjectProperty(Common.UIString('Exception'),exception,undefined,undefined,undefined,undefined,undefined,true));}
  910. const returnValue=callFrame.returnValue();if(returnValue){extraProperties.push(new SDK.RemoteObjectProperty(Common.UIString('Return value'),returnValue,undefined,undefined,undefined,undefined,undefined,true,callFrame.setReturnValue.bind(callFrame)));}}
  911. return extraProperties;}
  912. _sidebarPaneUpdatedForTest(){}};Sources.ScopeChainSidebarPane._pathSymbol=Symbol('path');;Sources.NetworkNavigatorView=class extends Sources.NavigatorView{constructor(){super();SDK.targetManager.addEventListener(SDK.TargetManager.Events.InspectedURLChanged,this._inspectedURLChanged,this);Host.userMetrics.panelLoaded('sources','DevTools.Launch.Sources');}
  913. acceptProject(project){return project.type()===Workspace.projectTypes.Network;}
  914. _inspectedURLChanged(event){const mainTarget=SDK.targetManager.mainTarget();if(event.data!==mainTarget){return;}
  915. const inspectedURL=mainTarget&&mainTarget.inspectedURL();if(!inspectedURL){return;}
  916. for(const uiSourceCode of this.workspace().uiSourceCodes()){if(this.acceptProject(uiSourceCode.project())&&uiSourceCode.url()===inspectedURL){this.revealUISourceCode(uiSourceCode,true);}}}
  917. uiSourceCodeAdded(uiSourceCode){const mainTarget=SDK.targetManager.mainTarget();const inspectedURL=mainTarget&&mainTarget.inspectedURL();if(!inspectedURL){return;}
  918. if(uiSourceCode.url()===inspectedURL){this.revealUISourceCode(uiSourceCode,true);}}};Sources.FilesNavigatorView=class extends Sources.NavigatorView{constructor(){super();const placeholder=new UI.EmptyWidget('');this.setPlaceholder(placeholder);placeholder.appendParagraph().appendChild(UI.html`
  919. <div>${ls`Sync changes in DevTools with the local filesystem`}</div><br />
  920. ${UI.XLink.create('https://developers.google.com/web/tools/chrome-devtools/workspaces/', ls`Learn more`)}
  921. `);const toolbar=new UI.Toolbar('navigator-toolbar');toolbar.appendItemsAtLocation('files-navigator-toolbar').then(()=>{if(!toolbar.empty()){this.contentElement.insertBefore(toolbar.element,this.contentElement.firstChild);}});}
  922. acceptProject(project){return project.type()===Workspace.projectTypes.FileSystem&&Persistence.FileSystemWorkspaceBinding.fileSystemType(project)!=='overrides'&&!Snippets.isSnippetsProject(project);}
  923. handleContextMenu(event){const contextMenu=new UI.ContextMenu(event);contextMenu.defaultSection().appendAction('sources.add-folder-to-workspace',undefined,true);contextMenu.show();}};Sources.OverridesNavigatorView=class extends Sources.NavigatorView{constructor(){super();const placeholder=new UI.EmptyWidget('');this.setPlaceholder(placeholder);placeholder.appendParagraph().appendChild(UI.html`
  924. <div>${ls`Override page assets with files from a local folder`}</div><br />
  925. ${UI.XLink.create('https://developers.google.com/web/updates/2018/01/devtools#overrides', ls`Learn more`)}
  926. `);this._toolbar=new UI.Toolbar('navigator-toolbar');this.contentElement.insertBefore(this._toolbar.element,this.contentElement.firstChild);Persistence.networkPersistenceManager.addEventListener(Persistence.NetworkPersistenceManager.Events.ProjectChanged,this._updateProjectAndUI,this);this.workspace().addEventListener(Workspace.Workspace.Events.ProjectAdded,this._onProjectAddOrRemoved,this);this.workspace().addEventListener(Workspace.Workspace.Events.ProjectRemoved,this._onProjectAddOrRemoved,this);this._updateProjectAndUI();}
  927. _onProjectAddOrRemoved(event){const project=(event.data);if(project&&project.type()===Workspace.projectTypes.FileSystem&&Persistence.FileSystemWorkspaceBinding.fileSystemType(project)!=='overrides'){return;}
  928. this._updateUI();}
  929. _updateProjectAndUI(){this.reset();const project=Persistence.networkPersistenceManager.project();if(project){this.tryAddProject(project);}
  930. this._updateUI();}
  931. _updateUI(){this._toolbar.removeToolbarItems();const project=Persistence.networkPersistenceManager.project();if(project){const enableCheckbox=new UI.ToolbarSettingCheckbox(Common.settings.moduleSetting('persistenceNetworkOverridesEnabled'));this._toolbar.appendToolbarItem(enableCheckbox);this._toolbar.appendToolbarItem(new UI.ToolbarSeparator(true));const clearButton=new UI.ToolbarButton(Common.UIString('Clear configuration'),'largeicon-clear');clearButton.addEventListener(UI.ToolbarButton.Events.Click,()=>{project.remove();});this._toolbar.appendToolbarItem(clearButton);return;}
  932. const title=Common.UIString('Select folder for overrides');const setupButton=new UI.ToolbarButton(title,'largeicon-add',title);setupButton.addEventListener(UI.ToolbarButton.Events.Click,this._setupNewWorkspace,this);this._toolbar.appendToolbarItem(setupButton);}
  933. async _setupNewWorkspace(){const fileSystem=await Persistence.isolatedFileSystemManager.addFileSystem('overrides');if(!fileSystem){return;}
  934. Common.settings.moduleSetting('persistenceNetworkOverridesEnabled').set(true);}
  935. acceptProject(project){return project===Persistence.networkPersistenceManager.project();}};Sources.ContentScriptsNavigatorView=class extends Sources.NavigatorView{constructor(){super();const placeholder=new UI.EmptyWidget('');this.setPlaceholder(placeholder);placeholder.appendParagraph().appendChild(UI.html`
  936. <div>${ls`Content scripts served by extensions appear here`}</div><br />
  937. ${UI.XLink.create('https://developer.chrome.com/extensions/content_scripts', ls`Learn more`)}
  938. `);}
  939. acceptProject(project){return project.type()===Workspace.projectTypes.ContentScripts;}};Sources.SnippetsNavigatorView=class extends Sources.NavigatorView{constructor(){super();const placeholder=new UI.EmptyWidget('');this.setPlaceholder(placeholder);placeholder.appendParagraph().appendChild(UI.html`
  940. <div>${ls`Create and save code snippets for later reuse`}</div><br />
  941. ${UI.XLink.create('https://developers.google.com/web/tools/chrome-devtools/javascript/snippets', ls`Learn more`)}
  942. `);const toolbar=new UI.Toolbar('navigator-toolbar');const newButton=new UI.ToolbarButton('','largeicon-add',Common.UIString('New snippet'));newButton.addEventListener(UI.ToolbarButton.Events.Click,()=>this.create(Snippets.project,''));toolbar.appendToolbarItem(newButton);this.contentElement.insertBefore(toolbar.element,this.contentElement.firstChild);}
  943. acceptProject(project){return Snippets.isSnippetsProject(project);}
  944. handleContextMenu(event){const contextMenu=new UI.ContextMenu(event);contextMenu.headerSection().appendItem(ls`Create new snippet`,()=>this.create(Snippets.project,''));contextMenu.show();}
  945. handleFileContextMenu(event,node){const uiSourceCode=node.uiSourceCode();const contextMenu=new UI.ContextMenu(event);contextMenu.headerSection().appendItem(Common.UIString('Run'),()=>Snippets.evaluateScriptSnippet(uiSourceCode));contextMenu.editSection().appendItem(Common.UIString('Rename\u2026'),()=>this.rename(node,false));contextMenu.editSection().appendItem(Common.UIString('Remove'),()=>uiSourceCode.project().deleteFile(uiSourceCode));contextMenu.saveSection().appendItem(Common.UIString('Save as...'),this._handleSaveAs.bind(this,uiSourceCode));contextMenu.show();}
  946. async _handleSaveAs(uiSourceCode){uiSourceCode.commitWorkingCopy();const{content}=await uiSourceCode.requestContent();Workspace.fileManager.save(uiSourceCode.url(),content||'',true);Workspace.fileManager.close(uiSourceCode.url());}};Sources.ActionDelegate=class{handleAction(context,actionId){switch(actionId){case'sources.create-snippet':Snippets.project.createFile('',null,'').then(uiSourceCode=>Common.Revealer.reveal(uiSourceCode));return true;case'sources.add-folder-to-workspace':Persistence.isolatedFileSystemManager.addFileSystem();return true;}
  947. return false;}};;Sources.OutlineQuickOpen=class extends QuickOpen.FilteredListWidget.Provider{constructor(){super();this._items=[];this._active=false;}
  948. attach(){this._items=[];this._active=false;const uiSourceCode=this._currentUISourceCode();if(uiSourceCode){this._active=Formatter.formatterWorkerPool().outlineForMimetype(uiSourceCode.workingCopy(),uiSourceCode.contentType().canonicalMimeType(),this._didBuildOutlineChunk.bind(this));}}
  949. _didBuildOutlineChunk(isLastChunk,items){this._items.push(...items);this.refresh();}
  950. itemCount(){return this._items.length;}
  951. itemKeyAt(itemIndex){const item=this._items[itemIndex];return item.title+(item.subtitle?item.subtitle:'');}
  952. itemScoreAt(itemIndex,query){const item=this._items[itemIndex];const methodName=query.split('(')[0];if(methodName.toLowerCase()===item.title.toLowerCase()){return 1/(1+item.line);}
  953. return-item.line-1;}
  954. renderItem(itemIndex,query,titleElement,subtitleElement){const item=this._items[itemIndex];titleElement.textContent=item.title+(item.subtitle?item.subtitle:'');QuickOpen.FilteredListWidget.highlightRanges(titleElement,query);subtitleElement.textContent=':'+(item.line+1);}
  955. selectItem(itemIndex,promptValue){if(itemIndex===null){return;}
  956. const uiSourceCode=this._currentUISourceCode();if(!uiSourceCode){return;}
  957. const lineNumber=this._items[itemIndex].line;if(!isNaN(lineNumber)&&lineNumber>=0){Common.Revealer.reveal(uiSourceCode.uiLocation(lineNumber,this._items[itemIndex].column));}}
  958. _currentUISourceCode(){const sourcesView=UI.context.flavor(Sources.SourcesView);if(!sourcesView){return null;}
  959. return sourcesView.currentUISourceCode();}
  960. notFoundText(){if(!this._currentUISourceCode()){return Common.UIString('No file selected.');}
  961. if(!this._active){return Common.UIString('Open a JavaScript or CSS file to see symbols');}
  962. return Common.UIString('No results found');}};;Sources.TabbedEditorContainerDelegate=function(){};Sources.TabbedEditorContainerDelegate.prototype={viewForFile(uiSourceCode){},recycleUISourceCodeFrame(sourceFrame,uiSourceCode){},};Sources.TabbedEditorContainer=class extends Common.Object{constructor(delegate,setting,placeholderElement,focusedPlaceholderElement){super();this._delegate=delegate;this._tabbedPane=new UI.TabbedPane();this._tabbedPane.setPlaceholderElement(placeholderElement,focusedPlaceholderElement);this._tabbedPane.setTabDelegate(new Sources.EditorContainerTabDelegate(this));this._tabbedPane.setCloseableTabs(true);this._tabbedPane.setAllowTabReorder(true,true);this._tabbedPane.addEventListener(UI.TabbedPane.Events.TabClosed,this._tabClosed,this);this._tabbedPane.addEventListener(UI.TabbedPane.Events.TabSelected,this._tabSelected,this);Persistence.persistence.addEventListener(Persistence.Persistence.Events.BindingCreated,this._onBindingCreated,this);Persistence.persistence.addEventListener(Persistence.Persistence.Events.BindingRemoved,this._onBindingRemoved,this);this._tabIds=new Map();this._files={};this._previouslyViewedFilesSetting=setting;this._history=Sources.TabbedEditorContainer.History.fromObject(this._previouslyViewedFilesSetting.get());}
  963. _onBindingCreated(event){const binding=(event.data);this._updateFileTitle(binding.fileSystem);const networkTabId=this._tabIds.get(binding.network);let fileSystemTabId=this._tabIds.get(binding.fileSystem);const wasSelectedInNetwork=this._currentFile===binding.network;const currentSelectionRange=this._history.selectionRange(binding.network.url());const currentScrollLineNumber=this._history.scrollLineNumber(binding.network.url());this._history.remove(binding.network.url());if(!networkTabId){return;}
  964. if(!fileSystemTabId){const networkView=this._tabbedPane.tabView(networkTabId);const tabIndex=this._tabbedPane.tabIndex(networkTabId);if(networkView instanceof Sources.UISourceCodeFrame){this._delegate.recycleUISourceCodeFrame(networkView,binding.fileSystem);fileSystemTabId=this._appendFileTab(binding.fileSystem,false,tabIndex,networkView);}else{fileSystemTabId=this._appendFileTab(binding.fileSystem,false,tabIndex);const fileSystemTabView=(this._tabbedPane.tabView(fileSystemTabId));this._restoreEditorProperties(fileSystemTabView,currentSelectionRange,currentScrollLineNumber);}}
  965. this._closeTabs([networkTabId],true);if(wasSelectedInNetwork){this._tabbedPane.selectTab(fileSystemTabId,false);}
  966. this._updateHistory();}
  967. _onBindingRemoved(event){const binding=(event.data);this._updateFileTitle(binding.fileSystem);}
  968. get view(){return this._tabbedPane;}
  969. get visibleView(){return this._tabbedPane.visibleView;}
  970. fileViews(){return(this._tabbedPane.tabViews());}
  971. leftToolbar(){return this._tabbedPane.leftToolbar();}
  972. rightToolbar(){return this._tabbedPane.rightToolbar();}
  973. show(parentElement){this._tabbedPane.show(parentElement);}
  974. showFile(uiSourceCode){this._innerShowFile(uiSourceCode,true);}
  975. closeFile(uiSourceCode){const tabId=this._tabIds.get(uiSourceCode);if(!tabId){return;}
  976. this._closeTabs([tabId]);}
  977. closeAllFiles(){this._closeTabs(this._tabbedPane.tabIds());}
  978. historyUISourceCodes(){const uriToUISourceCode={};for(const id in this._files){const uiSourceCode=this._files[id];uriToUISourceCode[uiSourceCode.url()]=uiSourceCode;}
  979. const result=[];const uris=this._history._urls();for(let i=0;i<uris.length;++i){const uiSourceCode=uriToUISourceCode[uris[i]];if(uiSourceCode){result.push(uiSourceCode);}}
  980. return result;}
  981. _addViewListeners(){if(!this._currentView||!this._currentView.textEditor){return;}
  982. this._currentView.textEditor.addEventListener(SourceFrame.SourcesTextEditor.Events.ScrollChanged,this._scrollChanged,this);this._currentView.textEditor.addEventListener(SourceFrame.SourcesTextEditor.Events.SelectionChanged,this._selectionChanged,this);}
  983. _removeViewListeners(){if(!this._currentView||!this._currentView.textEditor){return;}
  984. this._currentView.textEditor.removeEventListener(SourceFrame.SourcesTextEditor.Events.ScrollChanged,this._scrollChanged,this);this._currentView.textEditor.removeEventListener(SourceFrame.SourcesTextEditor.Events.SelectionChanged,this._selectionChanged,this);}
  985. _scrollChanged(event){if(this._scrollTimer){clearTimeout(this._scrollTimer);}
  986. const lineNumber=(event.data);this._scrollTimer=setTimeout(saveHistory.bind(this),100);this._history.updateScrollLineNumber(this._currentFile.url(),lineNumber);function saveHistory(){this._history.save(this._previouslyViewedFilesSetting);}}
  987. _selectionChanged(event){const range=(event.data);this._history.updateSelectionRange(this._currentFile.url(),range);this._history.save(this._previouslyViewedFilesSetting);Extensions.extensionServer.sourceSelectionChanged(this._currentFile.url(),range);}
  988. _innerShowFile(uiSourceCode,userGesture){const binding=Persistence.persistence.binding(uiSourceCode);uiSourceCode=binding?binding.fileSystem:uiSourceCode;if(this._currentFile===uiSourceCode){return;}
  989. this._removeViewListeners();this._currentFile=uiSourceCode;const tabId=this._tabIds.get(uiSourceCode)||this._appendFileTab(uiSourceCode,userGesture);this._tabbedPane.selectTab(tabId,userGesture);if(userGesture){this._editorSelectedByUserAction();}
  990. const previousView=this._currentView;this._currentView=this.visibleView;this._addViewListeners();const eventData={currentFile:this._currentFile,currentView:this._currentView,previousView:previousView,userGesture:userGesture};this.dispatchEventToListeners(Sources.TabbedEditorContainer.Events.EditorSelected,eventData);}
  991. _titleForFile(uiSourceCode){const maxDisplayNameLength=30;let title=uiSourceCode.displayName(true).trimMiddle(maxDisplayNameLength);if(uiSourceCode.isDirty()){title+='*';}
  992. return title;}
  993. _maybeCloseTab(id,nextTabId){const uiSourceCode=this._files[id];const shouldPrompt=uiSourceCode.isDirty()&&uiSourceCode.project().canSetFileContent();if(!shouldPrompt||confirm(Common.UIString('Are you sure you want to close unsaved file: %s?',uiSourceCode.name()))){uiSourceCode.resetWorkingCopy();if(nextTabId){this._tabbedPane.selectTab(nextTabId,true);}
  994. this._tabbedPane.closeTab(id,true);return true;}
  995. return false;}
  996. _closeTabs(ids,forceCloseDirtyTabs){const dirtyTabs=[];const cleanTabs=[];for(let i=0;i<ids.length;++i){const id=ids[i];const uiSourceCode=this._files[id];if(!forceCloseDirtyTabs&&uiSourceCode.isDirty()){dirtyTabs.push(id);}else{cleanTabs.push(id);}}
  997. if(dirtyTabs.length){this._tabbedPane.selectTab(dirtyTabs[0],true);}
  998. this._tabbedPane.closeTabs(cleanTabs,true);for(let i=0;i<dirtyTabs.length;++i){const nextTabId=i+1<dirtyTabs.length?dirtyTabs[i+1]:null;if(!this._maybeCloseTab(dirtyTabs[i],nextTabId)){break;}}}
  999. _onContextMenu(tabId,contextMenu){const uiSourceCode=this._files[tabId];if(uiSourceCode){contextMenu.appendApplicableItems(uiSourceCode);}}
  1000. addUISourceCode(uiSourceCode){const binding=Persistence.persistence.binding(uiSourceCode);uiSourceCode=binding?binding.fileSystem:uiSourceCode;if(this._currentFile===uiSourceCode){return;}
  1001. const uri=uiSourceCode.url();const index=this._history.index(uri);if(index===-1){return;}
  1002. if(!this._tabIds.has(uiSourceCode)){this._appendFileTab(uiSourceCode,false);}
  1003. if(!index){this._innerShowFile(uiSourceCode,false);return;}
  1004. if(!this._currentFile){return;}
  1005. const currentProjectIsSnippets=Snippets.isSnippetsUISourceCode(this._currentFile);const addedProjectIsSnippets=Snippets.isSnippetsUISourceCode(uiSourceCode);if(this._history.index(this._currentFile.url())&&currentProjectIsSnippets&&!addedProjectIsSnippets){this._innerShowFile(uiSourceCode,false);}}
  1006. removeUISourceCode(uiSourceCode){this.removeUISourceCodes([uiSourceCode]);}
  1007. removeUISourceCodes(uiSourceCodes){const tabIds=[];for(let i=0;i<uiSourceCodes.length;++i){const uiSourceCode=uiSourceCodes[i];const tabId=this._tabIds.get(uiSourceCode);if(tabId){tabIds.push(tabId);}}
  1008. this._tabbedPane.closeTabs(tabIds);}
  1009. _editorClosedByUserAction(uiSourceCode){this._history.remove(uiSourceCode.url());this._updateHistory();}
  1010. _editorSelectedByUserAction(){this._updateHistory();}
  1011. _updateHistory(){const tabIds=this._tabbedPane.lastOpenedTabIds(Sources.TabbedEditorContainer.maximalPreviouslyViewedFilesCount);function tabIdToURI(tabId){return this._files[tabId].url();}
  1012. this._history.update(tabIds.map(tabIdToURI.bind(this)));this._history.save(this._previouslyViewedFilesSetting);}
  1013. _tooltipForFile(uiSourceCode){uiSourceCode=Persistence.persistence.network(uiSourceCode)||uiSourceCode;return uiSourceCode.url();}
  1014. _appendFileTab(uiSourceCode,userGesture,index,replaceView){const view=replaceView||this._delegate.viewForFile(uiSourceCode);const title=this._titleForFile(uiSourceCode);const tooltip=this._tooltipForFile(uiSourceCode);const tabId=this._generateTabId();this._tabIds.set(uiSourceCode,tabId);this._files[tabId]=uiSourceCode;if(!replaceView){const savedSelectionRange=this._history.selectionRange(uiSourceCode.url());const savedScrollLineNumber=this._history.scrollLineNumber(uiSourceCode.url());this._restoreEditorProperties(view,savedSelectionRange,savedScrollLineNumber);}
  1015. this._tabbedPane.appendTab(tabId,title,view,tooltip,userGesture,undefined,index);this._updateFileTitle(uiSourceCode);this._addUISourceCodeListeners(uiSourceCode);if(uiSourceCode.loadError()){this._addLoadErrorIcon(tabId);}else if(!uiSourceCode.contentLoaded()){uiSourceCode.requestContent().then(content=>{if(uiSourceCode.loadError()){this._addLoadErrorIcon(tabId);}});}
  1016. return tabId;}
  1017. _addLoadErrorIcon(tabId){const icon=UI.Icon.create('smallicon-error');icon.title=ls`Unable to load this content.`;if(this._tabbedPane.tabView(tabId)){this._tabbedPane.setTabIcon(tabId,icon);}}
  1018. _restoreEditorProperties(editorView,selection,firstLineNumber){const sourceFrame=editorView instanceof SourceFrame.SourceFrame?(editorView):null;if(!sourceFrame){return;}
  1019. if(selection){sourceFrame.setSelection(selection);}
  1020. if(typeof firstLineNumber==='number'){sourceFrame.scrollToLine(firstLineNumber);}}
  1021. _tabClosed(event){const tabId=(event.data.tabId);const userGesture=(event.data.isUserGesture);const uiSourceCode=this._files[tabId];if(this._currentFile===uiSourceCode){this._removeViewListeners();delete this._currentView;delete this._currentFile;}
  1022. this._tabIds.remove(uiSourceCode);delete this._files[tabId];this._removeUISourceCodeListeners(uiSourceCode);this.dispatchEventToListeners(Sources.TabbedEditorContainer.Events.EditorClosed,uiSourceCode);if(userGesture){this._editorClosedByUserAction(uiSourceCode);}}
  1023. _tabSelected(event){const tabId=(event.data.tabId);const userGesture=(event.data.isUserGesture);const uiSourceCode=this._files[tabId];this._innerShowFile(uiSourceCode,userGesture);}
  1024. _addUISourceCodeListeners(uiSourceCode){uiSourceCode.addEventListener(Workspace.UISourceCode.Events.TitleChanged,this._uiSourceCodeTitleChanged,this);uiSourceCode.addEventListener(Workspace.UISourceCode.Events.WorkingCopyChanged,this._uiSourceCodeWorkingCopyChanged,this);uiSourceCode.addEventListener(Workspace.UISourceCode.Events.WorkingCopyCommitted,this._uiSourceCodeWorkingCopyCommitted,this);}
  1025. _removeUISourceCodeListeners(uiSourceCode){uiSourceCode.removeEventListener(Workspace.UISourceCode.Events.TitleChanged,this._uiSourceCodeTitleChanged,this);uiSourceCode.removeEventListener(Workspace.UISourceCode.Events.WorkingCopyChanged,this._uiSourceCodeWorkingCopyChanged,this);uiSourceCode.removeEventListener(Workspace.UISourceCode.Events.WorkingCopyCommitted,this._uiSourceCodeWorkingCopyCommitted,this);}
  1026. _updateFileTitle(uiSourceCode){const tabId=this._tabIds.get(uiSourceCode);if(tabId){const title=this._titleForFile(uiSourceCode);const tooltip=this._tooltipForFile(uiSourceCode);this._tabbedPane.changeTabTitle(tabId,title,tooltip);let icon=null;if(uiSourceCode.loadError()){icon=UI.Icon.create('smallicon-error');icon.title=ls`Unable to load this content.`;}else if(Persistence.persistence.hasUnsavedCommittedChanges(uiSourceCode)){icon=UI.Icon.create('smallicon-warning');icon.title=Common.UIString('Changes to this file were not saved to file system.');}else{icon=Persistence.PersistenceUtils.iconForUISourceCode(uiSourceCode);}
  1027. this._tabbedPane.setTabIcon(tabId,icon);}}
  1028. _uiSourceCodeTitleChanged(event){const uiSourceCode=(event.data);this._updateFileTitle(uiSourceCode);this._updateHistory();}
  1029. _uiSourceCodeWorkingCopyChanged(event){const uiSourceCode=(event.data);this._updateFileTitle(uiSourceCode);}
  1030. _uiSourceCodeWorkingCopyCommitted(event){const uiSourceCode=(event.data.uiSourceCode);this._updateFileTitle(uiSourceCode);}
  1031. _generateTabId(){return'tab_'+(Sources.TabbedEditorContainer._tabId++);}
  1032. currentFile(){return this._currentFile||null;}};Sources.TabbedEditorContainer.Events={EditorSelected:Symbol('EditorSelected'),EditorClosed:Symbol('EditorClosed')};Sources.TabbedEditorContainer._tabId=0;Sources.TabbedEditorContainer.maximalPreviouslyViewedFilesCount=30;Sources.TabbedEditorContainer.HistoryItem=class{constructor(url,selectionRange,scrollLineNumber){this.url=url;this._isSerializable=url.length<Sources.TabbedEditorContainer.HistoryItem.serializableUrlLengthLimit;this.selectionRange=selectionRange;this.scrollLineNumber=scrollLineNumber;}
  1033. static fromObject(serializedHistoryItem){const selectionRange=serializedHistoryItem.selectionRange?TextUtils.TextRange.fromObject(serializedHistoryItem.selectionRange):undefined;return new Sources.TabbedEditorContainer.HistoryItem(serializedHistoryItem.url,selectionRange,serializedHistoryItem.scrollLineNumber);}
  1034. serializeToObject(){if(!this._isSerializable){return null;}
  1035. const serializedHistoryItem={};serializedHistoryItem.url=this.url;serializedHistoryItem.selectionRange=this.selectionRange;serializedHistoryItem.scrollLineNumber=this.scrollLineNumber;return serializedHistoryItem;}};Sources.TabbedEditorContainer.HistoryItem.serializableUrlLengthLimit=4096;Sources.TabbedEditorContainer.History=class{constructor(items){this._items=items;this._rebuildItemIndex();}
  1036. static fromObject(serializedHistory){const items=[];for(let i=0;i<serializedHistory.length;++i){items.push(Sources.TabbedEditorContainer.HistoryItem.fromObject(serializedHistory[i]));}
  1037. return new Sources.TabbedEditorContainer.History(items);}
  1038. index(url){return this._itemsIndex.has(url)?(this._itemsIndex.get(url)):-1;}
  1039. _rebuildItemIndex(){this._itemsIndex=new Map();for(let i=0;i<this._items.length;++i){console.assert(!this._itemsIndex.has(this._items[i].url));this._itemsIndex.set(this._items[i].url,i);}}
  1040. selectionRange(url){const index=this.index(url);return index!==-1?this._items[index].selectionRange:undefined;}
  1041. updateSelectionRange(url,selectionRange){if(!selectionRange){return;}
  1042. const index=this.index(url);if(index===-1){return;}
  1043. this._items[index].selectionRange=selectionRange;}
  1044. scrollLineNumber(url){const index=this.index(url);return index!==-1?this._items[index].scrollLineNumber:undefined;}
  1045. updateScrollLineNumber(url,scrollLineNumber){const index=this.index(url);if(index===-1){return;}
  1046. this._items[index].scrollLineNumber=scrollLineNumber;}
  1047. update(urls){for(let i=urls.length-1;i>=0;--i){const index=this.index(urls[i]);let item;if(index!==-1){item=this._items[index];this._items.splice(index,1);}else{item=new Sources.TabbedEditorContainer.HistoryItem(urls[i]);}
  1048. this._items.unshift(item);this._rebuildItemIndex();}}
  1049. remove(url){const index=this.index(url);if(index!==-1){this._items.splice(index,1);this._rebuildItemIndex();}}
  1050. save(setting){setting.set(this._serializeToObject());}
  1051. _serializeToObject(){const serializedHistory=[];for(let i=0;i<this._items.length;++i){const serializedItem=this._items[i].serializeToObject();if(serializedItem){serializedHistory.push(serializedItem);}
  1052. if(serializedHistory.length===Sources.TabbedEditorContainer.maximalPreviouslyViewedFilesCount){break;}}
  1053. return serializedHistory;}
  1054. _urls(){const result=[];for(let i=0;i<this._items.length;++i){result.push(this._items[i].url);}
  1055. return result;}};Sources.EditorContainerTabDelegate=class{constructor(editorContainer){this._editorContainer=editorContainer;}
  1056. closeTabs(tabbedPane,ids){this._editorContainer._closeTabs(ids);}
  1057. onContextMenu(tabId,contextMenu){this._editorContainer._onContextMenu(tabId,contextMenu);}};;Sources.WatchExpressionsSidebarPane=class extends UI.ThrottledWidget{constructor(){super(true);this.registerRequiredCSS('object_ui/objectValue.css');this.registerRequiredCSS('sources/watchExpressionsSidebarPane.css');this._watchExpressions=[];this._watchExpressionsSetting=Common.settings.createLocalSetting('watchExpressions',[]);this._addButton=new UI.ToolbarButton(ls`Add watch expression`,'largeicon-add');this._addButton.addEventListener(UI.ToolbarButton.Events.Click,this._addButtonClicked.bind(this));this._refreshButton=new UI.ToolbarButton(ls`Refresh watch expressions`,'largeicon-refresh');this._refreshButton.addEventListener(UI.ToolbarButton.Events.Click,this.update,this);this.contentElement.classList.add('watch-expressions');this.contentElement.addEventListener('contextmenu',this._contextMenu.bind(this),false);this._treeOutline=new ObjectUI.ObjectPropertiesSectionsTreeOutline();this._treeOutline.registerRequiredCSS('sources/watchExpressionsSidebarPane.css');this._treeOutline.setShowSelectionOnKeyboardFocus(true);this._expandController=new ObjectUI.ObjectPropertiesSectionsTreeExpandController(this._treeOutline);UI.context.addFlavorChangeListener(SDK.ExecutionContext,this.update,this);UI.context.addFlavorChangeListener(SDK.DebuggerModel.CallFrame,this.update,this);this._linkifier=new Components.Linkifier();this.update();}
  1058. toolbarItems(){return[this._addButton,this._refreshButton];}
  1059. focus(){if(this.hasFocus()){return;}
  1060. if(this._watchExpressions.length>0){this._treeOutline.forceSelect();}}
  1061. hasExpressions(){return!!this._watchExpressionsSetting.get().length;}
  1062. _saveExpressions(){const toSave=[];for(let i=0;i<this._watchExpressions.length;i++){if(this._watchExpressions[i].expression()){toSave.push(this._watchExpressions[i].expression());}}
  1063. this._watchExpressionsSetting.set(toSave);}
  1064. async _addButtonClicked(){await UI.viewManager.showView('sources.watch');this._createWatchExpression(null).startEditing();}
  1065. doUpdate(){this._linkifier.reset();this.contentElement.removeChildren();this._treeOutline.removeChildren();this._watchExpressions=[];this._emptyElement=this.contentElement.createChild('div','gray-info-message');this._emptyElement.textContent=Common.UIString('No watch expressions');this._emptyElement.tabIndex=-1;const watchExpressionStrings=this._watchExpressionsSetting.get();for(let i=0;i<watchExpressionStrings.length;++i){const expression=watchExpressionStrings[i];if(!expression){continue;}
  1066. this._createWatchExpression(expression);}
  1067. return Promise.resolve();}
  1068. _createWatchExpression(expression){this._emptyElement.classList.add('hidden');this.contentElement.appendChild(this._treeOutline.element);const watchExpression=new Sources.WatchExpression(expression,this._expandController,this._linkifier);watchExpression.addEventListener(Sources.WatchExpression.Events.ExpressionUpdated,this._watchExpressionUpdated,this);this._treeOutline.appendChild(watchExpression.treeElement());this._watchExpressions.push(watchExpression);return watchExpression;}
  1069. _watchExpressionUpdated(event){const watchExpression=(event.data);if(!watchExpression.expression()){this._watchExpressions.remove(watchExpression);this._treeOutline.removeChild(watchExpression.treeElement());this._emptyElement.classList.toggle('hidden',!!this._watchExpressions.length);if(this._watchExpressions.length===0){this._treeOutline.element.remove();}}
  1070. this._saveExpressions();}
  1071. _contextMenu(event){const contextMenu=new UI.ContextMenu(event);this._populateContextMenu(contextMenu,event);contextMenu.show();}
  1072. _populateContextMenu(contextMenu,event){let isEditing=false;for(const watchExpression of this._watchExpressions){isEditing|=watchExpression.isEditing();}
  1073. if(!isEditing){contextMenu.debugSection().appendItem(Common.UIString('Add watch expression'),this._addButtonClicked.bind(this));}
  1074. if(this._watchExpressions.length>1){contextMenu.debugSection().appendItem(Common.UIString('Delete all watch expressions'),this._deleteAllButtonClicked.bind(this));}
  1075. const treeElement=this._treeOutline.treeElementFromEvent(event);if(!treeElement){return;}
  1076. const currentWatchExpression=this._watchExpressions.find(watchExpression=>treeElement.hasAncestorOrSelf(watchExpression.treeElement()));currentWatchExpression._populateContextMenu(contextMenu,event);}
  1077. _deleteAllButtonClicked(){this._watchExpressions=[];this._saveExpressions();this.update();}
  1078. _focusAndAddExpressionToWatch(expression){UI.viewManager.showView('sources.watch');this.doUpdate();this._addExpressionToWatch(expression);}
  1079. _addExpressionToWatch(expression){this._createWatchExpression(expression);this._saveExpressions();}
  1080. handleAction(context,actionId){const frame=UI.context.flavor(Sources.UISourceCodeFrame);if(!frame){return false;}
  1081. const text=frame.textEditor.text(frame.textEditor.selection());this._focusAndAddExpressionToWatch(text);return true;}
  1082. _addPropertyPathToWatch(target){this._addExpressionToWatch(target.path());}
  1083. appendApplicableItems(event,contextMenu,target){if(target instanceof ObjectUI.ObjectPropertyTreeElement&&!target.property.synthetic){contextMenu.debugSection().appendItem(ls`Add property path to watch`,this._addPropertyPathToWatch.bind(this,target));}
  1084. const frame=UI.context.flavor(Sources.UISourceCodeFrame);if(!frame||frame.textEditor.selection().isEmpty()){return;}
  1085. contextMenu.debugSection().appendAction('sources.add-to-watch');}};Sources.WatchExpression=class extends Common.Object{constructor(expression,expandController,linkifier){super();this._expression=expression;this._expandController=expandController;this._element=createElementWithClass('div','watch-expression monospace');this._editing=false;this._linkifier=linkifier;this._createWatchExpression();this.update();}
  1086. treeElement(){return this._treeElement;}
  1087. expression(){return this._expression;}
  1088. update(){const currentExecutionContext=UI.context.flavor(SDK.ExecutionContext);if(currentExecutionContext&&this._expression){currentExecutionContext.evaluate({expression:this._expression,objectGroup:Sources.WatchExpression._watchObjectGroupId,includeCommandLineAPI:false,silent:true,returnByValue:false,generatePreview:false},false,false).then(result=>this._createWatchExpression(result.object,result.exceptionDetails));}}
  1089. startEditing(){this._editing=true;this._element.removeChildren();const newDiv=this._element.createChild('div');newDiv.textContent=this._nameElement.textContent;this._textPrompt=new ObjectUI.ObjectPropertyPrompt();this._textPrompt.renderAsBlock();const proxyElement=this._textPrompt.attachAndStartEditing(newDiv,this._finishEditing.bind(this));this._treeElement.listItemElement.classList.add('watch-expression-editing');proxyElement.classList.add('watch-expression-text-prompt-proxy');proxyElement.addEventListener('keydown',this._promptKeyDown.bind(this),false);this._element.getComponentSelection().selectAllChildren(newDiv);}
  1090. isEditing(){return!!this._editing;}
  1091. _finishEditing(event,canceled){if(event){event.consume(canceled);}
  1092. this._editing=false;this._treeElement.listItemElement.classList.remove('watch-expression-editing');this._textPrompt.detach();const newExpression=canceled?this._expression:this._textPrompt.text();delete this._textPrompt;this._element.removeChildren();this._updateExpression(newExpression);}
  1093. _dblClickOnWatchExpression(event){event.consume();if(!this.isEditing()){this.startEditing();}}
  1094. _updateExpression(newExpression){if(this._expression){this._expandController.stopWatchSectionsWithId(this._expression);}
  1095. this._expression=newExpression;this.update();this.dispatchEventToListeners(Sources.WatchExpression.Events.ExpressionUpdated,this);}
  1096. _deleteWatchExpression(event){event.consume(true);this._updateExpression(null);}
  1097. _createWatchExpression(result,exceptionDetails){this._result=result||null;this._element.removeChildren();const oldTreeElement=this._treeElement;this._createWatchExpressionTreeElement(result,exceptionDetails);if(oldTreeElement&&oldTreeElement.parent){const root=oldTreeElement.parent;const index=root.indexOfChild(oldTreeElement);root.removeChild(oldTreeElement);root.insertChild(this._treeElement,index);}
  1098. this._treeElement.select();}
  1099. _createWatchExpressionHeader(expressionValue,exceptionDetails){const headerElement=this._element.createChild('div','watch-expression-header');const deleteButton=UI.Icon.create('smallicon-cross','watch-expression-delete-button');deleteButton.title=ls`Delete watch expression`;deleteButton.addEventListener('click',this._deleteWatchExpression.bind(this),false);headerElement.appendChild(deleteButton);const titleElement=headerElement.createChild('div','watch-expression-title tree-element-title');this._nameElement=ObjectUI.ObjectPropertiesSection.createNameElement(this._expression);if(!!exceptionDetails||!expressionValue){this._valueElement=createElementWithClass('span','watch-expression-error value');titleElement.classList.add('dimmed');this._valueElement.textContent=Common.UIString('<not available>');}else{this._valueElement=ObjectUI.ObjectPropertiesSection.createValueElementWithCustomSupport(expressionValue,!!exceptionDetails,false,titleElement,this._linkifier);}
  1100. const separatorElement=createElementWithClass('span','watch-expressions-separator');separatorElement.textContent=': ';titleElement.appendChildren(this._nameElement,separatorElement,this._valueElement);return headerElement;}
  1101. _createWatchExpressionTreeElement(expressionValue,exceptionDetails){const headerElement=this._createWatchExpressionHeader(expressionValue,exceptionDetails);if(!exceptionDetails&&expressionValue&&expressionValue.hasChildren&&!expressionValue.customPreview()){headerElement.classList.add('watch-expression-object-header');this._treeElement=new ObjectUI.ObjectPropertiesSection.RootElement(expressionValue,this._linkifier);this._expandController.watchSection((this._expression),this._treeElement);this._treeElement.toggleOnClick=false;this._treeElement.listItemElement.addEventListener('click',this._onSectionClick.bind(this),false);this._treeElement.listItemElement.addEventListener('dblclick',this._dblClickOnWatchExpression.bind(this));}else{headerElement.addEventListener('dblclick',this._dblClickOnWatchExpression.bind(this));this._treeElement=new UI.TreeElement();}
  1102. this._treeElement.title=this._element;this._treeElement.listItemElement.classList.add('watch-expression-tree-item');this._treeElement.listItemElement.addEventListener('keydown',event=>{if(isEnterKey(event)&&!this.isEditing()){this.startEditing();event.consume(true);}});}
  1103. _onSectionClick(event){event.consume(true);if(event.detail===1){this._preventClickTimeout=setTimeout(handleClick.bind(this),333);}else{clearTimeout(this._preventClickTimeout);delete this._preventClickTimeout;}
  1104. function handleClick(){if(!this._treeElement){return;}
  1105. if(this._treeElement.expanded){this._treeElement.collapse();}else{this._treeElement.expand();}}}
  1106. _promptKeyDown(event){if(isEnterKey(event)||isEscKey(event)){this._finishEditing(event,isEscKey(event));}}
  1107. _populateContextMenu(contextMenu,event){if(!this.isEditing()){contextMenu.editSection().appendItem(Common.UIString('Delete watch expression'),this._updateExpression.bind(this,null));}
  1108. if(!this.isEditing()&&this._result&&(this._result.type==='number'||this._result.type==='string')){contextMenu.clipboardSection().appendItem(Common.UIString('Copy value'),this._copyValueButtonClicked.bind(this));}
  1109. const target=event.deepElementFromPoint();if(target&&this._valueElement.isSelfOrAncestor(target)){contextMenu.appendApplicableItems(this._result);}}
  1110. _copyValueButtonClicked(){Host.InspectorFrontendHost.copyText(this._valueElement.textContent);}};Sources.WatchExpression._watchObjectGroupId='watch-group';Sources.WatchExpression.Events={ExpressionUpdated:Symbol('ExpressionUpdated')};;Sources.ThreadsSidebarPane=class extends UI.VBox{constructor(){super(true);this.registerRequiredCSS('sources/threadsSidebarPane.css');this._items=new UI.ListModel();this._list=new UI.ListControl(this._items,this,UI.ListMode.NonViewport);this.contentElement.appendChild(this._list.element);UI.context.addFlavorChangeListener(SDK.Target,this._targetFlavorChanged,this);SDK.targetManager.observeModels(SDK.DebuggerModel,this);}
  1111. static shouldBeShown(){return SDK.targetManager.models(SDK.DebuggerModel).length>=2;}
  1112. createElementForItem(debuggerModel){const element=createElementWithClass('div','thread-item');const title=element.createChild('div','thread-item-title');const pausedState=element.createChild('div','thread-item-paused-state');element.appendChild(UI.Icon.create('smallicon-thick-right-arrow','selected-thread-icon'));function updateTitle(){const executionContext=debuggerModel.runtimeModel().defaultExecutionContext();title.textContent=executionContext&&executionContext.label()?executionContext.label():debuggerModel.target().name();}
  1113. function updatePausedState(){pausedState.textContent=debuggerModel.isPaused()?ls`paused`:'';}
  1114. function targetNameChanged(event){const target=(event.data);if(target===debuggerModel.target()){updateTitle();}}
  1115. debuggerModel.addEventListener(SDK.DebuggerModel.Events.DebuggerPaused,updatePausedState);debuggerModel.addEventListener(SDK.DebuggerModel.Events.DebuggerResumed,updatePausedState);debuggerModel.runtimeModel().addEventListener(SDK.RuntimeModel.Events.ExecutionContextChanged,updateTitle);SDK.targetManager.addEventListener(SDK.TargetManager.Events.NameChanged,targetNameChanged);updatePausedState();updateTitle();return element;}
  1116. heightForItem(debuggerModel){console.assert(false);return 0;}
  1117. isItemSelectable(debuggerModel){return true;}
  1118. selectedItemChanged(from,to,fromElement,toElement){if(fromElement){fromElement.classList.remove('selected');}
  1119. if(toElement){toElement.classList.add('selected');}
  1120. if(to){UI.context.setFlavor(SDK.Target,to.target());}}
  1121. modelAdded(debuggerModel){this._items.insert(this._items.length,debuggerModel);const currentTarget=UI.context.flavor(SDK.Target);if(currentTarget===debuggerModel.target()){this._list.selectItem(debuggerModel);}}
  1122. modelRemoved(debuggerModel){this._items.remove(this._items.indexOf(debuggerModel));}
  1123. _targetFlavorChanged(event){const target=(event.data);const debuggerModel=target.model(SDK.DebuggerModel);if(debuggerModel){this._list.selectItem(debuggerModel);}}};;Sources.ScriptFormatterEditorAction=class{constructor(){this._pathsToFormatOnLoad=new Set();}
  1124. _editorSelected(event){const uiSourceCode=(event.data);this._updateButton(uiSourceCode);if(this._isFormatableScript(uiSourceCode)&&this._pathsToFormatOnLoad.has(uiSourceCode.url())&&!Sources.sourceFormatter.hasFormatted(uiSourceCode)){this._showFormatted(uiSourceCode);}}
  1125. _editorClosed(event){const uiSourceCode=(event.data.uiSourceCode);const wasSelected=(event.data.wasSelected);if(wasSelected){this._updateButton(null);}
  1126. const original=Sources.sourceFormatter.discardFormattedUISourceCode(uiSourceCode);if(original){this._pathsToFormatOnLoad.delete(original.url());}}
  1127. _updateButton(uiSourceCode){this._button.element.classList.toggle('hidden',!this._isFormatableScript(uiSourceCode));}
  1128. button(sourcesView){if(this._button){return this._button;}
  1129. this._sourcesView=sourcesView;this._sourcesView.addEventListener(Sources.SourcesView.Events.EditorSelected,this._editorSelected.bind(this));this._sourcesView.addEventListener(Sources.SourcesView.Events.EditorClosed,this._editorClosed.bind(this));this._button=new UI.ToolbarButton(Common.UIString('Pretty print'),'largeicon-pretty-print');this._button.addEventListener(UI.ToolbarButton.Events.Click,this._toggleFormatScriptSource,this);this._updateButton(sourcesView.currentUISourceCode());return this._button;}
  1130. _isFormatableScript(uiSourceCode){if(!uiSourceCode){return false;}
  1131. if(uiSourceCode.project().canSetFileContent()){return false;}
  1132. if(uiSourceCode.project().type()===Workspace.projectTypes.Formatter){return false;}
  1133. if(Persistence.persistence.binding(uiSourceCode)){return false;}
  1134. return uiSourceCode.contentType().hasScripts();}
  1135. _toggleFormatScriptSource(event){const uiSourceCode=this._sourcesView.currentUISourceCode();if(!this._isFormatableScript(uiSourceCode)){return;}
  1136. this._pathsToFormatOnLoad.add(uiSourceCode.url());this._showFormatted(uiSourceCode);}
  1137. async _showFormatted(uiSourceCode){const formatData=await Sources.sourceFormatter.format(uiSourceCode);if(uiSourceCode!==this._sourcesView.currentUISourceCode()){return;}
  1138. const sourceFrame=this._sourcesView.viewForFile(uiSourceCode);let start=[0,0];if(sourceFrame){const selection=sourceFrame.selection();start=formatData.mapping.originalToFormatted(selection.startLine,selection.startColumn);}
  1139. this._sourcesView.showSourceLocation(formatData.formattedSourceCode,start[0],start[1]);}};;Sources.InplaceFormatterEditorAction=class{_editorSelected(event){const uiSourceCode=(event.data);this._updateButton(uiSourceCode);}
  1140. _editorClosed(event){const wasSelected=(event.data.wasSelected);if(wasSelected){this._updateButton(null);}}
  1141. _updateButton(uiSourceCode){this._button.element.classList.toggle('hidden',!this._isFormattable(uiSourceCode));}
  1142. button(sourcesView){if(this._button){return this._button;}
  1143. this._sourcesView=sourcesView;this._sourcesView.addEventListener(Sources.SourcesView.Events.EditorSelected,this._editorSelected.bind(this));this._sourcesView.addEventListener(Sources.SourcesView.Events.EditorClosed,this._editorClosed.bind(this));this._button=new UI.ToolbarButton(Common.UIString('Format'),'largeicon-pretty-print');this._button.addEventListener(UI.ToolbarButton.Events.Click,this._formatSourceInPlace,this);this._updateButton(sourcesView.currentUISourceCode());return this._button;}
  1144. _isFormattable(uiSourceCode){if(!uiSourceCode){return false;}
  1145. if(uiSourceCode.project().canSetFileContent()){return true;}
  1146. if(Persistence.persistence.binding(uiSourceCode)){return true;}
  1147. return uiSourceCode.contentType().isStyleSheet();}
  1148. _formatSourceInPlace(event){const uiSourceCode=this._sourcesView.currentUISourceCode();if(!this._isFormattable(uiSourceCode)){return;}
  1149. if(uiSourceCode.isDirty()){this._contentLoaded(uiSourceCode,uiSourceCode.workingCopy());}else{uiSourceCode.requestContent().then(deferredContent=>{this._contentLoaded(uiSourceCode,deferredContent.content);});}}
  1150. _contentLoaded(uiSourceCode,content){const highlighterType=uiSourceCode.mimeType();Formatter.Formatter.format(uiSourceCode.contentType(),highlighterType,content,(formattedContent,formatterMapping)=>{this._formattingComplete(uiSourceCode,formattedContent,formatterMapping);});}
  1151. _formattingComplete(uiSourceCode,formattedContent,formatterMapping){if(uiSourceCode.workingCopy()===formattedContent){return;}
  1152. const sourceFrame=this._sourcesView.viewForFile(uiSourceCode);let start=[0,0];if(sourceFrame){const selection=sourceFrame.selection();start=formatterMapping.originalToFormatted(selection.startLine,selection.startColumn);}
  1153. uiSourceCode.setWorkingCopy(formattedContent);this._sourcesView.showSourceLocation(uiSourceCode,start[0],start[1]);}};;Sources.SourceFormatData=class{constructor(originalSourceCode,formattedSourceCode,mapping){this.originalSourceCode=originalSourceCode;this.formattedSourceCode=formattedSourceCode;this.mapping=mapping;}
  1154. originalPath(){return this.originalSourceCode.project().id()+':'+this.originalSourceCode.url();}
  1155. static _for(object){return object[Sources.SourceFormatData._formatDataSymbol];}};Sources.SourceFormatData._formatDataSymbol=Symbol('formatData');Sources.SourceFormatter=class{constructor(){this._projectId='formatter:';this._project=new Bindings.ContentProviderBasedProject(Workspace.workspace,this._projectId,Workspace.projectTypes.Formatter,'formatter',true);this._formattedSourceCodes=new Map();this._scriptMapping=new Sources.SourceFormatter.ScriptMapping();this._styleMapping=new Sources.SourceFormatter.StyleMapping();Workspace.workspace.addEventListener(Workspace.Workspace.Events.UISourceCodeRemoved,this._onUISourceCodeRemoved,this);}
  1156. _onUISourceCodeRemoved(event){const uiSourceCode=(event.data);const cacheEntry=this._formattedSourceCodes.get(uiSourceCode);if(cacheEntry&&cacheEntry.formatData){this._discardFormatData(cacheEntry.formatData);}
  1157. this._formattedSourceCodes.remove(uiSourceCode);}
  1158. discardFormattedUISourceCode(formattedUISourceCode){const formatData=Sources.SourceFormatData._for(formattedUISourceCode);if(!formatData){return null;}
  1159. this._discardFormatData(formatData);this._formattedSourceCodes.remove(formatData.originalSourceCode);return formatData.originalSourceCode;}
  1160. _discardFormatData(formatData){delete formatData.formattedSourceCode[Sources.SourceFormatData._formatDataSymbol];this._scriptMapping._setSourceMappingEnabled(formatData,false);this._styleMapping._setSourceMappingEnabled(formatData,false);this._project.removeFile(formatData.formattedSourceCode.url());}
  1161. hasFormatted(uiSourceCode){return this._formattedSourceCodes.has(uiSourceCode);}
  1162. async format(uiSourceCode){const cacheEntry=this._formattedSourceCodes.get(uiSourceCode);if(cacheEntry){return cacheEntry.promise;}
  1163. let fulfillFormatPromise;const resultPromise=new Promise(fulfill=>{fulfillFormatPromise=fulfill;});this._formattedSourceCodes.set(uiSourceCode,{promise:resultPromise,formatData:null});const{content}=await uiSourceCode.requestContent();Formatter.Formatter.format(uiSourceCode.contentType(),uiSourceCode.mimeType(),content||'',formatDone.bind(this));return resultPromise;function formatDone(formattedContent,formatterMapping){const cacheEntry=this._formattedSourceCodes.get(uiSourceCode);if(!cacheEntry||cacheEntry.promise!==resultPromise){return;}
  1164. let formattedURL;let count=0;let suffix='';do{formattedURL=`${uiSourceCode.url()}:formatted${suffix}`;suffix=`:${count++}`;}while(this._project.uiSourceCodeForURL(formattedURL));const contentProvider=Common.StaticContentProvider.fromString(formattedURL,uiSourceCode.contentType(),formattedContent);const formattedUISourceCode=this._project.addContentProvider(formattedURL,contentProvider,uiSourceCode.mimeType());const formatData=new Sources.SourceFormatData(uiSourceCode,formattedUISourceCode,formatterMapping);formattedUISourceCode[Sources.SourceFormatData._formatDataSymbol]=formatData;this._scriptMapping._setSourceMappingEnabled(formatData,true);this._styleMapping._setSourceMappingEnabled(formatData,true);cacheEntry.formatData=formatData;for(const decoration of uiSourceCode.allDecorations()){const range=decoration.range();const startLocation=formatterMapping.originalToFormatted(range.startLine,range.startColumn);const endLocation=formatterMapping.originalToFormatted(range.endLine,range.endColumn);formattedUISourceCode.addDecoration(new TextUtils.TextRange(startLocation[0],startLocation[1],endLocation[0],endLocation[1]),(decoration.type()),decoration.data());}
  1165. fulfillFormatPromise(formatData);}}};Sources.SourceFormatter.ScriptMapping=class{constructor(){Bindings.debuggerWorkspaceBinding.addSourceMapping(this);}
  1166. rawLocationToUILocation(rawLocation){const script=rawLocation.script();const formatData=script&&Sources.SourceFormatData._for(script);if(!formatData){return null;}
  1167. if(script.isInlineScriptWithSourceURL()){const[relativeLineNumber,relativeColumnNumber]=script.toRelativeLocation(rawLocation);const[formattedLineNumber,formattedColumnNumber]=formatData.mapping.originalToFormatted(relativeLineNumber,relativeColumnNumber);return formatData.formattedSourceCode.uiLocation(formattedLineNumber,formattedColumnNumber);}
  1168. const[lineNumber,columnNumber]=formatData.mapping.originalToFormatted(rawLocation.lineNumber,rawLocation.columnNumber||0);return formatData.formattedSourceCode.uiLocation(lineNumber,columnNumber);}
  1169. uiLocationToRawLocations(uiSourceCode,lineNumber,columnNumber){const formatData=Sources.SourceFormatData._for(uiSourceCode);if(!formatData){return[];}
  1170. const[originalLine,originalColumn]=formatData.mapping.formattedToOriginal(lineNumber,columnNumber);if(formatData.originalSourceCode.contentType().isScript()){const rawLocations=Bindings.debuggerWorkspaceBinding.uiLocationToRawLocations(formatData.originalSourceCode,originalLine,originalColumn);console.assert(rawLocations.every(l=>l&&!!l.script()));return rawLocations;}
  1171. if(formatData.originalSourceCode.contentType()===Common.resourceTypes.Document){const target=Bindings.NetworkProject.targetForUISourceCode(formatData.originalSourceCode);const debuggerModel=target&&target.model(SDK.DebuggerModel);if(debuggerModel){const scripts=debuggerModel.scriptsForSourceURL(formatData.originalSourceCode.url()).filter(script=>script.isInlineScript()&&!script.hasSourceURL);const locations=scripts.map(script=>script.rawLocation(originalLine,originalColumn)).filter(l=>!!l);console.assert(locations.every(l=>l&&!!l.script()));return locations;}}
  1172. return[];}
  1173. _setSourceMappingEnabled(formatData,enabled){const scripts=this._scriptsForUISourceCode(formatData.originalSourceCode);if(!scripts.length){return;}
  1174. if(enabled){for(const script of scripts){script[Sources.SourceFormatData._formatDataSymbol]=formatData;}}else{for(const script of scripts){delete script[Sources.SourceFormatData._formatDataSymbol];}}
  1175. for(const script of scripts){Bindings.debuggerWorkspaceBinding.updateLocations(script);}}
  1176. _scriptsForUISourceCode(uiSourceCode){if(uiSourceCode.contentType()===Common.resourceTypes.Document){const target=Bindings.NetworkProject.targetForUISourceCode(uiSourceCode);const debuggerModel=target&&target.model(SDK.DebuggerModel);if(debuggerModel){const scripts=debuggerModel.scriptsForSourceURL(uiSourceCode.url()).filter(script=>script.isInlineScript()&&!script.hasSourceURL);return scripts;}}
  1177. if(uiSourceCode.contentType().isScript()){const rawLocations=Bindings.debuggerWorkspaceBinding.uiLocationToRawLocations(uiSourceCode,0,0);return rawLocations.map(location=>location.script()).filter(script=>!!script);}
  1178. return[];}};Sources.SourceFormatter.StyleMapping=class{constructor(){Bindings.cssWorkspaceBinding.addSourceMapping(this);this._headersSymbol=Symbol('Sources.SourceFormatter.StyleMapping._headersSymbol');}
  1179. rawLocationToUILocation(rawLocation){const styleHeader=rawLocation.header();const formatData=styleHeader&&Sources.SourceFormatData._for(styleHeader);if(!formatData){return null;}
  1180. const formattedLocation=formatData.mapping.originalToFormatted(rawLocation.lineNumber,rawLocation.columnNumber||0);return formatData.formattedSourceCode.uiLocation(formattedLocation[0],formattedLocation[1]);}
  1181. uiLocationToRawLocations(uiLocation){const formatData=Sources.SourceFormatData._for(uiLocation.uiSourceCode);if(!formatData){return[];}
  1182. const[originalLine,originalColumn]=formatData.mapping.formattedToOriginal(uiLocation.lineNumber,uiLocation.columnNumber);const headers=formatData.originalSourceCode[this._headersSymbol].filter(header=>header.containsLocation(originalLine,originalColumn));return headers.map(header=>new SDK.CSSLocation(header,originalLine,originalColumn));}
  1183. _setSourceMappingEnabled(formatData,enable){const original=formatData.originalSourceCode;const headers=this._headersForUISourceCode(original);if(enable){original[this._headersSymbol]=headers;headers.forEach(header=>header[Sources.SourceFormatData._formatDataSymbol]=formatData);}else{original[this._headersSymbol]=null;headers.forEach(header=>delete header[Sources.SourceFormatData._formatDataSymbol]);}
  1184. headers.forEach(header=>Bindings.cssWorkspaceBinding.updateLocations(header));}
  1185. _headersForUISourceCode(uiSourceCode){if(uiSourceCode.contentType()===Common.resourceTypes.Document){const target=Bindings.NetworkProject.targetForUISourceCode(uiSourceCode);const cssModel=target&&target.model(SDK.CSSModel);if(cssModel){return cssModel.headersForSourceURL(uiSourceCode.url()).filter(header=>header.isInline&&!header.hasSourceURL);}}else if(uiSourceCode.contentType().isStyleSheet()){const rawLocations=Bindings.cssWorkspaceBinding.uiLocationToRawLocations(uiSourceCode.uiLocation(0,0));return rawLocations.map(rawLocation=>rawLocation.header()).filter(header=>!!header);}
  1186. return[];}};Sources.sourceFormatter=new Sources.SourceFormatter();;Sources.OpenFileQuickOpen=class extends Sources.FilteredUISourceCodeListProvider{attach(){this.setDefaultScores(Sources.SourcesView.defaultUISourceCodeScores());super.attach();}
  1187. uiSourceCodeSelected(uiSourceCode,lineNumber,columnNumber){Host.userMetrics.actionTaken(Host.UserMetrics.Action.SelectFileFromFilePicker);if(!uiSourceCode){return;}
  1188. if(typeof lineNumber==='number'){Common.Revealer.reveal(uiSourceCode.uiLocation(lineNumber,columnNumber));}else{Common.Revealer.reveal(uiSourceCode);}}
  1189. filterProject(project){return!project.isServiceProject();}
  1190. renderAsTwoRows(){return true;}};;Sources.SourcesView=class extends UI.VBox{constructor(){super();this.registerRequiredCSS('sources/sourcesView.css');this.element.id='sources-panel-sources-view';this.setMinimumAndPreferredSizes(88,52,150,100);const workspace=Workspace.workspace;this._searchableView=new UI.SearchableView(this,'sourcesViewSearchConfig');this._searchableView.setMinimalSearchQuerySize(0);this._searchableView.show(this.element);this._sourceViewByUISourceCode=new Map();this._editorContainer=new Sources.TabbedEditorContainer(this,Common.settings.createLocalSetting('previouslyViewedFiles',[]),this._placeholderElement(),this._focusedPlaceholderElement);this._editorContainer.show(this._searchableView.element);this._editorContainer.addEventListener(Sources.TabbedEditorContainer.Events.EditorSelected,this._editorSelected,this);this._editorContainer.addEventListener(Sources.TabbedEditorContainer.Events.EditorClosed,this._editorClosed,this);this._historyManager=new Sources.EditingLocationHistoryManager(this,this.currentSourceFrame.bind(this));this._toolbarContainerElement=this.element.createChild('div','sources-toolbar');if(!Root.Runtime.experiments.isEnabled('sourcesPrettyPrint')){this._toolbarEditorActions=new UI.Toolbar('',this._toolbarContainerElement);self.runtime.allInstances(Sources.SourcesView.EditorAction).then(appendButtonsForExtensions.bind(this));}
  1191. function appendButtonsForExtensions(actions){for(let i=0;i<actions.length;++i){this._toolbarEditorActions.appendToolbarItem(actions[i].button(this));}}
  1192. this._scriptViewToolbar=new UI.Toolbar('',this._toolbarContainerElement);this._scriptViewToolbar.element.style.flex='auto';this._bottomToolbar=new UI.Toolbar('',this._toolbarContainerElement);this._toolbarChangedListener=null;UI.startBatchUpdate();workspace.uiSourceCodes().forEach(this._addUISourceCode.bind(this));UI.endBatchUpdate();workspace.addEventListener(Workspace.Workspace.Events.UISourceCodeAdded,this._uiSourceCodeAdded,this);workspace.addEventListener(Workspace.Workspace.Events.UISourceCodeRemoved,this._uiSourceCodeRemoved,this);workspace.addEventListener(Workspace.Workspace.Events.ProjectRemoved,this._projectRemoved.bind(this),this);function handleBeforeUnload(event){if(event.returnValue){return;}
  1193. let unsavedSourceCodes=[];const projects=Workspace.workspace.projectsForType(Workspace.projectTypes.FileSystem);for(let i=0;i<projects.length;++i){unsavedSourceCodes=unsavedSourceCodes.concat(projects[i].uiSourceCodes().filter(sourceCode=>sourceCode.isDirty()));}
  1194. if(!unsavedSourceCodes.length){return;}
  1195. event.returnValue=Common.UIString('DevTools have unsaved changes that will be permanently lost.');UI.viewManager.showView('sources');for(let i=0;i<unsavedSourceCodes.length;++i){Common.Revealer.reveal(unsavedSourceCodes[i]);}}
  1196. if(!window.opener){window.addEventListener('beforeunload',handleBeforeUnload,true);}
  1197. this._shortcuts={};this.element.addEventListener('keydown',this._handleKeyDown.bind(this),false);}
  1198. _placeholderElement(){this._placeholderOptionArray=[];const shortcuts=[{actionId:'quickOpen.show',description:ls`Open file`},{actionId:'commandMenu.show',description:ls`Run command`},{actionId:'sources.add-folder-to-workspace',description:ls`Drop in a folder to add to workspace`}];const element=createElementWithClass('div');const list=element.createChild('div','tabbed-pane-placeholder');list.addEventListener('keydown',this._placeholderOnKeyDown.bind(this),false);UI.ARIAUtils.markAsList(list);UI.ARIAUtils.setAccessibleName(list,ls`Source View Actions`);for(let i=0;i<shortcuts.length;i++){const shortcut=shortcuts[i];const shortcutKeyText=UI.shortcutRegistry.shortcutTitleForAction(shortcut.actionId);const listItemElement=list.createChild('div');UI.ARIAUtils.markAsListitem(listItemElement);const row=listItemElement.createChild('div','tabbed-pane-placeholder-row');row.tabIndex=-1;UI.ARIAUtils.markAsButton(row);if(shortcutKeyText){row.createChild('div','tabbed-pane-placeholder-key').textContent=shortcutKeyText;row.createChild('div','tabbed-pane-placeholder-value').textContent=shortcut.description;}else{row.createChild('div','tabbed-pane-no-shortcut').textContent=shortcut.description;}
  1199. const action=UI.actionRegistry.action(shortcut.actionId);const actionHandler=action.execute.bind(action);this._placeholderOptionArray.push({element:row,handler:actionHandler});}
  1200. const firstElement=this._placeholderOptionArray[0].element;firstElement.tabIndex=0;this._focusedPlaceholderElement=firstElement;this._selectedIndex=0;element.appendChild(UI.XLink.create('https://developers.google.com/web/tools/chrome-devtools/sources?utm_source=devtools&utm_campaign=2018Q1','Learn more'));return element;}
  1201. _placeholderOnKeyDown(event){if(isEnterOrSpaceKey(event)){this._placeholderOptionArray[this._selectedIndex].handler.call();return;}
  1202. let offset=0;if(event.key==='ArrowDown'){offset=1;}else if(event.key==='ArrowUp'){offset=-1;}
  1203. const newIndex=Math.max(Math.min(this._placeholderOptionArray.length-1,this._selectedIndex+offset),0);const newElement=this._placeholderOptionArray[newIndex].element;const oldElement=this._placeholderOptionArray[this._selectedIndex].element;if(newElement!==oldElement){oldElement.tabIndex=-1;newElement.tabIndex=0;UI.ARIAUtils.setSelected(oldElement,false);UI.ARIAUtils.setSelected(newElement,true);this._selectedIndex=newIndex;newElement.focus();}}
  1204. _resetPlaceholderState(){this._placeholderOptionArray[this._selectedIndex].element.tabIndex=-1;this._placeholderOptionArray[0].element.tabIndex=0;this._selectedIndex=0;}
  1205. static defaultUISourceCodeScores(){const defaultScores=new Map();const sourcesView=UI.context.flavor(Sources.SourcesView);if(sourcesView){const uiSourceCodes=sourcesView._editorContainer.historyUISourceCodes();for(let i=1;i<uiSourceCodes.length;++i)
  1206. {defaultScores.set(uiSourceCodes[i],uiSourceCodes.length-i);}}
  1207. return defaultScores;}
  1208. leftToolbar(){return this._editorContainer.leftToolbar();}
  1209. rightToolbar(){return this._editorContainer.rightToolbar();}
  1210. bottomToolbar(){return this._bottomToolbar;}
  1211. _registerShortcuts(keys,handler){for(let i=0;i<keys.length;++i){this._shortcuts[keys[i].key]=handler;}}
  1212. _handleKeyDown(event){const shortcutKey=UI.KeyboardShortcut.makeKeyFromEvent(event);const handler=this._shortcuts[shortcutKey];if(handler&&handler()){event.consume(true);}}
  1213. wasShown(){super.wasShown();UI.context.setFlavor(Sources.SourcesView,this);}
  1214. willHide(){UI.context.setFlavor(Sources.SourcesView,null);this._resetPlaceholderState();super.willHide();}
  1215. toolbarContainerElement(){return this._toolbarContainerElement;}
  1216. searchableView(){return this._searchableView;}
  1217. visibleView(){return this._editorContainer.visibleView;}
  1218. currentSourceFrame(){const view=this.visibleView();if(!(view instanceof Sources.UISourceCodeFrame)){return null;}
  1219. return(view);}
  1220. currentUISourceCode(){return this._editorContainer.currentFile();}
  1221. _onCloseEditorTab(){const uiSourceCode=this._editorContainer.currentFile();if(!uiSourceCode){return false;}
  1222. this._editorContainer.closeFile(uiSourceCode);return true;}
  1223. _onJumpToPreviousLocation(){this._historyManager.rollback();}
  1224. _onJumpToNextLocation(){this._historyManager.rollover();}
  1225. _uiSourceCodeAdded(event){const uiSourceCode=(event.data);this._addUISourceCode(uiSourceCode);}
  1226. _addUISourceCode(uiSourceCode){if(uiSourceCode.project().isServiceProject()){return;}
  1227. if(uiSourceCode.project().type()===Workspace.projectTypes.FileSystem&&Persistence.FileSystemWorkspaceBinding.fileSystemType(uiSourceCode.project())==='overrides'){return;}
  1228. this._editorContainer.addUISourceCode(uiSourceCode);}
  1229. _uiSourceCodeRemoved(event){const uiSourceCode=(event.data);this._removeUISourceCodes([uiSourceCode]);}
  1230. _removeUISourceCodes(uiSourceCodes){this._editorContainer.removeUISourceCodes(uiSourceCodes);for(let i=0;i<uiSourceCodes.length;++i){this._removeSourceFrame(uiSourceCodes[i]);this._historyManager.removeHistoryForSourceCode(uiSourceCodes[i]);}}
  1231. _projectRemoved(event){const project=event.data;const uiSourceCodes=project.uiSourceCodes();this._removeUISourceCodes(uiSourceCodes);}
  1232. _updateScriptViewToolbarItems(){this._scriptViewToolbar.removeToolbarItems();const view=this.visibleView();if(view instanceof UI.SimpleView){for(const item of((view)).syncToolbarItems()){this._scriptViewToolbar.appendToolbarItem(item);}}}
  1233. showSourceLocation(uiSourceCode,lineNumber,columnNumber,omitFocus,omitHighlight){this._historyManager.updateCurrentState();this._editorContainer.showFile(uiSourceCode);const currentSourceFrame=this.currentSourceFrame();if(currentSourceFrame&&typeof lineNumber==='number'){currentSourceFrame.revealPosition(lineNumber,columnNumber,!omitHighlight);}
  1234. this._historyManager.pushNewState();if(!omitFocus){this.visibleView().focus();}}
  1235. _createSourceView(uiSourceCode){let sourceFrame;let sourceView;const contentType=uiSourceCode.contentType();if(contentType===Common.resourceTypes.Image){sourceView=new SourceFrame.ImageView(uiSourceCode.mimeType(),uiSourceCode);}else if(contentType===Common.resourceTypes.Font){sourceView=new SourceFrame.FontView(uiSourceCode.mimeType(),uiSourceCode);}else{sourceFrame=new Sources.UISourceCodeFrame(uiSourceCode);}
  1236. if(sourceFrame){this._historyManager.trackSourceFrameCursorJumps(sourceFrame);}
  1237. const widget=(sourceFrame||sourceView);this._sourceViewByUISourceCode.set(uiSourceCode,widget);return widget;}
  1238. _getOrCreateSourceView(uiSourceCode){return this._sourceViewByUISourceCode.get(uiSourceCode)||this._createSourceView(uiSourceCode);}
  1239. recycleUISourceCodeFrame(sourceFrame,uiSourceCode){this._sourceViewByUISourceCode.delete(sourceFrame.uiSourceCode());sourceFrame.setUISourceCode(uiSourceCode);this._sourceViewByUISourceCode.set(uiSourceCode,sourceFrame);}
  1240. viewForFile(uiSourceCode){return this._getOrCreateSourceView(uiSourceCode);}
  1241. _removeSourceFrame(uiSourceCode){const sourceView=this._sourceViewByUISourceCode.get(uiSourceCode);this._sourceViewByUISourceCode.remove(uiSourceCode);if(sourceView&&sourceView instanceof Sources.UISourceCodeFrame){(sourceView).dispose();}}
  1242. _editorClosed(event){const uiSourceCode=(event.data);this._historyManager.removeHistoryForSourceCode(uiSourceCode);let wasSelected=false;if(!this._editorContainer.currentFile()){wasSelected=true;}
  1243. this._removeToolbarChangedListener();this._updateScriptViewToolbarItems();this._searchableView.resetSearch();const data={};data.uiSourceCode=uiSourceCode;data.wasSelected=wasSelected;this.dispatchEventToListeners(Sources.SourcesView.Events.EditorClosed,data);}
  1244. _editorSelected(event){const previousSourceFrame=event.data.previousView instanceof Sources.UISourceCodeFrame?event.data.previousView:null;if(previousSourceFrame){previousSourceFrame.setSearchableView(null);}
  1245. const currentSourceFrame=event.data.currentView instanceof Sources.UISourceCodeFrame?event.data.currentView:null;if(currentSourceFrame){currentSourceFrame.setSearchableView(this._searchableView);}
  1246. this._searchableView.setReplaceable(!!currentSourceFrame&&currentSourceFrame.canEditSource());this._searchableView.refreshSearch();this._updateToolbarChangedListener();this._updateScriptViewToolbarItems();this.dispatchEventToListeners(Sources.SourcesView.Events.EditorSelected,this._editorContainer.currentFile());}
  1247. _removeToolbarChangedListener(){if(this._toolbarChangedListener){Common.EventTarget.removeEventListeners([this._toolbarChangedListener]);}
  1248. this._toolbarChangedListener=null;}
  1249. _updateToolbarChangedListener(){this._removeToolbarChangedListener();const sourceFrame=this.currentSourceFrame();if(!sourceFrame){return;}
  1250. this._toolbarChangedListener=sourceFrame.addEventListener(Sources.UISourceCodeFrame.Events.ToolbarItemsChanged,this._updateScriptViewToolbarItems,this);}
  1251. searchCanceled(){if(this._searchView){this._searchView.searchCanceled();}
  1252. delete this._searchView;delete this._searchConfig;}
  1253. performSearch(searchConfig,shouldJump,jumpBackwards){const sourceFrame=this.currentSourceFrame();if(!sourceFrame){return;}
  1254. this._searchView=sourceFrame;this._searchConfig=searchConfig;this._searchView.performSearch(this._searchConfig,shouldJump,jumpBackwards);}
  1255. jumpToNextSearchResult(){if(!this._searchView){return;}
  1256. if(this._searchView!==this.currentSourceFrame()){this.performSearch(this._searchConfig,true);return;}
  1257. this._searchView.jumpToNextSearchResult();}
  1258. jumpToPreviousSearchResult(){if(!this._searchView){return;}
  1259. if(this._searchView!==this.currentSourceFrame()){this.performSearch(this._searchConfig,true);if(this._searchView){this._searchView.jumpToLastSearchResult();}
  1260. return;}
  1261. this._searchView.jumpToPreviousSearchResult();}
  1262. supportsCaseSensitiveSearch(){return true;}
  1263. supportsRegexSearch(){return true;}
  1264. replaceSelectionWith(searchConfig,replacement){const sourceFrame=this.currentSourceFrame();if(!sourceFrame){console.assert(sourceFrame);return;}
  1265. sourceFrame.replaceSelectionWith(searchConfig,replacement);}
  1266. replaceAllWith(searchConfig,replacement){const sourceFrame=this.currentSourceFrame();if(!sourceFrame){console.assert(sourceFrame);return;}
  1267. sourceFrame.replaceAllWith(searchConfig,replacement);}
  1268. _showOutlineQuickOpen(){QuickOpen.QuickOpen.show('@');}
  1269. _showGoToLineQuickOpen(){if(this._editorContainer.currentFile()){QuickOpen.QuickOpen.show(':');}}
  1270. _save(){this._saveSourceFrame(this.currentSourceFrame());}
  1271. _saveAll(){const sourceFrames=this._editorContainer.fileViews();sourceFrames.forEach(this._saveSourceFrame.bind(this));}
  1272. _saveSourceFrame(sourceFrame){if(!(sourceFrame instanceof Sources.UISourceCodeFrame)){return;}
  1273. const uiSourceCodeFrame=(sourceFrame);uiSourceCodeFrame.commitEditing();}
  1274. toggleBreakpointsActiveState(active){this._editorContainer.view.element.classList.toggle('breakpoints-deactivated',!active);}};Sources.SourcesView.Events={EditorClosed:Symbol('EditorClosed'),EditorSelected:Symbol('EditorSelected'),};Sources.SourcesView.EditorAction=function(){};Sources.SourcesView.EditorAction.prototype={button(sourcesView){}};Sources.SourcesView.SwitchFileActionDelegate=class{static _nextFile(currentUISourceCode){function fileNamePrefix(name){const lastDotIndex=name.lastIndexOf('.');const namePrefix=name.substr(0,lastDotIndex!==-1?lastDotIndex:name.length);return namePrefix.toLowerCase();}
  1275. const uiSourceCodes=currentUISourceCode.project().uiSourceCodes();const candidates=[];const url=currentUISourceCode.parentURL();const name=currentUISourceCode.name();const namePrefix=fileNamePrefix(name);for(let i=0;i<uiSourceCodes.length;++i){const uiSourceCode=uiSourceCodes[i];if(url!==uiSourceCode.parentURL()){continue;}
  1276. if(fileNamePrefix(uiSourceCode.name())===namePrefix){candidates.push(uiSourceCode.name());}}
  1277. candidates.sort(String.naturalOrderComparator);const index=mod(candidates.indexOf(name)+1,candidates.length);const fullURL=(url?url+'/':'')+candidates[index];const nextUISourceCode=currentUISourceCode.project().uiSourceCodeForURL(fullURL);return nextUISourceCode!==currentUISourceCode?nextUISourceCode:null;}
  1278. handleAction(context,actionId){const sourcesView=UI.context.flavor(Sources.SourcesView);const currentUISourceCode=sourcesView.currentUISourceCode();if(!currentUISourceCode){return false;}
  1279. const nextUISourceCode=Sources.SourcesView.SwitchFileActionDelegate._nextFile(currentUISourceCode);if(!nextUISourceCode){return false;}
  1280. sourcesView.showSourceLocation(nextUISourceCode);return true;}};Sources.SourcesView.ActionDelegate=class{handleAction(context,actionId){const sourcesView=UI.context.flavor(Sources.SourcesView);if(!sourcesView){return false;}
  1281. switch(actionId){case'sources.close-all':sourcesView._editorContainer.closeAllFiles();return true;case'sources.jump-to-previous-location':sourcesView._onJumpToPreviousLocation();return true;case'sources.jump-to-next-location':sourcesView._onJumpToNextLocation();return true;case'sources.close-editor-tab':return sourcesView._onCloseEditorTab();case'sources.go-to-line':sourcesView._showGoToLineQuickOpen();return true;case'sources.go-to-member':sourcesView._showOutlineQuickOpen();return true;case'sources.save':sourcesView._save();return true;case'sources.save-all':sourcesView._saveAll();return true;}
  1282. return false;}};;Sources.SourcesSearchScope=class{constructor(){this._searchId=0;this._searchResultCandidates=[];this._searchResultCallback=null;this._searchFinishedCallback=null;this._searchConfig=null;}
  1283. static _filesComparator(uiSourceCode1,uiSourceCode2){if(uiSourceCode1.isDirty()&&!uiSourceCode2.isDirty()){return-1;}
  1284. if(!uiSourceCode1.isDirty()&&uiSourceCode2.isDirty()){return 1;}
  1285. const isFileSystem1=uiSourceCode1.project().type()===Workspace.projectTypes.FileSystem&&!Persistence.persistence.binding(uiSourceCode1);const isFileSystem2=uiSourceCode2.project().type()===Workspace.projectTypes.FileSystem&&!Persistence.persistence.binding(uiSourceCode2);if(isFileSystem1!==isFileSystem2){return isFileSystem1?1:-1;}
  1286. const url1=uiSourceCode1.url();const url2=uiSourceCode2.url();if(url1&&!url2){return-1;}
  1287. if(!url1&&url2){return 1;}
  1288. return String.naturalOrderComparator(uiSourceCode1.fullDisplayName(),uiSourceCode2.fullDisplayName());}
  1289. performIndexing(progress){this.stopSearch();const projects=this._projects();const compositeProgress=new Common.CompositeProgress(progress);for(let i=0;i<projects.length;++i){const project=projects[i];const projectProgress=compositeProgress.createSubProgress(project.uiSourceCodes().length);project.indexContent(projectProgress);}}
  1290. _projects(){const searchInAnonymousAndContentScripts=Common.moduleSetting('searchInAnonymousAndContentScripts').get();return Workspace.workspace.projects().filter(project=>{if(project.type()===Workspace.projectTypes.Service){return false;}
  1291. if(!searchInAnonymousAndContentScripts&&project.isServiceProject()){return false;}
  1292. if(!searchInAnonymousAndContentScripts&&project.type()===Workspace.projectTypes.ContentScripts){return false;}
  1293. return true;});}
  1294. performSearch(searchConfig,progress,searchResultCallback,searchFinishedCallback){this.stopSearch();this._searchResultCandidates=[];this._searchResultCallback=searchResultCallback;this._searchFinishedCallback=searchFinishedCallback;this._searchConfig=searchConfig;const promises=[];const compositeProgress=new Common.CompositeProgress(progress);const searchContentProgress=compositeProgress.createSubProgress();const findMatchingFilesProgress=new Common.CompositeProgress(compositeProgress.createSubProgress());for(const project of this._projects()){const weight=project.uiSourceCodes().length;const findMatchingFilesInProjectProgress=findMatchingFilesProgress.createSubProgress(weight);const filesMathingFileQuery=this._projectFilesMatchingFileQuery(project,searchConfig);const promise=project.findFilesMatchingSearchRequest(searchConfig,filesMathingFileQuery,findMatchingFilesInProjectProgress).then(this._processMatchingFilesForProject.bind(this,this._searchId,project,searchConfig,filesMathingFileQuery));promises.push(promise);}
  1295. Promise.all(promises).then(this._processMatchingFiles.bind(this,this._searchId,searchContentProgress,this._searchFinishedCallback.bind(this,true)));}
  1296. _projectFilesMatchingFileQuery(project,searchConfig,dirtyOnly){const result=[];const uiSourceCodes=project.uiSourceCodes();for(let i=0;i<uiSourceCodes.length;++i){const uiSourceCode=uiSourceCodes[i];if(!uiSourceCode.contentType().isTextType()){continue;}
  1297. const binding=Persistence.persistence.binding(uiSourceCode);if(binding&&binding.network===uiSourceCode){continue;}
  1298. if(dirtyOnly&&!uiSourceCode.isDirty()){continue;}
  1299. if(searchConfig.filePathMatchesFileQuery(uiSourceCode.fullDisplayName())){result.push(uiSourceCode.url());}}
  1300. result.sort(String.naturalOrderComparator);return result;}
  1301. _processMatchingFilesForProject(searchId,project,searchConfig,filesMathingFileQuery,files){if(searchId!==this._searchId){this._searchFinishedCallback(false);return;}
  1302. files.sort(String.naturalOrderComparator);files=files.intersectOrdered(filesMathingFileQuery,String.naturalOrderComparator);const dirtyFiles=this._projectFilesMatchingFileQuery(project,searchConfig,true);files=files.mergeOrdered(dirtyFiles,String.naturalOrderComparator);const uiSourceCodes=[];for(const file of files){const uiSourceCode=project.uiSourceCodeForURL(file);if(!uiSourceCode){continue;}
  1303. const script=Bindings.DefaultScriptMapping.scriptForUISourceCode(uiSourceCode);if(script&&!script.isAnonymousScript()){continue;}
  1304. uiSourceCodes.push(uiSourceCode);}
  1305. uiSourceCodes.sort(Sources.SourcesSearchScope._filesComparator);this._searchResultCandidates=this._searchResultCandidates.mergeOrdered(uiSourceCodes,Sources.SourcesSearchScope._filesComparator);}
  1306. _processMatchingFiles(searchId,progress,callback){if(searchId!==this._searchId){this._searchFinishedCallback(false);return;}
  1307. const files=this._searchResultCandidates;if(!files.length){progress.done();callback();return;}
  1308. progress.setTotalWork(files.length);let fileIndex=0;const maxFileContentRequests=20;let callbacksLeft=0;for(let i=0;i<maxFileContentRequests&&i<files.length;++i){scheduleSearchInNextFileOrFinish.call(this);}
  1309. function searchInNextFile(uiSourceCode){if(uiSourceCode.isDirty()){contentLoaded.call(this,uiSourceCode,uiSourceCode.workingCopy());}else{uiSourceCode.requestContent().then(deferredContent=>{contentLoaded.call(this,uiSourceCode,deferredContent.content||'');});}}
  1310. function scheduleSearchInNextFileOrFinish(){if(fileIndex>=files.length){if(!callbacksLeft){progress.done();callback();return;}
  1311. return;}
  1312. ++callbacksLeft;const uiSourceCode=files[fileIndex++];setTimeout(searchInNextFile.bind(this,uiSourceCode),0);}
  1313. function contentLoaded(uiSourceCode,content){function matchesComparator(a,b){return a.lineNumber-b.lineNumber;}
  1314. progress.worked(1);let matches=[];const queries=this._searchConfig.queries();if(content!==null){for(let i=0;i<queries.length;++i){const nextMatches=Common.ContentProvider.performSearchInContent(content,queries[i],!this._searchConfig.ignoreCase(),this._searchConfig.isRegex());matches=matches.mergeOrdered(nextMatches,matchesComparator);}}
  1315. if(matches){const searchResult=new Sources.FileBasedSearchResult(uiSourceCode,matches);this._searchResultCallback(searchResult);}
  1316. --callbacksLeft;scheduleSearchInNextFileOrFinish.call(this);}}
  1317. stopSearch(){++this._searchId;}};Sources.FileBasedSearchResult=class{constructor(uiSourceCode,searchMatches){this._uiSourceCode=uiSourceCode;this._searchMatches=searchMatches;}
  1318. label(){return this._uiSourceCode.displayName();}
  1319. description(){return this._uiSourceCode.fullDisplayName();}
  1320. matchesCount(){return this._searchMatches.length;}
  1321. matchLineContent(index){return this._searchMatches[index].lineContent;}
  1322. matchRevealable(index){const match=this._searchMatches[index];return this._uiSourceCode.uiLocation(match.lineNumber,undefined);}
  1323. matchLabel(index){return this._searchMatches[index].lineNumber+1;}};;Sources.SourcesPanel=class extends UI.Panel{constructor(){super('sources');Sources.SourcesPanel._instance=this;this.registerRequiredCSS('sources/sourcesPanel.css');new UI.DropTarget(this.element,[UI.DropTarget.Type.Folder],Common.UIString('Drop workspace folder here'),this._handleDrop.bind(this));this._workspace=Workspace.workspace;this._togglePauseAction=(UI.actionRegistry.action('debugger.toggle-pause'));this._stepOverAction=(UI.actionRegistry.action('debugger.step-over'));this._stepIntoAction=(UI.actionRegistry.action('debugger.step-into'));this._stepOutAction=(UI.actionRegistry.action('debugger.step-out'));this._stepAction=(UI.actionRegistry.action('debugger.step'));this._toggleBreakpointsActiveAction=(UI.actionRegistry.action('debugger.toggle-breakpoints-active'));this._debugToolbar=this._createDebugToolbar();this._debugToolbarDrawer=this._createDebugToolbarDrawer();this._debuggerPausedMessage=new Sources.DebuggerPausedMessage();const initialDebugSidebarWidth=225;this._splitWidget=new UI.SplitWidget(true,true,'sourcesPanelSplitViewState',initialDebugSidebarWidth);this._splitWidget.enableShowModeSaving();this._splitWidget.show(this.element);const initialNavigatorWidth=225;this.editorView=new UI.SplitWidget(true,false,'sourcesPanelNavigatorSplitViewState',initialNavigatorWidth);this.editorView.enableShowModeSaving();this._splitWidget.setMainWidget(this.editorView);this._navigatorTabbedLocation=UI.viewManager.createTabbedLocation(this._revealNavigatorSidebar.bind(this),'navigator-view',true);const tabbedPane=this._navigatorTabbedLocation.tabbedPane();tabbedPane.setMinimumSize(100,25);tabbedPane.element.classList.add('navigator-tabbed-pane');const navigatorMenuButton=new UI.ToolbarMenuButton(this._populateNavigatorMenu.bind(this),true);navigatorMenuButton.setTitle(Common.UIString('More options'));tabbedPane.rightToolbar().appendToolbarItem(navigatorMenuButton);if(UI.viewManager.hasViewsForLocation('run-view-sidebar')){const navigatorSplitWidget=new UI.SplitWidget(false,true,'sourcePanelNavigatorSidebarSplitViewState');navigatorSplitWidget.setMainWidget(tabbedPane);const runViewTabbedPane=UI.viewManager.createTabbedLocation(this._revealNavigatorSidebar.bind(this),'run-view-sidebar').tabbedPane();navigatorSplitWidget.setSidebarWidget(runViewTabbedPane);navigatorSplitWidget.installResizer(runViewTabbedPane.headerElement());this.editorView.setSidebarWidget(navigatorSplitWidget);}else{this.editorView.setSidebarWidget(tabbedPane);}
  1324. this._sourcesView=new Sources.SourcesView();this._sourcesView.addEventListener(Sources.SourcesView.Events.EditorSelected,this._editorSelected.bind(this));this._toggleNavigatorSidebarButton=this.editorView.createShowHideSidebarButton(ls`navigator`);this._toggleDebuggerSidebarButton=this._splitWidget.createShowHideSidebarButton(ls`debugger`);this.editorView.setMainWidget(this._sourcesView);this._threadsSidebarPane=null;this._watchSidebarPane=(UI.viewManager.view('sources.watch'));this._callstackPane=self.runtime.sharedInstance(Sources.CallStackSidebarPane);Common.moduleSetting('sidebarPosition').addChangeListener(this._updateSidebarPosition.bind(this));this._updateSidebarPosition();this._updateDebuggerButtonsAndStatus();this._pauseOnExceptionEnabledChanged();Common.moduleSetting('pauseOnExceptionEnabled').addChangeListener(this._pauseOnExceptionEnabledChanged,this);this._liveLocationPool=new Bindings.LiveLocationPool();this._setTarget(UI.context.flavor(SDK.Target));Common.moduleSetting('breakpointsActive').addChangeListener(this._breakpointsActiveStateChanged,this);UI.context.addFlavorChangeListener(SDK.Target,this._onCurrentTargetChanged,this);UI.context.addFlavorChangeListener(SDK.DebuggerModel.CallFrame,this._callFrameChanged,this);SDK.targetManager.addModelListener(SDK.DebuggerModel,SDK.DebuggerModel.Events.DebuggerWasEnabled,this._debuggerWasEnabled,this);SDK.targetManager.addModelListener(SDK.DebuggerModel,SDK.DebuggerModel.Events.DebuggerPaused,this._debuggerPaused,this);SDK.targetManager.addModelListener(SDK.DebuggerModel,SDK.DebuggerModel.Events.DebuggerResumed,event=>this._debuggerResumed((event.data)));SDK.targetManager.addModelListener(SDK.DebuggerModel,SDK.DebuggerModel.Events.GlobalObjectCleared,event=>this._debuggerResumed((event.data)));Extensions.extensionServer.addEventListener(Extensions.ExtensionServer.Events.SidebarPaneAdded,this._extensionSidebarPaneAdded,this);SDK.targetManager.observeTargets(this);}
  1325. static instance(){if(Sources.SourcesPanel._instance){return Sources.SourcesPanel._instance;}
  1326. return(self.runtime.sharedInstance(Sources.SourcesPanel));}
  1327. static updateResizerAndSidebarButtons(panel){panel._sourcesView.leftToolbar().removeToolbarItems();panel._sourcesView.rightToolbar().removeToolbarItems();panel._sourcesView.bottomToolbar().removeToolbarItems();const isInWrapper=Sources.SourcesPanel.WrapperView.isShowing()&&!UI.inspectorView.isDrawerMinimized();if(panel._splitWidget.isVertical()||isInWrapper){panel._splitWidget.uninstallResizer(panel._sourcesView.toolbarContainerElement());}else{panel._splitWidget.installResizer(panel._sourcesView.toolbarContainerElement());}
  1328. if(!isInWrapper){panel._sourcesView.leftToolbar().appendToolbarItem(panel._toggleNavigatorSidebarButton);if(panel._splitWidget.isVertical()){panel._sourcesView.rightToolbar().appendToolbarItem(panel._toggleDebuggerSidebarButton);}else{panel._sourcesView.bottomToolbar().appendToolbarItem(panel._toggleDebuggerSidebarButton);}}}
  1329. targetAdded(target){this._showThreadsIfNeeded();}
  1330. targetRemoved(target){}
  1331. _showThreadsIfNeeded(){if(Sources.ThreadsSidebarPane.shouldBeShown()&&!this._threadsSidebarPane){this._threadsSidebarPane=(UI.viewManager.view('sources.threads'));if(this._sidebarPaneStack&&this._threadsSidebarPane){this._sidebarPaneStack.showView(this._threadsSidebarPane,this._splitWidget.isVertical()?this._watchSidebarPane:this._callstackPane);}}}
  1332. _setTarget(target){if(!target){return;}
  1333. const debuggerModel=target.model(SDK.DebuggerModel);if(!debuggerModel){return;}
  1334. if(debuggerModel.isPaused()){this._showDebuggerPausedDetails((debuggerModel.debuggerPausedDetails()));}else{this._paused=false;this._clearInterface();this._toggleDebuggerSidebarButton.setEnabled(true);}}
  1335. _onCurrentTargetChanged(event){const target=(event.data);this._setTarget(target);}
  1336. paused(){return this._paused;}
  1337. wasShown(){UI.context.setFlavor(Sources.SourcesPanel,this);super.wasShown();const wrapper=Sources.SourcesPanel.WrapperView._instance;if(wrapper&&wrapper.isShowing()){UI.inspectorView.setDrawerMinimized(true);Sources.SourcesPanel.updateResizerAndSidebarButtons(this);}
  1338. this.editorView.setMainWidget(this._sourcesView);}
  1339. willHide(){super.willHide();UI.context.setFlavor(Sources.SourcesPanel,null);if(Sources.SourcesPanel.WrapperView.isShowing()){Sources.SourcesPanel.WrapperView._instance._showViewInWrapper();UI.inspectorView.setDrawerMinimized(false);Sources.SourcesPanel.updateResizerAndSidebarButtons(this);}}
  1340. resolveLocation(locationName){if(locationName==='sources.sidebar-top'||locationName==='sources.sidebar-bottom'||locationName==='sources.sidebar-tabs'){return this._sidebarPaneStack;}else{return this._navigatorTabbedLocation;}}
  1341. _ensureSourcesViewVisible(){if(Sources.SourcesPanel.WrapperView.isShowing()){return true;}
  1342. if(!UI.inspectorView.canSelectPanel('sources')){return false;}
  1343. UI.viewManager.showView('sources');return true;}
  1344. onResize(){if(Common.moduleSetting('sidebarPosition').get()==='auto'){this.element.window().requestAnimationFrame(this._updateSidebarPosition.bind(this));}}
  1345. searchableView(){return this._sourcesView.searchableView();}
  1346. _debuggerPaused(event){const debuggerModel=(event.data);const details=debuggerModel.debuggerPausedDetails();if(!this._paused){this._setAsCurrentPanel();}
  1347. if(UI.context.flavor(SDK.Target)===debuggerModel.target()){this._showDebuggerPausedDetails((details));}else if(!this._paused){UI.context.setFlavor(SDK.Target,debuggerModel.target());}}
  1348. _showDebuggerPausedDetails(details){this._paused=true;this._updateDebuggerButtonsAndStatus();UI.context.setFlavor(SDK.DebuggerPausedDetails,details);this._toggleDebuggerSidebarButton.setEnabled(false);this._revealDebuggerSidebar();window.focus();Host.InspectorFrontendHost.bringToFront();}
  1349. _debuggerResumed(debuggerModel){const target=debuggerModel.target();if(UI.context.flavor(SDK.Target)!==target){return;}
  1350. this._paused=false;this._clearInterface();this._toggleDebuggerSidebarButton.setEnabled(true);this._switchToPausedTargetTimeout=setTimeout(this._switchToPausedTarget.bind(this,debuggerModel),500);}
  1351. _debuggerWasEnabled(event){const debuggerModel=(event.data);if(UI.context.flavor(SDK.Target)!==debuggerModel.target()){return;}
  1352. this._updateDebuggerButtonsAndStatus();}
  1353. get visibleView(){return this._sourcesView.visibleView();}
  1354. showUISourceCode(uiSourceCode,lineNumber,columnNumber,omitFocus){if(omitFocus){const wrapperShowing=Sources.SourcesPanel.WrapperView._instance&&Sources.SourcesPanel.WrapperView._instance.isShowing();if(!this.isShowing()&&!wrapperShowing){return;}}else{this._showEditor();}
  1355. this._sourcesView.showSourceLocation(uiSourceCode,lineNumber,columnNumber,omitFocus);}
  1356. _showEditor(){if(Sources.SourcesPanel.WrapperView._instance&&Sources.SourcesPanel.WrapperView._instance.isShowing()){return;}
  1357. this._setAsCurrentPanel();}
  1358. showUILocation(uiLocation,omitFocus){this.showUISourceCode(uiLocation.uiSourceCode,uiLocation.lineNumber,uiLocation.columnNumber,omitFocus);}
  1359. _revealInNavigator(uiSourceCode,skipReveal){const extensions=self.runtime.extensions(Sources.NavigatorView);Promise.all(extensions.map(extension=>extension.instance())).then(filterNavigators.bind(this));function filterNavigators(objects){for(let i=0;i<objects.length;++i){const navigatorView=(objects[i]);const viewId=extensions[i].descriptor()['viewId'];if(navigatorView.acceptProject(uiSourceCode.project())){navigatorView.revealUISourceCode(uiSourceCode,true);if(skipReveal){this._navigatorTabbedLocation.tabbedPane().selectTab(viewId);}else{UI.viewManager.showView(viewId);}}}}}
  1360. _populateNavigatorMenu(contextMenu){const groupByFolderSetting=Common.moduleSetting('navigatorGroupByFolder');contextMenu.appendItemsAtLocation('navigatorMenu');contextMenu.viewSection().appendCheckboxItem(Common.UIString('Group by folder'),()=>groupByFolderSetting.set(!groupByFolderSetting.get()),groupByFolderSetting.get());}
  1361. setIgnoreExecutionLineEvents(ignoreExecutionLineEvents){this._ignoreExecutionLineEvents=ignoreExecutionLineEvents;}
  1362. updateLastModificationTime(){this._lastModificationTime=window.performance.now();}
  1363. _executionLineChanged(liveLocation){const uiLocation=liveLocation.uiLocation();if(!uiLocation){return;}
  1364. if(window.performance.now()-this._lastModificationTime<Sources.SourcesPanel._lastModificationTimeout){return;}
  1365. this._sourcesView.showSourceLocation(uiLocation.uiSourceCode,uiLocation.lineNumber,uiLocation.columnNumber,undefined,true);}
  1366. _lastModificationTimeoutPassedForTest(){Sources.SourcesPanel._lastModificationTimeout=Number.MIN_VALUE;}
  1367. _updateLastModificationTimeForTest(){Sources.SourcesPanel._lastModificationTimeout=Number.MAX_VALUE;}
  1368. _callFrameChanged(){const callFrame=UI.context.flavor(SDK.DebuggerModel.CallFrame);if(!callFrame){return;}
  1369. if(this._executionLineLocation){this._executionLineLocation.dispose();}
  1370. this._executionLineLocation=Bindings.debuggerWorkspaceBinding.createCallFrameLiveLocation(callFrame.location(),this._executionLineChanged.bind(this),this._liveLocationPool);}
  1371. _pauseOnExceptionEnabledChanged(){const enabled=Common.moduleSetting('pauseOnExceptionEnabled').get();this._pauseOnExceptionButton.setToggled(enabled);this._pauseOnExceptionButton.setTitle(enabled?ls`Don't pause on exceptions`:ls`Pause on exceptions`);this._debugToolbarDrawer.classList.toggle('expanded',enabled);}
  1372. async _updateDebuggerButtonsAndStatus(){const currentTarget=UI.context.flavor(SDK.Target);const currentDebuggerModel=currentTarget?currentTarget.model(SDK.DebuggerModel):null;if(!currentDebuggerModel){this._togglePauseAction.setEnabled(false);this._stepOverAction.setEnabled(false);this._stepIntoAction.setEnabled(false);this._stepOutAction.setEnabled(false);this._stepAction.setEnabled(false);}else if(this._paused){this._togglePauseAction.setToggled(true);this._togglePauseAction.setEnabled(true);this._stepOverAction.setEnabled(true);this._stepIntoAction.setEnabled(true);this._stepOutAction.setEnabled(true);this._stepAction.setEnabled(true);}else{this._togglePauseAction.setToggled(false);this._togglePauseAction.setEnabled(!currentDebuggerModel.isPausing());this._stepOverAction.setEnabled(false);this._stepIntoAction.setEnabled(false);this._stepOutAction.setEnabled(false);this._stepAction.setEnabled(false);}
  1373. const details=currentDebuggerModel?currentDebuggerModel.debuggerPausedDetails():null;await this._debuggerPausedMessage.render(details,Bindings.debuggerWorkspaceBinding,Bindings.breakpointManager);if(details){this._updateDebuggerButtonsAndStatusForTest();}}
  1374. _updateDebuggerButtonsAndStatusForTest(){}
  1375. _clearInterface(){this._updateDebuggerButtonsAndStatus();UI.context.setFlavor(SDK.DebuggerPausedDetails,null);if(this._switchToPausedTargetTimeout){clearTimeout(this._switchToPausedTargetTimeout);}
  1376. this._liveLocationPool.disposeAll();}
  1377. _switchToPausedTarget(debuggerModel){delete this._switchToPausedTargetTimeout;if(this._paused){return;}
  1378. if(debuggerModel.isPaused()){return;}
  1379. const debuggerModels=SDK.targetManager.models(SDK.DebuggerModel);for(let i=0;i<debuggerModels.length;++i){if(debuggerModels[i].isPaused()){UI.context.setFlavor(SDK.Target,debuggerModels[i].target());break;}}}
  1380. _togglePauseOnExceptions(){Common.moduleSetting('pauseOnExceptionEnabled').set(!this._pauseOnExceptionButton.toggled());}
  1381. _runSnippet(){const uiSourceCode=this._sourcesView.currentUISourceCode();if(!uiSourceCode){return;}
  1382. Snippets.evaluateScriptSnippet(uiSourceCode);}
  1383. _editorSelected(event){const uiSourceCode=(event.data);if(this.editorView.mainWidget()&&Common.moduleSetting('autoRevealInNavigator').get()){this._revealInNavigator(uiSourceCode,true);}}
  1384. _togglePause(){const target=UI.context.flavor(SDK.Target);if(!target){return true;}
  1385. const debuggerModel=target.model(SDK.DebuggerModel);if(!debuggerModel){return true;}
  1386. if(this._paused){this._paused=false;debuggerModel.resume();}else{debuggerModel.pause();}
  1387. this._clearInterface();return true;}
  1388. _prepareToResume(){if(!this._paused){return null;}
  1389. this._paused=false;this._clearInterface();const target=UI.context.flavor(SDK.Target);return target?target.model(SDK.DebuggerModel):null;}
  1390. _longResume(event){const debuggerModel=this._prepareToResume();if(!debuggerModel){return;}
  1391. debuggerModel.skipAllPausesUntilReloadOrTimeout(500);debuggerModel.resume();}
  1392. _terminateExecution(event){const debuggerModel=this._prepareToResume();if(!debuggerModel){return;}
  1393. debuggerModel.runtimeModel().terminateExecution();debuggerModel.resume();}
  1394. _stepOver(){const debuggerModel=this._prepareToResume();if(!debuggerModel){return true;}
  1395. debuggerModel.stepOver();return true;}
  1396. _stepInto(){const debuggerModel=this._prepareToResume();if(!debuggerModel){return true;}
  1397. debuggerModel.stepInto();return true;}
  1398. _stepIntoAsync(){const debuggerModel=this._prepareToResume();if(!debuggerModel){return true;}
  1399. debuggerModel.scheduleStepIntoAsync();return true;}
  1400. _stepOut(){const debuggerModel=this._prepareToResume();if(!debuggerModel){return true;}
  1401. debuggerModel.stepOut();return true;}
  1402. _continueToLocation(uiLocation){const executionContext=UI.context.flavor(SDK.ExecutionContext);if(!executionContext){return;}
  1403. const rawLocations=Bindings.debuggerWorkspaceBinding.uiLocationToRawLocations(uiLocation.uiSourceCode,uiLocation.lineNumber,0);const rawLocation=rawLocations.find(location=>location.debuggerModel===executionContext.debuggerModel);if(!rawLocation){return;}
  1404. if(!this._prepareToResume()){return;}
  1405. rawLocation.continueToLocation();}
  1406. _toggleBreakpointsActive(){Common.moduleSetting('breakpointsActive').set(!Common.moduleSetting('breakpointsActive').get());}
  1407. _breakpointsActiveStateChanged(){const active=Common.moduleSetting('breakpointsActive').get();this._toggleBreakpointsActiveAction.setToggled(!active);this._sourcesView.toggleBreakpointsActiveState(active);}
  1408. _createDebugToolbar(){const debugToolbar=new UI.Toolbar('scripts-debug-toolbar');const longResumeButton=new UI.ToolbarButton(Common.UIString('Resume with all pauses blocked for 500 ms'),'largeicon-play');longResumeButton.addEventListener(UI.ToolbarButton.Events.Click,this._longResume,this);const terminateExecutionButton=new UI.ToolbarButton(ls`Terminate current JavaScript call`,'largeicon-terminate-execution');terminateExecutionButton.addEventListener(UI.ToolbarButton.Events.Click,this._terminateExecution,this);debugToolbar.appendToolbarItem(UI.Toolbar.createLongPressActionButton(this._togglePauseAction,[terminateExecutionButton,longResumeButton],[]));debugToolbar.appendToolbarItem(UI.Toolbar.createActionButton(this._stepOverAction));debugToolbar.appendToolbarItem(UI.Toolbar.createActionButton(this._stepIntoAction));debugToolbar.appendToolbarItem(UI.Toolbar.createActionButton(this._stepOutAction));debugToolbar.appendToolbarItem(UI.Toolbar.createActionButton(this._stepAction));debugToolbar.appendSeparator();debugToolbar.appendToolbarItem(UI.Toolbar.createActionButton(this._toggleBreakpointsActiveAction));this._pauseOnExceptionButton=new UI.ToolbarToggle('','largeicon-pause-on-exceptions');this._pauseOnExceptionButton.addEventListener(UI.ToolbarButton.Events.Click,this._togglePauseOnExceptions,this);debugToolbar.appendToolbarItem(this._pauseOnExceptionButton);return debugToolbar;}
  1409. _createDebugToolbarDrawer(){const debugToolbarDrawer=createElementWithClass('div','scripts-debug-toolbar-drawer');const label=Common.UIString('Pause on caught exceptions');const setting=Common.moduleSetting('pauseOnCaughtException');debugToolbarDrawer.appendChild(UI.SettingsUI.createSettingCheckbox(label,setting,true));return debugToolbarDrawer;}
  1410. appendApplicableItems(event,contextMenu,target){this._appendUISourceCodeItems(event,contextMenu,target);this._appendUISourceCodeFrameItems(event,contextMenu,target);this.appendUILocationItems(contextMenu,target);this._appendRemoteObjectItems(contextMenu,target);this._appendNetworkRequestItems(contextMenu,target);}
  1411. _appendUISourceCodeItems(event,contextMenu,target){if(!(target instanceof Workspace.UISourceCode)){return;}
  1412. const uiSourceCode=(target);if(!uiSourceCode.project().isServiceProject()&&!event.target.isSelfOrDescendant(this._navigatorTabbedLocation.widget().element)){contextMenu.revealSection().appendItem(Common.UIString('Reveal in sidebar'),this._handleContextMenuReveal.bind(this,uiSourceCode));}}
  1413. _appendUISourceCodeFrameItems(event,contextMenu,target){if(!(target instanceof Sources.UISourceCodeFrame)){return;}
  1414. if(target.uiSourceCode().contentType().isFromSourceMap()||target.textEditor.selection().isEmpty()){return;}
  1415. contextMenu.debugSection().appendAction('debugger.evaluate-selection');}
  1416. appendUILocationItems(contextMenu,object){if(!(object instanceof Workspace.UILocation)){return;}
  1417. const uiLocation=(object);const uiSourceCode=uiLocation.uiSourceCode;const contentType=uiSourceCode.contentType();if(contentType.hasScripts()){const target=UI.context.flavor(SDK.Target);const debuggerModel=target?target.model(SDK.DebuggerModel):null;if(debuggerModel&&debuggerModel.isPaused()){contextMenu.debugSection().appendItem(Common.UIString('Continue to here'),this._continueToLocation.bind(this,uiLocation));}
  1418. this._callstackPane.appendBlackboxURLContextMenuItems(contextMenu,uiSourceCode);}}
  1419. _handleContextMenuReveal(uiSourceCode){this.editorView.showBoth();this._revealInNavigator(uiSourceCode);}
  1420. _appendRemoteObjectItems(contextMenu,target){if(!(target instanceof SDK.RemoteObject)){return;}
  1421. const remoteObject=(target);const executionContext=UI.context.flavor(SDK.ExecutionContext);contextMenu.debugSection().appendItem(ls`Store as global variable`,()=>SDK.consoleModel.saveToTempVariable(executionContext,remoteObject));if(remoteObject.type==='function'){contextMenu.debugSection().appendItem(ls`Show function definition`,this._showFunctionDefinition.bind(this,remoteObject));}}
  1422. _appendNetworkRequestItems(contextMenu,target){if(!(target instanceof SDK.NetworkRequest)){return;}
  1423. const request=(target);const uiSourceCode=this._workspace.uiSourceCodeForURL(request.url());if(!uiSourceCode){return;}
  1424. const openText=Common.UIString('Open in Sources panel');contextMenu.revealSection().appendItem(openText,this.showUILocation.bind(this,uiSourceCode.uiLocation(0,0)));}
  1425. _showFunctionDefinition(remoteObject){remoteObject.debuggerModel().functionDetailsPromise(remoteObject).then(this._didGetFunctionDetails.bind(this));}
  1426. _didGetFunctionDetails(response){if(!response||!response.location){return;}
  1427. const location=response.location;if(!location){return;}
  1428. const uiLocation=Bindings.debuggerWorkspaceBinding.rawLocationToUILocation(location);if(uiLocation){this.showUILocation(uiLocation);}}
  1429. _revealNavigatorSidebar(){this._setAsCurrentPanel();this.editorView.showBoth(true);}
  1430. _revealDebuggerSidebar(){this._setAsCurrentPanel();this._splitWidget.showBoth(true);}
  1431. _updateSidebarPosition(){let vertically;const position=Common.moduleSetting('sidebarPosition').get();if(position==='right'){vertically=false;}else if(position==='bottom'){vertically=true;}else{vertically=UI.inspectorView.element.offsetWidth<680;}
  1432. if(this.sidebarPaneView&&vertically===!this._splitWidget.isVertical()){return;}
  1433. if(this.sidebarPaneView&&this.sidebarPaneView.shouldHideOnDetach()){return;}
  1434. if(this.sidebarPaneView){this.sidebarPaneView.detach();}
  1435. this._splitWidget.setVertical(!vertically);this._splitWidget.element.classList.toggle('sources-split-view-vertical',vertically);Sources.SourcesPanel.updateResizerAndSidebarButtons(this);const vbox=new UI.VBox();vbox.element.appendChild(this._debugToolbar.element);vbox.element.appendChild(this._debugToolbarDrawer);vbox.setMinimumAndPreferredSizes(Sources.SourcesPanel.minToolbarWidth,25,Sources.SourcesPanel.minToolbarWidth,100);this._sidebarPaneStack=UI.viewManager.createStackLocation(this._revealDebuggerSidebar.bind(this));this._sidebarPaneStack.widget().element.classList.add('overflow-auto');this._sidebarPaneStack.widget().show(vbox.element);this._sidebarPaneStack.widget().element.appendChild(this._debuggerPausedMessage.element());this._sidebarPaneStack.appendApplicableItems('sources.sidebar-top');if(this._threadsSidebarPane){this._sidebarPaneStack.showView(this._threadsSidebarPane);}
  1436. if(!vertically){this._sidebarPaneStack.appendView(this._watchSidebarPane);}
  1437. this._sidebarPaneStack.showView(this._callstackPane);const jsBreakpoints=(UI.viewManager.view('sources.jsBreakpoints'));const scopeChainView=(UI.viewManager.view('sources.scopeChain'));if(this._tabbedLocationHeader){this._splitWidget.uninstallResizer(this._tabbedLocationHeader);this._tabbedLocationHeader=null;}
  1438. if(!vertically){this._sidebarPaneStack.showView(scopeChainView);this._sidebarPaneStack.showView(jsBreakpoints);this._extensionSidebarPanesContainer=this._sidebarPaneStack;this.sidebarPaneView=vbox;this._splitWidget.uninstallResizer(this._debugToolbar.gripElementForResize());}else{const splitWidget=new UI.SplitWidget(true,true,'sourcesPanelDebuggerSidebarSplitViewState',0.5);splitWidget.setMainWidget(vbox);this._sidebarPaneStack.showView(jsBreakpoints);const tabbedLocation=UI.viewManager.createTabbedLocation(this._revealDebuggerSidebar.bind(this));splitWidget.setSidebarWidget(tabbedLocation.tabbedPane());this._tabbedLocationHeader=tabbedLocation.tabbedPane().headerElement();this._splitWidget.installResizer(this._tabbedLocationHeader);this._splitWidget.installResizer(this._debugToolbar.gripElementForResize());tabbedLocation.appendView(scopeChainView);tabbedLocation.appendView(this._watchSidebarPane);tabbedLocation.appendApplicableItems('sources.sidebar-tabs');this._extensionSidebarPanesContainer=tabbedLocation;this.sidebarPaneView=splitWidget;}
  1439. this._sidebarPaneStack.appendApplicableItems('sources.sidebar-bottom');const extensionSidebarPanes=Extensions.extensionServer.sidebarPanes();for(let i=0;i<extensionSidebarPanes.length;++i){this._addExtensionSidebarPane(extensionSidebarPanes[i]);}
  1440. this._splitWidget.setSidebarWidget(this.sidebarPaneView);}
  1441. _setAsCurrentPanel(){return UI.viewManager.showView('sources');}
  1442. _extensionSidebarPaneAdded(event){const pane=(event.data);this._addExtensionSidebarPane(pane);}
  1443. _addExtensionSidebarPane(pane){if(pane.panelName()===this.name){this._extensionSidebarPanesContainer.appendView(pane);}}
  1444. sourcesView(){return this._sourcesView;}
  1445. _handleDrop(dataTransfer){const items=dataTransfer.items;if(!items.length){return;}
  1446. const entry=items[0].webkitGetAsEntry();if(!entry.isDirectory){return;}
  1447. Host.InspectorFrontendHost.upgradeDraggedFileSystemPermissions(entry.filesystem);}};Sources.SourcesPanel._lastModificationTimeout=200;Sources.SourcesPanel.minToolbarWidth=215;Sources.SourcesPanel.UILocationRevealer=class{reveal(uiLocation,omitFocus){if(!(uiLocation instanceof Workspace.UILocation)){return Promise.reject(new Error('Internal error: not a ui location'));}
  1448. Sources.SourcesPanel.instance().showUILocation(uiLocation,omitFocus);return Promise.resolve();}};Sources.SourcesPanel.DebuggerLocationRevealer=class{reveal(rawLocation,omitFocus){if(!(rawLocation instanceof SDK.DebuggerModel.Location)){return Promise.reject(new Error('Internal error: not a debugger location'));}
  1449. const uiLocation=Bindings.debuggerWorkspaceBinding.rawLocationToUILocation(rawLocation);if(!uiLocation){return Promise.resolve();}
  1450. Sources.SourcesPanel.instance().showUILocation(uiLocation,omitFocus);return Promise.resolve();}};Sources.SourcesPanel.UISourceCodeRevealer=class{reveal(uiSourceCode,omitFocus){if(!(uiSourceCode instanceof Workspace.UISourceCode)){return Promise.reject(new Error('Internal error: not a ui source code'));}
  1451. Sources.SourcesPanel.instance().showUISourceCode(uiSourceCode,undefined,undefined,omitFocus);return Promise.resolve();}};Sources.SourcesPanel.DebuggerPausedDetailsRevealer=class{reveal(object){return Sources.SourcesPanel.instance()._setAsCurrentPanel();}};Sources.SourcesPanel.RevealingActionDelegate=class{handleAction(context,actionId){const panel=Sources.SourcesPanel.instance();if(!panel._ensureSourcesViewVisible()){return false;}
  1452. switch(actionId){case'debugger.toggle-pause':panel._togglePause();return true;}
  1453. return false;}};Sources.SourcesPanel.DebuggingActionDelegate=class{handleAction(context,actionId){const panel=Sources.SourcesPanel.instance();switch(actionId){case'debugger.step-over':panel._stepOver();return true;case'debugger.step-into':panel._stepIntoAsync();return true;case'debugger.step':panel._stepInto();return true;case'debugger.step-out':panel._stepOut();return true;case'debugger.run-snippet':panel._runSnippet();return true;case'debugger.toggle-breakpoints-active':panel._toggleBreakpointsActive();return true;case'debugger.evaluate-selection':const frame=UI.context.flavor(Sources.UISourceCodeFrame);if(frame){let text=frame.textEditor.text(frame.textEditor.selection());const executionContext=UI.context.flavor(SDK.ExecutionContext);if(executionContext){const message=SDK.consoleModel.addCommandMessage(executionContext,text);text=ObjectUI.JavaScriptREPL.wrapObjectLiteral(text);SDK.consoleModel.evaluateCommandInConsole(executionContext,message,text,true,false);}}
  1454. return true;}
  1455. return false;}};Sources.SourcesPanel.WrapperView=class extends UI.VBox{constructor(){super();this.element.classList.add('sources-view-wrapper');Sources.SourcesPanel.WrapperView._instance=this;this._view=Sources.SourcesPanel.instance()._sourcesView;}
  1456. static isShowing(){return!!Sources.SourcesPanel.WrapperView._instance&&Sources.SourcesPanel.WrapperView._instance.isShowing();}
  1457. wasShown(){if(!Sources.SourcesPanel.instance().isShowing()){this._showViewInWrapper();}else{UI.inspectorView.setDrawerMinimized(true);}
  1458. Sources.SourcesPanel.updateResizerAndSidebarButtons(Sources.SourcesPanel.instance());}
  1459. willHide(){UI.inspectorView.setDrawerMinimized(false);setImmediate(()=>Sources.SourcesPanel.updateResizerAndSidebarButtons(Sources.SourcesPanel.instance()));}
  1460. _showViewInWrapper(){this._view.show(this.element);}};;Sources.JavaScriptCompilerPlugin=class extends Sources.UISourceCodeFrame.Plugin{constructor(textEditor,uiSourceCode){super();this._textEditor=textEditor;this._uiSourceCode=uiSourceCode;this._compiling=false;this._recompileScheduled=false;this._timeout=null;this._message=null;this._disposed=false;this._textEditor.addEventListener(UI.TextEditor.Events.TextChanged,this._scheduleCompile,this);if(this._uiSourceCode.hasCommits()||this._uiSourceCode.isDirty()){this._scheduleCompile();}}
  1461. static accepts(uiSourceCode){if(uiSourceCode.extension()==='js'){return true;}
  1462. if(Snippets.isSnippetsUISourceCode(uiSourceCode)){return true;}
  1463. for(const debuggerModel of SDK.targetManager.models(SDK.DebuggerModel)){if(Bindings.debuggerWorkspaceBinding.scriptFile(uiSourceCode,debuggerModel)){return true;}}
  1464. return false;}
  1465. _scheduleCompile(){if(this._compiling){this._recompileScheduled=true;return;}
  1466. if(this._timeout){clearTimeout(this._timeout);}
  1467. this._timeout=setTimeout(this._compile.bind(this),Sources.JavaScriptCompilerPlugin.CompileDelay);}
  1468. _findRuntimeModel(){const debuggerModels=SDK.targetManager.models(SDK.DebuggerModel);for(let i=0;i<debuggerModels.length;++i){const scriptFile=Bindings.debuggerWorkspaceBinding.scriptFile(this._uiSourceCode,debuggerModels[i]);if(scriptFile){return debuggerModels[i].runtimeModel();}}
  1469. return SDK.targetManager.mainTarget()?SDK.targetManager.mainTarget().model(SDK.RuntimeModel):null;}
  1470. async _compile(){const runtimeModel=this._findRuntimeModel();if(!runtimeModel){return;}
  1471. const currentExecutionContext=UI.context.flavor(SDK.ExecutionContext);if(!currentExecutionContext){return;}
  1472. const code=this._textEditor.text();if(code.length>1024*100){return;}
  1473. this._compiling=true;const result=await runtimeModel.compileScript(code,'',false,currentExecutionContext.id);this._compiling=false;if(this._recompileScheduled){this._recompileScheduled=false;this._scheduleCompile();return;}
  1474. if(this._message){this._uiSourceCode.removeMessage(this._message);}
  1475. if(this._disposed||!result||!result.exceptionDetails){return;}
  1476. const exceptionDetails=result.exceptionDetails;const text=SDK.RuntimeModel.simpleTextFromException(exceptionDetails);this._message=this._uiSourceCode.addLineMessage(Workspace.UISourceCode.Message.Level.Error,text,exceptionDetails.lineNumber,exceptionDetails.columnNumber);this._compilationFinishedForTest();}
  1477. _compilationFinishedForTest(){}
  1478. dispose(){this._textEditor.removeEventListener(UI.TextEditor.Events.TextChanged,this._scheduleCompile,this);if(this._message){this._uiSourceCode.removeMessage(this._message);}
  1479. this._disposed=true;if(this._timeout){clearTimeout(this._timeout);}}};Sources.JavaScriptCompilerPlugin.CompileDelay=1000;;Sources.SnippetsPlugin=class extends Sources.UISourceCodeFrame.Plugin{constructor(textEditor,uiSourceCode){super();this._textEditor=textEditor;this._uiSourceCode=uiSourceCode;}
  1480. static accepts(uiSourceCode){return Snippets.isSnippetsUISourceCode(uiSourceCode);}
  1481. rightToolbarItems(){const runSnippet=UI.Toolbar.createActionButtonForId('debugger.run-snippet');runSnippet.setText(Host.isMac()?Common.UIString('\u2318+Enter'):Common.UIString('Ctrl+Enter'));return[runSnippet];}};;Sources.ScriptOriginPlugin=class extends Sources.UISourceCodeFrame.Plugin{constructor(textEditor,uiSourceCode){super();this._textEditor=textEditor;this._uiSourceCode=uiSourceCode;}
  1482. static accepts(uiSourceCode){return uiSourceCode.contentType().hasScripts()||!!Sources.ScriptOriginPlugin._script(uiSourceCode);}
  1483. rightToolbarItems(){const originURL=Bindings.CompilerScriptMapping.uiSourceCodeOrigin(this._uiSourceCode);if(originURL){const item=UI.formatLocalized('(source mapped from %s)',[Components.Linkifier.linkifyURL(originURL)]);return[new UI.ToolbarItem(item)];}
  1484. const script=Sources.ScriptOriginPlugin._script(this._uiSourceCode);if(!script||!script.originStackTrace){return[];}
  1485. const link=Sources.ScriptOriginPlugin._linkifier.linkifyStackTraceTopFrame(script.debuggerModel.target(),script.originStackTrace);return[new UI.ToolbarItem(link)];}
  1486. static _script(uiSourceCode){const locations=Bindings.debuggerWorkspaceBinding.uiLocationToRawLocations(uiSourceCode,0,0);for(const location of locations){const script=location.script();if(script&&script.originStackTrace){return script;}}
  1487. return null;}};Sources.ScriptOriginPlugin._linkifier=new Components.Linkifier();;Root.Runtime.cachedResources["sources/breakpointEditDialog.css"]="/*\n * Copyright 2018 The Chromium Authors. All rights reserved.\n * Use of this source code is governed by a BSD-style license that can be\n * found in the LICENSE file.\n */\n\n:host {\n z-index: 30;\n padding: 4px;\n background-color: #e6e6e6;\n border-radius: 7px;\n border: 2px solid #bababa;\n width: 90%;\n pointer-events: auto;\n}\n\n:host(.sources-edit-breakpoint-dialog) {\n border: none;\n border-radius: 0;\n z-index: 30;\n background-color: var(--toolbar-bg-color);\n width: 555px;\n pointer-events: auto;\n margin: 2px 0 2px -1px;\n padding: 0 10px 10px 5px;\n border: 1px solid var(--divider-color);\n}\n\n:host-context(.sources-edit-breakpoint-dialog) .condition-editor {\n background-color: #fff;\n margin-left: 3px;\n}\n\n:host-context(.sources-edit-breakpoint-dialog) .source-frame-breakpoint-toolbar {\n font-family: sans-serif;\n font-size: 12px;\n}\n\n/*# sourceURL=sources/breakpointEditDialog.css */";Root.Runtime.cachedResources["sources/callStackSidebarPane.css"]="/*\n * Copyright 2016 The Chromium Authors. All rights reserved.\n * Use of this source code is governed by a BSD-style license that can be\n * found in the LICENSE file.\n */\n\n.blackboxed-message {\n text-align: center;\n font-style: italic;\n padding: 4px;\n color: #888;\n background-color: #FFFFC2;\n}\n\n.blackboxed-message > .link {\n margin-left: 5px;\n}\n\n.show-more-message {\n text-align: center;\n font-style: italic;\n padding: 4px;\n border-top: 1px solid #d8d8d8;\n}\n\n.show-more-message > .link {\n margin-left: 5px;\n}\n\n.call-frame-item {\n padding: 3px 8px 3px 20px;\n position: relative;\n min-height: 18px;\n line-height: 15px;\n display: flex;\n flex-wrap: wrap;\n}\n\n.call-frame-title-text {\n text-overflow: ellipsis;\n overflow: hidden;\n}\n\n.call-frame-item:not(.async-header) {\n border-top: 1px solid #efefef;\n}\n\n.call-frame-item:not(.async-header):hover {\n background-color: #eee;\n}\n\n.async-header + .call-frame-item {\n border-top: 0;\n}\n\n.call-frame-item-title,\n.call-frame-location {\n display: flex;\n white-space: nowrap;\n}\n\n.call-frame-location {\n color: #888;\n margin-left: auto;\n padding: 0 10px 0 10px;\n}\n\n.async-header::before {\n content: \" \";\n width: 100%;\n border-top: 1px solid #d8d8d8;\n margin-top: 8px;\n position: absolute;\n z-index: -1;\n left: 0;\n}\n\n.async-header .call-frame-item-title {\n font-weight: bold;\n color: #999;\n background-color: white;\n margin-left: -5px;\n padding: 0 5px;\n}\n\n.blackboxed-call-frame {\n opacity: 0.6;\n font-style: italic;\n}\n\n.selected-call-frame-icon {\n display: none;\n position: absolute;\n top: 5px;\n left: 4px;\n}\n\n.call-frame-item.selected .selected-call-frame-icon {\n display: block;\n}\n\n:host-context(.-theme-with-dark-background) .blackboxed-message {\n background-color: hsl(46, 98%, 22%);\n color: #aaa;\n}\n\n:host-context(.-theme-with-dark-background) .blackboxed-message > .link {\n color: hsl(0, 0%, 67%);\n}\n\n/*# sourceURL=sources/callStackSidebarPane.css */";Root.Runtime.cachedResources["sources/debuggerPausedMessage.css"]="/*\n * Copyright 2016 The Chromium Authors. All rights reserved.\n * Use of this source code is governed by a BSD-style license that can be\n * found in the LICENSE file.\n */\n\n.paused-status {\n padding: 6px;\n border-bottom: 1px solid transparent;\n border-top: 1px solid rgb(189, 189, 189);\n background-color: hsl(50, 100%, 95%);\n color: rgb(107, 97, 48);\n}\n\n.-theme-with-dark-background .paused-status {\n background-color: hsl(46, 98%, 22%);\n color: #ccc;\n}\n\n.paused-status.error-reason {\n background-color: hsl(0, 100%, 97%);\n color: #6b3b3b;\n}\n\n.status-main {\n font-weight: bold;\n padding-left: 15px;\n position: relative;\n}\n\n.status-sub:not(:empty) {\n padding-left: 15px;\n padding-top: 5px;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.paused-status.error-reason .status-sub {\n color: red;\n line-height: 11px;\n max-height: 27px;\n -webkit-user-select: text;\n}\n\n.status-icon {\n -webkit-filter: hue-rotate(190deg);\n position: absolute;\n left: 0;\n top: calc(50% - 5px);\n}\n\n.paused-status.error-reason .status-icon {\n -webkit-filter: none;\n}\n\n/*# sourceURL=sources/debuggerPausedMessage.css */";Root.Runtime.cachedResources["sources/javaScriptBreakpointsSidebarPane.css"]="/*\n * Copyright 2017 The Chromium Authors. All rights reserved.\n * Use of this source code is governed by a BSD-style license that can be\n * found in the LICENSE file.\n */\n\n.breakpoint-entry {\n padding: 3px 8px 3px 8px;\n min-height: 18px;\n line-height: 15px;\n border-top: 1px solid #efefef;\n}\n\n.breakpoint-entry [is=dt-checkbox] {\n max-width: 100%;\n white-space: nowrap;\n}\n\n:not(.breakpoints-list-deactivated) > .breakpoint-entry:hover {\n background-color: #eee;\n}\n\n.breakpoint-entry > .source-text {\n cursor: pointer;\n text-overflow: ellipsis;\n overflow: hidden;\n white-space: nowrap;\n margin-left: 22px;\n}\n\n.breakpoints-list-deactivated {\n background-color: #eee;\n opacity: 0.3;\n}\n\n.breakpoint-hit {\n background-color: rgb(255, 255, 194);\n border-right: 3px solid rgb(107, 97, 48);\n}\n\n:host-context(.-theme-with-dark-background) .breakpoint-hit {\n background-color: hsl(46, 98%, 22%);\n color: #ccc;\n}\n\n/*# sourceURL=sources/javaScriptBreakpointsSidebarPane.css */";Root.Runtime.cachedResources["sources/navigatorTree.css"]="/*\n * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.\n * Copyright (C) 2009 Anthony Ricaud <rik@webkit.org>\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and/or other materials provided with the distribution.\n * 3. Neither the name of Apple Computer, Inc. (\"Apple\") nor the names of\n * its contributors may be used to endorse or promote products derived\n * from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS \"AS IS\" AND ANY\n * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY\n * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\n * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n.icon, .icon-badge {\n margin: -3px -5px -3px -5px;\n}\n\n.icon-stack {\n position: relative;\n display: inline-flex;\n}\n\n.icon-stack > [is=ui-icon]:not(:first-child) {\n position: absolute;\n left: 0;\n top: 0;\n}\n\n.navigator-file-tree-item .icon {\n background: linear-gradient(45deg, hsl(0, 0%, 50%), hsl(0, 0%, 70%));\n}\n\n.navigator-fs-tree-item:not(.has-mapped-files):not(.selected) > :not(.selection),\n.navigator-fs-folder-tree-item:not(.has-mapped-files):not(.selected) > :not(.selection) {\n filter: grayscale(50%);\n opacity: 0.5;\n}\n\n.tree-outline li {\n min-height: 20px;\n}\n\n.tree-outline li:hover:not(.selected) .selection {\n display: block;\n background-color: var(--item-hover-color);\n}\n\n.navigator-folder-tree-item .icon {\n background-color: #555;\n}\n\n.navigator-sm-folder-tree-item .icon,\n.navigator-fs-tree-item .icon,\n.navigator-fs-folder-tree-item .icon {\n background: linear-gradient(45deg, hsl(28, 75%, 50%), hsl(28, 75%, 70%));\n}\n\n.navigator-nw-folder-tree-item .icon {\n background: linear-gradient(45deg, hsl(210, 82%, 65%), hsl(210, 82%, 80%));\n}\n\n.navigator-sm-script-tree-item .icon,\n.navigator-script-tree-item .icon,\n.navigator-snippet-tree-item .icon {\n background: linear-gradient(45deg, hsl(48, 70%, 50%), hsl(48, 70%, 70%));\n}\n\n.navigator-sm-stylesheet-tree-item .icon,\n.navigator-stylesheet-tree-item .icon {\n background: linear-gradient(45deg, hsl(256, 50%, 50%), hsl(256, 50%, 70%));\n}\n\n.navigator-image-tree-item .icon,\n.navigator-font-tree-item .icon {\n background: linear-gradient(45deg, hsl(109, 33%, 50%), hsl(109, 33%, 70%));\n}\n\n.navigator-sm-folder-tree-item .tree-element-title,\n.navigator-sm-script-tree-item .tree-element-title,\n.navigator-sm-stylesheet-tree-item .tree-element-title {\n font-style: italic;\n}\n\n:host{\n overflow-y: auto;\n}\n\n/*# sourceURL=sources/navigatorTree.css */";Root.Runtime.cachedResources["sources/navigatorView.css"]="/*\n * Copyright 2016 The Chromium Authors. All rights reserved.\n * Use of this source code is governed by a BSD-style license that can be\n * found in the LICENSE file.\n */\n\n.navigator-toolbar {\n border-bottom: 1px solid #ccc;\n padding-left: 8px;\n}\n\n/*# sourceURL=sources/navigatorView.css */";Root.Runtime.cachedResources["sources/scopeChainSidebarPane.css"]="/*\n * Copyright 2017 The Chromium Authors. All rights reserved.\n * Use of this source code is governed by a BSD-style license that can be\n * found in the LICENSE file.\n */\n\n.scope-chain-sidebar-pane-section-header {\n flex: auto;\n}\n\n.scope-chain-sidebar-pane-section-subtitle {\n float: right;\n margin-left: 5px;\n max-width: 55%;\n text-overflow: ellipsis;\n overflow: hidden;\n}\n\n.scope-chain-sidebar-pane-section-title {\n font-weight: normal;\n word-wrap: break-word;\n white-space: normal;\n}\n\n.scope-chain-sidebar-pane-section {\n padding: 2px 4px;\n flex: none;\n}\n\n/*# sourceURL=sources/scopeChainSidebarPane.css */";Root.Runtime.cachedResources["sources/sourcesPanel.css"]="/*\n * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.\n * Copyright (C) 2009 Anthony Ricaud <rik@webkit.org>\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and/or other materials provided with the distribution.\n * 3. Neither the name of Apple Computer, Inc. (\"Apple\") nor the names of\n * its contributors may be used to endorse or promote products derived\n * from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS \"AS IS\" AND ANY\n * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY\n * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\n * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n.scripts-debug-toolbar {\n position: absolute;\n top: 0;\n width: 100%;\n background-color: var(--toolbar-bg-color);\n border-bottom: 1px solid #ccc;\n overflow: hidden;\n}\n\n.scripts-debug-toolbar-drawer {\n flex: 0 0 52px;\n -webkit-transition: margin-top 0.1s ease-in-out;\n margin-top: -26px;\n padding-top: 25px;\n background-color: white;\n overflow: hidden;\n white-space: nowrap;\n}\n\n.scripts-debug-toolbar-drawer.expanded {\n margin-top: 0;\n}\n\n.scripts-debug-toolbar-drawer > [is=dt-checkbox] {\n display: none;\n padding-left: 3px;\n height: 28px;\n}\n\n.scripts-debug-toolbar-drawer.expanded > [is=dt-checkbox] {\n display: flex;\n}\n\n.cursor-auto {\n cursor: auto;\n}\n\n.navigator-tabbed-pane {\n background-color: var(--toolbar-bg-color);\n}\n\n/*# sourceURL=sources/sourcesPanel.css */";Root.Runtime.cachedResources["sources/sourcesView.css"]="/*\n * Copyright (C) 2013 Google Inc. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *\n * * Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * * Redistributions in binary form must reproduce the above\n * copyright notice, this list of conditions and the following disclaimer\n * in the documentation and/or other materials provided with the\n * distribution.\n * * Neither the name of Google Inc. nor the names of its\n * contributors may be used to endorse or promote products derived from\n * this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n * \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#sources-panel-sources-view {\n flex: auto;\n position: relative;\n}\n\n#sources-panel-sources-view .sources-toolbar {\n display: flex;\n flex: 0 0 27px;\n background-color: var(--toolbar-bg-color);\n border-top: var(--divider-border);\n overflow: hidden;\n z-index: 0;\n}\n\n.sources-toolbar .toolbar {\n cursor: default;\n}\n\n.source-frame-debugger-script {\n background-color: rgba(255, 255, 194, 0.5);\n}\n\n.-theme-with-dark-background .source-frame-debugger-script {\n background-color: #444;\n}\n\n@-webkit-keyframes source-frame-value-update-highlight-animation {\n from {\n background-color: inherit;\n color: inherit;\n }\n 10% {\n background-color: rgb(158, 54, 153);\n color: white;\n }\n to {\n background-color: inherit;\n color: inherit;\n }\n}\n\n.source-frame-value-update-highlight {\n -webkit-animation: source-frame-value-update-highlight-animation 0.8s 1 cubic-bezier(0, 0, 0.2, 1);\n border-radius: 2px;\n}\n\n.diff-entry-insert .diff-marker {\n border-left: 4px solid hsla(144, 55%, 37%, 1);\n}\n\n.diff-entry-insert .CodeMirror-gutter-background {\n background-color: hsla(144,55%,49%,.2);\n}\n\n.diff-entry-modify .diff-marker {\n border-left: 4px solid #9C27B0;\n}\n\n.diff-entry-modify .CodeMirror-gutter-background {\n background-color: rgba(186,104,200,0.2);\n}\n\n.diff-entry-delete .diff-marker {\n width: 0;\n height: 0;\n border-top: 6px solid transparent;\n border-bottom: 6px solid transparent;\n border-left: 6px solid #D32F2F;\n position: relative;\n top: 6px;\n cursor: pointer;\n left: 0px;\n}\n\n.diff-entry-delete .CodeMirror-gutter-background {\n border-bottom: 2px solid #D32F2F;\n}\n\n.CodeMirror-gutter-diff {\n width: 4px;\n}\n\n.highlight-line-modification {\n animation: source-line-modification-background-fadeout 0.4s 0s;\n animation-timing-function: cubic-bezier(0, 0, 0.2, 1);\n}\n\n.highlight-line-modification span {\n animation: source-line-modification-foreground-fadeout 0.4s 0s;\n animation-timing-function: cubic-bezier(0, 0, 0.2, 1);\n}\n\n@keyframes source-line-modification-background-fadeout {\n from { background-color: rgba(158, 54, 153, 0.5); }\n 50% { background-color: rgba(158, 54, 153, 0.5); }\n 90% { background-color: rgba(158, 54, 153, 0); }\n to { background-color: transparent; }\n}\n\n@keyframes source-line-modification-foreground-fadeout {\n from { color: white; }\n 50% { color: white; }\n 90% { color: initial; }\n to { color: initial; }\n}\n\n/*# sourceURL=sources/sourcesView.css */";Root.Runtime.cachedResources["sources/threadsSidebarPane.css"]="/*\n * Copyright 2017 The Chromium Authors. All rights reserved.\n * Use of this source code is governed by a BSD-style license that can be\n * found in the LICENSE file.\n */\n\n.thread-item {\n padding: 3px 8px 3px 20px;\n position: relative;\n min-height: 18px;\n line-height: 15px;\n display: flex;\n flex-wrap: wrap;\n}\n\n.thread-item + .thread-item {\n border-top: 1px solid #efefef;\n}\n\n.thread-item:hover {\n background-color: #eee;\n}\n\n.thread-item-title,\n.thread-item-paused-state {\n text-overflow: ellipsis;\n overflow: hidden;\n white-space: nowrap;\n}\n\n.thread-item-paused-state {\n color: #888;\n margin-left: auto;\n padding: 0 10px 0 10px;\n}\n\n.selected-thread-icon {\n display: none;\n position: absolute;\n top: 5px;\n left: 4px;\n}\n\n.thread-item.selected .selected-thread-icon {\n display: block;\n}\n\n\n/*# sourceURL=sources/threadsSidebarPane.css */";Root.Runtime.cachedResources["sources/watchExpressionsSidebarPane.css"]="/*\n * Copyright 2017 The Chromium Authors. All rights reserved.\n * Use of this source code is governed by a BSD-style license that can be\n * found in the LICENSE file.\n */\n\n.watch-expression-delete-button {\n position: absolute;\n top: 5px;\n right: 6px;\n cursor: pointer;\n opacity: 0;\n min-width: 20px;\n}\n\n.watch-expression-header:hover .watch-expression-delete-button {\n opacity: 0.5;\n}\n\n.watch-expression-header:hover .watch-expression-delete-button:hover {\n opacity: 1;\n}\n\n.watch-expressions {\n overflow-x: hidden;\n min-height: 26px;\n}\n\n.watch-expressions .dimmed {\n opacity: 0.6;\n}\n\n.watch-expression-title {\n white-space: nowrap;\n text-overflow: ellipsis;\n overflow: hidden;\n line-height: 20px;\n}\n\n.watch-expression-object-header .watch-expression-title {\n margin-left: 1px;\n}\n\n.watch-expression {\n position: relative;\n flex: auto;\n min-height: 20px;\n}\n\n.watch-expressions .name {\n color: rgb(136, 19, 145);\n flex: none;\n white-space: nowrap;\n text-overflow: ellipsis ;\n overflow: hidden;\n}\n\n.watch-expression-error {\n color: red;\n}\n\n:host-context(.-theme-with-dark-background) .watch-expression-error {\n color: hsl(0, 100%, 65%);\n}\n\n.watch-expressions-separator {\n flex: none;\n}\n\n.watch-expressions .value {\n white-space: nowrap;\n display: inline;\n}\n\n.watch-expression .text-prompt {\n text-overflow: clip;\n overflow: hidden;\n white-space: nowrap;\n padding-left: 4px;\n min-height: 18px;\n line-height: 18px;\n -webkit-user-select: text;\n}\n\n.watch-expression-text-prompt-proxy {\n margin: 2px 12px 2px -4px;\n padding-bottom: 3px;\n}\n\n.watch-expression-header {\n flex: auto;\n margin-left: -16px;\n padding-left: 15px;\n}\n\nli.watch-expression-tree-item:hover {\n background-color: #F0F0F0;\n}\n\nli.watch-expression-tree-item {\n padding-left: 4px;\n}\n\n.watch-expression-header:focus[data-keyboard-focus=\"true\"] {\n background: var(--focus-bg-color);\n}\n\nli.watch-expression-editing::before {\n background-color: transparent;\n}\n\n/*# sourceURL=sources/watchExpressionsSidebarPane.css */";Root.Runtime.cachedResources["sources/dialog.css"]="/*\n * Copyright (c) 2015 The Chromium Authors. All rights reserved.\n * Use of this source code is governed by a BSD-style license that can be\n * found in the LICENSE file.\n */\n\n:host {\n padding: 10px;\n}\n\n.widget {\n align-items: center;\n}\n\nlabel {\n white-space: nowrap;\n}\n\ninput[type=text].add-source-map {\n box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2);\n font-size: inherit;\n margin: 0 8px 0 5px;\n}\n\n/*# sourceURL=sources/dialog.css */";