debug: load the source map and print errors in the main process' stdout (add a source map file parser)
This commit is contained in:
parent
c3804d640c
commit
4a606b8109
7 changed files with 25 additions and 548 deletions
|
|
@ -13,6 +13,27 @@ TABS = {}
|
|||
PXSCALE = getComputedStyle(document.documentElement).getPropertyValue("--pixel-scale")
|
||||
INITIALZOOM = PXSCALE
|
||||
|
||||
///////////////////////
|
||||
|
||||
sourceMap = require('./libs/source-map.min.js')
|
||||
|
||||
var request = new XMLHttpRequest()
|
||||
|
||||
request.open('GET', 'scripts.js.map', true)
|
||||
|
||||
request.onload = function() {
|
||||
if (request.status >= 200 && request.status < 400) {
|
||||
var data = JSON.parse(request.responseText),
|
||||
smc = new sourceMap.SourceMapConsumer(data)
|
||||
|
||||
window.onerror = function(error,url,row,col) {
|
||||
var data = smc.originalPositionFor({line:row,column:col})
|
||||
ipc.send('log', `[Renderer process error]\n${error}\nSource: ${data.source} @ line ${data.line}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
request.send()
|
||||
|
||||
///////////////////////
|
||||
|
||||
|
|
|
|||
|
|
@ -1,354 +0,0 @@
|
|||
// jQuery drag event handler
|
||||
// note: triggerHandler() is used instead of trigger() when event bubblig is not
|
||||
// necessary, this increases performances a lot.
|
||||
;(function($){
|
||||
var events = {
|
||||
touch:{start:'touchstart',stop:'touchend touchcancel',move:'touchmove',touch:true},
|
||||
mouse:{start:'mousedown',stop:'mouseup',move:'mousemove',out:'mouseout',touch:false}
|
||||
},
|
||||
|
||||
|
||||
$document = $(document),
|
||||
getOffset = function(obj) {
|
||||
var offsetLeft = 0
|
||||
var offsetTop = 0
|
||||
if (obj) {
|
||||
do {
|
||||
if (!isNaN(obj.offsetLeft)) {
|
||||
offsetLeft += obj.offsetLeft - obj.scrollLeft
|
||||
}
|
||||
if (!isNaN(obj.offsetTop)) {
|
||||
offsetTop += obj.offsetTop - obj.scrollTop
|
||||
}
|
||||
} while(obj = obj.offsetParent )
|
||||
}
|
||||
|
||||
return {left: offsetLeft, top: offsetTop}
|
||||
}
|
||||
|
||||
|
||||
$.event.special.draginit = $.event.special.drag = {
|
||||
setup:function(){
|
||||
|
||||
var $this = $(this)
|
||||
|
||||
if ($this.data('dragSetup')) return
|
||||
$this.data('dragSetup','true')
|
||||
|
||||
|
||||
// mouse single touch handler
|
||||
var previousEvent = null,
|
||||
target = null,
|
||||
traversing = false,
|
||||
mouseStartHandler = function(e){
|
||||
|
||||
// ignore mouse event when fired by a simulated touch event
|
||||
if ((e.originalEvent.sourceCapabilities && e.originalEvent.sourceCapabilities.firesTouchEvents) || e.button == 2) return
|
||||
|
||||
isPointerDown = true
|
||||
target = $this
|
||||
previousEvent = e
|
||||
|
||||
e.speedX = 0
|
||||
e.speedY = 0
|
||||
e.deltaX = 0
|
||||
e.deltaY = 0
|
||||
|
||||
target.triggerHandler('draginit',[e,e.originalEvent.traversing])
|
||||
|
||||
$document.on(events.mouse.move,mouseMoveHandler)
|
||||
$document.on(events.mouse.stop,mouseStopHandler)
|
||||
$document.on(events.mouse.out,mouseOutHandler)
|
||||
|
||||
},
|
||||
mouseMoveHandler = function(e){
|
||||
e.stopPropagation()
|
||||
|
||||
e.speedX = e.pageX - previousEvent.pageX
|
||||
e.speedY = e.pageY - previousEvent.pageY
|
||||
e.deltaX = e.speedX + previousEvent.deltaX
|
||||
e.deltaY = e.speedY + previousEvent.deltaY
|
||||
|
||||
|
||||
if (e.originalEvent.traversing) {
|
||||
target = $(e.target)
|
||||
e.preventDefault()
|
||||
target.triggerHandler('draginit',[e,e.originalEvent.traversing])
|
||||
} else {
|
||||
target.triggerHandler('drag',[e,e.originalEvent.traversing])
|
||||
}
|
||||
|
||||
previousEvent = e
|
||||
},
|
||||
mouseStopHandler = function(e){
|
||||
e.stopPropagation()
|
||||
|
||||
// ignore mouse event when fired by a simulated touch event
|
||||
if (e.originalEvent.sourceCapabilities && e.originalEvent.sourceCapabilities.firesTouchEvents) return
|
||||
|
||||
e.speedX = e.pageX - previousEvent.pageX
|
||||
e.speedY = e.pageY - previousEvent.pageY
|
||||
e.deltaX = e.deltaX + previousEvent.deltaX
|
||||
e.deltaY = e.deltaY + previousEvent.deltaY
|
||||
|
||||
|
||||
target.trigger('dragend',[e,e.originalEvent.traversing])
|
||||
isPointerDown = false
|
||||
$document.off(events.mouse.move,mouseMoveHandler)
|
||||
$document.off(events.mouse.stop,mouseStopHandler)
|
||||
$document.off(events.mouse.out,mouseOutHandler)
|
||||
},
|
||||
mouseOutHandler = function(e){
|
||||
if (e.originalEvent.traversing) {
|
||||
e.stopPropagation()
|
||||
|
||||
e.speedX = e.pageX - previousEvent.pageX
|
||||
e.speedY = e.pageY - previousEvent.pageY
|
||||
e.deltaX = e.deltaX + previousEvent.deltaX
|
||||
e.deltaY = e.deltaY + previousEvent.deltaY
|
||||
|
||||
target.trigger('dragend',[e,e.originalEvent.traversing])
|
||||
|
||||
previousEvent = e
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this.on(events.mouse.start,mouseStartHandler)
|
||||
|
||||
|
||||
// multi touch hanlder
|
||||
window.targets = window.targets || {}
|
||||
window.previousTouches = window.previousTouches || {}
|
||||
window.touchActive = window.touchActive || false
|
||||
|
||||
var self = this,
|
||||
touchStartHandler = function(e){
|
||||
e.preventDefault()
|
||||
|
||||
var oE = e.originalEvent
|
||||
|
||||
for (i in oE.changedTouches) {
|
||||
if (isNaN(i)) continue
|
||||
|
||||
var touch = oE.changedTouches[i],
|
||||
id = touch.identifier,
|
||||
emit = true
|
||||
|
||||
for (j in targets) {
|
||||
if (targets[j][0].isSameNode(touch.target)) {
|
||||
emit = false
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
targets[id] = $(touch.target)
|
||||
previousTouches[id] = touch
|
||||
|
||||
touch.speedX = 0
|
||||
touch.speedY = 0
|
||||
|
||||
touch.deltaX = 0
|
||||
touch.deltaY = 0
|
||||
|
||||
var off = getOffset(touch.target)
|
||||
touch.offsetX = touch.pageX-off.left
|
||||
touch.offsetY = touch.pageY-off.top
|
||||
|
||||
|
||||
if (emit) targets[id].triggerHandler('draginit',[touch,e.originalEvent.traversing])
|
||||
|
||||
}
|
||||
|
||||
if (!touchActive) {
|
||||
$document.on(events.touch.move,touchMoveHandler)
|
||||
$document.on(events.touch.stop,touchStopHandler)
|
||||
touchActive = true
|
||||
}
|
||||
|
||||
},
|
||||
touchMoveHandler = function(e){
|
||||
|
||||
var oE = e.originalEvent
|
||||
|
||||
for (i in oE.changedTouches) {
|
||||
if (isNaN(i)) continue
|
||||
|
||||
var nFingers = 0
|
||||
for (j in oE.touches) {
|
||||
if (oE.touches[j].target && oE.touches[j].target.isSameNode(oE.changedTouches[i].target)) {
|
||||
nFingers += 1
|
||||
}
|
||||
}
|
||||
|
||||
var touch = oE.changedTouches[i],
|
||||
id = touch.identifier,
|
||||
speedFactor = nFingers * nFingers
|
||||
|
||||
if (e.originalEvent.traversing) {
|
||||
targets[id] = $(document.elementFromPoint(touch.clientX, touch.clientY))
|
||||
}
|
||||
|
||||
|
||||
touch.speedX = (touch.pageX - previousTouches[id].pageX) / speedFactor
|
||||
touch.speedY = (touch.pageY - previousTouches[id].pageY) / speedFactor
|
||||
|
||||
touch.deltaX = touch.speedX + previousTouches[id].deltaX
|
||||
touch.deltaY = touch.speedY + previousTouches[id].deltaY
|
||||
|
||||
touch.offsetX = previousTouches[id].offsetX+touch.speedX
|
||||
touch.offsetY = previousTouches[id].offsetY+touch.speedY
|
||||
|
||||
if (e.originalEvent.traversing) {
|
||||
touch.traversing = true
|
||||
var previousTarget = document.elementFromPoint(previousTouches[id].clientX, previousTouches[id].clientY)
|
||||
if (targets[id][0]!=previousTarget) {
|
||||
var off = getOffset(targets[id][0])
|
||||
touch.offsetX = touch.pageX-off.left
|
||||
touch.offsetY = touch.pageY-off.top
|
||||
$(previousTarget).trigger('dragend',[touch,e.originalEvent.traversing])
|
||||
}
|
||||
e.preventDefault()
|
||||
if (oE.traversingContainer.contains(targets[id][0])) targets[id].triggerHandler('draginit',[touch,e.originalEvent.traversing])
|
||||
|
||||
} else {
|
||||
|
||||
targets[id].triggerHandler('drag',[touch,e.originalEvent.traversing])
|
||||
|
||||
}
|
||||
|
||||
previousTouches[id] = touch
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
touchStopHandler = function(e){
|
||||
|
||||
var oE = e.originalEvent
|
||||
|
||||
for (i in oE.changedTouches) {
|
||||
|
||||
if (isNaN(i)) continue
|
||||
|
||||
var touch = oE.changedTouches[i],
|
||||
id = touch.identifier
|
||||
|
||||
$(oE.changedTouches[i].target).trigger('dragend',[touch,e.originalEvent.traversing])
|
||||
|
||||
delete previousTouches[id]
|
||||
delete targets[id]
|
||||
|
||||
}
|
||||
|
||||
if (oE.touches.length==0) {
|
||||
$document.off(events.touch.move,touchMoveHandler)
|
||||
$document.off(events.touch.stop,touchStopHandler)
|
||||
touchActive = false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$this.on(events.touch.start,touchStartHandler)
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var makeEventTraversing = function(e){
|
||||
e.traversing=true
|
||||
if (!e.traversingContainer) e.traversingContainer=this
|
||||
}
|
||||
|
||||
|
||||
$.fn.enableTraversingGestures = function() {
|
||||
|
||||
var self = this[0]
|
||||
|
||||
var down = function(e){
|
||||
makeEventTraversing(e)
|
||||
self.addEventListener("mousemove", makeEventTraversing, true)
|
||||
self.addEventListener("touchmove", makeEventTraversing, true)
|
||||
self.addEventListener("mouseout", makeEventTraversing, true)
|
||||
document.addEventListener("mouseup",up,true)
|
||||
document.addEventListener("touchend",up,true)
|
||||
},
|
||||
up = function(){
|
||||
self.removeEventListener("mousemove", makeEventTraversing, true)
|
||||
self.removeEventListener("touchmove", makeEventTraversing, true)
|
||||
self.removeEventListener("mouseout", makeEventTraversing, true)
|
||||
document.removeEventListener("mouseup",up,true)
|
||||
document.removeEventListener("touchend",up,true)
|
||||
}
|
||||
|
||||
self.addEventListener("mousedown", down, true)
|
||||
self.addEventListener("touchstart", down, true)
|
||||
|
||||
this.on('draginit.traversing',()=>{})
|
||||
|
||||
this.on('disableTraversingGestures',()=>{
|
||||
this.off('draginit.traversing')
|
||||
self.removeEventListener("mousedown", down, true)
|
||||
self.removeEventListener("touchstart", down, true)
|
||||
})
|
||||
|
||||
|
||||
return this
|
||||
|
||||
}
|
||||
|
||||
|
||||
$document.on('mousedown',function(e){
|
||||
|
||||
if (e.originalEvent.sourceCapabilities && e.originalEvent.sourceCapabilities.firesTouchEvents) return
|
||||
|
||||
$(e.target).trigger('fake-click')
|
||||
|
||||
if (e.button==2) {
|
||||
e.preventDefault()
|
||||
$(e.target).trigger('fake-right-click',e)
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
var touchTapTimer = false,
|
||||
clearTouchTapTimer = function() {
|
||||
clearTimeout(touchTapTimer)
|
||||
touchTapTimer = false
|
||||
}
|
||||
|
||||
$document.on(events.touch.start,function(e){
|
||||
$(e.target).trigger('fake-click')
|
||||
|
||||
if (!touchTapTimer&&e.originalEvent.touches.length==1) {
|
||||
touchTapTimer = setTimeout(function(){
|
||||
if (touchTapTimer) {
|
||||
var touch = e.originalEvent.changedTouches[0],
|
||||
off = getOffset(touch.target)
|
||||
|
||||
touch.offsetX = touch.pageX-off.left
|
||||
touch.offsetY = touch.pageY-off.top
|
||||
$(e.originalEvent.changedTouches[0].target).trigger('fake-right-click',touch)
|
||||
}
|
||||
touchTapTimer = false
|
||||
},600)
|
||||
} else {
|
||||
clearTouchTapTimer()
|
||||
}
|
||||
})
|
||||
|
||||
$document.on(events.touch.stop + ' ' + events.touch.move,function(e){
|
||||
clearTouchTapTimer()
|
||||
})
|
||||
|
||||
$document.on('contextmenu',function(){return false})
|
||||
|
||||
})(jQuery)
|
||||
|
|
@ -1,93 +0,0 @@
|
|||
;(function ($) {
|
||||
$.fn.fakeInput = function(options) {
|
||||
|
||||
var settings = $.extend({
|
||||
align:'left'
|
||||
}, options );
|
||||
|
||||
var self= this,
|
||||
canvas = $('<canvas></canvas>').appendTo(self),
|
||||
ctx = canvas[0].getContext('2d')
|
||||
|
||||
self.value = undefined
|
||||
self.height = undefined
|
||||
self.width = undefined
|
||||
self.color = undefined
|
||||
self.center = settings.align == 'center'
|
||||
self.visible = false
|
||||
|
||||
self.attr('tabindex',"0")
|
||||
|
||||
canvas.resize(function(e,width,height,checkColors){
|
||||
|
||||
var width = width*2,
|
||||
height = height*2
|
||||
|
||||
if (width && height) {
|
||||
self.height=height
|
||||
self.width=width
|
||||
|
||||
canvas[0].setAttribute('width',width)
|
||||
canvas[0].setAttribute('height',height)
|
||||
}
|
||||
|
||||
if (!self.visible || checkColors) {
|
||||
self.color = getComputedStyle(canvas[0]).getPropertyValue("--color-text")
|
||||
self.fontSize = parseInt(getComputedStyle(canvas[0]).getPropertyValue("font-size"))
|
||||
}
|
||||
|
||||
self.val(self.value)
|
||||
})
|
||||
|
||||
self.val = function(newVal) {
|
||||
if (newVal==undefined) return self.value
|
||||
|
||||
self.value = newVal
|
||||
|
||||
if (!self.height || !self.width || (self.height==100 && self.width==100)) return
|
||||
|
||||
ctx.clearRect(0,0,self.width,self.height)
|
||||
ctx.font = PXSCALE * 2 * self.fontSize + 'px Droid Sans'
|
||||
ctx.textBaseline = "middle"
|
||||
ctx.fillStyle = self.color
|
||||
|
||||
if (self.center) {
|
||||
ctx.textAlign = settings.align
|
||||
ctx.fillText(newVal,self.width/2,this.height/2)
|
||||
} else {
|
||||
ctx.fillText(newVal,0,this.height/2)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
self.on('focus',function(){
|
||||
self.attr('tabindex','-1')
|
||||
var i = $('<input></input>')
|
||||
.prependTo(self)
|
||||
.val(self.value)
|
||||
.focus()
|
||||
.change(function(){
|
||||
self.val($(this).val())
|
||||
i.blur()
|
||||
})
|
||||
i.blur(function(){
|
||||
self.attr('tabindex','0')
|
||||
i.remove()
|
||||
$(document).off('.fakeInput')
|
||||
})
|
||||
$(document).on('touchstart.fakeInput mousedown.fakeInput',function(e){
|
||||
if (e.originalEvent.target!=i[0]) {
|
||||
i.blur()
|
||||
}
|
||||
}).on('keydown.fakeInput', function(e){
|
||||
if (e.keyCode==13) i.change()
|
||||
if (e.keyCode==27) i.off('change').blur()
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
return self
|
||||
|
||||
}
|
||||
})(jQuery)
|
||||
4
src/browser/js/jquery/jquery.min.js
vendored
4
src/browser/js/jquery/jquery.min.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -1,77 +0,0 @@
|
|||
/* jquery.resize
|
||||
* based on jQuery resize event (@ "Cowboy" Ben Alman http://benalman.com/projects/jquery-resize-plugin/)
|
||||
* just lighter and faster
|
||||
*/
|
||||
(function($){
|
||||
|
||||
var elems = []
|
||||
|
||||
$.event.special.resize = {
|
||||
setup: function(data, namespaces, handler) {
|
||||
|
||||
if (this===window) return false
|
||||
|
||||
// Add this element to the list of internal elements to monitor.
|
||||
elems.push(this)
|
||||
|
||||
},
|
||||
teardown: function() {
|
||||
|
||||
if (this===window) return false
|
||||
|
||||
// Remove this element from the list of internal elements to monitor.
|
||||
for (var i = elems.length - 1; i >= 0; i--) {
|
||||
if(elems[i] == this){
|
||||
elems.splice(i, 1)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
add: function(handleObj) {
|
||||
if (this===window) return false
|
||||
|
||||
// Save a reference to the bound event handler.
|
||||
var old_handler = handleObj.handler
|
||||
|
||||
handleObj.handler = function(event,data) {
|
||||
// Call the originally-bound event handler and return its result.
|
||||
return old_handler.apply(this, arguments)
|
||||
}
|
||||
|
||||
this.resizeHandler = handleObj.handler
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function checkResizes(){
|
||||
// Iterate over all elements to which the 'resize' event is bound.
|
||||
var resizedElems = []
|
||||
for (var i = elems.length - 1; i >= 0; i--) {
|
||||
var elem = elems[i]
|
||||
|
||||
if (!document.contains(elem)) continue
|
||||
|
||||
var style = window.getComputedStyle(elem),
|
||||
width = parseInt(style['width']) - parseInt(style['padding-left']) - parseInt(style['padding-right']),
|
||||
height = parseInt(style['height']) - parseInt(style['padding-top']) - parseInt(style['padding-bottom'])
|
||||
|
||||
if (!width) continue
|
||||
|
||||
// If element size has changed since the last time, update the element
|
||||
// data store and trigger the 'resize' event.
|
||||
if ( width != elem.resizedataw || height != elem.resizedatah ) {
|
||||
elem.resizedataw = width
|
||||
elem.resizedatah = height
|
||||
resizedElems.push(elem)
|
||||
}
|
||||
}
|
||||
for (var i = resizedElems.length - 1; i >= 0; i--) {
|
||||
resizedElems[i].resizeHandler(undefined, resizedElems[i].resizedataw, resizedElems[i].resizedatah)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$(window).resize(checkResizes)
|
||||
|
||||
})(jQuery)
|
||||
File diff suppressed because one or more lines are too long
4
src/browser/js/libs/source-map.min.js
vendored
Normal file
4
src/browser/js/libs/source-map.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue