vega-event-selector
Advanced tools
Comparing version 1.1.0 to 2.0.0-beta
1184
index.js
@@ -1,1183 +0,1 @@ | ||
module.exports = (function() { | ||
"use strict"; | ||
/* | ||
* Generated by PEG.js 0.9.0. | ||
* | ||
* http://pegjs.org/ | ||
*/ | ||
function peg$subclass(child, parent) { | ||
function ctor() { this.constructor = child; } | ||
ctor.prototype = parent.prototype; | ||
child.prototype = new ctor(); | ||
} | ||
function peg$SyntaxError(message, expected, found, location) { | ||
this.message = message; | ||
this.expected = expected; | ||
this.found = found; | ||
this.location = location; | ||
this.name = "SyntaxError"; | ||
if (typeof Error.captureStackTrace === "function") { | ||
Error.captureStackTrace(this, peg$SyntaxError); | ||
} | ||
} | ||
peg$subclass(peg$SyntaxError, Error); | ||
function peg$parse(input) { | ||
var options = arguments.length > 1 ? arguments[1] : {}, | ||
parser = this, | ||
peg$FAILED = {}, | ||
peg$startRuleFunctions = { start: peg$parsestart }, | ||
peg$startRuleFunction = peg$parsestart, | ||
peg$c0 = ",", | ||
peg$c1 = { type: "literal", value: ",", description: "\",\"" }, | ||
peg$c2 = function(o, m) { return [o].concat(m); }, | ||
peg$c3 = function(o) { return [o]; }, | ||
peg$c4 = "[", | ||
peg$c5 = { type: "literal", value: "[", description: "\"[\"" }, | ||
peg$c6 = "]", | ||
peg$c7 = { type: "literal", value: "]", description: "\"]\"" }, | ||
peg$c8 = ">", | ||
peg$c9 = { type: "literal", value: ">", description: "\">\"" }, | ||
peg$c10 = function(f1, f2, o) { | ||
return { | ||
start: f1, middle: o, end: f2, | ||
str: '['+f1.str+', '+f2.str+'] > '+o.str}; | ||
}, | ||
peg$c11 = function(s, f) { | ||
s.filters = f; | ||
s.str += f.map(function(x) { return '['+x+']'; }).join(''); | ||
return s; | ||
}, | ||
peg$c12 = function(s) { return s; }, | ||
peg$c13 = "(", | ||
peg$c14 = { type: "literal", value: "(", description: "\"(\"" }, | ||
peg$c15 = ")", | ||
peg$c16 = { type: "literal", value: ")", description: "\")\"" }, | ||
peg$c17 = function(m) { | ||
return { | ||
stream: m, | ||
str: '('+m.map(function(m) { return m.str; }).join(', ')+')' | ||
}; | ||
}, | ||
peg$c18 = "@", | ||
peg$c19 = { type: "literal", value: "@", description: "\"@\"" }, | ||
peg$c20 = ":", | ||
peg$c21 = { type: "literal", value: ":", description: "\":\"" }, | ||
peg$c22 = function(n, e) { return {event: e, name: n, str: '@'+n+':'+e}; }, | ||
peg$c23 = function(m, e) { return {event: e, mark: m, str: m+':'+e}; }, | ||
peg$c24 = function(t, e) { return {event: e, target: t, str: t+':'+e}; }, | ||
peg$c25 = function(e) { return {event: e, str: e}; }, | ||
peg$c26 = function(s) { return {signal: s, str: s}; }, | ||
peg$c27 = "rect", | ||
peg$c28 = { type: "literal", value: "rect", description: "\"rect\"" }, | ||
peg$c29 = "symbol", | ||
peg$c30 = { type: "literal", value: "symbol", description: "\"symbol\"" }, | ||
peg$c31 = "path", | ||
peg$c32 = { type: "literal", value: "path", description: "\"path\"" }, | ||
peg$c33 = "arc", | ||
peg$c34 = { type: "literal", value: "arc", description: "\"arc\"" }, | ||
peg$c35 = "area", | ||
peg$c36 = { type: "literal", value: "area", description: "\"area\"" }, | ||
peg$c37 = "line", | ||
peg$c38 = { type: "literal", value: "line", description: "\"line\"" }, | ||
peg$c39 = "rule", | ||
peg$c40 = { type: "literal", value: "rule", description: "\"rule\"" }, | ||
peg$c41 = "image", | ||
peg$c42 = { type: "literal", value: "image", description: "\"image\"" }, | ||
peg$c43 = "text", | ||
peg$c44 = { type: "literal", value: "text", description: "\"text\"" }, | ||
peg$c45 = "group", | ||
peg$c46 = { type: "literal", value: "group", description: "\"group\"" }, | ||
peg$c47 = "mousedown", | ||
peg$c48 = { type: "literal", value: "mousedown", description: "\"mousedown\"" }, | ||
peg$c49 = "mouseup", | ||
peg$c50 = { type: "literal", value: "mouseup", description: "\"mouseup\"" }, | ||
peg$c51 = "click", | ||
peg$c52 = { type: "literal", value: "click", description: "\"click\"" }, | ||
peg$c53 = "dblclick", | ||
peg$c54 = { type: "literal", value: "dblclick", description: "\"dblclick\"" }, | ||
peg$c55 = "wheel", | ||
peg$c56 = { type: "literal", value: "wheel", description: "\"wheel\"" }, | ||
peg$c57 = "keydown", | ||
peg$c58 = { type: "literal", value: "keydown", description: "\"keydown\"" }, | ||
peg$c59 = "keypress", | ||
peg$c60 = { type: "literal", value: "keypress", description: "\"keypress\"" }, | ||
peg$c61 = "keyup", | ||
peg$c62 = { type: "literal", value: "keyup", description: "\"keyup\"" }, | ||
peg$c63 = "mousewheel", | ||
peg$c64 = { type: "literal", value: "mousewheel", description: "\"mousewheel\"" }, | ||
peg$c65 = "mousemove", | ||
peg$c66 = { type: "literal", value: "mousemove", description: "\"mousemove\"" }, | ||
peg$c67 = "mouseout", | ||
peg$c68 = { type: "literal", value: "mouseout", description: "\"mouseout\"" }, | ||
peg$c69 = "mouseover", | ||
peg$c70 = { type: "literal", value: "mouseover", description: "\"mouseover\"" }, | ||
peg$c71 = "mouseenter", | ||
peg$c72 = { type: "literal", value: "mouseenter", description: "\"mouseenter\"" }, | ||
peg$c73 = "touchstart", | ||
peg$c74 = { type: "literal", value: "touchstart", description: "\"touchstart\"" }, | ||
peg$c75 = "touchmove", | ||
peg$c76 = { type: "literal", value: "touchmove", description: "\"touchmove\"" }, | ||
peg$c77 = "touchend", | ||
peg$c78 = { type: "literal", value: "touchend", description: "\"touchend\"" }, | ||
peg$c79 = "dragenter", | ||
peg$c80 = { type: "literal", value: "dragenter", description: "\"dragenter\"" }, | ||
peg$c81 = "dragover", | ||
peg$c82 = { type: "literal", value: "dragover", description: "\"dragover\"" }, | ||
peg$c83 = "dragleave", | ||
peg$c84 = { type: "literal", value: "dragleave", description: "\"dragleave\"" }, | ||
peg$c85 = function(e) { return e; }, | ||
peg$c86 = /^[a-zA-Z0-9_\-]/, | ||
peg$c87 = { type: "class", value: "[a-zA-Z0-9_-]", description: "[a-zA-Z0-9_-]" }, | ||
peg$c88 = function(n) { return n.join(''); }, | ||
peg$c89 = /^[a-zA-Z0-9\-_ #.>+~[\]=|\^$*]/, | ||
peg$c90 = { type: "class", value: "[a-zA-Z0-9-_ #\\.\\>\\+~\\[\\]=|\\^\\$\\*]", description: "[a-zA-Z0-9-_ #\\.\\>\\+~\\[\\]=|\\^\\$\\*]" }, | ||
peg$c91 = function(c) { return c.join(''); }, | ||
peg$c92 = /^['"a-zA-Z0-9_().><=! \t-&|~]/, | ||
peg$c93 = { type: "class", value: "['\"a-zA-Z0-9_\\(\\)\\.\\>\\<\\=\\! \\t-&|~]", description: "['\"a-zA-Z0-9_\\(\\)\\.\\>\\<\\=\\! \\t-&|~]" }, | ||
peg$c94 = function(v) { return v.join(''); }, | ||
peg$c95 = /^[ \t\r\n]/, | ||
peg$c96 = { type: "class", value: "[ \\t\\r\\n]", description: "[ \\t\\r\\n]" }, | ||
peg$currPos = 0, | ||
peg$savedPos = 0, | ||
peg$posDetailsCache = [{ line: 1, column: 1, seenCR: false }], | ||
peg$maxFailPos = 0, | ||
peg$maxFailExpected = [], | ||
peg$silentFails = 0, | ||
peg$result; | ||
if ("startRule" in options) { | ||
if (!(options.startRule in peg$startRuleFunctions)) { | ||
throw new Error("Can't start parsing from rule \"" + options.startRule + "\"."); | ||
} | ||
peg$startRuleFunction = peg$startRuleFunctions[options.startRule]; | ||
} | ||
function text() { | ||
return input.substring(peg$savedPos, peg$currPos); | ||
} | ||
function location() { | ||
return peg$computeLocation(peg$savedPos, peg$currPos); | ||
} | ||
function expected(description) { | ||
throw peg$buildException( | ||
null, | ||
[{ type: "other", description: description }], | ||
input.substring(peg$savedPos, peg$currPos), | ||
peg$computeLocation(peg$savedPos, peg$currPos) | ||
); | ||
} | ||
function error(message) { | ||
throw peg$buildException( | ||
message, | ||
null, | ||
input.substring(peg$savedPos, peg$currPos), | ||
peg$computeLocation(peg$savedPos, peg$currPos) | ||
); | ||
} | ||
function peg$computePosDetails(pos) { | ||
var details = peg$posDetailsCache[pos], | ||
p, ch; | ||
if (details) { | ||
return details; | ||
} else { | ||
p = pos - 1; | ||
while (!peg$posDetailsCache[p]) { | ||
p--; | ||
} | ||
details = peg$posDetailsCache[p]; | ||
details = { | ||
line: details.line, | ||
column: details.column, | ||
seenCR: details.seenCR | ||
}; | ||
while (p < pos) { | ||
ch = input.charAt(p); | ||
if (ch === "\n") { | ||
if (!details.seenCR) { details.line++; } | ||
details.column = 1; | ||
details.seenCR = false; | ||
} else if (ch === "\r" || ch === "\u2028" || ch === "\u2029") { | ||
details.line++; | ||
details.column = 1; | ||
details.seenCR = true; | ||
} else { | ||
details.column++; | ||
details.seenCR = false; | ||
} | ||
p++; | ||
} | ||
peg$posDetailsCache[pos] = details; | ||
return details; | ||
} | ||
} | ||
function peg$computeLocation(startPos, endPos) { | ||
var startPosDetails = peg$computePosDetails(startPos), | ||
endPosDetails = peg$computePosDetails(endPos); | ||
return { | ||
start: { | ||
offset: startPos, | ||
line: startPosDetails.line, | ||
column: startPosDetails.column | ||
}, | ||
end: { | ||
offset: endPos, | ||
line: endPosDetails.line, | ||
column: endPosDetails.column | ||
} | ||
}; | ||
} | ||
function peg$fail(expected) { | ||
if (peg$currPos < peg$maxFailPos) { return; } | ||
if (peg$currPos > peg$maxFailPos) { | ||
peg$maxFailPos = peg$currPos; | ||
peg$maxFailExpected = []; | ||
} | ||
peg$maxFailExpected.push(expected); | ||
} | ||
function peg$buildException(message, expected, found, location) { | ||
function cleanupExpected(expected) { | ||
var i = 1; | ||
expected.sort(function(a, b) { | ||
if (a.description < b.description) { | ||
return -1; | ||
} else if (a.description > b.description) { | ||
return 1; | ||
} else { | ||
return 0; | ||
} | ||
}); | ||
while (i < expected.length) { | ||
if (expected[i - 1] === expected[i]) { | ||
expected.splice(i, 1); | ||
} else { | ||
i++; | ||
} | ||
} | ||
} | ||
function buildMessage(expected, found) { | ||
function stringEscape(s) { | ||
function hex(ch) { return ch.charCodeAt(0).toString(16).toUpperCase(); } | ||
return s | ||
.replace(/\\/g, '\\\\') | ||
.replace(/"/g, '\\"') | ||
.replace(/\x08/g, '\\b') | ||
.replace(/\t/g, '\\t') | ||
.replace(/\n/g, '\\n') | ||
.replace(/\f/g, '\\f') | ||
.replace(/\r/g, '\\r') | ||
.replace(/[\x00-\x07\x0B\x0E\x0F]/g, function(ch) { return '\\x0' + hex(ch); }) | ||
.replace(/[\x10-\x1F\x80-\xFF]/g, function(ch) { return '\\x' + hex(ch); }) | ||
.replace(/[\u0100-\u0FFF]/g, function(ch) { return '\\u0' + hex(ch); }) | ||
.replace(/[\u1000-\uFFFF]/g, function(ch) { return '\\u' + hex(ch); }); | ||
} | ||
var expectedDescs = new Array(expected.length), | ||
expectedDesc, foundDesc, i; | ||
for (i = 0; i < expected.length; i++) { | ||
expectedDescs[i] = expected[i].description; | ||
} | ||
expectedDesc = expected.length > 1 | ||
? expectedDescs.slice(0, -1).join(", ") | ||
+ " or " | ||
+ expectedDescs[expected.length - 1] | ||
: expectedDescs[0]; | ||
foundDesc = found ? "\"" + stringEscape(found) + "\"" : "end of input"; | ||
return "Expected " + expectedDesc + " but " + foundDesc + " found."; | ||
} | ||
if (expected !== null) { | ||
cleanupExpected(expected); | ||
} | ||
return new peg$SyntaxError( | ||
message !== null ? message : buildMessage(expected, found), | ||
expected, | ||
found, | ||
location | ||
); | ||
} | ||
function peg$parsestart() { | ||
var s0; | ||
s0 = peg$parsemerged(); | ||
return s0; | ||
} | ||
function peg$parsemerged() { | ||
var s0, s1, s2, s3, s4, s5; | ||
s0 = peg$currPos; | ||
s1 = peg$parseordered(); | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$parsesep(); | ||
if (s2 !== peg$FAILED) { | ||
if (input.charCodeAt(peg$currPos) === 44) { | ||
s3 = peg$c0; | ||
peg$currPos++; | ||
} else { | ||
s3 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c1); } | ||
} | ||
if (s3 !== peg$FAILED) { | ||
s4 = peg$parsesep(); | ||
if (s4 !== peg$FAILED) { | ||
s5 = peg$parsemerged(); | ||
if (s5 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c2(s1, s5); | ||
s0 = s1; | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
s1 = peg$parseordered(); | ||
if (s1 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c3(s1); | ||
} | ||
s0 = s1; | ||
} | ||
return s0; | ||
} | ||
function peg$parseordered() { | ||
var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13; | ||
s0 = peg$currPos; | ||
if (input.charCodeAt(peg$currPos) === 91) { | ||
s1 = peg$c4; | ||
peg$currPos++; | ||
} else { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c5); } | ||
} | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$parsesep(); | ||
if (s2 !== peg$FAILED) { | ||
s3 = peg$parsefiltered(); | ||
if (s3 !== peg$FAILED) { | ||
s4 = peg$parsesep(); | ||
if (s4 !== peg$FAILED) { | ||
if (input.charCodeAt(peg$currPos) === 44) { | ||
s5 = peg$c0; | ||
peg$currPos++; | ||
} else { | ||
s5 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c1); } | ||
} | ||
if (s5 !== peg$FAILED) { | ||
s6 = peg$parsesep(); | ||
if (s6 !== peg$FAILED) { | ||
s7 = peg$parsefiltered(); | ||
if (s7 !== peg$FAILED) { | ||
s8 = peg$parsesep(); | ||
if (s8 !== peg$FAILED) { | ||
if (input.charCodeAt(peg$currPos) === 93) { | ||
s9 = peg$c6; | ||
peg$currPos++; | ||
} else { | ||
s9 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c7); } | ||
} | ||
if (s9 !== peg$FAILED) { | ||
s10 = peg$parsesep(); | ||
if (s10 !== peg$FAILED) { | ||
if (input.charCodeAt(peg$currPos) === 62) { | ||
s11 = peg$c8; | ||
peg$currPos++; | ||
} else { | ||
s11 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c9); } | ||
} | ||
if (s11 !== peg$FAILED) { | ||
s12 = peg$parsesep(); | ||
if (s12 !== peg$FAILED) { | ||
s13 = peg$parseordered(); | ||
if (s13 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c10(s3, s7, s13); | ||
s0 = s1; | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$parsefiltered(); | ||
} | ||
return s0; | ||
} | ||
function peg$parsefiltered() { | ||
var s0, s1, s2, s3; | ||
s0 = peg$currPos; | ||
s1 = peg$parsestream(); | ||
if (s1 !== peg$FAILED) { | ||
s2 = []; | ||
s3 = peg$parsefilter(); | ||
if (s3 !== peg$FAILED) { | ||
while (s3 !== peg$FAILED) { | ||
s2.push(s3); | ||
s3 = peg$parsefilter(); | ||
} | ||
} else { | ||
s2 = peg$FAILED; | ||
} | ||
if (s2 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c11(s1, s2); | ||
s0 = s1; | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
s1 = peg$parsestream(); | ||
if (s1 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c12(s1); | ||
} | ||
s0 = s1; | ||
} | ||
return s0; | ||
} | ||
function peg$parsestream() { | ||
var s0, s1, s2, s3, s4; | ||
s0 = peg$currPos; | ||
if (input.charCodeAt(peg$currPos) === 40) { | ||
s1 = peg$c13; | ||
peg$currPos++; | ||
} else { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c14); } | ||
} | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$parsemerged(); | ||
if (s2 !== peg$FAILED) { | ||
if (input.charCodeAt(peg$currPos) === 41) { | ||
s3 = peg$c15; | ||
peg$currPos++; | ||
} else { | ||
s3 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c16); } | ||
} | ||
if (s3 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c17(s2); | ||
s0 = s1; | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
if (input.charCodeAt(peg$currPos) === 64) { | ||
s1 = peg$c18; | ||
peg$currPos++; | ||
} else { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c19); } | ||
} | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$parsename(); | ||
if (s2 !== peg$FAILED) { | ||
if (input.charCodeAt(peg$currPos) === 58) { | ||
s3 = peg$c20; | ||
peg$currPos++; | ||
} else { | ||
s3 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c21); } | ||
} | ||
if (s3 !== peg$FAILED) { | ||
s4 = peg$parseeventType(); | ||
if (s4 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c22(s2, s4); | ||
s0 = s1; | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
s1 = peg$parsemarkType(); | ||
if (s1 !== peg$FAILED) { | ||
if (input.charCodeAt(peg$currPos) === 58) { | ||
s2 = peg$c20; | ||
peg$currPos++; | ||
} else { | ||
s2 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c21); } | ||
} | ||
if (s2 !== peg$FAILED) { | ||
s3 = peg$parseeventType(); | ||
if (s3 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c23(s1, s3); | ||
s0 = s1; | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
s1 = peg$parsecss(); | ||
if (s1 !== peg$FAILED) { | ||
if (input.charCodeAt(peg$currPos) === 58) { | ||
s2 = peg$c20; | ||
peg$currPos++; | ||
} else { | ||
s2 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c21); } | ||
} | ||
if (s2 !== peg$FAILED) { | ||
s3 = peg$parseeventType(); | ||
if (s3 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c24(s1, s3); | ||
s0 = s1; | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
s1 = peg$parseeventType(); | ||
if (s1 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c25(s1); | ||
} | ||
s0 = s1; | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
s1 = peg$parsename(); | ||
if (s1 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c26(s1); | ||
} | ||
s0 = s1; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
return s0; | ||
} | ||
function peg$parsemarkType() { | ||
var s0; | ||
if (input.substr(peg$currPos, 4) === peg$c27) { | ||
s0 = peg$c27; | ||
peg$currPos += 4; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c28); } | ||
} | ||
if (s0 === peg$FAILED) { | ||
if (input.substr(peg$currPos, 6) === peg$c29) { | ||
s0 = peg$c29; | ||
peg$currPos += 6; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c30); } | ||
} | ||
if (s0 === peg$FAILED) { | ||
if (input.substr(peg$currPos, 4) === peg$c31) { | ||
s0 = peg$c31; | ||
peg$currPos += 4; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c32); } | ||
} | ||
if (s0 === peg$FAILED) { | ||
if (input.substr(peg$currPos, 3) === peg$c33) { | ||
s0 = peg$c33; | ||
peg$currPos += 3; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c34); } | ||
} | ||
if (s0 === peg$FAILED) { | ||
if (input.substr(peg$currPos, 4) === peg$c35) { | ||
s0 = peg$c35; | ||
peg$currPos += 4; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c36); } | ||
} | ||
if (s0 === peg$FAILED) { | ||
if (input.substr(peg$currPos, 4) === peg$c37) { | ||
s0 = peg$c37; | ||
peg$currPos += 4; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c38); } | ||
} | ||
if (s0 === peg$FAILED) { | ||
if (input.substr(peg$currPos, 4) === peg$c39) { | ||
s0 = peg$c39; | ||
peg$currPos += 4; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c40); } | ||
} | ||
if (s0 === peg$FAILED) { | ||
if (input.substr(peg$currPos, 5) === peg$c41) { | ||
s0 = peg$c41; | ||
peg$currPos += 5; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c42); } | ||
} | ||
if (s0 === peg$FAILED) { | ||
if (input.substr(peg$currPos, 4) === peg$c43) { | ||
s0 = peg$c43; | ||
peg$currPos += 4; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c44); } | ||
} | ||
if (s0 === peg$FAILED) { | ||
if (input.substr(peg$currPos, 5) === peg$c45) { | ||
s0 = peg$c45; | ||
peg$currPos += 5; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c46); } | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
return s0; | ||
} | ||
function peg$parseeventType() { | ||
var s0; | ||
if (input.substr(peg$currPos, 9) === peg$c47) { | ||
s0 = peg$c47; | ||
peg$currPos += 9; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c48); } | ||
} | ||
if (s0 === peg$FAILED) { | ||
if (input.substr(peg$currPos, 7) === peg$c49) { | ||
s0 = peg$c49; | ||
peg$currPos += 7; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c50); } | ||
} | ||
if (s0 === peg$FAILED) { | ||
if (input.substr(peg$currPos, 5) === peg$c51) { | ||
s0 = peg$c51; | ||
peg$currPos += 5; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c52); } | ||
} | ||
if (s0 === peg$FAILED) { | ||
if (input.substr(peg$currPos, 8) === peg$c53) { | ||
s0 = peg$c53; | ||
peg$currPos += 8; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c54); } | ||
} | ||
if (s0 === peg$FAILED) { | ||
if (input.substr(peg$currPos, 5) === peg$c55) { | ||
s0 = peg$c55; | ||
peg$currPos += 5; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c56); } | ||
} | ||
if (s0 === peg$FAILED) { | ||
if (input.substr(peg$currPos, 7) === peg$c57) { | ||
s0 = peg$c57; | ||
peg$currPos += 7; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c58); } | ||
} | ||
if (s0 === peg$FAILED) { | ||
if (input.substr(peg$currPos, 8) === peg$c59) { | ||
s0 = peg$c59; | ||
peg$currPos += 8; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c60); } | ||
} | ||
if (s0 === peg$FAILED) { | ||
if (input.substr(peg$currPos, 5) === peg$c61) { | ||
s0 = peg$c61; | ||
peg$currPos += 5; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c62); } | ||
} | ||
if (s0 === peg$FAILED) { | ||
if (input.substr(peg$currPos, 10) === peg$c63) { | ||
s0 = peg$c63; | ||
peg$currPos += 10; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c64); } | ||
} | ||
if (s0 === peg$FAILED) { | ||
if (input.substr(peg$currPos, 9) === peg$c65) { | ||
s0 = peg$c65; | ||
peg$currPos += 9; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c66); } | ||
} | ||
if (s0 === peg$FAILED) { | ||
if (input.substr(peg$currPos, 8) === peg$c67) { | ||
s0 = peg$c67; | ||
peg$currPos += 8; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c68); } | ||
} | ||
if (s0 === peg$FAILED) { | ||
if (input.substr(peg$currPos, 9) === peg$c69) { | ||
s0 = peg$c69; | ||
peg$currPos += 9; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c70); } | ||
} | ||
if (s0 === peg$FAILED) { | ||
if (input.substr(peg$currPos, 10) === peg$c71) { | ||
s0 = peg$c71; | ||
peg$currPos += 10; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c72); } | ||
} | ||
if (s0 === peg$FAILED) { | ||
if (input.substr(peg$currPos, 10) === peg$c73) { | ||
s0 = peg$c73; | ||
peg$currPos += 10; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c74); } | ||
} | ||
if (s0 === peg$FAILED) { | ||
if (input.substr(peg$currPos, 9) === peg$c75) { | ||
s0 = peg$c75; | ||
peg$currPos += 9; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c76); } | ||
} | ||
if (s0 === peg$FAILED) { | ||
if (input.substr(peg$currPos, 8) === peg$c77) { | ||
s0 = peg$c77; | ||
peg$currPos += 8; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c78); } | ||
} | ||
if (s0 === peg$FAILED) { | ||
if (input.substr(peg$currPos, 9) === peg$c79) { | ||
s0 = peg$c79; | ||
peg$currPos += 9; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c80); } | ||
} | ||
if (s0 === peg$FAILED) { | ||
if (input.substr(peg$currPos, 8) === peg$c81) { | ||
s0 = peg$c81; | ||
peg$currPos += 8; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c82); } | ||
} | ||
if (s0 === peg$FAILED) { | ||
if (input.substr(peg$currPos, 9) === peg$c83) { | ||
s0 = peg$c83; | ||
peg$currPos += 9; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c84); } | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
return s0; | ||
} | ||
function peg$parsefilter() { | ||
var s0, s1, s2, s3; | ||
s0 = peg$currPos; | ||
if (input.charCodeAt(peg$currPos) === 91) { | ||
s1 = peg$c4; | ||
peg$currPos++; | ||
} else { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c5); } | ||
} | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$parseexpr(); | ||
if (s2 !== peg$FAILED) { | ||
if (input.charCodeAt(peg$currPos) === 93) { | ||
s3 = peg$c6; | ||
peg$currPos++; | ||
} else { | ||
s3 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c7); } | ||
} | ||
if (s3 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c85(s2); | ||
s0 = s1; | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
return s0; | ||
} | ||
function peg$parsename() { | ||
var s0, s1, s2; | ||
s0 = peg$currPos; | ||
s1 = []; | ||
if (peg$c86.test(input.charAt(peg$currPos))) { | ||
s2 = input.charAt(peg$currPos); | ||
peg$currPos++; | ||
} else { | ||
s2 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c87); } | ||
} | ||
if (s2 !== peg$FAILED) { | ||
while (s2 !== peg$FAILED) { | ||
s1.push(s2); | ||
if (peg$c86.test(input.charAt(peg$currPos))) { | ||
s2 = input.charAt(peg$currPos); | ||
peg$currPos++; | ||
} else { | ||
s2 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c87); } | ||
} | ||
} | ||
} else { | ||
s1 = peg$FAILED; | ||
} | ||
if (s1 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c88(s1); | ||
} | ||
s0 = s1; | ||
return s0; | ||
} | ||
function peg$parsecss() { | ||
var s0, s1, s2; | ||
s0 = peg$currPos; | ||
s1 = []; | ||
if (peg$c89.test(input.charAt(peg$currPos))) { | ||
s2 = input.charAt(peg$currPos); | ||
peg$currPos++; | ||
} else { | ||
s2 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c90); } | ||
} | ||
if (s2 !== peg$FAILED) { | ||
while (s2 !== peg$FAILED) { | ||
s1.push(s2); | ||
if (peg$c89.test(input.charAt(peg$currPos))) { | ||
s2 = input.charAt(peg$currPos); | ||
peg$currPos++; | ||
} else { | ||
s2 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c90); } | ||
} | ||
} | ||
} else { | ||
s1 = peg$FAILED; | ||
} | ||
if (s1 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c91(s1); | ||
} | ||
s0 = s1; | ||
return s0; | ||
} | ||
function peg$parseexpr() { | ||
var s0, s1, s2; | ||
s0 = peg$currPos; | ||
s1 = []; | ||
if (peg$c92.test(input.charAt(peg$currPos))) { | ||
s2 = input.charAt(peg$currPos); | ||
peg$currPos++; | ||
} else { | ||
s2 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c93); } | ||
} | ||
if (s2 !== peg$FAILED) { | ||
while (s2 !== peg$FAILED) { | ||
s1.push(s2); | ||
if (peg$c92.test(input.charAt(peg$currPos))) { | ||
s2 = input.charAt(peg$currPos); | ||
peg$currPos++; | ||
} else { | ||
s2 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c93); } | ||
} | ||
} | ||
} else { | ||
s1 = peg$FAILED; | ||
} | ||
if (s1 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c94(s1); | ||
} | ||
s0 = s1; | ||
return s0; | ||
} | ||
function peg$parsesep() { | ||
var s0, s1; | ||
s0 = []; | ||
if (peg$c95.test(input.charAt(peg$currPos))) { | ||
s1 = input.charAt(peg$currPos); | ||
peg$currPos++; | ||
} else { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c96); } | ||
} | ||
while (s1 !== peg$FAILED) { | ||
s0.push(s1); | ||
if (peg$c95.test(input.charAt(peg$currPos))) { | ||
s1 = input.charAt(peg$currPos); | ||
peg$currPos++; | ||
} else { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c96); } | ||
} | ||
} | ||
return s0; | ||
} | ||
peg$result = peg$startRuleFunction(); | ||
if (peg$result !== peg$FAILED && peg$currPos === input.length) { | ||
return peg$result; | ||
} else { | ||
if (peg$result !== peg$FAILED && peg$currPos < input.length) { | ||
peg$fail({ type: "end", description: "end of input" }); | ||
} | ||
throw peg$buildException( | ||
null, | ||
peg$maxFailExpected, | ||
peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null, | ||
peg$maxFailPos < input.length | ||
? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1) | ||
: peg$computeLocation(peg$maxFailPos, peg$maxFailPos) | ||
); | ||
} | ||
} | ||
return { | ||
SyntaxError: peg$SyntaxError, | ||
parse: peg$parse | ||
}; | ||
})(); | ||
export {default as selector} from './src/event-selector'; |
{ | ||
"name": "vega-event-selector", | ||
"version": "1.1.0", | ||
"version": "2.0.0-beta", | ||
"description": "A CSS-inspired language to select, sequence, and compose DOM events.", | ||
"keywords": [ | ||
"vega", | ||
"events", | ||
"selectors" | ||
"event", | ||
"selector" | ||
], | ||
"license": "BSD-3-Clause", | ||
"author": { | ||
"name": "Arvind Satyanarayan", | ||
"url": "http://arvindsatya.com" | ||
"name": "UW Interactive Data Lab", | ||
"url": "http://idl.cs.washington.edu" | ||
}, | ||
"license": "BSD-3-Clause", | ||
"contributors": [ | ||
{ | ||
"name": "Jeffrey Heer", | ||
"url": "http://idl.cs.washington.edu" | ||
}, | ||
{ | ||
"name": "Arvind Satyanarayan", | ||
"url": "http://arvindsatya.com" | ||
} | ||
], | ||
"main": "build/vega-event-selector.js", | ||
"module": "index", | ||
"jsnext:main": "index", | ||
"repository": { | ||
"type": "git", | ||
"url": "http://github.com/vega/vega-event-selector.git" | ||
"url": "https://github.com/vega/vega-event-selector.git" | ||
}, | ||
"main": "index.js", | ||
"scripts": { | ||
"build": "npm run test && uglifyjs build/vega-event-selector.js -c -m -o build/vega-event-selector.min.js", | ||
"rollup": "rollup -f umd -n vega -o build/vega-event-selector.js -- index.js", | ||
"pretest": "rm -rf build && mkdir build && npm run rollup", | ||
"test": "tape 'test/**/*-test.js' && eslint index.js src test", | ||
"prepublish": "npm run build", | ||
"postpublish": "git push && git push --tags && zip -j build/vega-event-selector.zip -- LICENSE README.md build/vega-event-selector.js build/vega-event-selector.min.js" | ||
}, | ||
"devDependencies": { | ||
"chai": "^3.5.0", | ||
"datalib": "^1.6.1", | ||
"mocha": "^2.4.5", | ||
"pegjs": "^0.9.0" | ||
}, | ||
"scripts": { | ||
"build": "pegjs selector.pegjs index.js", | ||
"test": "mocha events.test.js" | ||
"eslint": "2", | ||
"rollup": "0.36", | ||
"tape": "4", | ||
"uglify-js": "2" | ||
} | ||
} | ||
} |
@@ -1,18 +0,11 @@ | ||
# vega-event-selectors | ||
A CSS-inspired language to select, sequence, and compose DOM events into "streams". The following syntax is supported: | ||
# vega-event-selector | ||
* `eventType` -- captures event of a specific type, for example `mousedown` or `touchmove`. By default, this captures all events of the given type, that occur anywhere on the visualization. | ||
A CSS-inspired language to select, sequence, and compose DOM events into event streams. | ||
* `target:eventType` -- only captures events that occur on the given target. The following targets are recognized: | ||
Exports the following method: | ||
* `markType` -- only captures events that occur on any mark instance of the given type. For example `rect:mousedown` captures all `mousedown` events that occur on rect marks. Supported mark types include `rect`, `symbol`, `path`, `arc`, `area`, `line`, `rule`, `image`, and `text`. | ||
<a name="selector" href="#selector">#</a> | ||
vega.<b>selector</b>(<i>selector</i>[, <i>source</i>, <i>marks</i>]) | ||
[<>](https://github.com/vega/vega-event-selector/blob/master/src/event-selector.js "Source") | ||
* `@markName` -- only captures events that occur on mark instances with the given name. For example, `@cell:mousemove` captures all `mousemove` events that occur on instances of the mark named `cell`. | ||
* `CSS selector` -- the full gamut of CSS selectors can be used to capture events on elements that exist outside the visualization. For example, `#header:mousemove` captures `mouseover` events that occur on the HTML element with ID `header`. | ||
* `eventStream[filterExpr]` -- filters for events in the stream that match the given expression. The filter expression should be specified using the [Vega Expression](https://github.com/vega/vega/wiki/Expressions) subset of the JavaScript syntax. Multiple expressions can also be specified through concatenation. For example, `mousedown[event.pageX > 5][event.pageY < 100] captures `mousedown` events which occur at least 5px horizontally, and no more than 100px vertically on the page. | ||
* `streamA, streamB` -- merges individual event streams into a single stream, with the constituent events interleaved correctly. For example, `@cell:mousemove, mousedown[event.pageX > 5]` produces a single stream of `@cell:mousedown` and `mousedown[event.pageX > 5]` events, interleaved as they occur. | ||
* `[streamA, streamB] > streamC` -- captures `streamC` events that occur between `streamA` and `streamB`. For example, `[mousedown, mouseup] > mousemove` captures `mousemove` events that occur between a `mousedown` and `mouseup` (i.e., a stream of "drag" events). | ||
Takes an [event _selector_ string](https://vega.github.io/vega/docs/event-streams/#selector) as input and returns a parsed [event stream object](https://vega.github.io/vega/docs/event-streams/#object) definition. The optional _source_ argument takes a string indicating the source value to use by default (normally `"view"`). The optional _marks_ argument takes an object whose keys will be treated as the legal mark types, so long as the corresponding values are truthy. For more, see the [Vega Event Stream documentation](https://vega.github.io/vega/docs/event-streams). |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8
14228
375
2
12
2