| 173 | }) |
| 174 | |
| 175 | var setUpBackboneMediator = function (app) { |
| 176 | let schemas |
| 177 | for (const definition in definitionSchemas) { schemas = definitionSchemas[definition]; Backbone.Mediator.addDefSchemas(schemas) } |
| 178 | for (const channel in channelSchemas) { schemas = channelSchemas[channel]; Backbone.Mediator.addChannelSchemas(schemas) } |
| 179 | // Major performance bottleneck if it is true in production |
| 180 | Backbone.Mediator.setValidationEnabled(!app.isProduction()) |
| 181 | |
| 182 | if (window.location.hostname === 'localhost') { |
| 183 | if ((window.sessionStorage != null ? window.sessionStorage.getItem('COCO_DEBUG_LOGGING') : undefined) === '1') { |
| 184 | const unwantedEventsRegex = new RegExp('tick|mouse-moved|mouse-over|mouse-out|hover-line|check-away|new-thang-added|zoom-updated|away-back') |
| 185 | const unwantedStackRegex = new RegExp('eval|debounce|defer|delay|Backbone|Idle') |
| 186 | const originalPublish = Backbone.Mediator.publish |
| 187 | return Backbone.Mediator.publish = function () { |
| 188 | if (!unwantedEventsRegex.test(arguments[0])) { |
| 189 | try { |
| 190 | const splitStack = (new Error()).stack.split('\n').slice(1) |
| 191 | const maxDepth = 5 |
| 192 | for (let i = 0; i < splitStack.length; i++) { |
| 193 | const s = splitStack[i] |
| 194 | if (i > maxDepth) { break } |
| 195 | let filteredStack = s.trim().replace(/at\ |prototype|module|exports/gi, '').replace('..', '') |
| 196 | filteredStack = filteredStack.split('(webpack-internal')[0] |
| 197 | if (!unwantedStackRegex.test(filteredStack)) { |
| 198 | console.log(`>>> ${filteredStack}->`, ...arguments) |
| 199 | break |
| 200 | } |
| 201 | } |
| 202 | } catch (error) { |
| 203 | console.log('>>> ? -> ', ...arguments) |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | return originalPublish.apply(Backbone.Mediator, arguments) |
| 208 | } |
| 209 | } else { |
| 210 | return console.log("Not logging Backbone events. Turn on by typing this in your browser console: window.sessionStorage.setItem('COCO_DEBUG_LOGGING', 1)") |
| 211 | } |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | var setUpMoment = function () { |
| 216 | const { me } = require('core/auth') |