|
2311 | 2311 | $container.addClass('bg-danger'); |
2312 | 2312 | } |
2313 | 2313 | } |
| 2314 | + $container.trigger('endOutput'); |
2314 | 2315 | }, |
2315 | 2316 | errorNotConsoled: function (logEntry, info) { |
2316 | 2317 | var $container = info.$container; |
|
2560 | 2561 | } |
2561 | 2562 | $node = buildEntryNode(logEntry); |
2562 | 2563 | $node.attr(attribs); |
2563 | | - if (method === 'error') { |
2564 | | - if (meta.trace && meta.trace.length > 1) { |
2565 | | - $node.append( |
2566 | | - $('<ul>', { class: 'list-unstyled no-indent' }).append( |
2567 | | - methods.trace({ |
2568 | | - method: 'trace', |
2569 | | - args: [meta.trace], |
2570 | | - meta: meta |
2571 | | - }).attr('data-detect-files', 'true') |
2572 | | - ) |
2573 | | - ); |
2574 | | - $node.find('.m_trace').debugEnhance(); |
2575 | | - if ($node.is('.error-fatal')) { |
2576 | | - this.endOutput(logEntry, info); |
2577 | | - } |
2578 | | - } else if (meta.context) { |
2579 | | - console.log('context', meta.context); |
2580 | | - $node.append( |
2581 | | - buildContext(meta.context, meta.line) |
2582 | | - ); |
| 2564 | + if (meta.trace && meta.trace.length > 1) { |
| 2565 | + $node.append( |
| 2566 | + $('<ul>', { class: 'list-unstyled no-indent' }).append( |
| 2567 | + methods.trace({ |
| 2568 | + method: 'trace', |
| 2569 | + args: [meta.trace], |
| 2570 | + meta: meta |
| 2571 | + }).attr('data-detect-files', 'true') |
| 2572 | + ) |
| 2573 | + ); |
| 2574 | + $node.find('.m_trace').debugEnhance(); |
| 2575 | + if ($node.is('.error-fatal')) { |
| 2576 | + this.endOutput(logEntry, info); |
2583 | 2577 | } |
| 2578 | + } else if (meta.context) { |
| 2579 | + console.log('context', meta.context); |
| 2580 | + $node.append( |
| 2581 | + buildContext(meta.context, meta.line) |
| 2582 | + ); |
2584 | 2583 | } |
2585 | 2584 | return $node |
2586 | 2585 | } |
|
2881 | 2880 | $node.attr('data-detect-files', meta.detectFiles); |
2882 | 2881 | $node.attr('data-found-files', meta.foundFiles ? meta.foundFiles : []); |
2883 | 2882 | } |
| 2883 | + $node.closest('.m_group.empty').removeClass('empty').trigger('updated.debug.group'); |
2884 | 2884 | if ($node.is(':visible:not(.filter-hidden)')) { |
2885 | 2885 | $node.debugEnhance(); |
2886 | 2886 | } |
2887 | | - $node.closest('.m_group').removeClass('empty'); |
2888 | 2887 | } catch (err) { |
2889 | 2888 | console.warn('Logger.processEntry error', err); |
2890 | 2889 | console.log('logEntry', logEntry); |
2891 | | - /* |
2892 | | - processEntry({ |
2893 | | - method: 'error', |
2894 | | - args: [ |
2895 | | - '%cDebugWampClient: %cerror processing %c' + method + '()', |
2896 | | - 'font-weight:bold;', |
2897 | | - '', |
2898 | | - 'font-family:monospace;' |
2899 | | - ], |
2900 | | - meta: meta |
2901 | | - }) |
2902 | | - */ |
2903 | 2890 | } |
2904 | 2891 | } |
2905 | 2892 |
|
|
3214 | 3201 |
|
3215 | 3202 | function Xdebug(pubSub) { |
3216 | 3203 | var self = this; |
3217 | | - console.warn('Xdebug init'); |
| 3204 | + var $root = $('#debug-cards'); |
3218 | 3205 | this.pubSub = pubSub; |
3219 | | - $('body').on('click', '.xdebug-commands .btn[data-cmd]', function () { |
| 3206 | + this.contextMsgReceived = null; |
| 3207 | + this.contextTimer = null; |
| 3208 | + $root.on('click', '.xdebug-commands .btn[data-cmd]', function () { |
3220 | 3209 | var cmd = $(this).data('cmd'); |
3221 | | - console.warn('clicked', cmd); |
3222 | | - self.pubSub.publish('wamp', 'publish', 'bdk.debug.xdebug', [cmd]); |
| 3210 | + var appId = $(this).closest('.card-body').find('.xdebug').data('appId'); |
3223 | 3211 | $(this).blur(); |
| 3212 | + self.sendCmd(appId, cmd); |
3224 | 3213 | }); |
3225 | | - $('body').on('shown.bs.collapse', '.card-body', function (e) { |
| 3214 | + $root.on('click', '.xdebug-menu-bar .btn[data-target]', function () { |
| 3215 | + var $node = $(this).closest('.card-body').find($(this).data('target')); |
| 3216 | + $(this).blur(); |
| 3217 | + self.scrollIntoView($node); |
| 3218 | + }); |
| 3219 | + $root.on('expanded.debug.array expanded.debug.object', '.max-depth', function (e) { |
| 3220 | + var appId = $(this).closest('.card-body').find('.xdebug').data('appId'); |
| 3221 | + // console.log('xdebug expanded .max-depth', this) |
| 3222 | + $(this).find('.array-inner, .object-inner').html( |
| 3223 | + '<i class="fa fa-spinner fa-pulse fa-lg"></i>' |
| 3224 | + ); |
| 3225 | + self.sendCmd( |
| 3226 | + appId, |
| 3227 | + 'property_get', |
| 3228 | + { |
| 3229 | + n: $(this).data('fullname') |
| 3230 | + } |
| 3231 | + ); |
| 3232 | + }); |
| 3233 | + $root.on('shown.bs.collapse', '.card-body', function (e) { |
3226 | 3234 | var $menuBar = $(this).find('.xdebug-menu-bar'); |
3227 | 3235 | self.positionToolbar($menuBar); |
3228 | 3236 | }); |
| 3237 | + $root.on('endOutput', '.card', function (e) { |
| 3238 | + self.remove(this); |
| 3239 | + }); |
3229 | 3240 | } |
3230 | 3241 |
|
| 3242 | + Xdebug.prototype.sendCmd = function (appId, cmd, args, data) { |
| 3243 | + this.pubSub.publish( |
| 3244 | + 'wamp', |
| 3245 | + 'publish', |
| 3246 | + 'bdk.debug.xdebug', |
| 3247 | + [appId, cmd, args, data] |
| 3248 | + ); |
| 3249 | + }; |
| 3250 | + |
3231 | 3251 | Xdebug.prototype.positionToolbar = function($menuBar) { |
3232 | | - console.warn('positionToolbar', $menuBar); |
3233 | 3252 | var $card = $menuBar.closest('.card'); |
3234 | | - console.warn({ |
3235 | | - navbarHeight: $('nav.navbar').outerHeight(), |
3236 | | - cardHeaderOuterHeight: $card.find('> .card-header').outerHeight(), |
3237 | | - debugMenuBarOuterHeight: $card.find('> .card-body > .debug-menu-bar').outerHeight() |
3238 | | - }); |
3239 | 3253 | $menuBar.css('top', |
3240 | 3254 | ( |
3241 | 3255 | $('nav.navbar').outerHeight() + |
|
3246 | 3260 | }; |
3247 | 3261 |
|
3248 | 3262 | Xdebug.prototype.processEntry = function (logEntry) { |
3249 | | - console.log('Xdebug.processEntry', JSON.parse(JSON.stringify(logEntry))); |
3250 | | - var info = this.getNodeInfo(); |
3251 | 3263 | var method = logEntry.method; |
3252 | 3264 | var meta = logEntry.meta; |
| 3265 | + var nodeInfo = this.getNodeInfo(meta.appId); |
3253 | 3266 | var $node; |
| 3267 | + var $node2; |
| 3268 | + var self = this; |
| 3269 | + // console.log('Xdebug.processEntry', JSON.parse(JSON.stringify(logEntry))) |
3254 | 3270 | try { |
3255 | | - if (methods[method]) { |
3256 | | - $node = methods[method](logEntry, info); |
3257 | | - } else { |
3258 | | - $node = methods.default(logEntry, info); |
3259 | | - } |
| 3271 | + if (meta.status === 'break') { |
| 3272 | + // console.info('received break') |
| 3273 | + this.contextMsgReceived = null; |
| 3274 | + this.contextTimer = setTimeout(function () { |
| 3275 | + if (self.contextMsgReceived === null) { |
| 3276 | + // console.warn('received break status, but no context') |
| 3277 | + // get globals |
| 3278 | + self.sendCmd( |
| 3279 | + meta.appId, |
| 3280 | + 'context_get', |
| 3281 | + { c: 1 } |
| 3282 | + ); |
| 3283 | + // get local |
| 3284 | + self.sendCmd( |
| 3285 | + meta.appId, |
| 3286 | + 'context_get', |
| 3287 | + { c: 0 } |
| 3288 | + ); |
| 3289 | + } |
| 3290 | + }, 250); |
| 3291 | + } else if (meta.command === 'context_get') { |
| 3292 | + this.contextMsgReceived = logEntry; |
| 3293 | + clearTimeout(self.contextTimer); |
| 3294 | + } |
| 3295 | + if (method === 'xdebug') { |
| 3296 | + // if (meta.status === 'stopping') { |
| 3297 | + // } |
| 3298 | + if (['property_get', 'property_value'].indexOf(meta.command) > -1) { |
| 3299 | + $node = methods.default(logEntry, nodeInfo).find('> *'); // array = span, object = div |
| 3300 | + // find open .max-depth where data-fullname = meta.fullname |
| 3301 | + $node2 = nodeInfo.$node.find('.max-depth.expanded').filter(function (i, nodeTemp) { |
| 3302 | + return $(nodeTemp).data('fullname') === meta.fullname |
| 3303 | + }); |
| 3304 | + $node2.replaceWith($node); |
| 3305 | + $node.debugEnhance().debugEnhance('expand'); |
| 3306 | + } |
| 3307 | + return |
| 3308 | + } |
| 3309 | + $node = methods[method] |
| 3310 | + ? methods[method](logEntry, nodeInfo) |
| 3311 | + : methods.default(logEntry, nodeInfo); |
3260 | 3312 | if (!$node) { |
3261 | 3313 | return |
3262 | 3314 | } |
| 3315 | + if (meta.status === 'break') { |
| 3316 | + nodeInfo.$node.html('<li class="m_info" style="display:block; margin: 8px -10px; border-bottom: solid 1px; font-weight:bold;">Xdebug</li>'); |
| 3317 | + self.scrollIntoView(nodeInfo.$node); |
| 3318 | + } |
3263 | 3319 | if (meta.detectFiles) { |
3264 | 3320 | // using attr so can find via css selector |
3265 | 3321 | $node.attr('data-detect-files', meta.detectFiles); |
3266 | 3322 | $node.attr('data-found-files', meta.foundFiles ? meta.foundFiles : []); |
3267 | 3323 | } |
3268 | | - info.$node.append($node); |
| 3324 | + nodeInfo.$node.append($node); |
| 3325 | + $node.debugEnhance(); |
3269 | 3326 | } catch (err) { |
3270 | | - console.warn('Xdebug.processEntry error', err); |
3271 | | - console.log('logEntry', logEntry); |
| 3327 | + console.warn('Xdebug.processEntry error', err, logEntry); |
3272 | 3328 | } |
3273 | 3329 | }; |
3274 | 3330 |
|
3275 | | - Xdebug.prototype.getNodeInfo = function () { |
| 3331 | + Xdebug.prototype.getNodeInfo = function (appId) { |
3276 | 3332 | var id = 'xdebug'; |
3277 | 3333 | // var $container = $('#' + id) |
3278 | 3334 | var $container = $('#debug-cards .card.working').filter(function () { |
3279 | | - var data = $(this).data(); |
3280 | | - console.warn('data', data); |
3281 | | - return true |
| 3335 | + var dataCard = $(this).data() || {}; |
| 3336 | + var dataXdebug = $(this).find('.xdebug').data() || {}; |
| 3337 | + if (dataXdebug.appId === appId) { |
| 3338 | + // xdebug appId match |
| 3339 | + return true |
| 3340 | + } |
| 3341 | + if (dataCard.meta.processId == appId) { |
| 3342 | + // card processId match |
| 3343 | + return true |
| 3344 | + } |
| 3345 | + return false |
3282 | 3346 | }).last(); |
3283 | 3347 | var info = {}; |
3284 | 3348 | var channelNameRoot = 'general'; |
|
3328 | 3392 | if ($xdebug.length === 0) { |
3329 | 3393 | $menuBar = $('' + |
3330 | 3394 | '<header class="debug-bar xdebug-menu-bar">' + |
3331 | | - '<div class="btn-group xdebug-commands" role="group" aria-label="Xdebug Commands">' + |
3332 | | - '<button type="button" class="btn btn-secondary" data-cmd="run" title="Run"><i class="fa fa-play"></i></button>' + |
3333 | | - '<button type="button" class="btn btn-secondary" data-cmd="step_into" title="Step Into"><img src="?action=img&src=icon/step_into.svg" style="width:18px; height:18px;" /></button>' + |
3334 | | - '<button type="button" class="btn btn-secondary" data-cmd="step_over" title="Step Over"><img src="?action=img&src=icon/step_over.svg" style="width:18px; height:18px;" /></button>' + |
3335 | | - '<button type="button" class="btn btn-secondary" data-cmd="step_out" title="Step Out"><img src="?action=img&src=icon/step_out.svg" style="width:18px; height:18px;" /></button>' + |
3336 | | - '<button type="button" class="btn btn-secondary" data-cmd="stop" title="Stop Script"><i class="fa fa-stop"></i></button>' + |
3337 | | - '<button type="button" class="btn btn-secondary" data-cmd="detatch" title="Stop Debugging"><i class="fa fa-sign-out"></i></button>' + |
3338 | | - '</div>' + |
| 3395 | + '<div class="btn-toolbar" role="toolbar" aria-label="Xdebug">' + |
| 3396 | + '<div class="btn-group xdebug-commands mr-2" role="group" aria-label="Xdebug Commands">' + |
| 3397 | + '<button type="button" class="btn btn-secondary" data-cmd="run" title="Run"><i class="fa fa-play"></i></button>' + |
| 3398 | + '<button type="button" class="btn btn-secondary" data-cmd="step_into" title="Step Into"><img src="?action=img&src=icon/step_into.svg" style="width:18px; height:18px;" /></button>' + |
| 3399 | + '<button type="button" class="btn btn-secondary" data-cmd="step_over" title="Step Over"><img src="?action=img&src=icon/step_over.svg" style="width:18px; height:18px;" /></button>' + |
| 3400 | + '<button type="button" class="btn btn-secondary" data-cmd="step_out" title="Step Out"><img src="?action=img&src=icon/step_out.svg" style="width:18px; height:18px;" /></button>' + |
| 3401 | + '<button type="button" class="btn btn-secondary" data-cmd="stop" title="Stop Script"><i class="fa fa-stop"></i></button>' + |
| 3402 | + '<button type="button" class="btn btn-secondary" data-cmd="detatch" title="Stop Debugging"><i class="fa fa-sign-out"></i></button>' + |
| 3403 | + '</div>' + |
| 3404 | + '<div class="btn-group" role="group">' + |
| 3405 | + '<button type="button" class="btn btn-secondary" data-target=".xdebug" title="Jump to Xdebug Info"><i class="fa fa-link"></i></button>' + |
| 3406 | + '</div>' + |
| 3407 | + '</div>' + |
3339 | 3408 | '</header>' |
3340 | 3409 | ); |
3341 | 3410 | $xdebug = $('<ul class="xdebug group-body"></ul>'); |
| 3411 | + $xdebug.data('appId', appId); |
3342 | 3412 | $container.find('.debug > header').after($menuBar); |
3343 | 3413 | $container.find('.tab-primary .tab-body').append($xdebug); |
3344 | 3414 | this.positionToolbar($menuBar); |
3345 | 3415 | } |
3346 | 3416 |
|
3347 | 3417 | info = { |
3348 | 3418 | $container: $container, |
3349 | | - $node: $xdebug |
3350 | | - // $tabPane: null, |
3351 | | - // channelName: channelName, |
3352 | | - // channelNameRoot: channelNameRoot, |
3353 | | - // channelNameTop: channelSplit.shift(), // ie channelName of tab |
3354 | | - // channels: [] |
| 3419 | + $node: $xdebug, |
| 3420 | + $toolbar: $container.find('.xdebug-menu-bar') |
3355 | 3421 | }; |
3356 | 3422 | return info |
3357 | 3423 | }; |
3358 | 3424 |
|
| 3425 | + Xdebug.prototype.remove = function ($container) { |
| 3426 | + $container = $($container); |
| 3427 | + $container.find('.xdebug-menu-bar').remove(); |
| 3428 | + $container.find('.xdebug.group-body').remove(); |
| 3429 | + }; |
| 3430 | + |
| 3431 | + Xdebug.prototype.scrollIntoView = function (node) { |
| 3432 | + var toolbarBottom = $(node).closest('.card-body').find('.xdebug-menu-bar')[0].getBoundingClientRect().bottom; |
| 3433 | + var nodePos; |
| 3434 | + var adjustY; |
| 3435 | + node = $(node)[0]; |
| 3436 | + nodePos = node.getBoundingClientRect(); |
| 3437 | + adjustY = nodePos.top - toolbarBottom; |
| 3438 | + /* |
| 3439 | + console.warn('scrollIntoView', { |
| 3440 | + toolbarBottom: toolbarBottom, |
| 3441 | + nodePosTop: nodePos.top, |
| 3442 | + adjustY: adjustY |
| 3443 | + }) |
| 3444 | + */ |
| 3445 | + window.scrollBy(0, adjustY); |
| 3446 | + }; |
| 3447 | + |
3359 | 3448 | function nameToClassname$1 (name) { |
3360 | 3449 | return 'debug-tab-' + name.toLowerCase().replace(/\W+/g, '-') |
3361 | 3450 | } |
|
0 commit comments