├── icon.png ├── docs ├── extend.jpg ├── egret-inspector.jpg └── inspector-error.jpg ├── ipt └── panel │ ├── style │ ├── refresh.png │ └── devtool.css │ ├── index.html │ └── scripts │ └── Loader.js ├── devtools.html ├── manifest.json ├── README.md ├── devtoolinit.js ├── backgroudScripts.min.js ├── contentScripts.min.js └── injectScripts.min.js /icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaocore/egret-inspector-install/HEAD/icon.png -------------------------------------------------------------------------------- /docs/extend.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaocore/egret-inspector-install/HEAD/docs/extend.jpg -------------------------------------------------------------------------------- /docs/egret-inspector.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaocore/egret-inspector-install/HEAD/docs/egret-inspector.jpg -------------------------------------------------------------------------------- /docs/inspector-error.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaocore/egret-inspector-install/HEAD/docs/inspector-error.jpg -------------------------------------------------------------------------------- /ipt/panel/style/refresh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaocore/egret-inspector-install/HEAD/ipt/panel/style/refresh.png -------------------------------------------------------------------------------- /devtools.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest_version": 2, 3 | "name": "Egret Inspector", 4 | "description": "Egret Chrome Debug Tool", 5 | "version": "2.5.5", 6 | "devtools_page": "devtools.html", 7 | "key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuBlYFyBNwukEl8rNPtiMmK9Uav+S93hcNSdXDqzBp89yI4LdyK06D5vynZU+hPFVuDIRb2/7omOUkMjyZ5Wu7qAWZisHl57DtPv5jsRxeI0fUPiSem7+ibpwuJCuTJA5r+TYUGLjw8YrhCO39k4VX9GUHygTBh9tlHhtKhSzuKmCYiM5fQBz4tjUIgOCACvSlm6rYmF98sqMlg+8TgBGSh1ifTPV2SL5vaZPry8I9OHVMHoQ0c7sa0owmqtHertHVON7QRoXXkax1KHEPzKix2qv7vVzbeL/DLLEviAeqd6tiwHipyEsgUJnsqVbg4l7kGVZOXYnjmHh7SLVJP323wIDAQAB", 8 | "content_scripts": [ 9 | { 10 | "matches": [ "" ], 11 | "js": [ 12 | "contentScripts.min.js" 13 | ], 14 | "run_at": "document_end" 15 | } 16 | ], 17 | "background": { 18 | "scripts": [ "backgroudScripts.min.js" ] 19 | }, 20 | "permissions": [ 21 | "*://*/*", 22 | "system.cpu", 23 | "tabs", 24 | "storage", 25 | "nativeMessaging" 26 | ], 27 | "web_accessible_resources": [ 28 | "*/*", 29 | "*" 30 | ], 31 | "icons": { 32 | 33 | "48": "icon.png" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Egret 白鹭开发Chrome插件(修复版) 2 | ### 更新:20210113更新 3 | 亲测Chrome 87.0.4280.141(正式版本)有效 4 | 5 | 6 | 控制台偶尔会报错 Uncaught TypeError: this.addChild is not a function 。 7 | 这插件依赖页面中的 Egret 引擎,当它在加载时,游戏页面中的 Egret 引擎可能还未完全加载,所以调用 this.addChild 方法导致报错。 8 | 9 | ![inspector error](https://github.com/jsl6/EgretInspector-install/blob/master/docs/inspector-error.jpg?raw=true) 10 | 11 | ### 解决 this.addChild is not a function 报错 12 | 13 | EgretInspector-install 目录中的 contentScripts.min.js 文件,将压缩后的代码进行格式化还原。再将还原后的 313 - 320 行代码进行替换,原代码: 14 | ```javascript 15 | 16 | if (EGRETRELEASE) { 17 | n = ["injectScripts.min.js"]; 18 | } 19 | e.addScript(n); 20 | window.setTimeout(function() { 21 | t.startInspectIfDevToolOpen(); 22 | }, 200); 23 | ``` 24 | 25 | 修改为: 26 | ```javascript 27 | if (EGRETRELEASE) { 28 | n = ["injectScripts.min.js"]; 29 | } 30 | 31 | window.setTimeout(function() { 32 | e.addScript(n); 33 | t.startInspectIfDevToolOpen(); 34 | }, 200); 35 | ``` 36 | 37 | ### 直接使用 38 | ```shell 39 | git clone https://github.com/jsl6/EgretInspector-install.git 40 | ``` 41 | 42 | 打开chrome 扩展程序,开发模式下,加载已解压的扩展程序 43 | ![extend](https://github.com/jsl6/EgretInspector-install/blob/master/docs/extend.jpg?raw=true) 44 | 45 | 选择前面EgretInspector-install即可。 46 | 这时打开Egret运行页面,插件不会报错。 47 | ![EgretInspector](https://github.com/jsl6/EgretInspector-install/blob/master/docs/egret-inspector.jpg?raw=true) 48 | 49 | 亲测Chrome 87.0.4280.141(正式版本)有效 - 20210113更新。 50 | 修改基于:EgretInspector-v2.5.5。 -------------------------------------------------------------------------------- /devtoolinit.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | // The function below is executed in the context of the inspected page. 5 | var page_getProperties = function () { 6 | var data = egret ? egret.MainContext.instance : {}; 7 | // Make a shallow copy with a null prototype, so that sidebar does not 8 | // expose prototype. 9 | var props = Object.getOwnPropertyNames(data); 10 | var copy = { __proto__: null }; 11 | for (var i = 0; i < props.length; ++i) 12 | copy[props[i]] = data[props[i]]; 13 | return copy; 14 | }; 15 | chrome.devtools.panels.elements.createSidebarPane("Egret Properties", function (sidebar) { 16 | function updateElementProperties() { 17 | sidebar.setExpression("(" + page_getProperties.toString() + ")()"); 18 | } 19 | updateElementProperties(); 20 | chrome.devtools.panels.elements.onSelectionChanged.addListener(updateElementProperties); 21 | }); 22 | //(function () { var t = window.setInterval(function () { var a = egret && (window.clearInterval(t) || egret.devtool.start()); console.log("waiting") }, 100);egret && egret.devtool && (window.clearInterval(t) || egret.devtool.start());})(); 23 | chrome.devtools.panels.create("Egret", "icon.png", "ipt/panel/index.html", function (panel) { 24 | var connected = false; 25 | panel.onShown.addListener(function (w) { 26 | if (!connected) 27 | chrome.devtools.inspectedWindow.eval('(function () { var t = window.setInterval(function () { var a = egret && egret.devtool && egret.devtool.start&& (window.clearInterval(t) || egret.devtool.start()); console.log("waiting") }, 100);egret && egret.devtool && egret.devtool.start&&(window.clearInterval(t) || egret.devtool.start());})();'); 28 | backgroundPageConnection.postMessage({ 29 | toDevTool: true, 30 | toggleMask: true, 31 | devToolHidden: false 32 | }); 33 | connected = true; 34 | }); 35 | panel.onHidden.addListener(function (w) { 36 | backgroundPageConnection.postMessage({ 37 | toDevTool: true, 38 | toggleMask: true, 39 | devToolHidden: true 40 | }); 41 | }); 42 | var backgroundPageConnection = chrome.runtime.connect({ 43 | name: btoa("for" + String(chrome.devtools.inspectedWindow.tabId)) 44 | }); 45 | backgroundPageConnection.onMessage.addListener(function (message) { 46 | // Handle responses from the background page, if any 47 | }); 48 | backgroundPageConnection.postMessage({ 49 | tabId: chrome.devtools.inspectedWindow.tabId 50 | }); 51 | panel.onSearch.addListener(function (action, query) { 52 | return false; 53 | }); 54 | }); 55 | -------------------------------------------------------------------------------- /backgroudScripts.min.js: -------------------------------------------------------------------------------- 1 | var __extends=this&&this.__extends||function(e,t){for(var n in t)if(t.hasOwnProperty(n))e[n]=t[n];function o(){this.constructor=e}e.prototype=t===null?Object.create(t):(o.prototype=t.prototype,new o)};var devToolPort=null;var contentPort=null;var inspTabId=0;chrome.runtime.onMessage.addListener(function(e,t,n){if(e.from=="devtools-page"&&e.tabId){inspTabId=e.tabId}if(devToolPort&&e.toDevTool){devToolPort.postMessage(e)}if(e=="getTab"){n(t)}});var PortHandler=function(){function e(e){this.port=e;e.onMessage.addListener(this.messageReceived);e.onDisconnect.addListener(this.disconnect)}e.prototype.messageReceived=function(e){if(e.toContent){if(contentPort)contentPort.postMessage(e)}if(e.toDevTool){if(devToolPort)devToolPort.postMessage(e)}};e.prototype.postMessage=function(e){this.port.postMessage(e)};e.prototype.disconnect=function(e){};return e}();var ContentPortHandler=function(e){__extends(t,e);function t(){e.apply(this,arguments)}t.prototype.messageReceived=function(t){e.prototype.messageReceived.call(this,t)};t.prototype.disconnect=function(e){contentPort=null};return t}(PortHandler);var ToolPortHandler=function(e){__extends(t,e);function t(){e.apply(this,arguments)}t.prototype.messageReceived=function(t){e.prototype.messageReceived.call(this,t);if(t.open){chrome.tabs.executeScript(inspTabId,{code:"startListen()"})}};t.prototype.disconnect=function(e){contentPort=null};return t}(PortHandler);var PortServer=function(){function e(){this.conns={stage:{},view:{},indexConnection:null};this.stageViewMapping={};this.inspecters={};this.views={};this.viewOpened=false;this.indexConnection=null}e.prototype.saveConnection=function(e,t){var n=e.data.from;var o=e.key;var i=e.data.targetKey;if(i)i=decodeURIComponent(i);this.conns[o]=t;t["key"]=o;this.conns[n][o]=e.data.href;if(i){this.stageViewMapping[i]=o;this.stageViewMapping[o]=i}this.updateStageList()};e.prototype.updateStageList=function(){var e=this.conns.indexConnection;if(e&&e["disconnected"]){e=null;this.conns.indexConnection=null}if(!e)return;e.postMessage({data:{name:"stageListUpdated",stages:this.conns.stage}})};e.prototype.createServer=function(e){var t=this;if(e===void 0){e=3001}chrome.runtime.onConnect.addListener(function(e){e.onMessage.addListener(function(n){n.key=decodeURIComponent(n.key);var o=n.key;if(n.data&&n.data.name=="init"){t.saveConnection(n,e)}if(n.data&&n.data.type=="index"){t.conns.indexConnection=e;e.onDisconnect.addListener(function(){return t.conns.indexConnection=null});t.updateStageList()}if(n.data&&n.data.name=="isDevToolOpen"){var i=t.stageViewMapping[o];var s=i&&t.conns[i];s=!!s;e.postMessage({id:n.id,toContent:true,data:s})}if(o in t.stageViewMapping){var a=t.stageViewMapping[o];var r=t.conns[a];r&&r.postMessage(n)}});e.onDisconnect.addListener(function(n,o){var i=e["key"]||e.name;e["disconnected"]=true;var s=t.stageViewMapping[i];if(s){var a=t.conns[s];a.postMessage({data:{name:"initOptions",highlightClick:false,highlightHover:false,preventTouch:false,showMethods:false,showPrivate:true},key:i})}delete t.conns[i];delete t.conns.stage[i];delete t.conns.view[i];t.updateStageList()})})};return e}();(new PortServer).createServer(); -------------------------------------------------------------------------------- /ipt/panel/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Egret Inspector 5 | 6 | 7 | 8 | 9 | 10 |
11 |
12 |
13 | 14 | 60fps 15 |
16 |
17 | 18 | 19 | 20 | 21 |
22 |
23 |
24 |
25 | {icon} 26 | {memberName} {name} 27 | 28 |
29 |
30 |
31 |
32 |
33 | 38 |
39 |
40 |
41 |
42 |
43 |
44 | 47 | 50 | 51 |
52 |
53 |
54 |
    55 |
  1. 56 | {icon} 57 | 58 | {name} 59 | : 60 | {value} 61 |
  2. 62 |
63 |
64 |
65 | 66 |
67 |
68 |
69 | 70 | 71 |
72 |

Egret Inspector 2.5.5

73 |

https://github.com/jsl6/egret-inspector-install 20210113更新,欢迎Start一波

74 |

最新支持Chrome 87.0.4280.141

75 |

支持 Egret 5.0 版本

76 |

更改了插件的安装方式,chrome 63版本以后要使用扩展中的开发者模式安装,修复了63版本以上插件损坏问题

77 |

修复了chrome 62版本一下断开后无法重现连接问题

78 |

修复了树结构面板中有时切换后台重新回到操作无法同步属性面板

79 |

修复了this.addChild is not a function 报错

80 | 81 |
82 | 83 | 84 | -------------------------------------------------------------------------------- /ipt/panel/style/devtool.css: -------------------------------------------------------------------------------- 1 | ::-webkit-scrollbar { 2 | -webkit-appearance: none; 3 | width: 7px; 4 | height:7px; 5 | } 6 | ::-webkit-scrollbar-corner { 7 | -webkit-appearance: none; 8 | } 9 | ::-webkit-scrollbar-thumb { 10 | border-radius: 4px; 11 | background-color: rgba(120,120,120,.5); 12 | -webkit-box-shadow: 0 0 2px rgba(255,255,255,.5); 13 | } 14 | 15 | 16 | html,body{ 17 | height:100%; 18 | margin:0; 19 | padding:0; 20 | background-color:#000; 21 | } 22 | iframe{ 23 | border:none; 24 | position:fixed; 25 | height:100%; 26 | width:100% 27 | } 28 | 29 | #gameDiv { 30 | margin:0; 31 | } 32 | .egret-dev-panel { 33 | color:#DDD; 34 | position:fixed; 35 | top:0; 36 | right:0; 37 | bottom:0; 38 | display:block; 39 | width:300px; 40 | text-align:left; 41 | font-family:Consolas,Courier New, Courier, monospace; 42 | font-size:12px; 43 | background-color:#091528 44 | } 45 | .handle-v{ 46 | cursor:move; 47 | width:10px; 48 | height:100%; 49 | float:left; 50 | background-color:#666; 51 | } 52 | .handle{ 53 | cursor:move; 54 | } 55 | .left { 56 | 57 | float:left; 58 | } 59 | #profile { 60 | height: 60px; 61 | width: 400px; 62 | text-align: right; 63 | white-space: nowrap; 64 | overflow: hidden; 65 | float:right; 66 | } 67 | #fps { 68 | font-size:50px; 69 | color:green; 70 | } 71 | #fpsChart { 72 | margin-left:5px; 73 | } 74 | #control { 75 | position:static; 76 | display:block; 77 | clear:both; 78 | border-top: solid 5px #666666; 79 | line-height:18px; 80 | } 81 | .refresh { 82 | border-radius: 10px; 83 | outline: none; 84 | height: 18px; 85 | width: 18px; 86 | vertical-align: middle; 87 | background-color:white; 88 | cursor:pointer; 89 | } 90 | .nodes { 91 | height:100%; 92 | overflow-y:auto; 93 | width:100%; 94 | clear:both; 95 | padding:0; 96 | position:relative; 97 | } 98 | #layout { 99 | text-align:center; 100 | } 101 | #layout div{ 102 | display:inline-block; 103 | } 104 | #layout .content{ 105 | padding:10px; 106 | border:1px solid #AAA; 107 | } 108 | .display-object{ 109 | color: yellowgreen; 110 | cursor:default; 111 | line-height:16px; 112 | white-space:nowrap; 113 | clear: both; 114 | } 115 | .display-object .icon{ 116 | cursor:pointer; 117 | } 118 | .display-object .icon::after{ 119 | content:" " 120 | } 121 | .display-object .icon::before{ 122 | content:" " 123 | } 124 | .display-object.invisible { 125 | opacity:0.5; 126 | } 127 | .children { 128 | display:none; 129 | } 130 | .memberName { 131 | color: #FF9DC3; 132 | } 133 | .memberName:after { 134 | content:' :' 135 | } 136 | .display-object.hidden,.display-object.hidden .display-object{ 137 | color: #B6B6B6; 138 | } 139 | #searchBar { 140 | background-color:#666; 141 | padding:5px; 142 | } 143 | #txtSearchName{ 144 | width:240px; 145 | border-radius: 2px; 146 | border: none; 147 | height: 16px; 148 | padding-left: 5px; 149 | outline: none; 150 | } 151 | #searchProp { 152 | background-color: #666; 153 | padding: 5px; 154 | } 155 | #txtSearchProp{ 156 | width:240px; 157 | border-radius: 2px; 158 | border: none; 159 | height: 16px; 160 | padding-left: 5px; 161 | outline: none; 162 | } 163 | .right { 164 | height:100%; 165 | width:300px; 166 | position: absolute; 167 | right: 0; 168 | } 169 | .props { 170 | overflow-y:auto; 171 | height:100%; 172 | width:100%; 173 | } 174 | .header{ 175 | padding: 4px; 176 | -webkit-user-select: none; 177 | -moz-user-select: -moz-none; 178 | -ms-user-select: none; 179 | user-select: none; 180 | } 181 | .controls { 182 | clear:both; 183 | } 184 | .controls input{ 185 | vertical-align:sub; 186 | } 187 | .props .title{ 188 | float:left; 189 | } 190 | .property { 191 | text-indent:5px; 192 | margin:1px; 193 | } 194 | .property.function .name:after { 195 | content:'()'; 196 | } 197 | .property.searchResult { 198 | border-radius: 3px; 199 | background-color: rgba(82, 82, 82, 0.72); 200 | } 201 | .property.searchResult.searchCurrent { 202 | color:black; 203 | background-color: yellow; 204 | } 205 | li.expandable{ 206 | cursor:pointer; 207 | } 208 | li.expandable ul{ 209 | cursor:default; 210 | padding-left:2em; 211 | } 212 | span.value { 213 | color: yellowgreen; 214 | } 215 | span.getter { 216 | display:none; 217 | } 218 | span.getter:after{ 219 | content:'get ' 220 | } 221 | li.noSetter > span.getter{ 222 | display:inline; 223 | opacity:0.5; 224 | } 225 | span.value input{height: 12px; 226 | padding: 0; 227 | border: 0; 228 | box-shadow: #FFF 0px 0px; 229 | width: 100px; 230 | background-color: #091528; 231 | color: yellowgreen; 232 | font-family: Consolas,Courier New, Courier, monospace; 233 | vertical-align: text-top; 234 | border-bottom: #EEE 1px solid; 235 | font-size: 12px; 236 | } 237 | span.name { 238 | color: #FF9DC3; 239 | } 240 | .searchCurrent span.name { 241 | color:rgb(202, 0, 0); 242 | } 243 | .searchCurrent span.value { 244 | color:rgb(3, 94, 76); 245 | } 246 | .props .properties { 247 | padding-left: 1em; 248 | } 249 | 250 | .properties li{ 251 | 252 | white-space: nowrap; 253 | } 254 | span.expand { 255 | cursor:pointer; 256 | } 257 | 258 | input.toggle { 259 | margin: 0; 260 | height: 14px; 261 | float: right; 262 | } 263 | 264 | .parent:hover{ 265 | background-color:#000; 266 | } 267 | .parent.selected{ 268 | background-color:#16376B; 269 | } 270 | 271 | ol{ 272 | outline-style:none; 273 | padding-left:2em; 274 | margin: 0; 275 | } 276 | ol li{ 277 | list-style:none; 278 | } 279 | 280 | 281 | 282 | .context-menu-list { 283 | margin:0; 284 | padding:0; 285 | 286 | min-width: 120px; 287 | max-width: 250px; 288 | display: inline-block; 289 | position: absolute; 290 | list-style-type: none; 291 | 292 | border: 1px solid #DDD; 293 | background: #EEE; 294 | 295 | -webkit-box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5); 296 | -moz-box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5); 297 | -ms-box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5); 298 | -o-box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5); 299 | box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5); 300 | 301 | font-family: Verdana, Arial, Helvetica, sans-serif; 302 | font-size: 11px; 303 | } 304 | 305 | .context-menu-item { 306 | padding: 2px 2px 2px 24px; 307 | background-color: #EEE; 308 | position: relative; 309 | -webkit-user-select: none; 310 | -moz-user-select: -moz-none; 311 | -ms-user-select: none; 312 | user-select: none; 313 | } 314 | 315 | .context-menu-separator { 316 | padding-bottom:0; 317 | border-bottom: 1px solid #DDD; 318 | } 319 | 320 | .context-menu-item > label > input, 321 | .context-menu-item > label > textarea { 322 | -webkit-user-select: text; 323 | -moz-user-select: text; 324 | -ms-user-select: text; 325 | user-select: text; 326 | } 327 | 328 | .context-menu-item.hover { 329 | cursor: pointer; 330 | background-color: #39F; 331 | } 332 | 333 | .context-menu-item.disabled { 334 | color: #666; 335 | } 336 | 337 | .context-menu-input.hover, 338 | .context-menu-item.disabled.hover { 339 | cursor: default; 340 | background-color: #EEE; 341 | } 342 | 343 | .context-menu-submenu:after { 344 | content: ">"; 345 | color: #666; 346 | position: absolute; 347 | top: 0; 348 | right: 3px; 349 | z-index: 1; 350 | } 351 | 352 | /* icons 353 | #protip: 354 | In case you want to use sprites for icons (which I would suggest you do) have a look at 355 | http://css-tricks.com/13224-pseudo-spriting/ to get an idea of how to implement 356 | .context-menu-item.icon:before {} 357 | */ 358 | .context-menu-item.icon { min-height: 18px; background-repeat: no-repeat; background-position: 4px 2px; } 359 | .context-menu-item.icon-edit { background-image: url(images/page_white_edit.png); } 360 | .context-menu-item.icon-cut { background-image: url(images/cut.png); } 361 | .context-menu-item.icon-copy { background-image: url(images/page_white_copy.png); } 362 | .context-menu-item.icon-paste { background-image: url(images/page_white_paste.png); } 363 | .context-menu-item.icon-delete { background-image: url(images/page_white_delete.png); } 364 | .context-menu-item.icon-add { background-image: url(images/page_white_add.png); } 365 | .context-menu-item.icon-quit { background-image: url(images/door.png); } 366 | 367 | /* vertically align inside labels */ 368 | .context-menu-input > label > * { vertical-align: top; } 369 | 370 | /* position checkboxes and radios as icons */ 371 | .context-menu-input > label > input[type="checkbox"], 372 | .context-menu-input > label > input[type="radio"] { 373 | margin-left: -17px; 374 | } 375 | .context-menu-input > label > span { 376 | margin-left: 5px; 377 | } 378 | 379 | .context-menu-input > label, 380 | .context-menu-input > label > input[type="text"], 381 | .context-menu-input > label > textarea, 382 | .context-menu-input > label > select { 383 | display: block; 384 | width: 100%; 385 | 386 | -webkit-box-sizing: border-box; 387 | -moz-box-sizing: border-box; 388 | -ms-box-sizing: border-box; 389 | -o-box-sizing: border-box; 390 | box-sizing: border-box; 391 | } 392 | 393 | .context-menu-input > label > textarea { 394 | height: 100px; 395 | } 396 | .context-menu-item > .context-menu-list { 397 | display: none; 398 | /* re-positioned by js */ 399 | right: -5px; 400 | top: 5px; 401 | } 402 | 403 | .context-menu-item.hover > .context-menu-list { 404 | display: block; 405 | } 406 | 407 | .context-menu-accesskey { 408 | text-decoration: underline; 409 | } 410 | 411 | 412 | #changes { 413 | position: absolute; 414 | margin: 50px 0; 415 | background-color: #28354f; 416 | color: #DDD; 417 | right: 50px; 418 | padding: 10px 30px; 419 | left: 50px; 420 | display:none; 421 | } 422 | 423 | #changes .close { 424 | position: absolute; 425 | right: 10px; 426 | bottom: 10px; 427 | } -------------------------------------------------------------------------------- /contentScripts.min.js: -------------------------------------------------------------------------------- 1 | var egret; 2 | (function (t) { 3 | var e; 4 | (function (t) { 5 | var e = (function () { 6 | function t() { 7 | var t = this; 8 | this.events = {}; 9 | this.on = function (e, n) { 10 | if (!(e in t.events)) t.events[e] = []; 11 | t.events[e].push(n); 12 | return t; 13 | }; 14 | this.trigger = function (e, n) { 15 | var o = t.events[e]; 16 | if (!o) return; 17 | for (var r = 0; r < o.length; r++) { 18 | if (typeof o[r] == 'function') { 19 | o[r](n); 20 | } 21 | } 22 | }; 23 | } 24 | t.prototype.removeAllEvents = function () { 25 | this.events = {}; 26 | }; 27 | return t; 28 | })(); 29 | t.EventBase = e; 30 | })((e = t.devtool || (t.devtool = {}))); 31 | })(egret || (egret = {})); 32 | var EGRETRELEASE = true; 33 | var egret; 34 | (function (t) { 35 | var e; 36 | (function (t) { 37 | var e = (function () { 38 | function t(t, e) { 39 | this.host = t; 40 | this.callbacks = {}; 41 | this.namedCallbacks = {}; 42 | this.key = null; 43 | this.getKey(); 44 | this._connect(e); 45 | } 46 | t.prototype._connect = function (t) {}; 47 | t.prototype.post = function (t, e, n) { 48 | if (e === void 0) { 49 | e = null; 50 | } 51 | var o = e; 52 | if (n) { 53 | o = (performance.now() + Math.random() * 100).toString(); 54 | this.callbacks[o] = n; 55 | } 56 | var r = { id: o, data: t, key: this.key }; 57 | this._doPost(r); 58 | return this; 59 | }; 60 | t.prototype._doPost = function (t) { 61 | this.port.postMessage(t); 62 | }; 63 | t.prototype.on = function (t, e) { 64 | if (!this.namedCallbacks[t]) this.namedCallbacks[t] = []; 65 | this.namedCallbacks[t].push(e); 66 | return this; 67 | }; 68 | t.prototype.remove = function (t, e) { 69 | var n = this.namedCallbacks[t]; 70 | if (n) { 71 | var o = n.indexOf(e); 72 | if (o < 0) return; 73 | n.splice(o, 1); 74 | } 75 | return this; 76 | }; 77 | t.prototype.removeAll = function () { 78 | this.namedCallbacks = {}; 79 | return this; 80 | }; 81 | t.prototype._parseMsgData = function (t) { 82 | return null; 83 | }; 84 | t.prototype._onMessage = function (t) { 85 | var e = this; 86 | var n = this._parseMsgData(t); 87 | var o = n.id; 88 | var r = n.data.name; 89 | var i = this.callbacks[o]; 90 | if (i) { 91 | i(n.data); 92 | delete this.callbacks[o]; 93 | } 94 | var s = this.namedCallbacks[r]; 95 | if (s) { 96 | s.forEach(function (t) { 97 | var r = t(n.data, function (t) { 98 | if (o) { 99 | e.post(t, o); 100 | } 101 | }); 102 | if (o && r) { 103 | e.post(r, o); 104 | } 105 | }); 106 | } 107 | }; 108 | t.prototype.getKey = function () { 109 | if (window.name == '') { 110 | window.name = Date.now().toString(); 111 | } 112 | this.key = window.name; 113 | }; 114 | return t; 115 | })(); 116 | t.PortBase = e; 117 | })((e = t.devtool || (t.devtool = {}))); 118 | })(egret || (egret = {})); 119 | var __extends = 120 | (this && this.__extends) || 121 | function (t, e) { 122 | for (var n in e) if (e.hasOwnProperty(n)) t[n] = e[n]; 123 | function o() { 124 | this.constructor = t; 125 | } 126 | t.prototype = 127 | e === null ? Object.create(e) : ((o.prototype = e.prototype), new o()); 128 | }; 129 | var egret; 130 | (function (t) { 131 | var e; 132 | (function (t) { 133 | var e = (function (t) { 134 | __extends(e, t); 135 | function e() { 136 | t.apply(this, arguments); 137 | } 138 | e.prototype._connect = function (t) { 139 | var e = this; 140 | var n = chrome.runtime.connect(); 141 | n.onMessage.addListener(function (t) { 142 | return e._onMessage(t); 143 | }); 144 | this.port = n; 145 | t && window.setTimeout(t.bind(this), 0); 146 | }; 147 | e.prototype._doPost = function (t) { 148 | this.port.postMessage(t); 149 | }; 150 | e.prototype._parseMsgData = function (t) { 151 | return t; 152 | }; 153 | return e; 154 | })(t.PortBase); 155 | t.ChromePort = e; 156 | var n = (function (t) { 157 | __extends(e, t); 158 | function e() { 159 | t.apply(this, arguments); 160 | } 161 | e.prototype._connect = function (t) { 162 | var e = this; 163 | var n = chrome.runtime.connect(); 164 | n.onMessage.addListener(function (t) { 165 | return e._onMessage(t); 166 | }); 167 | this.port = n; 168 | window.addEventListener('message', function (t) { 169 | return e._onWindowMessage(t.data); 170 | }); 171 | t && window.setTimeout(t.bind(this), 0); 172 | }; 173 | e.prototype._doPost = function (t) { 174 | this.port.postMessage(t); 175 | }; 176 | e.prototype._parseMsgData = function (t) { 177 | return t; 178 | }; 179 | e.prototype._onMessage = function (e) { 180 | if (e.toContent) { 181 | t.prototype._onMessage.call(this, e); 182 | } else { 183 | window.postMessage(e, '*'); 184 | } 185 | }; 186 | e.prototype._onWindowMessage = function (t) { 187 | if (t['from'] == 'stage') { 188 | var e = JSON.parse(t.data); 189 | this.post(e, t.id); 190 | } 191 | }; 192 | return e; 193 | })(t.PortBase); 194 | t.ContentPort = n; 195 | var o = (function (t) { 196 | __extends(e, t); 197 | function e() { 198 | t.apply(this, arguments); 199 | } 200 | e.prototype._connect = function (t) { 201 | var e = this; 202 | window.addEventListener('message', function (t) { 203 | return e._onMessage(t); 204 | }); 205 | t && window.setTimeout(t.bind(this), 0); 206 | }; 207 | e.prototype._doPost = function (t) { 208 | window.postMessage( 209 | { from: 'stage', id: t.id, data: JSON.stringify(t.data) }, 210 | '*' 211 | ); 212 | }; 213 | e.prototype._parseMsgData = function (t) { 214 | return t.data; 215 | }; 216 | e.prototype._onMessage = function (e) { 217 | var n = this._parseMsgData(e); 218 | if (!n.data) return; 219 | if (n['from'] == 'stage') return false; 220 | t.prototype._onMessage.call(this, e); 221 | }; 222 | return e; 223 | })(t.PortBase); 224 | t.StagePort = o; 225 | var r = (function (t) { 226 | __extends(e, t); 227 | function e() { 228 | t.apply(this, arguments); 229 | } 230 | e.prototype._connect = function (t) { 231 | var e = this; 232 | var n = new WebSocket('ws://' + this.host); 233 | this.port = n; 234 | n.addEventListener('message', function (t) { 235 | return e._onMessage(t); 236 | }); 237 | n.addEventListener('open', function (n) { 238 | return t(e); 239 | }); 240 | }; 241 | e.prototype._doPost = function (t) { 242 | var e = this.port; 243 | e.send(JSON.stringify(t)); 244 | }; 245 | e.prototype._parseMsgData = function (t) { 246 | return JSON.parse(t.data); 247 | }; 248 | return e; 249 | })(t.PortBase); 250 | t.WsPort = r; 251 | })((e = t.devtool || (t.devtool = {}))); 252 | })(egret || (egret = {})); 253 | var egret; 254 | (function (t) { 255 | var e; 256 | (function (t) { 257 | t.PortFactory = null; 258 | })((e = t.devtool || (t.devtool = {}))); 259 | })(egret || (egret = {})); 260 | var egret; 261 | (function (t) { 262 | var e; 263 | (function (e) { 264 | var n = (function () { 265 | function e() {} 266 | e.prototype.getStagePortClass = function () { 267 | return t.devtool.StagePort; 268 | }; 269 | e.prototype.getPanelPortClass = function () { 270 | return t.devtool.ChromePort; 271 | }; 272 | e.prototype.getExtContentPortClass = function () { 273 | return t.devtool.ContentPort; 274 | }; 275 | return e; 276 | })(); 277 | e.ChromePortFactory = n; 278 | e.PortFactory = new n(); 279 | })((e = t.devtool || (t.devtool = {}))); 280 | })(egret || (egret = {})); 281 | var egret; 282 | (function (t) { 283 | var e; 284 | (function (t) { 285 | var e = (function () { 286 | function e() {} 287 | e.start = function () { 288 | if (e.instance == null) { 289 | e.instance = new e(); 290 | } 291 | var n = t.PortFactory.getExtContentPortClass(); 292 | var o = new n(location.host, function () { 293 | e.instance.port = o; 294 | e.instance.injectScripts(); 295 | }); 296 | }; 297 | e.prototype.injectScripts = function () { 298 | var t = this; 299 | var n = [ 300 | 'ipt/shared/EventBase.js', 301 | 'ipt/shared/utils.js', 302 | 'ipt/shared/TreeNode.js', 303 | 'ipt/shared/PortBase.js', 304 | 'ipt/shared/Port.js', 305 | 'ipt/shared/IPortFactory.js', 306 | 'ipt/shared/ChromePortFactory.js', 307 | 'ipt/inject/IInspector.js', 308 | 'ipt/inject/Inspector.js', 309 | 'ipt/inject/LarkInspector.js', 310 | 'ipt/inject/Egret2xInspector.js', 311 | 'ipt/inject/Main.js', 312 | ]; 313 | if (EGRETRELEASE) { 314 | n = ['injectScripts.min.js']; 315 | } 316 | window.setTimeout(function () { 317 | e.addScript(n); 318 | t.startInspectIfDevToolOpen(); 319 | }, 200); 320 | }; 321 | e.prototype.injectScript = function (t) { 322 | var e = document.createElement('script'); 323 | e.innerHTML = t; 324 | document.head.appendChild(e); 325 | }; 326 | e.addScript = function (t) { 327 | var e = this; 328 | t.forEach(function (t) { 329 | var n = e.urlFormatFunc(); 330 | var o = document.createElement('script'); 331 | o.src = n(t); 332 | o.async = false; 333 | document.head.appendChild(o); 334 | }); 335 | }; 336 | e.prototype.startInspectIfDevToolOpen = function () { 337 | var t = this; 338 | this.port.post({ name: 'isDevToolOpen' }, null, function (e) { 339 | if (e) { 340 | t.injectScript( 341 | '(function () { var t = window.setInterval(function () { var a = egret && egret.devtool && egret.devtool.start&& (window.clearInterval(t) || egret.devtool.start()); console.log("waiting") }, 100);egret && egret.devtool && egret.devtool.start&&(window.clearInterval(t) || egret.devtool.start());})();' 342 | ); 343 | } 344 | }); 345 | }; 346 | e.urlFormatFunc = function () { 347 | var t = window['chrome'] || null; 348 | if (t && t.extension && t.extension.getURL) return t.extension.getURL; 349 | return function (t) { 350 | return t; 351 | }; 352 | }; 353 | return e; 354 | })(); 355 | t.Loader = e; 356 | })((e = t.devtool || (t.devtool = {}))); 357 | })(egret || (egret = {})); 358 | egret.devtool.Loader.start(); 359 | -------------------------------------------------------------------------------- /ipt/panel/scripts/Loader.js: -------------------------------------------------------------------------------- 1 | var egret;(function(e){var t;(function(e){var t=function(){function e(){var e=this;this.events={};this.on=function(t,n){if(!(t in e.events))e.events[t]=[];e.events[t].push(n);return e};this.trigger=function(t,n){var r=e.events[t];if(!r)return;for(var i=0;i1?n[1]:null});return t}e.parseParam=i})(t=e.devtool||(e.devtool={}))})(egret||(egret={}));Object.defineProperty(Object.prototype,"getDisplayName",{value:function(){if(typeof this=="number")return this;if(egret.getQualifiedClassName)return egret.getQualifiedClassName(this);if(this.constructor&&this.constructor.name)return this.constructor.name;if(lark&&this.__classFlag__){return lark.Types[this.__classFlag__]}}});var __extends=this&&this.__extends||function(e,t){for(var n in t)if(t.hasOwnProperty(n))e[n]=t[n];function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)};var egret;(function(e){var t;(function(e){var t=function(e){__extends(t,e);function t(){e.apply(this,arguments);this._children=[];this._props=[];this.parentHash=-1;this.show=false;this.visible=true;this.type=null;this.memberName=null;this.selected=false;this.expandable=false;this.isGetter=false;this.isSetter=false;this.icon="-";this.dirty=false;this.hasChildren=false}t.prototype.updateIcon=function(){this.icon=this.hasChildren==false?" ":this.show?"-":"+"};t.prototype.recover=function(){if(this.show&&this.hasChildren&&(this.children!=this._children||this.props!=this._props)){this.children=null;this.props=null;this.showChildren()}};t.prototype.showChildren=function(){if(!this.hasChildren)return;this.show=true;if(!this.children){this.children=this._children;this.props=this._props;this.trigger(t.ChildrenChange)}this.updateIcon();this.trigger(t.Show)};t.prototype.toggle=function(){if(!this.children&&!this.show){this.showChildren();return}this.show=!this.show;this.updateIcon();this.trigger(t.Show)};t.prototype.parseChildren=function(){t.parseChildren(this.raw,this)};t.prototype.reset=function(e){if(e===void 0){e=true}this._children.forEach(function(e){return e.reset()});this._props.forEach(function(e){return e.reset()});this._children=[];this._props=[];this.children=null;this.props=null;this.show=false;if(e){t.hash2Node[this.rawHash]=undefined;t.hash2DisplayObject[this.rawHash]=undefined}};Object.defineProperty(t.prototype,"raw",{get:function(){return t.hash2DisplayObject[this.rawHash]},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"parent",{get:function(){if(this.parentHash==-1)return null;return t.hash2Node[this.parentHash]},enumerable:true,configurable:true});t.getValue=function(e,t){if(e==null)return String(e);var n=typeof e;var r=null;t.type=n;switch(n){case"string":r=JSON.stringify(e);break;case"number":if(e==NaN)e="NaN";r=e;return r;case"array":r=String(e);t.expandable=true;break;case"object":r=e.constructor["name"]||e["__class__"]||"object";t.expandable=true;break;case"function":r=String(e);t.name;break;default:r=String(e)}return r};t.prototype.naviToDisplayObject=function(e){if(!t.isLinked(e)){t.linkToIt(e);this.dirty=true}this.naviToNode(e.hashCode)};t.prototype.naviToNode=function(e,n){if(n===void 0){n=false}var r=t.getByHash(e);var i=[];var o=r.parent;while(o!=null){i.push(o);o=o.parent}for(var s=i.length-1;s>=0;s--)i[s].showChildren();r.showUp()};t.prototype.showUp=function(){if(t.selected){t.selected.selected=false;t.selected.trigger(t.UnSelected)}this.selected=true;t.selected=this;this.trigger(t.OnSelected)};t.prototype.find=function(e,t){if(this.rawHash==e){t.push(this);return true}if(!this.hasChildren)return false;t.push(this);var n=this._props.filter(function(n){return n.find(e,t)});var r=n.length>0;if(!r){n=this._children.filter(function(n){return n.find(e,t)});r=n.length>0}if(!r){t.pop();return false}return true};t.prototype.parseRawProps=function(e,n,r){if(n===void 0){n=new t}return t.parseRawProps(this.raw,e,n,r)};t.parseRawProps=function(e,n,r,i){if(r===void 0){r=new t}if(i===void 0){i={showPrivate:true,showMethods:false}}if(n<0)return;if(typeof e!="object")return;var o=[];for(var s in e){if(i.showPrivate===false&&(String(s).indexOf("_")==0||String(s).indexOf("$")==0)){continue}var a=new t;a.name=s;var h=null;var c=null;var l=e;c=Object.getOwnPropertyDescriptor(e,s);while(c==null&&l){l=Object.getPrototypeOf(l);c=Object.getOwnPropertyDescriptor(l,s)}if(c){a.isGetter=c.get!=undefined;a.isSetter=a.isGetter&&c.set!=undefined}try{h=e[s]}catch(u){h="faild to get value"}if(typeof h=="function"&&i.showMethods!=true)continue;t.parseRawProps(h,n-1,a);a.value=t.getValue(h,a);o.push(a)}o.sort(function(e,t){var n=e.name;var r=t.name;return n>r?1:n==r?0:-1});r.name=e.getDisplayName();r._props=o;return r};t.parseRawProp=function(e,n,r,i){if(i===void 0){i=new t}i.name=e;t.parseRawProps(n,r-1,i);i.value=t.getValue(n,i);return i};t.prototype.toString=function(){return this.name};t.linkToIt=function(e,n){if(n===void 0){n=null}var r=t.hash2Node[e.hashCode];var i=r!=undefined;if(i){r.reset(false);t.parseChildren(e,r,0)}else{r=t.parseNode(e)}r.showChildren();if(n){for(var o=0;o0);if(e.parent)n.parentHash=e.parent.hashCode;if(i>0){t.parseChildren(e,n,i-1)}n.updateIcon();return n};t.parseRawObject=function(e,n){if(n===void 0){n=new t}return t.parseRawProps(e,0,n)};t.getByHash=function(e){return t.hash2Node[e]};t.clear=function(){t.hash2Node={};t.hash2DisplayObject={}};t.clone=function(e,n,r){if(n===void 0){n=false}r=r||new t;var i=Object.getOwnPropertyNames(e);i.forEach(function(t){if(t=="events"||t=="_children"||t=="_props")return;r[t]=e[t]});t.hash2Node[r.rawHash]=r;if(e._children.length>0)r._children=e._children.map(function(e){return t.clone(e,false,t.getByHash(e.rawHash))});r.recover();n&&r.trigger(t.Changed);return r};t.Show="show";t.UnSelected="unselected";t.OnSelected="selected";t.ChildrenChange="childrenchange";t.Changed="changed";t.hash2Node={};t.hash2DisplayObject={};t.ignore={_parent:1,parent:1,_stage:1,stage:1,_eventTarget:1,_children:1,_owner:1,_rendererOwner:1};t.selected=null;return t}(e.EventBase);e.TreeNode=t;var n=function(){function e(){this.dirtyCount=[];this.dirtyKey={};this.init=false}e.prototype.push=function(e){while(e!=null){if(e.hashCode in this.dirtyKey){this.dirtyCount[this.dirtyKey[e.hashCode]]+=1;break}else if(this.init==false){var t=0;if(this.dirtyCount.length==0)t=1;this.dirtyCount.push(t);this.dirtyKey[e.hashCode]=this.dirtyCount.length-1}e=e.parent}this.init=true};e.prototype.getRootHash=function(){for(var e=this.dirtyCount.length;e>=0;e--){if(this.dirtyCount[e]>0){break}}for(var t in this.dirtyKey){if(this.dirtyKey[t]==e)return t}};e.prototype.reset=function(){this.dirtyCount=[];this.dirtyKey={};this.init=false};return e}();e.TreeDirtyCache=n})(t=e.devtool||(e.devtool={}))})(egret||(egret={}));var EGRETRELEASE=true;var egret;(function(e){var t;(function(e){var t=function(){function e(e,t){this.host=e;this.callbacks={};this.namedCallbacks={};this.key=null;this.getKey();this._connect(t)}e.prototype._connect=function(e){};e.prototype.post=function(e,t,n){if(t===void 0){t=null}var r=t;if(n){r=(performance.now()+Math.random()*100).toString();this.callbacks[r]=n}var i={id:r,data:e,key:this.key};this._doPost(i);return this};e.prototype._doPost=function(e){this.port.postMessage(e)};e.prototype.on=function(e,t){if(!this.namedCallbacks[e])this.namedCallbacks[e]=[];this.namedCallbacks[e].push(t);return this};e.prototype.remove=function(e,t){var n=this.namedCallbacks[e];if(n){var r=n.indexOf(t);if(r<0)return;n.splice(r,1)}return this};e.prototype.removeAll=function(){this.namedCallbacks={};return this};e.prototype._parseMsgData=function(e){return null};e.prototype._onMessage=function(e){var t=this;var n=this._parseMsgData(e);var r=n.id;var i=n.data.name;var o=this.callbacks[r];if(o){o(n.data);delete this.callbacks[r]}var s=this.namedCallbacks[i];if(s){s.forEach(function(e){var i=e(n.data,function(e){if(r){t.post(e,r)}});if(r&&i){t.post(i,r)}})}};e.prototype.getKey=function(){if(window.name==""){window.name=Date.now().toString()}this.key=window.name};return e}();e.PortBase=t})(t=e.devtool||(e.devtool={}))})(egret||(egret={}));var __extends=this&&this.__extends||function(e,t){for(var n in t)if(t.hasOwnProperty(n))e[n]=t[n];function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)};var egret;(function(e){var t;(function(e){var t=function(e){__extends(t,e);function t(){e.apply(this,arguments)}t.prototype._connect=function(e){var t=this;var n=chrome.runtime.connect();n.onMessage.addListener(function(e){return t._onMessage(e)});this.port=n;e&&window.setTimeout(e.bind(this),0)};t.prototype._doPost=function(e){this.port.postMessage(e)};t.prototype._parseMsgData=function(e){return e};return t}(e.PortBase);e.ChromePort=t;var n=function(e){__extends(t,e);function t(){e.apply(this,arguments)}t.prototype._connect=function(e){var t=this;var n=chrome.runtime.connect();n.onMessage.addListener(function(e){return t._onMessage(e)});this.port=n;window.addEventListener("message",function(e){return t._onWindowMessage(e.data)});e&&window.setTimeout(e.bind(this),0)};t.prototype._doPost=function(e){this.port.postMessage(e)};t.prototype._parseMsgData=function(e){return e};t.prototype._onMessage=function(t){if(t.toContent){e.prototype._onMessage.call(this,t)}else{window.postMessage(t,"*")}};t.prototype._onWindowMessage=function(e){if(e["from"]=="stage"){var t=JSON.parse(e.data);this.post(t,e.id)}};return t}(e.PortBase);e.ContentPort=n;var r=function(e){__extends(t,e);function t(){e.apply(this,arguments)}t.prototype._connect=function(e){var t=this;window.addEventListener("message",function(e){return t._onMessage(e)});e&&window.setTimeout(e.bind(this),0)};t.prototype._doPost=function(e){window.postMessage({from:"stage",id:e.id,data:JSON.stringify(e.data)},"*")};t.prototype._parseMsgData=function(e){return e.data};t.prototype._onMessage=function(t){var n=this._parseMsgData(t);if(!n.data)return;if(n["from"]=="stage")return false;e.prototype._onMessage.call(this,t)};return t}(e.PortBase);e.StagePort=r;var i=function(e){__extends(t,e);function t(){e.apply(this,arguments)}t.prototype._connect=function(e){var t=this;var n=new WebSocket("ws://"+this.host);this.port=n;n.addEventListener("message",function(e){return t._onMessage(e)});n.addEventListener("open",function(n){return e(t)})};t.prototype._doPost=function(e){var t=this.port;t.send(JSON.stringify(e))};t.prototype._parseMsgData=function(e){return JSON.parse(e.data)};return t}(e.PortBase);e.WsPort=i})(t=e.devtool||(e.devtool={}))})(egret||(egret={}));var egret;(function(e){var t;(function(e){e.PortFactory=null})(t=e.devtool||(e.devtool={}))})(egret||(egret={}));var egret;(function(e){var t;(function(t){var n=function(){function t(){}t.prototype.getStagePortClass=function(){return e.devtool.StagePort};t.prototype.getPanelPortClass=function(){return e.devtool.ChromePort};t.prototype.getExtContentPortClass=function(){return e.devtool.ContentPort};return t}();t.ChromePortFactory=n;t.PortFactory=new n})(t=e.devtool||(e.devtool={}))})(egret||(egret={}));var __extends=this&&this.__extends||function(e,t){for(var n in t)if(t.hasOwnProperty(n))e[n]=t[n];function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)};var egret;(function(e){var t;(function(e){var t=function(e){__extends(t,e);function t(){e.apply(this,arguments)}Object.defineProperty(t.prototype,"height",{set:function(e){this.container.height(e)},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"width",{set:function(e){this.container.width(e)},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"data",{get:function(){return this._data},set:function(e){this._data=e;this.trigger("datachange")},enumerable:true,configurable:true});t.prototype.init=function(){};t.prototype.showChildren=function(){};return t}(e.EventBase);e.Panel=t})(t=e.devtool||(e.devtool={}))})(egret||(egret={}));var __extends=this&&this.__extends||function(e,t){for(var n in t)if(t.hasOwnProperty(n))e[n]=t[n];function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)};var egret;(function(e){var t;(function(e){var t=function(e){__extends(t,e);function t(){e.apply(this,arguments);this.maxBarCount=60;this._fpsList=[];this._fps=0}Object.defineProperty(t.prototype,"fps",{get:function(){return this._fps},set:function(e){this._fps=e;this._fpsList.push(e);if(this._fpsList.length>this.maxBarCount){this._fpsList.shift()}this.trigger("fps")},enumerable:true,configurable:true});t.prototype.init=function(){var e=this;this.container=$("#profile");this.fpsTag=$("#fps");this.chartCtx=document.getElementById("fpsChart").getContext("2d");this.on("fps",function(){e.fpsTag.text(e._fps);e.drawChart()})};t.prototype.drawChart=function(){var e=this._fpsList.length;var t=this.chartCtx.canvas.width;var n=this.chartCtx.canvas.height;var r=Math.round(t/this.maxBarCount);var i=Math.min.apply(Math,this._fpsList);i=0;this.chartCtx.clearRect(0,0,t,n);for(var o=0;ot||i<0){var o=r.container.scrollTop()+i;r.container.scrollTop(o)}}).on(e.TreeNode.UnSelected,function(e){p.removeClass("selected")});p.click(function(){return i.showItInGame(t)});p.mouseenter(function(){return i.showItInGame(t,true)});l.click(function(){t.toggle();return false});p.dblclick(function(){t.toggle();return false});n.append(s)};n.prototype.showGameSelection=function(t,n){if(n){var r=e.TreeNode.getByHash(n.rawHash);e.TreeNode.clone(n,true,r)}this._data.naviToNode(t)};n.prototype.showItInGame=function(e,t){if(t===void 0){t=false}if(!t){this.mainPanel.propsPanel.selectedHash=e.rawHash;e.showUp()}if(!t||t&&this._highlightHover)this.transTreeSelection(e.rawHash,t)};n.prototype.transTreeSelection=function(e,t){if(t===void 0){t=false}this.mainPanel.port.post({name:"showTreeSelection",data:e,isHover:t})};n.prototype.refresh=function(){var t=this;this.port.post({name:"refresh"},null,function(n){e.TreeNode.clear();var r=e.TreeNode.clone(n.tree,false);t.data=r;t.data.naviToNode(n.hash)})};n.prototype.search=function(){var e=this;var t=$("#txtSearchName").val();if(!t)return false;var n={name:"search",option:{current:this.searchForm.data("current"),name:t}};this.port.post(n,null,function(t){console.log(t.results);e.searchForm.data("current",t.current)});return false};n.prototype._onChkPreventTouchChange=function(){this.preventTouch=this.chkPreventTouch.is(":checked")};n.prototype._onChkHighlightClickChange=function(){this.highlightClick=this.chkHighlightClick.is(":checked")};n.prototype._onChkHighlightHoverChange=function(){this.highlightHover=this.chkHighlightHover.is(":checked")};return n}(e.Panel);e.TreePanel=t})(t=e.devtool||(e.devtool={}))})(egret||(egret={}));var __extends=this&&this.__extends||function(e,t){for(var n in t)if(t.hasOwnProperty(n))e[n]=t[n];function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)};var egret;(function(e){var t;(function(e){var t=["x","y","width","height","measuredWidth","measuredHeight","layoutBoundsWidth","layoutBoundsHeight","preferredWidth","preferredHeight","left","right","top","bottom","percentWidth","percentHeight","verticalCenter","horizontalCenter","explicitWidth","explicitHeight","includeInLayout","preferredX","preferredY","layoutBoundsX","layoutBoundsY","maxWidth","minWidth","skin","skinName","source","content","maxHeight","minHeight","visible","alpha","parent"];var n=function(e){__extends(n,e);function n(){var t=this;e.apply(this,arguments);this._showMethods=false;this._showPrivate=true;this.onShowPrivateChanged=function(){t.showPrivate=t.chkShowPrivate.is(":checked")};this.onShowMethodsChanged=function(){t.showMethods=t.chkShowMethods.is(":checked")};this.refresh=function(){t.port.post({name:"refreshProp",hash:t.selectedHash})};this.lastQuery="";this.filterProps=function(){var e=t.txtSearchProp.val();if(!e){t.container.find(".property.searchResult").removeClass("searchResult searchCurrent");t.lastQuery=e;return}var n=null;if(t.lastQuery!=e){t.container.find(".property.searchResult").removeClass("searchResult searchCurrent");var r=t.container.find(".property:Contains("+e+")");r.addClass("searchResult");$(r[0]).addClass("searchCurrent");t.lastQuery=e;n=$(r[0])}else{var r=t.container.find(".property.searchResult");if(r.length==1){n=r;return}for(var i=0;ih||l<0){var u=t.container.scrollTop()+l;t.container.animate({scrollTop:u},200)}}}Object.defineProperty(n.prototype,"showMethods",{set:function(e){this._showMethods=e;if(e!=this.chkShowMethods.is(":checked"))this.chkShowMethods.attr("checked",e);window.localStorage.setItem("showMethods",String(e));this.port.post({name:"showMethodsChanged",showMethods:this._showMethods,hash:this.selectedHash})},enumerable:true,configurable:true});Object.defineProperty(n.prototype,"showPrivate",{set:function(e){this._showPrivate=e;if(e!=this.chkShowPrivate.is(":checked"))this.chkShowPrivate.attr("checked",e);window.localStorage.setItem("showPrivate",String(e));this.port.post({name:"showPrivateChanged",showPrivate:this._showPrivate,hash:this.selectedHash})},enumerable:true,configurable:true});n.prototype.init=function(){var t=this;e.prototype.init.call(this);this.container=$("#props");this.title=this.container.find(".title");this.properties=this.container.find(".properties");this.chkShowMethods=$("#showMethods");this.chkShowPrivate=$("#showPrivate");this.txtSearchProp=$("#txtSearchProp");this.btnRefreshProps=$("#refreshProps");this.itemTmpl=this.properties.html();this.properties.html("");this.on("datachange",function(){return t.showChildren()});this.showPrivate=(window.localStorage.getItem("showPrivate")||"true")=="true";this.showMethods=(window.localStorage.getItem("showMethods")||"false")=="true";this.chkShowPrivate.click(this.onShowPrivateChanged);this.chkShowMethods.click(this.onShowMethodsChanged);this.btnRefreshProps.click(this.refresh);window.addEventListener("keydown",function(e){if((e.ctrlKey||e.metaKey)&&e.keyCode==70&&!e.shiftKey){t.txtSearchProp.focus().select();e.stopPropagation();e.preventDefault()}},true);this.txtSearchProp.keyup(function(e){window.setTimeout(t.filterProps,0)});$.contextMenu({selector:".property",items:{store:{name:"存储为全局变量"}},callback:function(e,n){var r=n.$trigger;var i=t.selectedHash;t.port.post({name:"store",hashCode:i,expression:r.data("expression")})}})};n.prototype.showChildren=function(e,n){var r=this;if(e===void 0){e=this._data}if(n===void 0){n=this.properties}this.lastQuery="";var i=e;this.title.text(i.name);n.html("");i._props=i._props.sort(function(e,n){var r=t.indexOf(e.name);var i=t.indexOf(n.name);if(r>=0&&i>=0){return r>i?1:-1}else if(r>=0){return-1}else if(i>=0){return 1}else{return e.name>n.name?1:-1}});var o=n.data("expression")||"";var s=i._props.map(function(e){return r.showProperty(e,o+"['"+e.name+"']")});n.append(s)};n.prototype.showProperty=function(e,t,n){if(n===void 0){n=this._initPropElement(e)}var r=e.name;var i=e.value;n.data("expression",t);if(r.toLowerCase().indexOf("color")>=0&&typeof i=="number"){i=i.toString(16);while(i.length<6){i="0"+i}i="0x"+i;e.value=i}if(e.type=="function"){n.addClass("function");i="function(){...}"}var o=n.children(".value");o.text(i);o.attr("title",e.value);this._initValueActions(e,n,t);if(e.expandable){this._initChildrenActions(e,n,t)}return n};n.prototype._initPropElement=function(e){var t=this.itemTmpl.replace("{icon}",e.expandable?"+":" ").replace("{name}",e.name);var n=$(t);if(e.isGetter&&e.isSetter==false)n.addClass("noSetter");return n};n.prototype._initValueActions=function(e,t,n){var r=this;var i=t.children(".value");i.data("expression",n);i.dblclick(function(){if(e.expandable||e.isGetter&&e.isSetter==false)return;var t=$('');t.width(i.width()+10);t.val(e.value);i.text("").append(t);t.focus().select();var o=function(){var o=t.val();t.remove();if(o=="")o=String(e.value);i.text(o);if(o==String(e.value))return;r.applyChange(n,o,function(t){t=JSON.stringify(t);if(t=='"NaN"')t="NaN";e.value=t;i.text(t)})};t.blur(o).keypress(function(e){if(e.keyCode==13){o()}})})};n.prototype._initChildrenActions=function(e,t,n){var r=this;var i=t.children(".icon");i.data("expanded",false);t.addClass("expandable");t.children("span").click(function(){var e=i.data("expanded");if(!e){var n=$("
    ").data("expression",t.data("expression"));n.click(function(e){return false});t.append(n);r.expand(t.data("expression"),n);i.text("-")}else{var n=t.children("ul");n.remove();i.text("+")}i.data("expanded",!e);return false})};n.prototype.expand=function(e,t){var n=this;this.mainPanel.port.post({name:"expand",hash:this.selectedHash,expression:e},null,function(e){n.showChildren(e,t)})};n.prototype.invokeGetter=function(e,t,n){var r=this;this.mainPanel.port.post({name:"invokeGetter",hash:this.selectedHash,expression:t,propName:e},null,function(e){r.showProperty(e,t,n)})};n.prototype.applyChange=function(e,t,n){this.mainPanel.port.post({name:"applyChange",hash:this.selectedHash,expression:e,value:t},null,function(e){if(e.success){n&&n(e.result)}})};n.prototype.showGameSelection=function(e,t){this._data=t;this.selectedHash=e;this.showChildren()};return n}(e.Panel);e.PropertiesPanel=n})(t=e.devtool||(e.devtool={}))})(egret||(egret={}));var __extends=this&&this.__extends||function(e,t){for(var n in t)if(t.hasOwnProperty(n))e[n]=t[n];function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)};var egret;(function(e){var t;(function(e){var t=function(t){__extends(n,t);function n(){var n=this;t.apply(this,arguments);this.treePanel=new e.TreePanel;this.propsPanel=new e.PropertiesPanel;this.profilePanel=new e.ProfilePanel;this.targetKey=null;this.portReady=function(){var t=n.port;t.post({name:"init",from:"view",targetKey:n.targetKey});t.on("ready",function(e){return n.sendOptions()});t.on("updateTree",function(t){var r=t.data;if(!n.treePanel.data)n.treePanel.data=e.TreeNode.clone(r);else{var i=e.TreeNode.getByHash(r.rawHash);e.TreeNode.clone(r,true,i);n.treePanel.data=n.treePanel.data}});t.on("updateSelection",function(e){return n.showGameSelection(e.data.hash,e.data.props,e.data.treeChange)});t.on("fps",function(e){return n.profilePanel.fps=e.data});n.treePanel.mainPanel=n;n.propsPanel.mainPanel=n;n.profilePanel.mainPanel=n;n.treePanel.port=t;n.propsPanel.port=t;n.profilePanel.port=t;n.treePanel.init();n.propsPanel.init();n.profilePanel.init();n.sendOptions()};this.changeLayout=function(e){var t=$(".left").width();var n=$(window).width();t+=e;t=Math.max(t,310);var r=n-$(".handle-v").outerWidth()-t;$(".left").width(t);$(".right").width(r);$("#props .header").width(r);var i=$("#profile").height();var o=$(window).innerHeight();var s=$("#control").outerHeight();var a=$("#searchBar").outerHeight();$(".nodes").outerHeight(o-i-s-a);$("#props").outerHeight(o-$("#searchProp").outerHeight()-$("#propHeader").outerHeight())}}n.prototype.init=function(){var t=this;var n=new e.PanelHandle($(".handle-v"));n.monitorY=false;n.on("move",this.changeLayout);this.changeLayout(0);var r=e.PortFactory.getPanelPortClass();this._getTargetKey(function(e){t.targetKey=e;t.port=new r(location.host,t.portReady)})};n.prototype._getTargetKey=function(t){var n=window["chrome"]||null;if(n&&n.devtools&&n.devtools.inspectedWindow){n.devtools.inspectedWindow.eval("window.name",function(e){return t(e)})}else{var r=e.parseParam(location.search);var i=r["key"];t(i)}};n.prototype.sendOptions=function(){this.port.post({name:"initOptions",highlightClick:this.treePanel._highlightClick,highlightHover:this.treePanel._highlightHover,preventTouch:this.treePanel._preventTouch,showMethods:this.propsPanel._showMethods,showPrivate:this.propsPanel._showPrivate})};n.prototype.showGameSelection=function(e,t,n){this.treePanel.showGameSelection(e,n);this.propsPanel.showGameSelection(e,t)};return n}(e.EventBase);e.MainPanel=t;$(function(){var e=new t;e.init();window["mainPanel"]=e; 2 | 3 | showChanges()})})(t=e.devtool||(e.devtool={}))})(egret||(egret={}));function showChanges(){var e="2.5.4";if(window.localStorage.getItem("showChange"+e))return;var t=document.getElementById("changes");t.style.display="block";var n=document.querySelector("#changes .close");n.addEventListener("click",function(){return t.style.display="none"});window.localStorage.setItem("showChange"+e,"true")} -------------------------------------------------------------------------------- /injectScripts.min.js: -------------------------------------------------------------------------------- 1 | var egret; 2 | (function (t) { 3 | var e; 4 | (function (t) { 5 | var e = (function () { 6 | function t() { 7 | var t = this; 8 | this.events = {}; 9 | this.on = function (e, r) { 10 | if (!(e in t.events)) t.events[e] = []; 11 | t.events[e].push(r); 12 | return t; 13 | }; 14 | this.trigger = function (e, r) { 15 | var i = t.events[e]; 16 | if (!i) return; 17 | for (var n = 0; n < i.length; n++) { 18 | if (typeof i[n] == 'function') { 19 | i[n](r); 20 | } 21 | } 22 | }; 23 | } 24 | t.prototype.removeAllEvents = function () { 25 | this.events = {}; 26 | }; 27 | return t; 28 | })(); 29 | t.EventBase = e; 30 | })((e = t.devtool || (t.devtool = {}))); 31 | })(egret || (egret = {})); 32 | var __extends = 33 | (this && this.__extends) || 34 | function (t, e) { 35 | for (var r in e) if (e.hasOwnProperty(r)) t[r] = e[r]; 36 | function i() { 37 | this.constructor = t; 38 | } 39 | t.prototype = 40 | e === null ? Object.create(e) : ((i.prototype = e.prototype), new i()); 41 | }; 42 | var egret; 43 | (function (t) { 44 | var e; 45 | (function (t) { 46 | var e = (function () { 47 | function t() {} 48 | t.after = function (e, r, i) { 49 | if (t.funcs[r]) return; 50 | t.funcs[r] = window.setTimeout(function () { 51 | t.funcs[r] = null; 52 | i(); 53 | }, e); 54 | }; 55 | t.funcs = {}; 56 | return t; 57 | })(); 58 | t.RunIt = e; 59 | var r = (function (t) { 60 | __extends(e, t); 61 | function e(e) { 62 | var r = this; 63 | t.call(this); 64 | this.el = e; 65 | this.lastX = 0; 66 | this.lastY = 0; 67 | this.isMouseDown = false; 68 | this.monitorY = true; 69 | this.begin = function (t) { 70 | if (r.isMouseDown) return; 71 | r.lastX = t.screenX; 72 | r.lastY = t.screenY; 73 | r.isMouseDown = true; 74 | document.documentElement.addEventListener('mousemove', r.move); 75 | document.documentElement.addEventListener('mouseup', r.end); 76 | document.body.style['-webkit-user-select'] = 'none'; 77 | }; 78 | this.move = function (t) { 79 | if (r.isMouseDown == false) return; 80 | var e = t.screenY - r.lastY; 81 | var i = t.screenX - r.lastX; 82 | if (r.monitorY) { 83 | r.el.css({ transform: 'translateY(' + e + 'px)' }); 84 | } else { 85 | r.el.css({ transform: 'translateX(' + i + 'px)' }); 86 | } 87 | }; 88 | this.end = function (t) { 89 | r.isMouseDown = false; 90 | document.documentElement.removeEventListener('mousemove', r.move); 91 | document.documentElement.removeEventListener('mouseup', r.end); 92 | document.body.style['-webkit-user-select'] = ''; 93 | var e = t.screenY - r.lastY; 94 | var i = t.screenX - r.lastX; 95 | r.trigger('move', r.monitorY ? e : i); 96 | r.el.css({ transform: '' }); 97 | }; 98 | window.addEventListener('resize', function () { 99 | r.trigger('move', 0); 100 | }); 101 | e.mousedown(this.begin); 102 | } 103 | return e; 104 | })(t.EventBase); 105 | t.PanelHandle = r; 106 | var i = (function () { 107 | function t() { 108 | var t = this; 109 | this.controlHeight = 30; 110 | this.nodesHeight = 300; 111 | this.propsHeight = 300; 112 | this.nodesWidth = 300; 113 | this.propsWidth = 300; 114 | this.width = 300; 115 | window.addEventListener('resize', function () { 116 | t.resize(0, 0); 117 | }); 118 | this.resize(0, 0); 119 | } 120 | t.prototype.resize = function (t, e) { 121 | var r = window.innerHeight; 122 | var i = window.innerWidth; 123 | this.nodesHeight = this.propsHeight = r; 124 | this.propsWidth -= t; 125 | this.nodesWidth = i - this.propsWidth - 10; 126 | }; 127 | t.prototype.setWidth = function (t) { 128 | this.width -= t; 129 | }; 130 | return t; 131 | })(); 132 | t.Layout = i; 133 | function n(t) { 134 | var e = {}; 135 | if (!t) return e; 136 | if (t.indexOf('?') == 0) t = t.substr(1); 137 | var r = t.split('&'); 138 | r.forEach(function (t) { 139 | if (t == '?') return; 140 | if (!t) return; 141 | var r = t.split('='); 142 | e[r[0]] = r.length > 1 ? r[1] : null; 143 | }); 144 | return e; 145 | } 146 | t.parseParam = n; 147 | })((e = t.devtool || (t.devtool = {}))); 148 | })(egret || (egret = {})); 149 | egret.$hashCount && 150 | Object.defineProperty(Object.prototype, 'getDisplayName', { 151 | value: function () { 152 | if (typeof this == 'number') return this; 153 | if (egret.getQualifiedClassName) return egret.getQualifiedClassName(this); 154 | if (this.constructor && this.constructor.name) 155 | return this.constructor.name; 156 | if (lark && this.__classFlag__) { 157 | return lark.Types[this.__classFlag__]; 158 | } 159 | }, 160 | }); 161 | var __extends = 162 | (this && this.__extends) || 163 | function (t, e) { 164 | for (var r in e) if (e.hasOwnProperty(r)) t[r] = e[r]; 165 | function i() { 166 | this.constructor = t; 167 | } 168 | t.prototype = 169 | e === null ? Object.create(e) : ((i.prototype = e.prototype), new i()); 170 | }; 171 | var egret; 172 | (function (t) { 173 | var e; 174 | (function (t) { 175 | var e = (function (t) { 176 | __extends(e, t); 177 | function e() { 178 | t.apply(this, arguments); 179 | this._children = []; 180 | this._props = []; 181 | this.parentHash = -1; 182 | this.show = false; 183 | this.visible = true; 184 | this.type = null; 185 | this.memberName = null; 186 | this.selected = false; 187 | this.expandable = false; 188 | this.isGetter = false; 189 | this.isSetter = false; 190 | this.icon = '-'; 191 | this.dirty = false; 192 | this.hasChildren = false; 193 | } 194 | e.prototype.updateIcon = function () { 195 | this.icon = 196 | this.hasChildren == false ? ' ' : this.show ? '-' : '+'; 197 | }; 198 | e.prototype.recover = function () { 199 | if ( 200 | this.show && 201 | this.hasChildren && 202 | (this.children != this._children || this.props != this._props) 203 | ) { 204 | this.children = null; 205 | this.props = null; 206 | this.showChildren(); 207 | } 208 | }; 209 | e.prototype.showChildren = function () { 210 | if (!this.hasChildren) return; 211 | this.show = true; 212 | if (!this.children) { 213 | this.children = this._children; 214 | this.props = this._props; 215 | this.trigger(e.ChildrenChange); 216 | } 217 | this.updateIcon(); 218 | this.trigger(e.Show); 219 | }; 220 | e.prototype.toggle = function () { 221 | if (!this.children && !this.show) { 222 | this.showChildren(); 223 | return; 224 | } 225 | this.show = !this.show; 226 | this.updateIcon(); 227 | this.trigger(e.Show); 228 | }; 229 | e.prototype.parseChildren = function () { 230 | e.parseChildren(this.raw, this); 231 | }; 232 | e.prototype.reset = function (t) { 233 | if (t === void 0) { 234 | t = true; 235 | } 236 | this._children.forEach(function (t) { 237 | return t.reset(); 238 | }); 239 | this._props.forEach(function (t) { 240 | return t.reset(); 241 | }); 242 | this._children = []; 243 | this._props = []; 244 | this.children = null; 245 | this.props = null; 246 | this.show = false; 247 | if (t) { 248 | e.hash2Node[this.rawHash] = undefined; 249 | e.hash2DisplayObject[this.rawHash] = undefined; 250 | } 251 | }; 252 | Object.defineProperty(e.prototype, 'raw', { 253 | get: function () { 254 | return e.hash2DisplayObject[this.rawHash]; 255 | }, 256 | enumerable: true, 257 | configurable: true, 258 | }); 259 | Object.defineProperty(e.prototype, 'parent', { 260 | get: function () { 261 | if (this.parentHash == -1) return null; 262 | return e.hash2Node[this.parentHash]; 263 | }, 264 | enumerable: true, 265 | configurable: true, 266 | }); 267 | e.getValue = function (t, e) { 268 | if (t == null) return String(t); 269 | var r = typeof t; 270 | var i = null; 271 | e.type = r; 272 | switch (r) { 273 | case 'string': 274 | i = JSON.stringify(t); 275 | break; 276 | case 'number': 277 | if (t == NaN) t = 'NaN'; 278 | i = t; 279 | return i; 280 | case 'array': 281 | i = String(t); 282 | e.expandable = true; 283 | break; 284 | case 'object': 285 | i = t.constructor['name'] || t['__class__'] || 'object'; 286 | e.expandable = true; 287 | break; 288 | case 'function': 289 | i = String(t); 290 | e.name; 291 | break; 292 | default: 293 | i = String(t); 294 | } 295 | return i; 296 | }; 297 | e.prototype.naviToDisplayObject = function (t) { 298 | if (!e.isLinked(t)) { 299 | e.linkToIt(t); 300 | this.dirty = true; 301 | } 302 | this.naviToNode(t.hashCode); 303 | }; 304 | e.prototype.naviToNode = function (t, r) { 305 | if (r === void 0) { 306 | r = false; 307 | } 308 | var i = e.getByHash(t); 309 | var n = []; 310 | var s = i.parent; 311 | while (s != null) { 312 | n.push(s); 313 | s = s.parent; 314 | } 315 | for (var o = n.length - 1; o >= 0; o--) n[o].showChildren(); 316 | i.showUp(); 317 | }; 318 | e.prototype.showUp = function () { 319 | if (e.selected) { 320 | e.selected.selected = false; 321 | e.selected.trigger(e.UnSelected); 322 | } 323 | this.selected = true; 324 | e.selected = this; 325 | this.trigger(e.OnSelected); 326 | }; 327 | e.prototype.find = function (t, e) { 328 | if (this.rawHash == t) { 329 | e.push(this); 330 | return true; 331 | } 332 | if (!this.hasChildren) return false; 333 | e.push(this); 334 | var r = this._props.filter(function (r) { 335 | return r.find(t, e); 336 | }); 337 | var i = r.length > 0; 338 | if (!i) { 339 | r = this._children.filter(function (r) { 340 | return r.find(t, e); 341 | }); 342 | i = r.length > 0; 343 | } 344 | if (!i) { 345 | e.pop(); 346 | return false; 347 | } 348 | return true; 349 | }; 350 | e.prototype.parseRawProps = function (t, r, i) { 351 | if (r === void 0) { 352 | r = new e(); 353 | } 354 | return e.parseRawProps(this.raw, t, r, i); 355 | }; 356 | e.parseRawProps = function (t, r, i, n) { 357 | if (i === void 0) { 358 | i = new e(); 359 | } 360 | if (n === void 0) { 361 | n = { showPrivate: true, showMethods: false }; 362 | } 363 | if (r < 0) return; 364 | if (typeof t != 'object') return; 365 | var s = []; 366 | for (var o in t) { 367 | if ( 368 | n.showPrivate === false && 369 | (String(o).indexOf('_') == 0 || String(o).indexOf('$') == 0) 370 | ) { 371 | continue; 372 | } 373 | var a = new e(); 374 | a.name = o; 375 | var h = null; 376 | var l = null; 377 | var c = t; 378 | l = Object.getOwnPropertyDescriptor(t, o); 379 | while (l == null && c) { 380 | c = Object.getPrototypeOf(c); 381 | l = Object.getOwnPropertyDescriptor(c, o); 382 | } 383 | if (l) { 384 | a.isGetter = l.get != undefined; 385 | a.isSetter = a.isGetter && l.set != undefined; 386 | } 387 | try { 388 | h = t[o]; 389 | } catch (u) { 390 | h = 'faild to get value'; 391 | } 392 | if (typeof h == 'function' && n.showMethods != true) continue; 393 | e.parseRawProps(h, r - 1, a); 394 | a.value = e.getValue(h, a); 395 | s.push(a); 396 | } 397 | s.sort(function (t, e) { 398 | var r = t.name; 399 | var i = e.name; 400 | return r > i ? 1 : r == i ? 0 : -1; 401 | }); 402 | i.name = t.getDisplayName(); 403 | i._props = s; 404 | return i; 405 | }; 406 | e.parseRawProp = function (t, r, i, n) { 407 | if (n === void 0) { 408 | n = new e(); 409 | } 410 | n.name = t; 411 | e.parseRawProps(r, i - 1, n); 412 | n.value = e.getValue(r, n); 413 | return n; 414 | }; 415 | e.prototype.toString = function () { 416 | return this.name; 417 | }; 418 | e.linkToIt = function (t, r) { 419 | if (r === void 0) { 420 | r = null; 421 | } 422 | var i = e.hash2Node[t.hashCode]; 423 | var n = i != undefined; 424 | if (n) { 425 | i.reset(false); 426 | e.parseChildren(t, i, 0); 427 | } else { 428 | i = e.parseNode(t); 429 | } 430 | i.showChildren(); 431 | if (r) { 432 | for (var s = 0; s < i._children.length; s++) { 433 | if (i._children[s].rawHash == r.rawHash) i._children[s] = r; 434 | } 435 | } 436 | if (n || !t.parent) return i; 437 | return e.linkToIt(t.parent, i); 438 | }; 439 | e.unLinkIt = function (t) { 440 | var r = e.hash2Node[t.hashCode]; 441 | var i = r.parent; 442 | var n = i._children.indexOf(r); 443 | i._children.splice(n, 1); 444 | }; 445 | e.isLinked = function (t) { 446 | return e.hash2Node[t.hashCode] != undefined; 447 | }; 448 | e.parseChildren = function (t, r, i) { 449 | if (i === void 0) { 450 | i = 0; 451 | } 452 | if (t['numChildren'] !== undefined) { 453 | var n = t; 454 | if (n.numChildren == 0) { 455 | r.hasChildren = false; 456 | return; 457 | } else r.hasChildren = true; 458 | r._children = []; 459 | for (var s = 0, o = n.numChildren; s < o; s++) { 460 | var a = e.parseNode(n.getChildAt(s), new e(), false, i); 461 | r._children.push(a); 462 | } 463 | } 464 | }; 465 | e.parseNode = function (t, r, i, n) { 466 | if (r === void 0) { 467 | r = new e(); 468 | } 469 | if (i === void 0) { 470 | i = false; 471 | } 472 | if (n === void 0) { 473 | n = 1; 474 | } 475 | if (n < 0) return null; 476 | if (i) { 477 | e.clear(); 478 | } 479 | e.hash2Node[t.hashCode] = r; 480 | e.hash2DisplayObject[t.hashCode] = t; 481 | var s = t.getDisplayName(); 482 | r.name = s; 483 | r.memberName = t.name; 484 | r.type = s; 485 | r.visible = t.visible && t.alpha != 0; 486 | r.rawHash = t.hashCode; 487 | var o = t; 488 | r.hasChildren = !!(o.numChildren && o.numChildren > 0); 489 | if (t.parent) r.parentHash = t.parent.hashCode; 490 | if (n > 0) { 491 | e.parseChildren(t, r, n - 1); 492 | } 493 | r.updateIcon(); 494 | return r; 495 | }; 496 | e.parseRawObject = function (t, r) { 497 | if (r === void 0) { 498 | r = new e(); 499 | } 500 | return e.parseRawProps(t, 0, r); 501 | }; 502 | e.getByHash = function (t) { 503 | return e.hash2Node[t]; 504 | }; 505 | e.clear = function () { 506 | e.hash2Node = {}; 507 | e.hash2DisplayObject = {}; 508 | }; 509 | e.clone = function (t, r, i) { 510 | if (r === void 0) { 511 | r = false; 512 | } 513 | i = i || new e(); 514 | var n = Object.getOwnPropertyNames(t); 515 | n.forEach(function (e) { 516 | if (e == 'events' || e == '_children' || e == '_props') return; 517 | i[e] = t[e]; 518 | }); 519 | e.hash2Node[i.rawHash] = i; 520 | if (t._children.length > 0) 521 | i._children = t._children.map(function (t) { 522 | return e.clone(t, false, e.getByHash(t.rawHash)); 523 | }); 524 | i.recover(); 525 | r && i.trigger(e.Changed); 526 | return i; 527 | }; 528 | e.Show = 'show'; 529 | e.UnSelected = 'unselected'; 530 | e.OnSelected = 'selected'; 531 | e.ChildrenChange = 'childrenchange'; 532 | e.Changed = 'changed'; 533 | e.hash2Node = {}; 534 | e.hash2DisplayObject = {}; 535 | e.ignore = { 536 | _parent: 1, 537 | parent: 1, 538 | _stage: 1, 539 | stage: 1, 540 | _eventTarget: 1, 541 | _children: 1, 542 | _owner: 1, 543 | _rendererOwner: 1, 544 | }; 545 | e.selected = null; 546 | return e; 547 | })(t.EventBase); 548 | t.TreeNode = e; 549 | var r = (function () { 550 | function t() { 551 | this.dirtyCount = []; 552 | this.dirtyKey = {}; 553 | this.init = false; 554 | } 555 | t.prototype.push = function (t) { 556 | while (t != null) { 557 | if (t.hashCode in this.dirtyKey) { 558 | this.dirtyCount[this.dirtyKey[t.hashCode]] += 1; 559 | break; 560 | } else if (this.init == false) { 561 | var e = 0; 562 | if (this.dirtyCount.length == 0) e = 1; 563 | this.dirtyCount.push(e); 564 | this.dirtyKey[t.hashCode] = this.dirtyCount.length - 1; 565 | } 566 | t = t.parent; 567 | } 568 | this.init = true; 569 | }; 570 | t.prototype.getRootHash = function () { 571 | for (var t = this.dirtyCount.length; t >= 0; t--) { 572 | if (this.dirtyCount[t] > 0) { 573 | break; 574 | } 575 | } 576 | for (var e in this.dirtyKey) { 577 | if (this.dirtyKey[e] == t) return e; 578 | } 579 | }; 580 | t.prototype.reset = function () { 581 | this.dirtyCount = []; 582 | this.dirtyKey = {}; 583 | this.init = false; 584 | }; 585 | return t; 586 | })(); 587 | t.TreeDirtyCache = r; 588 | })((e = t.devtool || (t.devtool = {}))); 589 | })(egret || (egret = {})); 590 | var EGRETRELEASE = true; 591 | var egret; 592 | (function (t) { 593 | var e; 594 | (function (t) { 595 | var e = (function () { 596 | function t(t, e) { 597 | this.host = t; 598 | this.callbacks = {}; 599 | this.namedCallbacks = {}; 600 | this.key = null; 601 | this.getKey(); 602 | this._connect(e); 603 | } 604 | t.prototype._connect = function (t) {}; 605 | t.prototype.post = function (t, e, r) { 606 | if (e === void 0) { 607 | e = null; 608 | } 609 | var i = e; 610 | if (r) { 611 | i = (performance.now() + Math.random() * 100).toString(); 612 | this.callbacks[i] = r; 613 | } 614 | var n = { id: i, data: t, key: this.key }; 615 | this._doPost(n); 616 | return this; 617 | }; 618 | t.prototype._doPost = function (t) { 619 | this.port.postMessage(t); 620 | }; 621 | t.prototype.on = function (t, e) { 622 | if (!this.namedCallbacks[t]) this.namedCallbacks[t] = []; 623 | this.namedCallbacks[t].push(e); 624 | return this; 625 | }; 626 | t.prototype.remove = function (t, e) { 627 | var r = this.namedCallbacks[t]; 628 | if (r) { 629 | var i = r.indexOf(e); 630 | if (i < 0) return; 631 | r.splice(i, 1); 632 | } 633 | return this; 634 | }; 635 | t.prototype.removeAll = function () { 636 | this.namedCallbacks = {}; 637 | return this; 638 | }; 639 | t.prototype._parseMsgData = function (t) { 640 | return null; 641 | }; 642 | t.prototype._onMessage = function (t) { 643 | var e = this; 644 | var r = this._parseMsgData(t); 645 | var i = r.id; 646 | var n = r.data.name; 647 | var s = this.callbacks[i]; 648 | if (s) { 649 | s(r.data); 650 | delete this.callbacks[i]; 651 | } 652 | var o = this.namedCallbacks[n]; 653 | if (o) { 654 | o.forEach(function (t) { 655 | var n = t(r.data, function (t) { 656 | if (i) { 657 | e.post(t, i); 658 | } 659 | }); 660 | if (i && n) { 661 | e.post(n, i); 662 | } 663 | }); 664 | } 665 | }; 666 | t.prototype.getKey = function () { 667 | if (window.name == '') { 668 | window.name = Date.now().toString(); 669 | } 670 | this.key = window.name; 671 | }; 672 | return t; 673 | })(); 674 | t.PortBase = e; 675 | })((e = t.devtool || (t.devtool = {}))); 676 | })(egret || (egret = {})); 677 | var __extends = 678 | (this && this.__extends) || 679 | function (t, e) { 680 | for (var r in e) if (e.hasOwnProperty(r)) t[r] = e[r]; 681 | function i() { 682 | this.constructor = t; 683 | } 684 | t.prototype = 685 | e === null ? Object.create(e) : ((i.prototype = e.prototype), new i()); 686 | }; 687 | var egret; 688 | (function (t) { 689 | var e; 690 | (function (t) { 691 | var e = (function (t) { 692 | __extends(e, t); 693 | function e() { 694 | t.apply(this, arguments); 695 | } 696 | e.prototype._connect = function (t) { 697 | var e = this; 698 | var r = chrome.runtime.connect(); 699 | r.onMessage.addListener(function (t) { 700 | return e._onMessage(t); 701 | }); 702 | this.port = r; 703 | t && window.setTimeout(t.bind(this), 0); 704 | }; 705 | e.prototype._doPost = function (t) { 706 | this.port.postMessage(t); 707 | }; 708 | e.prototype._parseMsgData = function (t) { 709 | return t; 710 | }; 711 | return e; 712 | })(t.PortBase); 713 | t.ChromePort = e; 714 | var r = (function (t) { 715 | __extends(e, t); 716 | function e() { 717 | t.apply(this, arguments); 718 | } 719 | e.prototype._connect = function (t) { 720 | var e = this; 721 | var r = chrome.runtime.connect(); 722 | r.onMessage.addListener(function (t) { 723 | return e._onMessage(t); 724 | }); 725 | this.port = r; 726 | window.addEventListener('message', function (t) { 727 | return e._onWindowMessage(t.data); 728 | }); 729 | t && window.setTimeout(t.bind(this), 0); 730 | }; 731 | e.prototype._doPost = function (t) { 732 | this.port.postMessage(t); 733 | }; 734 | e.prototype._parseMsgData = function (t) { 735 | return t; 736 | }; 737 | e.prototype._onMessage = function (e) { 738 | if (e.toContent) { 739 | t.prototype._onMessage.call(this, e); 740 | } else { 741 | window.postMessage(e, '*'); 742 | } 743 | }; 744 | e.prototype._onWindowMessage = function (t) { 745 | if (t['from'] == 'stage') { 746 | var e = JSON.parse(t.data); 747 | this.post(e, t.id); 748 | } 749 | }; 750 | return e; 751 | })(t.PortBase); 752 | t.ContentPort = r; 753 | var i = (function (t) { 754 | __extends(e, t); 755 | function e() { 756 | t.apply(this, arguments); 757 | } 758 | e.prototype._connect = function (t) { 759 | var e = this; 760 | window.addEventListener('message', function (t) { 761 | return e._onMessage(t); 762 | }); 763 | t && window.setTimeout(t.bind(this), 0); 764 | }; 765 | e.prototype._doPost = function (t) { 766 | window.postMessage( 767 | { from: 'stage', id: t.id, data: JSON.stringify(t.data) }, 768 | '*' 769 | ); 770 | }; 771 | e.prototype._parseMsgData = function (t) { 772 | return t.data; 773 | }; 774 | e.prototype._onMessage = function (e) { 775 | var r = this._parseMsgData(e); 776 | if (!r.data) return; 777 | if (r['from'] == 'stage') return false; 778 | t.prototype._onMessage.call(this, e); 779 | }; 780 | return e; 781 | })(t.PortBase); 782 | t.StagePort = i; 783 | var n = (function (t) { 784 | __extends(e, t); 785 | function e() { 786 | t.apply(this, arguments); 787 | } 788 | e.prototype._connect = function (t) { 789 | var e = this; 790 | var r = new WebSocket('ws://' + this.host); 791 | this.port = r; 792 | r.addEventListener('message', function (t) { 793 | return e._onMessage(t); 794 | }); 795 | r.addEventListener('open', function (r) { 796 | return t(e); 797 | }); 798 | }; 799 | e.prototype._doPost = function (t) { 800 | var e = this.port; 801 | e.send(JSON.stringify(t)); 802 | }; 803 | e.prototype._parseMsgData = function (t) { 804 | return JSON.parse(t.data); 805 | }; 806 | return e; 807 | })(t.PortBase); 808 | t.WsPort = n; 809 | })((e = t.devtool || (t.devtool = {}))); 810 | })(egret || (egret = {})); 811 | var egret; 812 | (function (t) { 813 | var e; 814 | (function (t) { 815 | t.PortFactory = null; 816 | })((e = t.devtool || (t.devtool = {}))); 817 | })(egret || (egret = {})); 818 | var egret; 819 | (function (t) { 820 | var e; 821 | (function (e) { 822 | var r = (function () { 823 | function e() {} 824 | e.prototype.getStagePortClass = function () { 825 | return t.devtool.StagePort; 826 | }; 827 | e.prototype.getPanelPortClass = function () { 828 | return t.devtool.ChromePort; 829 | }; 830 | e.prototype.getExtContentPortClass = function () { 831 | return t.devtool.ContentPort; 832 | }; 833 | return e; 834 | })(); 835 | e.ChromePortFactory = r; 836 | e.PortFactory = new r(); 837 | })((e = t.devtool || (t.devtool = {}))); 838 | })(egret || (egret = {})); 839 | var __extends = 840 | (this && this.__extends) || 841 | function (t, e) { 842 | for (var r in e) if (e.hasOwnProperty(r)) t[r] = e[r]; 843 | function i() { 844 | this.constructor = t; 845 | } 846 | t.prototype = 847 | e === null ? Object.create(e) : ((i.prototype = e.prototype), new i()); 848 | }; 849 | var egret; 850 | (function (t) { 851 | var e; 852 | (function (e) { 853 | var r = 'devtool_showSelected'; 854 | var i = 'devtool_showHover'; 855 | var n = '#00AA00'; 856 | var s = 'rgba(79, 169, 144, 0.13)'; 857 | var o = '#AA0000'; 858 | var a = 'rgba(169, 0, 0, 0.5)'; 859 | var h = 'rgba(79, 92, 169, 0.88)'; 860 | var l = 'rgba(79, 92, 169, 0.13)'; 861 | var c = (function (e) { 862 | __extends(r, e); 863 | function r() { 864 | e.apply(this, arguments); 865 | this._tick = 0; 866 | this._totalDeltaTime = 0; 867 | } 868 | r.prototype.run = function () { 869 | t.Ticker.getInstance().register(this.update, this); 870 | }; 871 | r.prototype.update = function (t) { 872 | this._tick++; 873 | this._totalDeltaTime += t; 874 | if (this._totalDeltaTime >= r._maxDeltaTime) { 875 | var e = Math.floor((this._tick * 1e3) / this._totalDeltaTime); 876 | this.trigger('fps', e); 877 | this._totalDeltaTime = 0; 878 | this._tick = 0; 879 | } 880 | }; 881 | r.instance = null; 882 | r._maxDeltaTime = 500; 883 | return r; 884 | })(t.devtool.EventBase); 885 | e.Profiler = c; 886 | var u = (function () { 887 | function e() {} 888 | e.checkContainer = function (r, i, n) { 889 | var s; 890 | if (!r.visible) { 891 | return null; 892 | } 893 | if (r.scrollRect) { 894 | if ( 895 | i < r.scrollRect.x || 896 | n < r.scrollRect.y || 897 | i > r.scrollRect.x + r.scrollRect.width || 898 | n > r.scrollRect.y + r.scrollRect.height 899 | ) { 900 | return null; 901 | } 902 | } else if (r.mask) { 903 | if ( 904 | r.mask.x > i || 905 | i > r.mask.x + r.mask.width || 906 | r.mask.y > n || 907 | n > r.mask.y + r.mask.height 908 | ) { 909 | return null; 910 | } 911 | } 912 | var o = r._children; 913 | var a = o.length; 914 | var h = r._touchChildren; 915 | for (var l = a - 1; l >= 0; l--) { 916 | var c = o[l]; 917 | var u = c._getMatrix(); 918 | var d = c.scrollRect; 919 | if (d) { 920 | u.append(1, 0, 0, 1, -d.x, -d.y); 921 | } 922 | u.invert(); 923 | var p = t.Matrix.transformCoords(u, i, n); 924 | var f = p.x, 925 | v = p.y; 926 | var g = e.checkDispObject; 927 | if (c instanceof t.DisplayObjectContainer) g = e.checkContainer; 928 | var y = g(c, f, v); 929 | if (y) { 930 | if (!h) { 931 | return r; 932 | } 933 | return y; 934 | } 935 | } 936 | if (s) { 937 | return s; 938 | } else if (r._texture_to_render || r['_graphics']) { 939 | return e.checkDispObject(r, i, n); 940 | } 941 | return null; 942 | }; 943 | e.checkDispObject = function (e, r, i) { 944 | if (!e.visible) { 945 | return null; 946 | } 947 | var n = e._getSize(t.Rectangle.identity); 948 | if (!(0 <= r && r < n.width && 0 <= i && i < n.height)) { 949 | return null; 950 | } 951 | var s = e.mask || e.scrollRect; 952 | if (!s) return e; 953 | var o = [e.mask, e.scrollRect]; 954 | var a = o.some(function (t) { 955 | return ( 956 | t && 957 | r >= t.x && 958 | i >= t.y && 959 | r <= t.x + t.width && 960 | i <= t.y + t.height 961 | ); 962 | }); 963 | return a ? e : null; 964 | }; 965 | e.find = function (t, r) { 966 | if ( 967 | r.hashCode == t || 968 | (r.name && 969 | r.name.toLowerCase().indexOf(t.toString().toLowerCase()) >= 0) 970 | ) 971 | return [r]; 972 | var i = r.numChildren ? r : null; 973 | if (i == null) return null; 974 | var n = null; 975 | for (var s = 0; s < i.numChildren; s++) { 976 | var o = i.getChildAt(s); 977 | var a = e.find(t, o); 978 | if (a) { 979 | if (!n) n = a; 980 | else n = n.concat(a); 981 | } 982 | } 983 | return n; 984 | }; 985 | return e; 986 | })(); 987 | e.DisplayObjectLocator = u; 988 | var d = (function () { 989 | function e(t, e, r) { 990 | if (r === void 0) { 991 | r = 1; 992 | } 993 | this.stageW = t; 994 | this.stageH = e; 995 | this.ratio = r; 996 | } 997 | e.prototype.draw = function (e, r, i) { 998 | if (i === void 0) { 999 | i = true; 1000 | } 1001 | if (r == null) return; 1002 | var o; 1003 | if (e instanceof t.HTML5CanvasRenderer) { 1004 | o = e.canvasContext; 1005 | } 1006 | var a = r.x; 1007 | var c = r.y; 1008 | var u = o.globalAlpha; 1009 | o.save(); 1010 | o.globalAlpha = 1; 1011 | var d = r._worldTransform; 1012 | var p = this.ratio; 1013 | o.setTransform(d.a, d.b, d.c, d.d, d.tx, d.ty); 1014 | var f = 0, 1015 | v = 0; 1016 | var g = { x: 0, y: 0, width: r.width, height: r.height }; 1017 | var y = i ? n : h; 1018 | var m = i ? s : l; 1019 | var w = r.mask || r.scrollRect; 1020 | if (w) { 1021 | g.x = w.x; 1022 | g.y = w.y; 1023 | g.width = w.width; 1024 | g.height = w.height; 1025 | f += w.x; 1026 | v += w.y; 1027 | } 1028 | this.drawRect(o, g, y, m); 1029 | f = f + d.tx < 0 ? -f - d.tx : f; 1030 | v = v + d.ty < 0 ? -v - d.ty : v; 1031 | o.setTransform(1, 0, 0, 1, d.tx, d.ty); 1032 | o.lineDashOffset = 0; 1033 | var T = [ 1034 | 'x:', 1035 | Math.round(a), 1036 | ',y:', 1037 | Math.round(c), 1038 | ',w:', 1039 | Math.round(r.width), 1040 | ',h:', 1041 | Math.round(r.height), 1042 | ].join(''); 1043 | o.fillStyle = '#333'; 1044 | o.lineWidth = 1; 1045 | o.globalAlpha = 0.6; 1046 | o.font = 12 * p + 'px Consolas,Courier New, Courier, monospace'; 1047 | o.fillRect(f, v, o.measureText(T).width + 10, 16 * p); 1048 | o.fillStyle = '#FFF'; 1049 | o.globalAlpha = 1; 1050 | o.fillText(T, f + 5 * p, v + 12 * p); 1051 | o.closePath(); 1052 | o.setTransform(1, 0, 0, 1, 0, 0); 1053 | o.restore(); 1054 | o.globalAlpha = u; 1055 | }; 1056 | e.prototype.drawRect = function (t, e, r, i) { 1057 | t.fillStyle = i; 1058 | t.beginPath(); 1059 | t.fillRect(e.x, e.y, e.width, e.height); 1060 | t.closePath(); 1061 | t.beginPath(); 1062 | t.strokeStyle = r; 1063 | t.lineWidth = 1; 1064 | t.strokeRect(e.x, e.y, e.width, e.height); 1065 | }; 1066 | return e; 1067 | })(); 1068 | e.Pen = d; 1069 | var p = (function (e) { 1070 | __extends(r, e); 1071 | function r(r, i, n) { 1072 | if (n === void 0) { 1073 | n = 1; 1074 | } 1075 | e.call(this, r, i, n); 1076 | this.stageW = r; 1077 | this.stageH = i; 1078 | this.ratio = n; 1079 | this.tipTextField = new t.TextField(); 1080 | this.graphicsPoints = null; 1081 | this.graphicsIndices = null; 1082 | this.graphicsBuffer = null; 1083 | this.graphicsIndexBuffer = null; 1084 | this.tipTextField.textColor = 16777215; 1085 | this.tipTextField.size = 12 * n; 1086 | this.tipTextField.fontFamily = 1087 | 'Consolas,Courier New, Courier, monospace'; 1088 | this.tipTextField._parentChanged(new t.DisplayObjectContainer()); 1089 | this.glRenderer = t.MainContext.instance.rendererContext; 1090 | } 1091 | r.prototype.draw = function (e, r, i) { 1092 | if (i === void 0) { 1093 | i = true; 1094 | } 1095 | if (r == null) return; 1096 | var o; 1097 | if (e instanceof t.WebGLRenderer) o = e; 1098 | var a = r.x; 1099 | var c = r.y; 1100 | var u = r._worldTransform; 1101 | var d = 1; 1102 | o.setTransform(u); 1103 | var p = 0, 1104 | f = 0; 1105 | var v = i 1106 | ? { r: 79 / 255, g: 169 / 255, b: 144 / 255, a: 0.2 } 1107 | : { r: 79 / 255, g: 96 / 255, b: 169 / 255, a: 0.2 }; 1108 | var g = { 1109 | x: 0, 1110 | y: 0, 1111 | w: r.width, 1112 | h: r.height, 1113 | r: v.r, 1114 | g: v.g, 1115 | b: v.b, 1116 | a: v.a, 1117 | }; 1118 | var y = i ? n : h; 1119 | var m = i ? s : l; 1120 | var w = r.mask || r.scrollRect; 1121 | if (w) { 1122 | g.x = w.x; 1123 | g.y = w.y; 1124 | g.w = w.width; 1125 | g.h = w.height; 1126 | p += w.x; 1127 | f += w.y; 1128 | } 1129 | var T = { x: g.x, y: g.y, w: g.w, h: g.h }; 1130 | this.drawRect(g); 1131 | g.a = 1; 1132 | g.w = 1; 1133 | this.drawRect(g); 1134 | g.x += T.w; 1135 | this.drawRect(g); 1136 | g.x -= T.w; 1137 | g.h = 1; 1138 | g.w = T.w + 1; 1139 | this.drawRect(g); 1140 | g.y += T.h; 1141 | this.drawRect(g); 1142 | p = u.tx; 1143 | f = u.ty; 1144 | var x = new t.Matrix(1, 0, 0, 1, u.tx, u.ty); 1145 | this.glRenderer.setTransform(x); 1146 | var _ = [ 1147 | 'x:', 1148 | Math.round(a), 1149 | ',y:', 1150 | Math.round(c), 1151 | ',w:', 1152 | Math.round(r.width), 1153 | ',h:', 1154 | Math.round(r.height), 1155 | ].join(''); 1156 | if (this.tipTextField.text != _) { 1157 | this.tipTextField.text = _; 1158 | } 1159 | this.tipTextField.x = p; 1160 | this.tipTextField.y = f; 1161 | this.drawRect({ 1162 | x: 0, 1163 | y: 0, 1164 | w: this.tipTextField.width, 1165 | h: this.tipTextField.height, 1166 | r: 0, 1167 | g: 0, 1168 | b: 0, 1169 | a: 0.6, 1170 | }); 1171 | this.tipTextField._draw(this.glRenderer); 1172 | this.glRenderer['_drawWebGL'](); 1173 | }; 1174 | r.prototype.drawRect = function (t) { 1175 | this.renderGraphics(t); 1176 | }; 1177 | r.prototype.renderGraphics = function (t) { 1178 | var e = this.glRenderer['gl']; 1179 | var r = this.glRenderer['shaderManager'].primitiveShader; 1180 | if (!this.graphicsPoints) { 1181 | this.graphicsPoints = []; 1182 | this.graphicsIndices = []; 1183 | this.graphicsBuffer = e.createBuffer(); 1184 | this.graphicsIndexBuffer = e.createBuffer(); 1185 | } else { 1186 | this.graphicsPoints.length = 0; 1187 | this.graphicsIndices.length = 0; 1188 | } 1189 | this.updateGraphics(t); 1190 | this.glRenderer['shaderManager'].activateShader(r); 1191 | e.blendFunc(e.ONE, e.ONE_MINUS_SRC_ALPHA); 1192 | e.uniformMatrix3fv( 1193 | r.translationMatrix, 1194 | false, 1195 | this.glRenderer['worldTransform'].toArray(true) 1196 | ); 1197 | e.uniform2f( 1198 | r.projectionVector, 1199 | this.glRenderer['projectionX'], 1200 | -this.glRenderer['projectionY'] 1201 | ); 1202 | e.uniform2f(r.offsetVector, 0, 0); 1203 | e.uniform3fv(r.tintColor, [1, 1, 1]); 1204 | e.uniform1f(r.alpha, t.a); 1205 | e.bindBuffer(e.ARRAY_BUFFER, this.graphicsBuffer); 1206 | e.vertexAttribPointer(r.aVertexPosition, 2, e.FLOAT, false, 4 * 6, 0); 1207 | e.vertexAttribPointer( 1208 | r.colorAttribute, 1209 | 4, 1210 | e.FLOAT, 1211 | false, 1212 | 4 * 6, 1213 | 2 * 4 1214 | ); 1215 | e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, this.graphicsIndexBuffer); 1216 | e.drawElements( 1217 | e.TRIANGLE_STRIP, 1218 | this.graphicsIndices.length, 1219 | e.UNSIGNED_SHORT, 1220 | 0 1221 | ); 1222 | this.glRenderer['shaderManager'].activateShader( 1223 | this.glRenderer['shaderManager'].defaultShader 1224 | ); 1225 | }; 1226 | r.prototype.updateGraphics = function (t) { 1227 | var e = this.glRenderer['gl']; 1228 | this.buildRectangle(t); 1229 | e.bindBuffer(e.ARRAY_BUFFER, this.graphicsBuffer); 1230 | e.bufferData( 1231 | e.ARRAY_BUFFER, 1232 | new Float32Array(this.graphicsPoints), 1233 | e.STATIC_DRAW 1234 | ); 1235 | e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, this.graphicsIndexBuffer); 1236 | e.bufferData( 1237 | e.ELEMENT_ARRAY_BUFFER, 1238 | new Uint16Array(this.graphicsIndices), 1239 | e.STATIC_DRAW 1240 | ); 1241 | }; 1242 | r.prototype.buildRectangle = function (t) { 1243 | var e = t.x; 1244 | var r = t.y; 1245 | var i = t.w; 1246 | var n = t.h; 1247 | var s = t.r; 1248 | var o = t.g; 1249 | var a = t.b; 1250 | var h = 1; 1251 | var l = this.graphicsPoints; 1252 | var c = this.graphicsIndices; 1253 | var u = l.length / 6; 1254 | l.push(e, r); 1255 | l.push(s, o, a, h); 1256 | l.push(e + i, r); 1257 | l.push(s, o, a, h); 1258 | l.push(e, r + n); 1259 | l.push(s, o, a, h); 1260 | l.push(e + i, r + n); 1261 | l.push(s, o, a, h); 1262 | c.push(u, u, u + 1, u + 2, u + 3, u + 3); 1263 | }; 1264 | return r; 1265 | })(d); 1266 | e.GlPen = p; 1267 | var f = (function (t) { 1268 | __extends(e, t); 1269 | function e() { 1270 | t.apply(this, arguments); 1271 | } 1272 | return e; 1273 | })(d); 1274 | e.CanvasPen = f; 1275 | var v = (function (e) { 1276 | __extends(r, e); 1277 | function r() { 1278 | var r = this; 1279 | e.apply(this, arguments); 1280 | this.highlightHover = false; 1281 | this.highlightClick = true; 1282 | this.executeMouseEvents = true; 1283 | this.onMouseMove = function (e) { 1284 | if (r.highlightHover == false) return; 1285 | var i = r.translate(e); 1286 | var n = t.MainContext.instance.stage; 1287 | var s = u.checkContainer(n, i.x, i.y); 1288 | if (!s || s == r.hovered || s == t.MainContext.instance.stage) return; 1289 | r.hovered = s; 1290 | }; 1291 | this.onMouseOut = function (t, e) { 1292 | if (e === void 0) { 1293 | e = false; 1294 | } 1295 | r.hovered = null; 1296 | }; 1297 | this.onMouseDown = function (e) { 1298 | if (r.highlightClick == false) return; 1299 | var i = r.translate(e); 1300 | var n = t.MainContext.instance.stage; 1301 | var s = u.checkContainer(n, i.x, i.y); 1302 | if (!s || s == r.selected) return; 1303 | r.selected = s; 1304 | }; 1305 | } 1306 | Object.defineProperty(r.prototype, 'hovered', { 1307 | get: function () { 1308 | return this._hovered; 1309 | }, 1310 | set: function (t) { 1311 | if (t == this._hovered) return; 1312 | this._hovered = t; 1313 | this.trigger('hovered', t); 1314 | }, 1315 | enumerable: true, 1316 | configurable: true, 1317 | }); 1318 | Object.defineProperty(r.prototype, 'selected', { 1319 | get: function () { 1320 | return this._selected; 1321 | }, 1322 | set: function (t) { 1323 | if (t == this._selected) return; 1324 | this._selected = t; 1325 | if (t) this.trigger('selected', t); 1326 | }, 1327 | enumerable: true, 1328 | configurable: true, 1329 | }); 1330 | r.prototype.init = function () { 1331 | var e = document.getElementById(t.StageDelegate.canvas_div_name); 1332 | this.div = e; 1333 | this.target_div = e; 1334 | this.div.addEventListener('mousedown', this.onMouseDown); 1335 | this.div.addEventListener('mousemove', this.onMouseMove); 1336 | this.div.addEventListener('mouseleave', this.onMouseOut); 1337 | this.div.addEventListener('MSPointerDown', this.onMouseDown, true); 1338 | this.div.addEventListener('MSPointerMove', this.onMouseMove, true); 1339 | this.div.addEventListener('touchstart', this.onMouseDown); 1340 | this.div.addEventListener('touchmove', this.onMouseMove); 1341 | this.div.addEventListener('touchcancel', this.onMouseOut); 1342 | this.divPosition = this.target_div.getBoundingClientRect(); 1343 | return this; 1344 | }; 1345 | r.prototype.reset = function () { 1346 | this.div.removeEventListener('mousedown', this.onMouseDown); 1347 | this.div.removeEventListener('mousemove', this.onMouseMove); 1348 | this.div.removeEventListener('mouseleave', this.onMouseOut); 1349 | }; 1350 | r.prototype.translate = function (e) { 1351 | var r = t.HTML5TouchContext.prototype; 1352 | if (e.touches) { 1353 | e = e.touches[0]; 1354 | } 1355 | return r.getLocation(this.target_div, e); 1356 | }; 1357 | r.prototype.preventTouch = function (t) { 1358 | this.executeMouseEvents = !t; 1359 | }; 1360 | return r; 1361 | })(t.devtool.EventBase); 1362 | e.Mask = v; 1363 | var g = (function (r) { 1364 | __extends(i, r); 1365 | function i() { 1366 | r.apply(this, arguments); 1367 | this.renderCost = {}; 1368 | this.textureCanvas = null; 1369 | this.textureOptions = { 1370 | ratio: 1, 1371 | stageW: 400, 1372 | stageH: 800, 1373 | textureCanvas: this.textureCanvas, 1374 | textureCtx: this.textureCtx, 1375 | bufferTexture: this.bufferTexture, 1376 | }; 1377 | this.textureCtx = null; 1378 | this.lastSelected = null; 1379 | this.lastHovered = null; 1380 | this._rawDraw = null; 1381 | this._mask = null; 1382 | this._antOffset = 0; 1383 | this._preventTouch = false; 1384 | this.performance = window.performance; 1385 | } 1386 | i.attach = function (t) { 1387 | if (i.instance == null) { 1388 | i.instance = new i(); 1389 | } 1390 | i.instance.attach(t); 1391 | }; 1392 | i.show = function (t) { 1393 | i.instance.show(t); 1394 | }; 1395 | i.prototype.attach = function (r) { 1396 | var i = this; 1397 | var n = this; 1398 | var s = t.MainContext.instance; 1399 | this._mask = new v().init(); 1400 | this._mask.on('selected', function (t) { 1401 | return i.show(t, e.TartgetType.active); 1402 | }); 1403 | this._mask.on('hovered', function (t) { 1404 | return i.show(t, e.TartgetType.hover); 1405 | }); 1406 | var o = e.Profiler.instance || new e.Profiler(); 1407 | o.removeAllEvents(); 1408 | o.on('fps', function (t) { 1409 | i.trigger('fps', t); 1410 | }); 1411 | r.addEventListener( 1412 | t.TouchEvent.LEAVE_STAGE, 1413 | function (t) { 1414 | return (i.lastHovered = null); 1415 | }, 1416 | this 1417 | ); 1418 | r.addEventListener( 1419 | t.Event.REMOVED, 1420 | function (t) { 1421 | var e = t.target; 1422 | i.trigger('displayObjectRemoved', e); 1423 | }, 1424 | this 1425 | ); 1426 | var a = s.rendererContext.onRenderFinish; 1427 | s.rendererContext.onRenderFinish = function () { 1428 | a.call(this); 1429 | n._drawTarget(); 1430 | }; 1431 | this.textureCanvas = document.createElement('canvas'); 1432 | var h = document.getElementById(t.StageDelegate.canvas_name); 1433 | var l = t.MainContext.instance.stage.stageWidth, 1434 | c = t.MainContext.instance.stage.stageHeight; 1435 | var u = Math.max(c, l); 1436 | var d = u > 1200 ? Math.round(u / 800) : 1; 1437 | var g = s.rendererContext instanceof t.WebGLRenderer; 1438 | this.pen = g ? new p(l, c, d) : new f(l, c, d); 1439 | this.textureCtx = this.textureCanvas.getContext('2d'); 1440 | this.textureCtx.font = 1441 | 12 * d + 'px Consolas,Courier New, Courier, monospace'; 1442 | this.textureCanvas.width = l / d; 1443 | this.textureCanvas.height = c / d; 1444 | this.textureOptions.ratio = d; 1445 | this.textureOptions.stageH = c; 1446 | this.textureOptions.stageW = l; 1447 | var y = s.touchContext.onTouchBegan; 1448 | s.touchContext.onTouchBegan = function (t, e, r) { 1449 | if (n._preventTouch) return; 1450 | y.call(this, t, e, r); 1451 | }; 1452 | e.Profiler.instance = o; 1453 | o.run(); 1454 | }; 1455 | i.prototype.detach = function (t) { 1456 | this.lastSelected = null; 1457 | this.lastHovered = null; 1458 | this._mask.reset(); 1459 | }; 1460 | i.prototype.show = function (t, r) { 1461 | if (r === void 0) { 1462 | r = e.TartgetType.hover; 1463 | } 1464 | var i = t; 1465 | var n = r == e.TartgetType.hover; 1466 | if (n) { 1467 | this.lastHovered = i; 1468 | this._mask._hovered = i; 1469 | } else { 1470 | this.lastSelected = i; 1471 | this._mask._selected = i; 1472 | } 1473 | if (!n) this.trigger('selected', i); 1474 | }; 1475 | i.prototype.getLastSelected = function () { 1476 | return this.lastSelected && this.lastSelected.stage 1477 | ? this.lastSelected 1478 | : undefined; 1479 | }; 1480 | i.prototype.highlightType = function (t, r) { 1481 | if (e.TartgetType.active == t) this.highlightClick = r; 1482 | if (e.TartgetType.hover == t) this.highlightHover = r; 1483 | }; 1484 | i.prototype.preventTouch = function (t) { 1485 | this._preventTouch = t; 1486 | this._mask.preventTouch(t); 1487 | }; 1488 | i.prototype.update = function () {}; 1489 | i.prototype._drawTarget = function () { 1490 | var e = t.MainContext.instance.rendererContext; 1491 | this.pen.draw(e, this.lastSelected, true); 1492 | this.pen.draw(e, this.lastHovered, false); 1493 | }; 1494 | i.prototype._rewriteStageEvents = function () {}; 1495 | i.prototype._rewriteDraw = function () { 1496 | if (t.DisplayObject.prototype['rewrite']) return; 1497 | this._rawDraw = t.DisplayObject.prototype._draw; 1498 | var e = this; 1499 | var r = function (t) { 1500 | var r = this; 1501 | var i = e.performance.now(); 1502 | e._rawDraw.call(this, t); 1503 | var n = e.performance.now(); 1504 | var s = n - i; 1505 | e.renderCost[r.hashCode] = s; 1506 | }; 1507 | t.DisplayObject.prototype._draw = r; 1508 | t.DisplayObject.prototype['rewrite'] = true; 1509 | }; 1510 | Object.defineProperty(i.prototype, 'highlightHover', { 1511 | set: function (t) { 1512 | this._mask.highlightHover = t; 1513 | if (!t) { 1514 | this.lastHovered = null; 1515 | this._mask._hovered = null; 1516 | } 1517 | }, 1518 | enumerable: true, 1519 | configurable: true, 1520 | }); 1521 | Object.defineProperty(i.prototype, 'highlightClick', { 1522 | set: function (t) { 1523 | this._mask.highlightClick = t; 1524 | if (!t) { 1525 | this.lastSelected = null; 1526 | this._mask._selected = null; 1527 | } 1528 | }, 1529 | enumerable: true, 1530 | configurable: true, 1531 | }); 1532 | i.instance = null; 1533 | return i; 1534 | })(t.devtool.EventBase); 1535 | e.Inspector = g; 1536 | })((e = t.devtool || (t.devtool = {}))); 1537 | })(egret || (egret = {})); 1538 | var __extends = 1539 | (this && this.__extends) || 1540 | function (t, e) { 1541 | for (var r in e) if (e.hasOwnProperty(r)) t[r] = e[r]; 1542 | function i() { 1543 | this.constructor = t; 1544 | } 1545 | t.prototype = 1546 | e === null ? Object.create(e) : ((i.prototype = e.prototype), new i()); 1547 | }; 1548 | var egret; 1549 | (function (t) { 1550 | var e; 1551 | (function (e) { 1552 | window['lark'] = window['lark'] || {}; 1553 | if (!lark.Sprite) { 1554 | lark['Sprite'] = function () {}; 1555 | } 1556 | (function (t) { 1557 | t[(t['active'] = 0)] = 'active'; 1558 | t[(t['hover'] = 1)] = 'hover'; 1559 | })(e.TartgetType || (e.TartgetType = {})); 1560 | var r = e.TartgetType; 1561 | var i = (function (t) { 1562 | __extends(e, t); 1563 | function e() { 1564 | t.apply(this, arguments); 1565 | this.profiler = new o(); 1566 | this.mask = new s(); 1567 | this._preventTouch = false; 1568 | } 1569 | e.prototype.attach = function (t) { 1570 | var e = this; 1571 | this.stage = t; 1572 | t.addChild(this.mask); 1573 | t.on(lark.TouchEvent.TOUCH_BEGIN, this.touchHandler, this, true, 9999); 1574 | t.on(lark.TouchEvent.TOUCH_END, this.touchHandler, this, true, 9999); 1575 | t.on(lark.TouchEvent.TOUCH_MOVE, this.touchHandler, this, true, 9999); 1576 | t.on(lark.Event.ENTER_FRAME, this.enterFrameHandler, this, false, 9999); 1577 | this.profiler.run(); 1578 | this.profiler.on('fps', function (t) { 1579 | return e.trigger('fps', t); 1580 | }); 1581 | }; 1582 | e.prototype.detach = function () { 1583 | this.stage.removeChild(this.mask); 1584 | this.stage.removeListener( 1585 | lark.TouchEvent.TOUCH_BEGIN, 1586 | this.touchHandler, 1587 | this, 1588 | true 1589 | ); 1590 | this.stage.removeListener( 1591 | lark.TouchEvent.TOUCH_END, 1592 | this.touchHandler, 1593 | this, 1594 | true 1595 | ); 1596 | this.stage.removeListener( 1597 | lark.TouchEvent.TOUCH_MOVE, 1598 | this.touchHandler, 1599 | this, 1600 | true 1601 | ); 1602 | this.stage.removeListener( 1603 | lark.Event.ENTER_FRAME, 1604 | this.enterFrameHandler, 1605 | this, 1606 | false 1607 | ); 1608 | this.profiler.stop(); 1609 | }; 1610 | e.prototype.show = function (t, e) { 1611 | if (e === void 0) { 1612 | e = r.hover; 1613 | } 1614 | var i = t; 1615 | this.mask.setTarget(i, e); 1616 | if (e == r.active) this.trigger('selected', t); 1617 | }; 1618 | e.prototype.getLastSelected = function () { 1619 | return this.mask.targets[r.active]; 1620 | }; 1621 | e.prototype.highlightType = function (t, e) { 1622 | if (e === void 0) { 1623 | e = true; 1624 | } 1625 | this.mask.highlight[t] = !!e; 1626 | }; 1627 | e.prototype.preventTouch = function (t) { 1628 | this._preventTouch = t; 1629 | }; 1630 | e.prototype.touchHandler = function (t) { 1631 | if (this._preventTouch) { 1632 | t.preventDefault(); 1633 | t.stopImmediatePropagation(); 1634 | } 1635 | var e = t.target; 1636 | if (t.type == lark.TouchEvent.TOUCH_BEGIN) { 1637 | this.mask.setTarget(e, r.active); 1638 | this.trigger('selected', e); 1639 | } 1640 | if (t.type == lark.TouchEvent.TOUCH_MOVE) { 1641 | this.mask.setTarget(e, r.hover); 1642 | } 1643 | }; 1644 | e.prototype.enterFrameHandler = function () { 1645 | this.mask.drawTargets(); 1646 | }; 1647 | return e; 1648 | })(e.EventBase); 1649 | e.LarkInspector = i; 1650 | var n = { 1651 | 0: ['rgba(0,200,0,0.3)', 'rgba(0,200,0,0.5)'], 1652 | 1: ['rgba(0,0,150,0.3)', 'rgba(0,0,150,0.5)'], 1653 | }; 1654 | var s = (function (t) { 1655 | __extends(e, t); 1656 | function e() { 1657 | t.call(this); 1658 | this.shape = new lark.Shape(); 1659 | this.metrics = new lark.TextField(); 1660 | this.targets = {}; 1661 | this.highlight = {}; 1662 | this.name = '$LarkMetricMask'; 1663 | this.shape.touchEnabled = false; 1664 | this.addChild(this.shape); 1665 | this.metrics.fontFamily = 'monospace'; 1666 | this.metrics.fontSize = 12; 1667 | this.metrics.touchEnabled = false; 1668 | this.addChild(this.metrics); 1669 | this.touchEnabled = false; 1670 | } 1671 | e.prototype.setTarget = function (t, e) { 1672 | if (e === void 0) { 1673 | e = r.active; 1674 | } 1675 | this.targets[e] = t; 1676 | this.drawTargets(); 1677 | }; 1678 | e.prototype.drawTargets = function () { 1679 | this.metrics.visible = false; 1680 | var t = this.shape.graphics; 1681 | t.clear(); 1682 | var e = false; 1683 | for (var i in this.targets) { 1684 | var n = this.highlight[i] == false; 1685 | if (n) continue; 1686 | this.drawTarget(this.targets[i], i); 1687 | e = true; 1688 | } 1689 | if (e) this.showMetrics(this.targets[r.active]); 1690 | }; 1691 | e.prototype.showMetrics = function (t) { 1692 | if (!t) return; 1693 | this.metrics.visible = true; 1694 | var e = t.$getOriginalBounds(); 1695 | var r = t.localToGlobal(e.x, e.y).clone(); 1696 | var i = 1697 | 'x:' + 1698 | t.x.toFixed(0) + 1699 | ',y:' + 1700 | t.y.toFixed(0) + 1701 | ',w:' + 1702 | t.width.toFixed(0) + 1703 | ',h:' + 1704 | t.height.toFixed(0); 1705 | r.x = Math.max(r.x, 0); 1706 | r.y = Math.max(r.y, 0); 1707 | this.metrics.x = r.x + 2; 1708 | this.metrics.y = r.y + 2; 1709 | this.metrics.text = i; 1710 | var n = this.shape.graphics; 1711 | var s = this.metrics.textWidth + 4; 1712 | var o = this.metrics.textHeight + 4; 1713 | var a = { x: r.x - 0.5, y: r.y - 0.5 }; 1714 | n.moveTo(a.x, a.y); 1715 | n.beginPath(); 1716 | n.lineTo(a.x + s, a.y); 1717 | n.lineTo(a.x + s, a.y + o); 1718 | n.lineTo(a.x, a.y + o); 1719 | n.lineTo(a.x, a.y); 1720 | n.closePath(); 1721 | n.fillStyle = 'rgba(243, 241, 189, 0.7)'; 1722 | n.fill(); 1723 | n.lineCap = 'butt'; 1724 | n.lineWidth = 1; 1725 | n.strokeStyle = 'rgba(243, 241, 189, 0.9)'; 1726 | n.stroke(); 1727 | }; 1728 | e.prototype.drawTarget = function (t, e) { 1729 | var r = t.$getOriginalBounds(); 1730 | var i = r.width, 1731 | s = r.height; 1732 | var o = t.localToGlobal(r.x, r.y), 1733 | a = t.localToGlobal(r.x + i, r.y), 1734 | h = t.localToGlobal(r.x + i, r.y + s), 1735 | l = t.localToGlobal(r.x, r.y + s); 1736 | var c = n[e]; 1737 | var u = this.shape.graphics; 1738 | u.moveTo(o.x - 0.5, o.y - 0.5); 1739 | u.beginPath(); 1740 | u.lineTo(a.x - 0.5, a.y - 0.5); 1741 | u.lineTo(h.x - 0.5, h.y - 0.5); 1742 | u.lineTo(l.x - 0.5, l.y - 0.5); 1743 | u.lineTo(o.x - 0.5, o.y - 0.5); 1744 | u.closePath(); 1745 | u.fillStyle = c[0]; 1746 | u.fill(); 1747 | u.lineCap = 'butt'; 1748 | u.lineWidth = 1; 1749 | u.strokeStyle = c[1]; 1750 | u.stroke(); 1751 | }; 1752 | return e; 1753 | })(lark.Sprite); 1754 | e.MetricMask = s; 1755 | var o = (function (t) { 1756 | __extends(e, t); 1757 | function e() { 1758 | t.apply(this, arguments); 1759 | this.tick = 0; 1760 | this.lastTime = 0; 1761 | } 1762 | e.prototype.run = function () { 1763 | lark.startTick(this.update, this); 1764 | }; 1765 | e.prototype.stop = function () { 1766 | lark.stopTick(this.update, this); 1767 | this.removeAllEvents(); 1768 | }; 1769 | e.prototype.update = function (t) { 1770 | this.tick++; 1771 | if (t - this.lastTime >= e.maxDeltaTime) { 1772 | var r = Math.floor((this.tick * 1e3) / (t - this.lastTime)); 1773 | this.trigger('fps', r); 1774 | this.lastTime = t; 1775 | this.tick = 0; 1776 | } 1777 | return false; 1778 | }; 1779 | e.instance = null; 1780 | e.maxDeltaTime = 500; 1781 | return e; 1782 | })(t.devtool.EventBase); 1783 | e.LarkProfiler = o; 1784 | })((e = t.devtool || (t.devtool = {}))); 1785 | })(egret || (egret = {})); 1786 | var a = [1, 2, 3]; 1787 | Object.defineProperty(Array.prototype, 'toAllString', { 1788 | value: function () { 1789 | return ''; 1790 | }, 1791 | }); 1792 | var __extends = 1793 | (this && this.__extends) || 1794 | function (t, e) { 1795 | for (var r in e) if (e.hasOwnProperty(r)) t[r] = e[r]; 1796 | function i() { 1797 | this.constructor = t; 1798 | } 1799 | t.prototype = 1800 | e === null ? Object.create(e) : ((i.prototype = e.prototype), new i()); 1801 | }; 1802 | var egret; 1803 | (function (t) { 1804 | var e; 1805 | (function (e) { 1806 | window['egret'] = window['egret'] || {}; 1807 | if (!t.Sprite) { 1808 | t['Sprite'] = function () {}; 1809 | } 1810 | function r(e, r, i) { 1811 | Object.defineProperty(e, r, { 1812 | get: function () { 1813 | return i; 1814 | }, 1815 | set: function (i) { 1816 | console.error('属性是只读的:', t.getQualifiedClassName(e), r); 1817 | }, 1818 | enumerable: true, 1819 | configurable: true, 1820 | }); 1821 | } 1822 | var i = (function (i) { 1823 | __extends(s, i); 1824 | function s() { 1825 | i.apply(this, arguments); 1826 | this.mask = new a(); 1827 | this._preventTouch = false; 1828 | } 1829 | s.prototype.attach = function (t) { 1830 | var e = this; 1831 | this.stage = t; 1832 | var i = t.getChildByName('$LarkMetricMask'); 1833 | if (i) { 1834 | t.removeChild(i); 1835 | } 1836 | t.addChild(this.mask); 1837 | this.addListeners(); 1838 | this.profiler = h.instance || new h(); 1839 | h.instance = this.profiler; 1840 | this.profiler.removeAllEvents(); 1841 | this.profiler.run(t); 1842 | this.profiler.on('fps', function (t) { 1843 | return e.trigger('fps', t); 1844 | }); 1845 | r(t, 'alpha', 1); 1846 | r(t, 'visible', true); 1847 | r(t, 'x', 0); 1848 | r(t, 'y', 0); 1849 | r(t, 'scaleX', 1); 1850 | r(t, 'scaleY', 1); 1851 | r(t, 'rotation', 0); 1852 | r(t, 'cacheAsBitmap', false); 1853 | r(t, 'scrollRect', null); 1854 | r(t, 'filters', null); 1855 | r(t, 'blendMode', null); 1856 | r(t, 'touchEnabled', true); 1857 | r(t, 'matrix', null); 1858 | }; 1859 | s.prototype.detach = function () { 1860 | this.stage.removeChild(this.mask); 1861 | this.profiler.stop(); 1862 | this.removeListeners(); 1863 | }; 1864 | s.prototype.addListeners = function () { 1865 | this.removeListeners(); 1866 | this.stage.addEventListener( 1867 | t.TouchEvent.TOUCH_BEGIN, 1868 | this.touchHandler, 1869 | this, 1870 | true, 1871 | 9999 1872 | ); 1873 | this.stage.addEventListener( 1874 | t.TouchEvent.TOUCH_END, 1875 | this.touchHandler, 1876 | this, 1877 | true, 1878 | 9999 1879 | ); 1880 | this.stage.addEventListener( 1881 | t.TouchEvent.TOUCH_MOVE, 1882 | this.touchHandler, 1883 | this, 1884 | true, 1885 | 9999 1886 | ); 1887 | this.stage.addEventListener( 1888 | t.TouchEvent.TOUCH_TAP, 1889 | this.touchHandler, 1890 | this, 1891 | true, 1892 | 9999 1893 | ); 1894 | this.stage.addEventListener( 1895 | t.Event.ENTER_FRAME, 1896 | this.enterFrameHandler, 1897 | this, 1898 | false, 1899 | 9999 1900 | ); 1901 | }; 1902 | s.prototype.removeListeners = function () { 1903 | this.stage.removeEventListener( 1904 | t.TouchEvent.TOUCH_BEGIN, 1905 | this.touchHandler, 1906 | this, 1907 | true 1908 | ); 1909 | this.stage.removeEventListener( 1910 | t.TouchEvent.TOUCH_END, 1911 | this.touchHandler, 1912 | this, 1913 | true 1914 | ); 1915 | this.stage.removeEventListener( 1916 | t.TouchEvent.TOUCH_MOVE, 1917 | this.touchHandler, 1918 | this, 1919 | true 1920 | ); 1921 | this.stage.removeEventListener( 1922 | t.TouchEvent.TOUCH_TAP, 1923 | this.touchHandler, 1924 | this, 1925 | true 1926 | ); 1927 | this.stage.removeEventListener( 1928 | t.Event.ENTER_FRAME, 1929 | this.enterFrameHandler, 1930 | this, 1931 | false 1932 | ); 1933 | }; 1934 | s.prototype.show = function (t, r) { 1935 | if (r === void 0) { 1936 | r = e.TartgetType.hover; 1937 | } 1938 | var i = t; 1939 | this.mask.setTarget(i, r); 1940 | if (r == e.TartgetType.active) this.trigger('selected', t); 1941 | }; 1942 | s.prototype.getLastSelected = function () { 1943 | return this.mask.targets[e.TartgetType.active]; 1944 | }; 1945 | s.prototype.highlightType = function (t, e) { 1946 | if (e === void 0) { 1947 | e = true; 1948 | } 1949 | e = !!e; 1950 | this.mask.highlight[t] = e; 1951 | if (!e) this.mask.setTarget(null, t); 1952 | this.confirmListeners(); 1953 | }; 1954 | s.prototype.preventTouch = function (t) { 1955 | this._preventTouch = t; 1956 | this.confirmListeners(); 1957 | }; 1958 | s.prototype.confirmListeners = function () { 1959 | if ( 1960 | this.mask.highlight[e.TartgetType.active] || 1961 | this.mask.highlight[e.TartgetType.hover] || 1962 | this._preventTouch 1963 | ) 1964 | this.addListeners(); 1965 | else this.removeListeners(); 1966 | }; 1967 | s.prototype.touchHandler = function (r) { 1968 | if (this._preventTouch) { 1969 | r.preventDefault(); 1970 | r.stopImmediatePropagation(); 1971 | r.stopPropagation(); 1972 | } 1973 | var i = r.target; 1974 | var s = n(this.stage, r.stageX, r.stageY); 1975 | if (s) i = s; 1976 | if (r.type == t.TouchEvent.TOUCH_BEGIN) { 1977 | this.mask.setTarget(i, e.TartgetType.active); 1978 | this.trigger('selected', i); 1979 | } 1980 | if (r.type == t.TouchEvent.TOUCH_MOVE) { 1981 | this.mask.setTarget(i, e.TartgetType.hover); 1982 | } 1983 | }; 1984 | s.prototype.enterFrameHandler = function () { 1985 | this.mask.drawTargets(); 1986 | }; 1987 | return s; 1988 | })(e.EventBase); 1989 | e.Egret2xInspector = i; 1990 | function n(t, e, r) { 1991 | if (!t.visible) { 1992 | return null; 1993 | } 1994 | var i = t.$getInvertedConcatenatedMatrix(); 1995 | var s = i.a * e + i.c * r + i.tx; 1996 | var o = i.b * e + i.d * r + i.ty; 1997 | var a = t.$scrollRect ? t.$scrollRect : t.$maskRect; 1998 | if (a && !a.contains(s, o)) { 1999 | return null; 2000 | } 2001 | if (this.$mask && !t.$mask.$hitTest(e, r)) { 2002 | return null; 2003 | } 2004 | var h = t.$children; 2005 | var l = false; 2006 | if (h) { 2007 | for (var c = h.length - 1; c >= 0; c--) { 2008 | var u = h[c]; 2009 | if (u.$maskedObject) { 2010 | continue; 2011 | } 2012 | var d = n(u, e, r); 2013 | if (d && d.ispTouchThrough !== true) { 2014 | l = true; 2015 | break; 2016 | } 2017 | } 2018 | } 2019 | if (d) { 2020 | return d; 2021 | } 2022 | if (l) { 2023 | return t; 2024 | } 2025 | return t.$hitTest(e, r); 2026 | } 2027 | function s(t, e, r) { 2028 | if (r === void 0) { 2029 | r = false; 2030 | } 2031 | if (this.$children && !r) return n(this, t, e); 2032 | if (!this.$renderRegion || !this.$visible) { 2033 | return null; 2034 | } 2035 | var i = this.$getInvertedConcatenatedMatrix(); 2036 | var s = this.$getContentBounds(); 2037 | var o = i.a * t + i.c * e + i.tx; 2038 | var a = i.b * t + i.d * e + i.ty; 2039 | if (s.contains(o, a)) { 2040 | if (!this.$children) { 2041 | var h = this.$scrollRect ? this.$scrollRect : this.$maskRect; 2042 | if (h && !h.contains(o, a)) { 2043 | return null; 2044 | } 2045 | if (this.$mask && !this.$mask.$hitTest(t, e)) { 2046 | return null; 2047 | } 2048 | } 2049 | return this; 2050 | } 2051 | return null; 2052 | } 2053 | var o = { 0: [51200, 51200], 1: [150, 150] }; 2054 | var a = (function (r) { 2055 | __extends(i, r); 2056 | function i() { 2057 | r.call(this); 2058 | this.shape = new t.Shape(); 2059 | this.metrics = new t.TextField(); 2060 | this.targets = {}; 2061 | this.highlight = {}; 2062 | this.ispTouchThrough = true; 2063 | this.isFPS = true; 2064 | this.name = '$LarkMetricMask'; 2065 | this.shape.touchEnabled = false; 2066 | this.shape['ispTouchThrough'] = true; 2067 | this.addChild(this.shape); 2068 | this.metrics.fontFamily = 'monospace'; 2069 | this.metrics.size = 12; 2070 | this.metrics.textColor = 3355443; 2071 | this.metrics.touchEnabled = false; 2072 | this.metrics['ispTouchThrough'] = true; 2073 | this.addChild(this.metrics); 2074 | this.touchEnabled = false; 2075 | } 2076 | i.prototype.setTarget = function (t, r) { 2077 | if (r === void 0) { 2078 | r = e.TartgetType.active; 2079 | } 2080 | if (!t) delete this.targets[r]; 2081 | else this.targets[r] = t; 2082 | this.drawTargets(); 2083 | }; 2084 | i.prototype.drawTargets = function () { 2085 | this.metrics.visible = false; 2086 | var t = this.shape.graphics; 2087 | t.clear(); 2088 | var r = false; 2089 | for (var i in this.targets) { 2090 | var n = this.highlight[i] == false; 2091 | if (n) continue; 2092 | this.drawTarget(this.targets[i], i); 2093 | r = true; 2094 | } 2095 | if (r) this.showMetrics(this.targets[e.TartgetType.active]); 2096 | }; 2097 | i.prototype.showMetrics = function (t) { 2098 | if (!t) return; 2099 | this.metrics.visible = true; 2100 | var e = t['$getOriginalBounds'](); 2101 | var r = { x: 0, y: 0 }; 2102 | if (t.scrollRect) { 2103 | r.x = t.scrollRect.x; 2104 | r.y = t.scrollRect.y; 2105 | } 2106 | if (t.mask) { 2107 | r.x = t.mask.x; 2108 | r.y = t.mask.y; 2109 | } 2110 | var i = t.localToGlobal(r.x, r.y).clone(); 2111 | var n = 2112 | 'x:' + 2113 | t.x.toFixed(0) + 2114 | ',y:' + 2115 | t.y.toFixed(0) + 2116 | ',w:' + 2117 | t.width.toFixed(0) + 2118 | ',h:' + 2119 | t.height.toFixed(0); 2120 | i.x = Math.max(i.x, 0); 2121 | i.y = Math.max(i.y - 18, 0); 2122 | this.metrics.x = i.x + 2; 2123 | this.metrics.y = i.y + 2; 2124 | this.metrics.text = n; 2125 | var s = this.shape.graphics; 2126 | var o = this.metrics.textWidth + 4; 2127 | var a = this.metrics.textHeight + 4; 2128 | var h = { x: i.x - 0.5, y: i.y - 0.5 }; 2129 | s.moveTo(h.x, h.y); 2130 | s.lineStyle(1, 15987133, 0.9); 2131 | s.beginFill(15987133, 0.7); 2132 | s.lineTo(h.x + o, h.y); 2133 | s.lineTo(h.x + o, h.y + a); 2134 | s.lineTo(h.x, h.y + a); 2135 | s.lineTo(h.x, h.y); 2136 | s.endFill(); 2137 | }; 2138 | i.prototype.drawTarget = function (t, e) { 2139 | var r = { x: 0, y: 0 }; 2140 | if (t.scrollRect) { 2141 | r.x = t.scrollRect.x; 2142 | r.y = t.scrollRect.y; 2143 | } 2144 | if (t.mask) { 2145 | r.x = t.mask.x; 2146 | r.y = t.mask.y; 2147 | } 2148 | var i = t.width, 2149 | n = t.height; 2150 | var s = t.localToGlobal(r.x, r.y), 2151 | a = t.localToGlobal(r.x + i, r.y), 2152 | h = t.localToGlobal(r.x + i, r.y + n), 2153 | l = t.localToGlobal(r.x, r.y + n); 2154 | var c = o[e]; 2155 | var u = this.shape.graphics; 2156 | u.moveTo(s.x - 0.5, s.y - 0.5); 2157 | u.lineStyle(1, c[0], 0.5); 2158 | u.beginFill(c[0], 0.2); 2159 | u.lineTo(a.x - 0.5, a.y - 0.5); 2160 | u.lineTo(h.x - 0.5, h.y - 0.5); 2161 | u.lineTo(l.x - 0.5, l.y - 0.5); 2162 | u.lineTo(s.x - 0.5, s.y - 0.5); 2163 | u.endFill(); 2164 | }; 2165 | return i; 2166 | })(t.Sprite); 2167 | e.EgretMetricMask = a; 2168 | var h = (function (e) { 2169 | __extends(r, e); 2170 | function r() { 2171 | e.apply(this, arguments); 2172 | this.tick = 0; 2173 | this.lastTime = 0; 2174 | } 2175 | r.prototype.run = function (e) { 2176 | e.addEventListener(t.Event.ENTER_FRAME, this.update, this); 2177 | this.stage = e; 2178 | }; 2179 | r.prototype.stop = function () { 2180 | this.stage = null; 2181 | this.stage.removeEventListener(t.Event.ENTER_FRAME, this.update, this); 2182 | this.removeAllEvents(); 2183 | }; 2184 | r.prototype.update = function () { 2185 | var t = Date.now(); 2186 | this.tick++; 2187 | if (t - this.lastTime >= r.maxDeltaTime) { 2188 | var e = Math.floor((this.tick * 1e3) / (t - this.lastTime)); 2189 | this.trigger('fps', e); 2190 | this.lastTime = t; 2191 | this.tick = 0; 2192 | } 2193 | return false; 2194 | }; 2195 | r.instance = null; 2196 | r.maxDeltaTime = 500; 2197 | return r; 2198 | })(t.devtool.EventBase); 2199 | e.Egret2xProfiler = h; 2200 | })((e = t.devtool || (t.devtool = {}))); 2201 | })(egret || (egret = {})); 2202 | var currentStage; 2203 | var currentInspector; 2204 | var egret; 2205 | (function (egret) { 2206 | var devtool; 2207 | (function (devtool) { 2208 | var rootDiv; 2209 | var Main = (function () { 2210 | function Main() { 2211 | var t = this; 2212 | this.tree = null; 2213 | this.showMethods = false; 2214 | this.showPrivate = true; 2215 | this.treeDirtyCache = new devtool.TreeDirtyCache(); 2216 | this.linkAndShow = function (e) { 2217 | var r = null; 2218 | if (devtool.TreeNode.isLinked(e) == false) { 2219 | r = devtool.TreeNode.linkToIt(e); 2220 | } 2221 | t.showItInTree(e.hashCode, r); 2222 | }; 2223 | this.search = function (e, r) { 2224 | if (!e.option) return; 2225 | var i = e.option.name; 2226 | var n = e.option.current; 2227 | var s = devtool.DisplayObjectLocator.find( 2228 | i, 2229 | egret.MainContext.instance.stage 2230 | ); 2231 | if (s == null || s.length == 0) { 2232 | r([]); 2233 | return; 2234 | } 2235 | var o = null; 2236 | if (n) { 2237 | var a = 0; 2238 | while (a < s.length) { 2239 | if (s[a].hashCode == n) break; 2240 | a++; 2241 | } 2242 | a++; 2243 | if (a >= s.length) { 2244 | a = 0; 2245 | } 2246 | o = s[a]; 2247 | } else o = s[0]; 2248 | t.linkAndShow(o); 2249 | t.showTreeSelection(o.hashCode); 2250 | r({ 2251 | current: o.hashCode, 2252 | results: s.map(function (t) { 2253 | return t.hashCode; 2254 | }), 2255 | }); 2256 | }; 2257 | } 2258 | Main.prototype.init = function () { 2259 | var _this = this; 2260 | window.setTimeout(function () { 2261 | return _this.refresh(); 2262 | }, 200); 2263 | var isp = currentInspector; 2264 | isp.removeAllEvents(); 2265 | isp.on('selected', this.linkAndShow).on('fps', function (t) { 2266 | _this.port.post({ name: 'fps', data: t }); 2267 | }); 2268 | var port = this.port; 2269 | isp.preventTouch(Main.preventTouch); 2270 | port.removeAll(); 2271 | port.on('showTreeSelection', function (t) { 2272 | return _this.showTreeSelection(t.data, t.isHover); 2273 | }); 2274 | port.on('preventTouch', function (t) { 2275 | var e = t.data; 2276 | Main.preventTouch = e; 2277 | _this.preventTouch(e); 2278 | }); 2279 | port.on('highlightHover', function (t) { 2280 | isp.highlightType(devtool.TartgetType.hover, t.data); 2281 | }); 2282 | port.on('highlightClick', function (t) { 2283 | isp.highlightType(devtool.TartgetType.active, t.data); 2284 | }); 2285 | port.on('showMethodsChanged', function (t) { 2286 | _this.showMethods = t.showMethods; 2287 | t.hash && _this.showItInTree(t.hash); 2288 | }); 2289 | port.on('showPrivateChanged', function (t) { 2290 | _this.showPrivate = t.showPrivate; 2291 | t.hash && _this.showItInTree(t.hash); 2292 | }); 2293 | port.on('initOptions', function (t) { 2294 | isp.highlightType(devtool.TartgetType.hover, t.highlightHover); 2295 | isp.highlightType(devtool.TartgetType.active, t.highlightClick); 2296 | Main.preventTouch = t.preventTouch; 2297 | _this.preventTouch(t.preventTouch); 2298 | _this.showMethods = t.showMethods; 2299 | _this.showPrivate = t.showPrivate; 2300 | }); 2301 | port.on('init', function (t) { 2302 | _this.refresh(); 2303 | }); 2304 | port.on('expand', function (msg, callback) { 2305 | if (devtool.TreeNode.getByHash(msg.hash) == null) { 2306 | console.log('该显示对象已经不存在,请刷新显示列表'); 2307 | return; 2308 | } 2309 | var it = devtool.TreeNode.getByHash(msg.hash).raw; 2310 | var expression = msg.expression; 2311 | var value = eval('it' + expression); 2312 | var tree = devtool.TreeNode.parseRawProps( 2313 | value, 2314 | 0, 2315 | new devtool.TreeNode(), 2316 | { showMethods: _this.showMethods, showPrivate: _this.showPrivate } 2317 | ); 2318 | callback(tree); 2319 | }); 2320 | var propIdx = 0; 2321 | port.on('store', function (msg) { 2322 | if (devtool.TreeNode.getByHash(msg.hashCode) == null) { 2323 | console.log('该显示对象已经不存在,请刷新显示列表'); 2324 | return; 2325 | } 2326 | var value = devtool.TreeNode.getByHash(msg.hashCode).raw; 2327 | var varName = 'obj' + msg.hashCode; 2328 | if (msg.expression) { 2329 | value = eval('value' + msg.expression); 2330 | varName = 'prop' + propIdx++; 2331 | } 2332 | window[varName] = value; 2333 | console.log(varName); 2334 | console.log(value); 2335 | }); 2336 | port.on('applyChange', function (msg, callback) { 2337 | var node = devtool.TreeNode.getByHash(msg.hash); 2338 | if (!node) { 2339 | callback({ success: false }); 2340 | return; 2341 | } 2342 | var it = node.raw; 2343 | var expression = msg.expression, 2344 | exps = msg.expressions || {}; 2345 | var result = {}; 2346 | var applyChange = function (exp, value, it) { 2347 | if (!exp) return undefined; 2348 | eval('it' + exp + "=eval('(" + value + ")')"); 2349 | return eval('it' + exp); 2350 | }; 2351 | try { 2352 | if (expression) result = applyChange(expression, msg.value, it); 2353 | for (var exp in exps) { 2354 | result[exp] = applyChange(exp, exps[exp], it); 2355 | } 2356 | if (result == NaN) result = 'NaN'; 2357 | window.setTimeout(function () { 2358 | return callback({ success: true, result: result }); 2359 | }, 20); 2360 | } catch (e) { 2361 | console.log(e.stack); 2362 | callback({ success: false }); 2363 | } 2364 | }); 2365 | port.on('expandTree', function (t, e) { 2366 | var r = devtool.TreeNode.getByHash(t.hashCode); 2367 | r.parseChildren(); 2368 | e(r); 2369 | }); 2370 | port.on('refresh', function (t, e) { 2371 | devtool.TreeNode.clear(); 2372 | var r = isp.getLastSelected(); 2373 | if (!r || !r.stage) { 2374 | r = currentStage || lark_stages[0]; 2375 | } 2376 | var i = devtool.TreeNode.linkToIt(r); 2377 | e({ tree: i, hash: r.hashCode }); 2378 | _this.showItInTree(r.hashCode); 2379 | }); 2380 | port.on('refreshProp', function (t) { 2381 | _this.showItInTree(t.hash, null); 2382 | }); 2383 | port.on('search', this.search); 2384 | return this; 2385 | }; 2386 | Main.prototype.refresh = function () { 2387 | devtool.TreeNode.clear(); 2388 | var t = currentStage; 2389 | this.tree = devtool.TreeNode.parseNode( 2390 | t, 2391 | new devtool.TreeNode(), 2392 | true, 2393 | 2 2394 | ); 2395 | this.tree.showChildren(); 2396 | this.transTreeToPanel(); 2397 | this.showItInTree(t.hashCode); 2398 | }; 2399 | Main.prototype.transTreeToPanel = function (t) { 2400 | if (t === void 0) { 2401 | t = this.tree; 2402 | } 2403 | this.port.post({ name: 'updateTree', data: this.tree }); 2404 | }; 2405 | Main.prototype.showItInTree = function (t, e) { 2406 | if (e === void 0) { 2407 | e = null; 2408 | } 2409 | var r = devtool.TreeNode.getByHash(t); 2410 | if (!r) return; 2411 | var i = r.parseRawProps(0, new devtool.TreeNode(), { 2412 | showPrivate: this.showPrivate, 2413 | showMethods: this.showMethods, 2414 | }); 2415 | this.transGameSelection(r.rawHash, i, e); 2416 | }; 2417 | Main.prototype.transGameSelection = function (t, e, r) { 2418 | if (r === void 0) { 2419 | r = null; 2420 | } 2421 | this.port.post({ 2422 | name: 'updateSelection', 2423 | data: { hash: t, props: e, treeChange: r }, 2424 | }); 2425 | }; 2426 | Main.prototype.showTreeSelection = function (t, e) { 2427 | if (e === void 0) { 2428 | e = false; 2429 | } 2430 | var r = devtool.TreeNode.getByHash(t); 2431 | r && 2432 | currentInspector.show( 2433 | r.raw, 2434 | e ? devtool.TartgetType.hover : devtool.TartgetType.active 2435 | ); 2436 | }; 2437 | Main.prototype.preventTouch = function (t) { 2438 | currentInspector.preventTouch(t); 2439 | }; 2440 | Main.preventTouch = false; 2441 | Main.instance = null; 2442 | return Main; 2443 | })(); 2444 | devtool.Main = Main; 2445 | function start() { 2446 | var t = function (t) { 2447 | t.post({ name: 'init', from: 'stage', href: location.href }); 2448 | t.post({ name: 'ready' }); 2449 | Main.instance.port = t; 2450 | Main.instance.init(); 2451 | }; 2452 | var e = function () { 2453 | Main.instance = new Main(); 2454 | if (stagePort) { 2455 | t(stagePort); 2456 | } else { 2457 | var e = devtool.PortFactory.getStagePortClass(); 2458 | stagePort = new e(location.host, function () { 2459 | t(port); 2460 | }); 2461 | } 2462 | }; 2463 | function r() { 2464 | var t = document.querySelector('.egret-player'); 2465 | if (!t) return null; 2466 | if (!t['egret-player']) { 2467 | return null; 2468 | } 2469 | return t['egret-player'].stage; 2470 | } 2471 | function i() { 2472 | return ( 2473 | egret.MainContext && 2474 | egret.MainContext.instance && 2475 | egret.MainContext.instance.stage 2476 | ); 2477 | } 2478 | var n = r(); 2479 | var s = i(); 2480 | if (n || s) { 2481 | if (egret.devtool.Inspector.instance) return; 2482 | if (n) { 2483 | currentStage = n; 2484 | currentInspector = new devtool.Egret2xInspector(); 2485 | currentInspector.attach(currentStage); 2486 | } else { 2487 | currentStage = s; 2488 | egret.devtool.Inspector.attach(currentStage); 2489 | currentInspector = egret.devtool.Inspector.instance; 2490 | } 2491 | e(); 2492 | } else if (window['lark_stages'] && lark_stages.length) { 2493 | currentStage = lark_stages[0]; 2494 | currentInspector = new devtool.LarkInspector(); 2495 | currentInspector.attach(currentStage); 2496 | e(); 2497 | } else { 2498 | window.setTimeout(start, 200); 2499 | } 2500 | } 2501 | devtool.start = start; 2502 | function reset() { 2503 | if (Main.instance) { 2504 | Main.instance.tree.reset(); 2505 | currentInspector.detach(currentStage); 2506 | console.log('remove listeners'); 2507 | stagePort.removeAll(); 2508 | } 2509 | } 2510 | devtool.reset = reset; 2511 | function pause() {} 2512 | devtool.pause = pause; 2513 | function resume() {} 2514 | devtool.resume = resume; 2515 | var stagePort = null; 2516 | function ping() { 2517 | var t = devtool.PortFactory.getStagePortClass(); 2518 | stagePort = new t(location.host, function () { 2519 | stagePort.post({ name: 'isDevToolOpen' }, null, function (t) { 2520 | if (t) { 2521 | start(); 2522 | } 2523 | }); 2524 | }); 2525 | } 2526 | devtool.ping = ping; 2527 | ping(); 2528 | })((devtool = egret.devtool || (egret.devtool = {}))); 2529 | })(egret || (egret = {})); 2530 | --------------------------------------------------------------------------------