vega-interpreter 2.3.0 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,314 +1,311 @@
|
|
|
1
|
-
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vega-util')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'vega-util'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.vega = global.vega || {}, global.vega));
|
|
5
|
-
})(this, (function (exports, vegaUtil) { 'use strict';
|
|
1
|
+
import { ascending, isString, DisallowedObjectProperties } from 'vega-util';
|
|
6
2
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
item.width = item.x2 - item.x;
|
|
17
|
-
} else {
|
|
18
|
-
item.x = item.x2 - (item.width || 0);
|
|
3
|
+
function adjustSpatial (item, encode, swap) {
|
|
4
|
+
let t;
|
|
5
|
+
if (encode.x2) {
|
|
6
|
+
if (encode.x) {
|
|
7
|
+
if (swap && item.x > item.x2) {
|
|
8
|
+
t = item.x;
|
|
9
|
+
item.x = item.x2;
|
|
10
|
+
item.x2 = t;
|
|
19
11
|
}
|
|
12
|
+
item.width = item.x2 - item.x;
|
|
13
|
+
} else {
|
|
14
|
+
item.x = item.x2 - (item.width || 0);
|
|
20
15
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
item.height = item.y2 - item.y;
|
|
32
|
-
} else {
|
|
33
|
-
item.y = item.y2 - (item.height || 0);
|
|
16
|
+
}
|
|
17
|
+
if (encode.xc) {
|
|
18
|
+
item.x = item.xc - (item.width || 0) / 2;
|
|
19
|
+
}
|
|
20
|
+
if (encode.y2) {
|
|
21
|
+
if (encode.y) {
|
|
22
|
+
if (swap && item.y > item.y2) {
|
|
23
|
+
t = item.y;
|
|
24
|
+
item.y = item.y2;
|
|
25
|
+
item.y2 = t;
|
|
34
26
|
}
|
|
27
|
+
item.height = item.y2 - item.y;
|
|
28
|
+
} else {
|
|
29
|
+
item.y = item.y2 - (item.height || 0);
|
|
35
30
|
}
|
|
36
|
-
if (encode.yc) {
|
|
37
|
-
item.y = item.yc - (item.height || 0) / 2;
|
|
38
|
-
}
|
|
39
31
|
}
|
|
32
|
+
if (encode.yc) {
|
|
33
|
+
item.y = item.yc - (item.height || 0) / 2;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
40
36
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
37
|
+
var Constants = {
|
|
38
|
+
NaN: NaN,
|
|
39
|
+
E: Math.E,
|
|
40
|
+
LN2: Math.LN2,
|
|
41
|
+
LN10: Math.LN10,
|
|
42
|
+
LOG2E: Math.LOG2E,
|
|
43
|
+
LOG10E: Math.LOG10E,
|
|
44
|
+
PI: Math.PI,
|
|
45
|
+
SQRT1_2: Math.SQRT1_2,
|
|
46
|
+
SQRT2: Math.SQRT2,
|
|
47
|
+
MIN_VALUE: Number.MIN_VALUE,
|
|
48
|
+
MAX_VALUE: Number.MAX_VALUE
|
|
49
|
+
};
|
|
54
50
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
51
|
+
var Ops = {
|
|
52
|
+
'*': (a, b) => a * b,
|
|
53
|
+
'+': (a, b) => a + b,
|
|
54
|
+
'-': (a, b) => a - b,
|
|
55
|
+
'/': (a, b) => a / b,
|
|
56
|
+
'%': (a, b) => a % b,
|
|
57
|
+
'>': (a, b) => a > b,
|
|
58
|
+
'<': (a, b) => a < b,
|
|
59
|
+
'<=': (a, b) => a <= b,
|
|
60
|
+
'>=': (a, b) => a >= b,
|
|
61
|
+
'==': (a, b) => a == b,
|
|
62
|
+
'!=': (a, b) => a != b,
|
|
63
|
+
'===': (a, b) => a === b,
|
|
64
|
+
'!==': (a, b) => a !== b,
|
|
65
|
+
'&': (a, b) => a & b,
|
|
66
|
+
'|': (a, b) => a | b,
|
|
67
|
+
'^': (a, b) => a ^ b,
|
|
68
|
+
'<<': (a, b) => a << b,
|
|
69
|
+
'>>': (a, b) => a >> b,
|
|
70
|
+
'>>>': (a, b) => a >>> b
|
|
71
|
+
};
|
|
76
72
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
73
|
+
var Unary = {
|
|
74
|
+
'+': a => +a,
|
|
75
|
+
'-': a => -a,
|
|
76
|
+
'~': a => ~a,
|
|
77
|
+
'!': a => !a
|
|
78
|
+
};
|
|
83
79
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
80
|
+
const slice = Array.prototype.slice;
|
|
81
|
+
const apply = (m, args, cast) => {
|
|
82
|
+
const obj = cast ? cast(args[0]) : args[0];
|
|
83
|
+
return obj[m].apply(obj, slice.call(args, 1));
|
|
84
|
+
};
|
|
85
|
+
const datetime = (yearOrTimestring, m = 0, d = 1, H = 0, M = 0, S = 0, ms = 0) => isString(yearOrTimestring) ? new Date(yearOrTimestring) : new Date(yearOrTimestring, m, d, H, M, S, ms);
|
|
86
|
+
var Functions = {
|
|
87
|
+
// math functions
|
|
88
|
+
isNaN: Number.isNaN,
|
|
89
|
+
isFinite: Number.isFinite,
|
|
90
|
+
abs: Math.abs,
|
|
91
|
+
acos: Math.acos,
|
|
92
|
+
asin: Math.asin,
|
|
93
|
+
atan: Math.atan,
|
|
94
|
+
atan2: Math.atan2,
|
|
95
|
+
ceil: Math.ceil,
|
|
96
|
+
cos: Math.cos,
|
|
97
|
+
exp: Math.exp,
|
|
98
|
+
floor: Math.floor,
|
|
99
|
+
log: Math.log,
|
|
100
|
+
max: Math.max,
|
|
101
|
+
min: Math.min,
|
|
102
|
+
pow: Math.pow,
|
|
103
|
+
random: Math.random,
|
|
104
|
+
round: Math.round,
|
|
105
|
+
sin: Math.sin,
|
|
106
|
+
sqrt: Math.sqrt,
|
|
107
|
+
tan: Math.tan,
|
|
108
|
+
clamp: (a, b, c) => Math.max(b, Math.min(c, a)),
|
|
109
|
+
// date functions
|
|
110
|
+
now: Date.now,
|
|
111
|
+
utc: Date.UTC,
|
|
112
|
+
datetime: datetime,
|
|
113
|
+
date: d => new Date(d).getDate(),
|
|
114
|
+
day: d => new Date(d).getDay(),
|
|
115
|
+
year: d => new Date(d).getFullYear(),
|
|
116
|
+
month: d => new Date(d).getMonth(),
|
|
117
|
+
hours: d => new Date(d).getHours(),
|
|
118
|
+
minutes: d => new Date(d).getMinutes(),
|
|
119
|
+
seconds: d => new Date(d).getSeconds(),
|
|
120
|
+
milliseconds: d => new Date(d).getMilliseconds(),
|
|
121
|
+
time: d => new Date(d).getTime(),
|
|
122
|
+
timezoneoffset: d => new Date(d).getTimezoneOffset(),
|
|
123
|
+
utcdate: d => new Date(d).getUTCDate(),
|
|
124
|
+
utcday: d => new Date(d).getUTCDay(),
|
|
125
|
+
utcyear: d => new Date(d).getUTCFullYear(),
|
|
126
|
+
utcmonth: d => new Date(d).getUTCMonth(),
|
|
127
|
+
utchours: d => new Date(d).getUTCHours(),
|
|
128
|
+
utcminutes: d => new Date(d).getUTCMinutes(),
|
|
129
|
+
utcseconds: d => new Date(d).getUTCSeconds(),
|
|
130
|
+
utcmilliseconds: d => new Date(d).getUTCMilliseconds(),
|
|
131
|
+
// sequence functions
|
|
132
|
+
length: x => x.length,
|
|
133
|
+
join: function () {
|
|
134
|
+
return apply('join', arguments);
|
|
135
|
+
},
|
|
136
|
+
indexof: function () {
|
|
137
|
+
return apply('indexOf', arguments);
|
|
138
|
+
},
|
|
139
|
+
lastindexof: function () {
|
|
140
|
+
return apply('lastIndexOf', arguments);
|
|
141
|
+
},
|
|
142
|
+
slice: function () {
|
|
143
|
+
return apply('slice', arguments);
|
|
144
|
+
},
|
|
145
|
+
reverse: x => x.slice().reverse(),
|
|
146
|
+
sort: x => x.slice().sort(ascending),
|
|
147
|
+
// string functions
|
|
148
|
+
parseFloat: parseFloat,
|
|
149
|
+
parseInt: parseInt,
|
|
150
|
+
upper: x => String(x).toUpperCase(),
|
|
151
|
+
lower: x => String(x).toLowerCase(),
|
|
152
|
+
substring: function () {
|
|
153
|
+
return apply('substring', arguments, String);
|
|
154
|
+
},
|
|
155
|
+
split: function () {
|
|
156
|
+
return apply('split', arguments, String);
|
|
157
|
+
},
|
|
158
|
+
replace: function () {
|
|
159
|
+
return apply('replace', arguments, String);
|
|
160
|
+
},
|
|
161
|
+
trim: x => String(x).trim(),
|
|
162
|
+
// Base64 encode/decode
|
|
163
|
+
// Convert binary string to base64-encoded ascii
|
|
164
|
+
btoa: x => btoa(x),
|
|
165
|
+
// Convert base64-encoded ascii to binary string
|
|
166
|
+
atob: x => atob(x),
|
|
167
|
+
// URI encoding
|
|
168
|
+
encodeURIComponent: x => encodeURIComponent(x),
|
|
169
|
+
// regexp functions
|
|
170
|
+
regexp: RegExp,
|
|
171
|
+
test: (r, t) => RegExp(r).test(t)
|
|
172
|
+
};
|
|
175
173
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
174
|
+
const EventFunctions = ['view', 'item', 'group', 'xy', 'x', 'y'];
|
|
175
|
+
const DisallowedMethods = new Set([Function, eval, setTimeout, setInterval]);
|
|
176
|
+
if (typeof setImmediate === 'function') DisallowedMethods.add(setImmediate);
|
|
177
|
+
const Visitors = {
|
|
178
|
+
Literal: ($, n) => n.value,
|
|
179
|
+
Identifier: ($, n) => {
|
|
180
|
+
const id = n.name;
|
|
181
|
+
return $.memberDepth > 0 ? id : id === 'datum' ? $.datum : id === 'event' ? $.event : id === 'item' ? $.item : Constants[id] || $.params['$' + id];
|
|
182
|
+
},
|
|
183
|
+
MemberExpression: ($, n) => {
|
|
184
|
+
const d = !n.computed,
|
|
185
|
+
o = $(n.object);
|
|
186
|
+
if (d) $.memberDepth += 1;
|
|
187
|
+
const p = $(n.property);
|
|
188
|
+
if (d) $.memberDepth -= 1;
|
|
189
|
+
if (DisallowedMethods.has(o[p])) {
|
|
190
|
+
// eslint-disable-next-line no-console
|
|
191
|
+
console.error(`Prevented interpretation of member "${p}" which could lead to insecure code execution`);
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
return o[p];
|
|
195
|
+
},
|
|
196
|
+
CallExpression: ($, n) => {
|
|
197
|
+
const args = n.arguments;
|
|
198
|
+
let name = n.callee.name;
|
|
201
199
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
200
|
+
// handle special internal functions used by encoders
|
|
201
|
+
// re-route to corresponding standard function
|
|
202
|
+
if (name.startsWith('_')) {
|
|
203
|
+
name = name.slice(1);
|
|
204
|
+
}
|
|
207
205
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
206
|
+
// special case "if" due to conditional evaluation of branches
|
|
207
|
+
return name === 'if' ? $(args[0]) ? $(args[1]) : $(args[2]) : ($.fn[name] || Functions[name]).apply($.fn, args.map($));
|
|
208
|
+
},
|
|
209
|
+
ArrayExpression: ($, n) => n.elements.map($),
|
|
210
|
+
BinaryExpression: ($, n) => Ops[n.operator]($(n.left), $(n.right)),
|
|
211
|
+
UnaryExpression: ($, n) => Unary[n.operator]($(n.argument)),
|
|
212
|
+
ConditionalExpression: ($, n) => $(n.test) ? $(n.consequent) : $(n.alternate),
|
|
213
|
+
LogicalExpression: ($, n) => n.operator === '&&' ? $(n.left) && $(n.right) : $(n.left) || $(n.right),
|
|
214
|
+
ObjectExpression: ($, n) => n.properties.reduce((o, p) => {
|
|
215
|
+
$.memberDepth += 1;
|
|
216
|
+
const k = $(p.key);
|
|
217
|
+
$.memberDepth -= 1;
|
|
218
|
+
const v = $(p.value);
|
|
219
|
+
if (DisallowedObjectProperties.has(k)) {
|
|
220
|
+
// eslint-disable-next-line no-console
|
|
221
|
+
console.error(`Prevented interpretation of property "${k}" which could lead to insecure code execution`);
|
|
222
|
+
} else if (DisallowedMethods.has(v)) {
|
|
223
|
+
// eslint-disable-next-line no-console
|
|
224
|
+
console.error(`Prevented interpretation of method "${k}" which could lead to insecure code execution`);
|
|
225
|
+
} else {
|
|
226
|
+
o[k] = v;
|
|
227
|
+
}
|
|
228
|
+
return o;
|
|
229
|
+
}, {})
|
|
230
|
+
};
|
|
231
|
+
function interpret (ast, fn, params, datum, event, item) {
|
|
232
|
+
const $ = n => Visitors[n.type]($, n);
|
|
233
|
+
$.memberDepth = 0;
|
|
234
|
+
$.fn = Object.create(fn);
|
|
235
|
+
$.params = params;
|
|
236
|
+
$.datum = datum;
|
|
237
|
+
$.event = event;
|
|
238
|
+
$.item = item;
|
|
241
239
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
240
|
+
// route event functions to annotated vega event context
|
|
241
|
+
EventFunctions.forEach(f => $.fn[f] = (...args) => event.vega[f](...args));
|
|
242
|
+
return $(ast);
|
|
243
|
+
}
|
|
246
244
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
if (marktype !== 'rule') {
|
|
305
|
-
adjustSpatial(item, channels, swap);
|
|
245
|
+
var expression = {
|
|
246
|
+
/**
|
|
247
|
+
* Parse an expression used to update an operator value.
|
|
248
|
+
*/
|
|
249
|
+
operator(ctx, expr) {
|
|
250
|
+
const ast = expr.ast,
|
|
251
|
+
fn = ctx.functions;
|
|
252
|
+
return _ => interpret(ast, fn, _);
|
|
253
|
+
},
|
|
254
|
+
/**
|
|
255
|
+
* Parse an expression provided as an operator parameter value.
|
|
256
|
+
*/
|
|
257
|
+
parameter(ctx, expr) {
|
|
258
|
+
const ast = expr.ast,
|
|
259
|
+
fn = ctx.functions;
|
|
260
|
+
return (datum, _) => interpret(ast, fn, _, datum);
|
|
261
|
+
},
|
|
262
|
+
/**
|
|
263
|
+
* Parse an expression applied to an event stream.
|
|
264
|
+
*/
|
|
265
|
+
event(ctx, expr) {
|
|
266
|
+
const ast = expr.ast,
|
|
267
|
+
fn = ctx.functions;
|
|
268
|
+
return event => interpret(ast, fn, undefined, undefined, event);
|
|
269
|
+
},
|
|
270
|
+
/**
|
|
271
|
+
* Parse an expression used to handle an event-driven operator update.
|
|
272
|
+
*/
|
|
273
|
+
handler(ctx, expr) {
|
|
274
|
+
const ast = expr.ast,
|
|
275
|
+
fn = ctx.functions;
|
|
276
|
+
return (_, event) => {
|
|
277
|
+
const datum = event.item && event.item.datum;
|
|
278
|
+
return interpret(ast, fn, _, datum, event);
|
|
279
|
+
};
|
|
280
|
+
},
|
|
281
|
+
/**
|
|
282
|
+
* Parse an expression that performs visual encoding.
|
|
283
|
+
*/
|
|
284
|
+
encode(ctx, encode) {
|
|
285
|
+
const {
|
|
286
|
+
marktype,
|
|
287
|
+
channels
|
|
288
|
+
} = encode,
|
|
289
|
+
fn = ctx.functions,
|
|
290
|
+
swap = marktype === 'group' || marktype === 'image' || marktype === 'rect';
|
|
291
|
+
return (item, _) => {
|
|
292
|
+
const datum = item.datum;
|
|
293
|
+
let m = 0,
|
|
294
|
+
v;
|
|
295
|
+
for (const name in channels) {
|
|
296
|
+
v = interpret(channels[name].ast, fn, _, datum, undefined, item);
|
|
297
|
+
if (item[name] !== v) {
|
|
298
|
+
item[name] = v;
|
|
299
|
+
m = 1;
|
|
306
300
|
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
301
|
+
}
|
|
302
|
+
if (marktype !== 'rule') {
|
|
303
|
+
adjustSpatial(item, channels, swap);
|
|
304
|
+
}
|
|
305
|
+
return m;
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
};
|
|
313
309
|
|
|
314
|
-
}
|
|
310
|
+
export { expression as expressionInterpreter };
|
|
311
|
+
//# sourceMappingURL=vega-interpreter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vega-interpreter.js","sources":["../src/adjust-spatial.js","../src/constants.js","../src/ops-binary.js","../src/ops-unary.js","../src/functions.js","../src/interpret.js","../src/expression.js"],"sourcesContent":["export default function(item, encode, swap) {\n let t;\n\n if (encode.x2) {\n if (encode.x) {\n if (swap && item.x > item.x2) {\n t = item.x;\n item.x = item.x2;\n item.x2 = t;\n }\n item.width = item.x2 - item.x;\n } else {\n item.x = item.x2 - (item.width || 0);\n }\n }\n\n if (encode.xc) {\n item.x = item.xc - (item.width || 0) / 2;\n }\n\n if (encode.y2) {\n if (encode.y) {\n if (swap && item.y > item.y2) {\n t = item.y;\n item.y = item.y2;\n item.y2 = t;\n }\n item.height = item.y2 - item.y;\n } else {\n item.y = item.y2 - (item.height || 0);\n }\n }\n\n if (encode.yc) {\n item.y = item.yc - (item.height || 0) / 2;\n }\n}\n","export default {\n NaN: NaN,\n E: Math.E,\n LN2: Math.LN2,\n LN10: Math.LN10,\n LOG2E: Math.LOG2E,\n LOG10E: Math.LOG10E,\n PI: Math.PI,\n SQRT1_2: Math.SQRT1_2,\n SQRT2: Math.SQRT2,\n MIN_VALUE: Number.MIN_VALUE,\n MAX_VALUE: Number.MAX_VALUE\n};\n","export default {\n '*': (a, b) => a * b,\n '+': (a, b) => a + b,\n '-': (a, b) => a - b,\n '/': (a, b) => a / b,\n '%': (a, b) => a % b,\n '>': (a, b) => a > b,\n '<': (a, b) => a < b,\n '<=': (a, b) => a <= b,\n '>=': (a, b) => a >= b,\n '==': (a, b) => a == b,\n '!=': (a, b) => a != b,\n '===': (a, b) => a === b,\n '!==': (a, b) => a !== b,\n '&': (a, b) => a & b,\n '|': (a, b) => a | b,\n '^': (a, b) => a ^ b,\n '<<': (a, b) => a << b,\n '>>': (a, b) => a >> b,\n '>>>': (a, b) => a >>> b\n};\n","export default {\n '+': a => +a,\n '-': a => -a,\n '~': a => ~a,\n '!': a => !a\n};\n","import { ascending, isString } from 'vega-util';\n\nconst slice = Array.prototype.slice;\n\nconst apply = (m, args, cast) => {\n const obj = cast ? cast(args[0]) : args[0];\n return obj[m].apply(obj, slice.call(args, 1));\n};\n\nconst datetime = (yearOrTimestring, m = 0, d = 1, H = 0, M = 0, S = 0, ms = 0) =>\n isString(yearOrTimestring)\n ? new Date(yearOrTimestring)\n : new Date(yearOrTimestring, m, d, H, M, S, ms);\n\nexport default {\n // math functions\n isNaN: Number.isNaN,\n isFinite: Number.isFinite,\n abs: Math.abs,\n acos: Math.acos,\n asin: Math.asin,\n atan: Math.atan,\n atan2: Math.atan2,\n ceil: Math.ceil,\n cos: Math.cos,\n exp: Math.exp,\n floor: Math.floor,\n log: Math.log,\n max: Math.max,\n min: Math.min,\n pow: Math.pow,\n random: Math.random,\n round: Math.round,\n sin: Math.sin,\n sqrt: Math.sqrt,\n tan: Math.tan,\n clamp: (a, b, c) => Math.max(b, Math.min(c, a)),\n\n // date functions\n now: Date.now,\n utc: Date.UTC,\n datetime: datetime,\n date: d => new Date(d).getDate(),\n day: d => new Date(d).getDay(),\n year: d => new Date(d).getFullYear(),\n month: d => new Date(d).getMonth(),\n hours: d => new Date(d).getHours(),\n minutes: d => new Date(d).getMinutes(),\n seconds: d => new Date(d).getSeconds(),\n milliseconds: d => new Date(d).getMilliseconds(),\n time: d => new Date(d).getTime(),\n timezoneoffset: d => new Date(d).getTimezoneOffset(),\n utcdate: d => new Date(d).getUTCDate(),\n utcday: d => new Date(d).getUTCDay(),\n utcyear: d => new Date(d).getUTCFullYear(),\n utcmonth: d => new Date(d).getUTCMonth(),\n utchours: d => new Date(d).getUTCHours(),\n utcminutes: d => new Date(d).getUTCMinutes(),\n utcseconds: d => new Date(d).getUTCSeconds(),\n utcmilliseconds: d => new Date(d).getUTCMilliseconds(),\n\n // sequence functions\n length: x => x.length,\n join: function() { return apply('join', arguments); },\n indexof: function() { return apply('indexOf', arguments); },\n lastindexof: function() { return apply('lastIndexOf', arguments); },\n slice: function() { return apply('slice', arguments); },\n reverse: x => x.slice().reverse(),\n sort: x => x.slice().sort(ascending),\n\n // string functions\n parseFloat: parseFloat,\n parseInt: parseInt,\n upper: x => String(x).toUpperCase(),\n lower: x => String(x).toLowerCase(),\n substring: function() { return apply('substring', arguments, String); },\n split: function() { return apply('split', arguments, String); },\n replace: function() { return apply('replace', arguments, String); },\n trim: x => String(x).trim(),\n // Base64 encode/decode\n // Convert binary string to base64-encoded ascii\n btoa: x => btoa(x),\n // Convert base64-encoded ascii to binary string\n atob: x => atob(x),\n // URI encoding\n encodeURIComponent: x => encodeURIComponent(x),\n\n // regexp functions\n regexp: RegExp,\n test: (r, t) => RegExp(r).test(t)\n};\n","import Constants from './constants.js';\nimport Ops from './ops-binary.js';\nimport Unary from './ops-unary.js';\nimport Functions from './functions.js';\nimport {DisallowedObjectProperties} from 'vega-util';\n\nconst EventFunctions = ['view', 'item', 'group', 'xy', 'x', 'y'];\nconst DisallowedMethods = new Set([\n Function,\n eval,\n setTimeout,\n setInterval\n]);\n\nif (typeof setImmediate === 'function') DisallowedMethods.add(setImmediate);\n\nconst Visitors = {\n Literal: ($, n) => n.value,\n\n Identifier: ($, n) => {\n const id = n.name;\n return $.memberDepth > 0 ? id\n : id === 'datum' ? $.datum\n : id === 'event' ? $.event\n : id === 'item' ? $.item\n : Constants[id] || $.params['$' + id];\n },\n\n MemberExpression: ($, n) => {\n const d = !n.computed,\n o = $(n.object);\n if (d) $.memberDepth += 1;\n const p = $(n.property);\n if (d) $.memberDepth -= 1;\n if (DisallowedMethods.has(o[p])) {\n // eslint-disable-next-line no-console\n console.error(`Prevented interpretation of member \"${p}\" which could lead to insecure code execution`);\n return;\n }\n return o[p];\n },\n\n CallExpression: ($, n) => {\n const args = n.arguments;\n let name = n.callee.name;\n\n // handle special internal functions used by encoders\n // re-route to corresponding standard function\n if (name.startsWith('_')) {\n name = name.slice(1);\n }\n\n // special case \"if\" due to conditional evaluation of branches\n return name === 'if'\n ? ($(args[0]) ? $(args[1]) : $(args[2]))\n : ($.fn[name] || Functions[name]).apply($.fn, args.map($));\n },\n\n ArrayExpression: ($, n) => n.elements.map($),\n\n BinaryExpression: ($, n) => Ops[n.operator]($(n.left), $(n.right)),\n\n UnaryExpression: ($, n) => Unary[n.operator]($(n.argument)),\n\n ConditionalExpression: ($, n) => $(n.test)\n ? $(n.consequent)\n : $(n.alternate),\n\n LogicalExpression: ($, n) => n.operator === '&&'\n ? $(n.left) && $(n.right)\n : $(n.left) || $(n.right),\n\n ObjectExpression: ($, n) => n.properties.reduce((o, p) => {\n $.memberDepth += 1;\n const k = $(p.key);\n $.memberDepth -= 1;\n const v = $(p.value);\n if (DisallowedObjectProperties.has(k)) { // eslint-disable-next-line no-console\n console.error(`Prevented interpretation of property \"${k}\" which could lead to insecure code execution`);\n } else if (DisallowedMethods.has(v)) { // eslint-disable-next-line no-console\n console.error(`Prevented interpretation of method \"${k}\" which could lead to insecure code execution`);\n } else {\n o[k] = v;\n }\n return o;\n }, {})\n};\n\nexport default function(ast, fn, params, datum, event, item) {\n const $ = n => Visitors[n.type]($, n);\n $.memberDepth = 0;\n $.fn = Object.create(fn);\n $.params = params;\n $.datum = datum;\n $.event = event;\n $.item = item;\n\n // route event functions to annotated vega event context\n EventFunctions.forEach(f => $.fn[f] = (...args) => event.vega[f](...args));\n\n return $(ast);\n}\n","import adjustSpatial from './adjust-spatial.js';\nimport interpret from './interpret.js';\n\nexport default {\n /**\n * Parse an expression used to update an operator value.\n */\n operator(ctx, expr) {\n const ast = expr.ast, fn = ctx.functions;\n return _ => interpret(ast, fn, _);\n },\n\n /**\n * Parse an expression provided as an operator parameter value.\n */\n parameter(ctx, expr) {\n const ast = expr.ast, fn = ctx.functions;\n return (datum, _) => interpret(ast, fn, _, datum);\n },\n\n /**\n * Parse an expression applied to an event stream.\n */\n event(ctx, expr) {\n const ast = expr.ast, fn = ctx.functions;\n return event => interpret(ast, fn, undefined, undefined, event);\n },\n\n /**\n * Parse an expression used to handle an event-driven operator update.\n */\n handler(ctx, expr) {\n const ast = expr.ast, fn = ctx.functions;\n return (_, event) => {\n const datum = event.item && event.item.datum;\n return interpret(ast, fn, _, datum, event);\n };\n },\n\n /**\n * Parse an expression that performs visual encoding.\n */\n encode(ctx, encode) {\n const {marktype, channels} = encode,\n fn = ctx.functions,\n swap = marktype === 'group'\n || marktype === 'image'\n || marktype === 'rect';\n\n return (item, _) => {\n const datum = item.datum;\n let m = 0, v;\n\n for (const name in channels) {\n v = interpret(channels[name].ast, fn, _, datum, undefined, item);\n if (item[name] !== v) {\n item[name] = v;\n m = 1;\n }\n }\n\n if (marktype !== 'rule') {\n adjustSpatial(item, channels, swap);\n }\n return m;\n };\n }\n};\n"],"names":["item","encode","swap","t","x2","x","width","xc","y2","y","height","yc","NaN","E","Math","LN2","LN10","LOG2E","LOG10E","PI","SQRT1_2","SQRT2","MIN_VALUE","Number","MAX_VALUE","*","a","b","+","-","/","%",">","<","<=",">=","==","!=","===","!==","&","|","^","<<",">>",">>>","slice","Array","prototype","apply","m","args","cast","obj","call","datetime","yearOrTimestring","d","H","M","S","ms","isString","Date","isNaN","isFinite","abs","acos","asin","atan","atan2","ceil","cos","exp","floor","log","max","min","pow","random","round","sin","sqrt","tan","clamp","c","now","utc","UTC","date","getDate","day","getDay","year","getFullYear","month","getMonth","hours","getHours","minutes","getMinutes","seconds","getSeconds","milliseconds","getMilliseconds","time","getTime","timezoneoffset","getTimezoneOffset","utcdate","getUTCDate","utcday","getUTCDay","utcyear","getUTCFullYear","utcmonth","getUTCMonth","utchours","getUTCHours","utcminutes","getUTCMinutes","utcseconds","getUTCSeconds","utcmilliseconds","getUTCMilliseconds","length","join","arguments","indexof","lastindexof","reverse","sort","ascending","parseFloat","parseInt","upper","String","toUpperCase","lower","toLowerCase","substring","split","replace","trim","btoa","atob","encodeURIComponent","regexp","RegExp","test","r","EventFunctions","DisallowedMethods","Set","Function","eval","setTimeout","setInterval","setImmediate","add","Visitors","Literal","$","n","value","Identifier","id","name","memberDepth","datum","event","Constants","params","MemberExpression","computed","o","object","p","property","has","console","error","CallExpression","callee","startsWith","fn","Functions","map","ArrayExpression","elements","BinaryExpression","Ops","operator","left","right","UnaryExpression","Unary","argument","ConditionalExpression","consequent","alternate","LogicalExpression","ObjectExpression","properties","reduce","k","key","v","DisallowedObjectProperties","ast","type","Object","create","forEach","f","vega","ctx","expr","functions","_","interpret","parameter","undefined","handler","marktype","channels","adjustSpatial"],"mappings":";;AAAe,wBAASA,IAAI,EAAEC,MAAM,EAAEC,IAAI,EAAE;AAC1C,EAAA,IAAIC,CAAC;EAEL,IAAIF,MAAM,CAACG,EAAE,EAAE;IACb,IAAIH,MAAM,CAACI,CAAC,EAAE;MACZ,IAAIH,IAAI,IAAIF,IAAI,CAACK,CAAC,GAAGL,IAAI,CAACI,EAAE,EAAE;QAC5BD,CAAC,GAAGH,IAAI,CAACK,CAAC;AACVL,QAAAA,IAAI,CAACK,CAAC,GAAGL,IAAI,CAACI,EAAE;QAChBJ,IAAI,CAACI,EAAE,GAAGD,CAAC;AACb,MAAA;MACAH,IAAI,CAACM,KAAK,GAAGN,IAAI,CAACI,EAAE,GAAGJ,IAAI,CAACK,CAAC;AAC/B,IAAA,CAAC,MAAM;AACLL,MAAAA,IAAI,CAACK,CAAC,GAAGL,IAAI,CAACI,EAAE,IAAIJ,IAAI,CAACM,KAAK,IAAI,CAAC,CAAC;AACtC,IAAA;AACF,EAAA;EAEA,IAAIL,MAAM,CAACM,EAAE,EAAE;AACbP,IAAAA,IAAI,CAACK,CAAC,GAAGL,IAAI,CAACO,EAAE,GAAG,CAACP,IAAI,CAACM,KAAK,IAAI,CAAC,IAAI,CAAC;AAC1C,EAAA;EAEA,IAAIL,MAAM,CAACO,EAAE,EAAE;IACb,IAAIP,MAAM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|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vega-interpreter",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"description": "CSP-compliant interpreter for Vega expressions.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vega",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"vega-util": "^2.1.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"vega": "
|
|
41
|
+
"vega": "6.3.1"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "6cd7a7074c311de7172bf950f5df0bbe6917678d"
|
|
44
44
|
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vega-util")):"function"==typeof define&&define.amd?define(["exports","vega-util"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).vega=e.vega||{},e.vega)}(this,(function(e,t){"use strict";var n={NaN:NaN,E:Math.E,LN2:Math.LN2,LN10:Math.LN10,LOG2E:Math.LOG2E,LOG10E:Math.LOG10E,PI:Math.PI,SQRT1_2:Math.SQRT1_2,SQRT2:Math.SQRT2,MIN_VALUE:Number.MIN_VALUE,MAX_VALUE:Number.MAX_VALUE},r={"*":(e,t)=>e*t,"+":(e,t)=>e+t,"-":(e,t)=>e-t,"/":(e,t)=>e/t,"%":(e,t)=>e%t,">":(e,t)=>e>t,"<":(e,t)=>e<t,"<=":(e,t)=>e<=t,">=":(e,t)=>e>=t,"==":(e,t)=>e==t,"!=":(e,t)=>e!=t,"===":(e,t)=>e===t,"!==":(e,t)=>e!==t,"&":(e,t)=>e&t,"|":(e,t)=>e|t,"^":(e,t)=>e^t,"<<":(e,t)=>e<<t,">>":(e,t)=>e>>t,">>>":(e,t)=>e>>>t},a={"+":e=>+e,"-":e=>-e,"~":e=>~e,"!":e=>!e};const o=Array.prototype.slice,i=(e,t,n)=>{const r=n?n(t[0]):t[0];return r[e].apply(r,o.call(t,1))};var s={isNaN:Number.isNaN,isFinite:Number.isFinite,abs:Math.abs,acos:Math.acos,asin:Math.asin,atan:Math.atan,atan2:Math.atan2,ceil:Math.ceil,cos:Math.cos,exp:Math.exp,floor:Math.floor,log:Math.log,max:Math.max,min:Math.min,pow:Math.pow,random:Math.random,round:Math.round,sin:Math.sin,sqrt:Math.sqrt,tan:Math.tan,clamp:(e,t,n)=>Math.max(t,Math.min(n,e)),now:Date.now,utc:Date.UTC,datetime:(e,t,n,r,a,o,i)=>new Date(e,t||0,null!=n?n:1,r||0,a||0,o||0,i||0),date:e=>new Date(e).getDate(),day:e=>new Date(e).getDay(),year:e=>new Date(e).getFullYear(),month:e=>new Date(e).getMonth(),hours:e=>new Date(e).getHours(),minutes:e=>new Date(e).getMinutes(),seconds:e=>new Date(e).getSeconds(),milliseconds:e=>new Date(e).getMilliseconds(),time:e=>new Date(e).getTime(),timezoneoffset:e=>new Date(e).getTimezoneOffset(),utcdate:e=>new Date(e).getUTCDate(),utcday:e=>new Date(e).getUTCDay(),utcyear:e=>new Date(e).getUTCFullYear(),utcmonth:e=>new Date(e).getUTCMonth(),utchours:e=>new Date(e).getUTCHours(),utcminutes:e=>new Date(e).getUTCMinutes(),utcseconds:e=>new Date(e).getUTCSeconds(),utcmilliseconds:e=>new Date(e).getUTCMilliseconds(),length:e=>e.length,join:function(){return i("join",arguments)},indexof:function(){return i("indexOf",arguments)},lastindexof:function(){return i("lastIndexOf",arguments)},slice:function(){return i("slice",arguments)},reverse:e=>e.slice().reverse(),sort:e=>e.slice().sort(t.ascending),parseFloat:parseFloat,parseInt:parseInt,upper:e=>String(e).toUpperCase(),lower:e=>String(e).toLowerCase(),substring:function(){return i("substring",arguments,String)},split:function(){return i("split",arguments,String)},replace:function(){return i("replace",arguments,String)},trim:e=>String(e).trim(),btoa:e=>btoa(e),atob:e=>atob(e),regexp:RegExp,test:(e,t)=>RegExp(e).test(t)};const c=["view","item","group","xy","x","y"],u=new Set([Function,eval,setTimeout,setInterval]);"function"==typeof setImmediate&&u.add(setImmediate);const l={Literal:(e,t)=>t.value,Identifier:(e,t)=>{const r=t.name;return e.memberDepth>0?r:"datum"===r?e.datum:"event"===r?e.event:"item"===r?e.item:n[r]||e.params["$"+r]},MemberExpression:(e,t)=>{const n=!t.computed,r=e(t.object);n&&(e.memberDepth+=1);const a=e(t.property);if(n&&(e.memberDepth-=1),!u.has(r[a]))return r[a];console.error(`Prevented interpretation of member "${a}" which could lead to insecure code execution`)},CallExpression:(e,t)=>{const n=t.arguments;let r=t.callee.name;return r.startsWith("_")&&(r=r.slice(1)),"if"===r?e(n[0])?e(n[1]):e(n[2]):(e.fn[r]||s[r]).apply(e.fn,n.map(e))},ArrayExpression:(e,t)=>t.elements.map(e),BinaryExpression:(e,t)=>r[t.operator](e(t.left),e(t.right)),UnaryExpression:(e,t)=>a[t.operator](e(t.argument)),ConditionalExpression:(e,t)=>e(t.test)?e(t.consequent):e(t.alternate),LogicalExpression:(e,t)=>"&&"===t.operator?e(t.left)&&e(t.right):e(t.left)||e(t.right),ObjectExpression:(e,n)=>n.properties.reduce(((n,r)=>{e.memberDepth+=1;const a=e(r.key);e.memberDepth-=1;const o=e(r.value);return t.DisallowedObjectProperties.has(a)?console.error(`Prevented interpretation of property "${a}" which could lead to insecure code execution`):u.has(o)?console.error(`Prevented interpretation of method "${o}" which could lead to insecure code execution`):n[a]=o,n}),{})};function p(e,t,n,r,a,o){const i=e=>l[e.type](i,e);return i.memberDepth=0,i.fn=Object.create(t),i.params=n,i.datum=r,i.event=a,i.item=o,c.forEach((e=>i.fn[e]=function(){return a.vega[e](...arguments)})),i(e)}var m={operator(e,t){const n=t.ast,r=e.functions;return e=>p(n,r,e)},parameter(e,t){const n=t.ast,r=e.functions;return(e,t)=>p(n,r,t,e)},event(e,t){const n=t.ast,r=e.functions;return e=>p(n,r,void 0,void 0,e)},handler(e,t){const n=t.ast,r=e.functions;return(e,t)=>{const a=t.item&&t.item.datum;return p(n,r,e,a,t)}},encode(e,t){const{marktype:n,channels:r}=t,a=e.functions,o="group"===n||"image"===n||"rect"===n;return(e,t)=>{const i=e.datum;let s,c=0;for(const n in r)s=p(r[n].ast,a,t,i,void 0,e),e[n]!==s&&(e[n]=s,c=1);return"rule"!==n&&function(e,t,n){let r;t.x2&&(t.x?(n&&e.x>e.x2&&(r=e.x,e.x=e.x2,e.x2=r),e.width=e.x2-e.x):e.x=e.x2-(e.width||0)),t.xc&&(e.x=e.xc-(e.width||0)/2),t.y2&&(t.y?(n&&e.y>e.y2&&(r=e.y,e.y=e.y2,e.y2=r),e.height=e.y2-e.y):e.y=e.y2-(e.height||0)),t.yc&&(e.y=e.yc-(e.height||0)/2)}(e,r,o),c}}};e.expressionInterpreter=m}));
|
|
2
|
-
//# sourceMappingURL=vega-interpreter.min.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vega-interpreter.min.js","sources":["../src/constants.js","../src/ops-binary.js","../src/ops-unary.js","../src/functions.js","../src/interpret.js","../src/expression.js","../src/adjust-spatial.js"],"sourcesContent":["export default {\n NaN: NaN,\n E: Math.E,\n LN2: Math.LN2,\n LN10: Math.LN10,\n LOG2E: Math.LOG2E,\n LOG10E: Math.LOG10E,\n PI: Math.PI,\n SQRT1_2: Math.SQRT1_2,\n SQRT2: Math.SQRT2,\n MIN_VALUE: Number.MIN_VALUE,\n MAX_VALUE: Number.MAX_VALUE\n};\n","export default {\n '*': (a, b) => a * b,\n '+': (a, b) => a + b,\n '-': (a, b) => a - b,\n '/': (a, b) => a / b,\n '%': (a, b) => a % b,\n '>': (a, b) => a > b,\n '<': (a, b) => a < b,\n '<=': (a, b) => a <= b,\n '>=': (a, b) => a >= b,\n '==': (a, b) => a == b,\n '!=': (a, b) => a != b,\n '===': (a, b) => a === b,\n '!==': (a, b) => a !== b,\n '&': (a, b) => a & b,\n '|': (a, b) => a | b,\n '^': (a, b) => a ^ b,\n '<<': (a, b) => a << b,\n '>>': (a, b) => a >> b,\n '>>>': (a, b) => a >>> b\n};\n","export default {\n '+': a => +a,\n '-': a => -a,\n '~': a => ~a,\n '!': a => !a\n};\n","import { ascending } from 'vega-util';\n\nconst slice = Array.prototype.slice;\n\nconst apply = (m, args, cast) => {\n const obj = cast ? cast(args[0]) : args[0];\n return obj[m].apply(obj, slice.call(args, 1));\n};\n\nconst datetime = (y, m, d, H, M, S, ms) =>\n new Date(y, m || 0, d != null ? d : 1, H || 0, M || 0, S || 0, ms || 0);\n\nexport default {\n // math functions\n isNaN: Number.isNaN,\n isFinite: Number.isFinite,\n abs: Math.abs,\n acos: Math.acos,\n asin: Math.asin,\n atan: Math.atan,\n atan2: Math.atan2,\n ceil: Math.ceil,\n cos: Math.cos,\n exp: Math.exp,\n floor: Math.floor,\n log: Math.log,\n max: Math.max,\n min: Math.min,\n pow: Math.pow,\n random: Math.random,\n round: Math.round,\n sin: Math.sin,\n sqrt: Math.sqrt,\n tan: Math.tan,\n clamp: (a, b, c) => Math.max(b, Math.min(c, a)),\n\n // date functions\n now: Date.now,\n utc: Date.UTC,\n datetime: datetime,\n date: d => new Date(d).getDate(),\n day: d => new Date(d).getDay(),\n year: d => new Date(d).getFullYear(),\n month: d => new Date(d).getMonth(),\n hours: d => new Date(d).getHours(),\n minutes: d => new Date(d).getMinutes(),\n seconds: d => new Date(d).getSeconds(),\n milliseconds: d => new Date(d).getMilliseconds(),\n time: d => new Date(d).getTime(),\n timezoneoffset: d => new Date(d).getTimezoneOffset(),\n utcdate: d => new Date(d).getUTCDate(),\n utcday: d => new Date(d).getUTCDay(),\n utcyear: d => new Date(d).getUTCFullYear(),\n utcmonth: d => new Date(d).getUTCMonth(),\n utchours: d => new Date(d).getUTCHours(),\n utcminutes: d => new Date(d).getUTCMinutes(),\n utcseconds: d => new Date(d).getUTCSeconds(),\n utcmilliseconds: d => new Date(d).getUTCMilliseconds(),\n\n // sequence functions\n length: x => x.length,\n join: function() { return apply('join', arguments); },\n indexof: function() { return apply('indexOf', arguments); },\n lastindexof: function() { return apply('lastIndexOf', arguments); },\n slice: function() { return apply('slice', arguments); },\n reverse: x => x.slice().reverse(),\n sort: x => x.slice().sort(ascending),\n\n // string functions\n parseFloat: parseFloat,\n parseInt: parseInt,\n upper: x => String(x).toUpperCase(),\n lower: x => String(x).toLowerCase(),\n substring: function() { return apply('substring', arguments, String); },\n split: function() { return apply('split', arguments, String); },\n replace: function() { return apply('replace', arguments, String); },\n trim: x => String(x).trim(),\n // Base64 encode/decode\n // Convert binary string to base64-encoded ascii\n btoa: x => btoa(x),\n // Convert base64-encoded ascii to binary string\n atob: x => atob(x),\n\n // regexp functions\n regexp: RegExp,\n test: (r, t) => RegExp(r).test(t)\n};\n","import Constants from './constants';\nimport Ops from './ops-binary';\nimport Unary from './ops-unary';\nimport Functions from './functions';\nimport {DisallowedObjectProperties} from 'vega-util';\n\nconst EventFunctions = ['view', 'item', 'group', 'xy', 'x', 'y'];\nconst DisallowedMethods = new Set([\n Function,\n eval,\n setTimeout,\n setInterval\n]);\n\nif (typeof setImmediate === 'function') DisallowedMethods.add(setImmediate);\n\nconst Visitors = {\n Literal: ($, n) => n.value,\n\n Identifier: ($, n) => {\n const id = n.name;\n return $.memberDepth > 0 ? id\n : id === 'datum' ? $.datum\n : id === 'event' ? $.event\n : id === 'item' ? $.item\n : Constants[id] || $.params['$' + id];\n },\n\n MemberExpression: ($, n) => {\n const d = !n.computed,\n o = $(n.object);\n if (d) $.memberDepth += 1;\n const p = $(n.property);\n if (d) $.memberDepth -= 1;\n if (DisallowedMethods.has(o[p])) {\n // eslint-disable-next-line no-console\n console.error(`Prevented interpretation of member \"${p}\" which could lead to insecure code execution`);\n return;\n }\n return o[p];\n },\n\n CallExpression: ($, n) => {\n const args = n.arguments;\n let name = n.callee.name;\n\n // handle special internal functions used by encoders\n // re-route to corresponding standard function\n if (name.startsWith('_')) {\n name = name.slice(1);\n }\n\n // special case \"if\" due to conditional evaluation of branches\n return name === 'if'\n ? ($(args[0]) ? $(args[1]) : $(args[2]))\n : ($.fn[name] || Functions[name]).apply($.fn, args.map($));\n },\n\n ArrayExpression: ($, n) => n.elements.map($),\n\n BinaryExpression: ($, n) => Ops[n.operator]($(n.left), $(n.right)),\n\n UnaryExpression: ($, n) => Unary[n.operator]($(n.argument)),\n\n ConditionalExpression: ($, n) => $(n.test)\n ? $(n.consequent)\n : $(n.alternate),\n\n LogicalExpression: ($, n) => n.operator === '&&'\n ? $(n.left) && $(n.right)\n : $(n.left) || $(n.right),\n\n ObjectExpression: ($, n) => n.properties.reduce((o, p) => {\n $.memberDepth += 1;\n const k = $(p.key);\n $.memberDepth -= 1;\n const v = $(p.value);\n if (DisallowedObjectProperties.has(k)) { // eslint-disable-next-line no-console\n console.error(`Prevented interpretation of property \"${k}\" which could lead to insecure code execution`);\n } else if (DisallowedMethods.has(v)) { // eslint-disable-next-line no-console\n console.error(`Prevented interpretation of method \"${v}\" which could lead to insecure code execution`);\n } else {\n o[k] = v;\n }\n return o;\n }, {})\n};\n\nexport default function(ast, fn, params, datum, event, item) {\n const $ = n => Visitors[n.type]($, n);\n $.memberDepth = 0;\n $.fn = Object.create(fn);\n $.params = params;\n $.datum = datum;\n $.event = event;\n $.item = item;\n\n // route event functions to annotated vega event context\n EventFunctions.forEach(f => $.fn[f] = (...args) => event.vega[f](...args));\n\n return $(ast);\n}\n","import adjustSpatial from './adjust-spatial';\nimport interpret from './interpret';\n\nexport default {\n /**\n * Parse an expression used to update an operator value.\n */\n operator(ctx, expr) {\n const ast = expr.ast, fn = ctx.functions;\n return _ => interpret(ast, fn, _);\n },\n\n /**\n * Parse an expression provided as an operator parameter value.\n */\n parameter(ctx, expr) {\n const ast = expr.ast, fn = ctx.functions;\n return (datum, _) => interpret(ast, fn, _, datum);\n },\n\n /**\n * Parse an expression applied to an event stream.\n */\n event(ctx, expr) {\n const ast = expr.ast, fn = ctx.functions;\n return event => interpret(ast, fn, undefined, undefined, event);\n },\n\n /**\n * Parse an expression used to handle an event-driven operator update.\n */\n handler(ctx, expr) {\n const ast = expr.ast, fn = ctx.functions;\n return (_, event) => {\n const datum = event.item && event.item.datum;\n return interpret(ast, fn, _, datum, event);\n };\n },\n\n /**\n * Parse an expression that performs visual encoding.\n */\n encode(ctx, encode) {\n const {marktype, channels} = encode,\n fn = ctx.functions,\n swap = marktype === 'group'\n || marktype === 'image'\n || marktype === 'rect';\n\n return (item, _) => {\n const datum = item.datum;\n let m = 0, v;\n\n for (const name in channels) {\n v = interpret(channels[name].ast, fn, _, datum, undefined, item);\n if (item[name] !== v) {\n item[name] = v;\n m = 1;\n }\n }\n\n if (marktype !== 'rule') {\n adjustSpatial(item, channels, swap);\n }\n return m;\n };\n }\n};\n","export default function(item, encode, swap) {\n let t;\n\n if (encode.x2) {\n if (encode.x) {\n if (swap && item.x > item.x2) {\n t = item.x;\n item.x = item.x2;\n item.x2 = t;\n }\n item.width = item.x2 - item.x;\n } else {\n item.x = item.x2 - (item.width || 0);\n }\n }\n\n if (encode.xc) {\n item.x = item.xc - (item.width || 0) / 2;\n }\n\n if (encode.y2) {\n if (encode.y) {\n if (swap && item.y > item.y2) {\n t = item.y;\n item.y = item.y2;\n item.y2 = t;\n }\n item.height = item.y2 - item.y;\n } else {\n item.y = item.y2 - (item.height || 0);\n }\n }\n\n if (encode.yc) {\n item.y = item.yc - (item.height || 0) / 2;\n }\n}\n"],"names":["Constants","NaN","E","Math","LN2","LN10","LOG2E","LOG10E","PI","SQRT1_2","SQRT2","MIN_VALUE","Number","MAX_VALUE","Ops","*","a","b","+","-","/","%",">","<","<=",">=","==","!=","===","!==","&","|","^","<<",">>",">>>","Unary","slice","Array","prototype","apply","m","args","cast","obj","call","Functions","isNaN","isFinite","abs","acos","asin","atan","atan2","ceil","cos","exp","floor","log","max","min","pow","random","round","sin","sqrt","tan","clamp","c","now","Date","utc","UTC","datetime","y","d","H","M","S","ms","date","getDate","day","getDay","year","getFullYear","month","getMonth","hours","getHours","minutes","getMinutes","seconds","getSeconds","milliseconds","getMilliseconds","time","getTime","timezoneoffset","getTimezoneOffset","utcdate","getUTCDate","utcday","getUTCDay","utcyear","getUTCFullYear","utcmonth","getUTCMonth","utchours","getUTCHours","utcminutes","getUTCMinutes","utcseconds","getUTCSeconds","utcmilliseconds","getUTCMilliseconds","length","x","join","arguments","indexof","lastindexof","reverse","sort","ascending","parseFloat","parseInt","upper","String","toUpperCase","lower","toLowerCase","substring","split","replace","trim","btoa","atob","regexp","RegExp","test","r","t","EventFunctions","DisallowedMethods","Set","Function","eval","setTimeout","setInterval","setImmediate","add","Visitors","Literal","$","n","value","Identifier","id","name","memberDepth","datum","event","item","params","MemberExpression","computed","o","object","p","property","has","console","error","CallExpression","callee","startsWith","fn","map","ArrayExpression","elements","BinaryExpression","operator","left","right","UnaryExpression","argument","ConditionalExpression","consequent","alternate","LogicalExpression","ObjectExpression","properties","reduce","k","key","v","DisallowedObjectProperties","interpret","ast","type","Object","create","forEach","f","vega","expression","ctx","expr","functions","_","parameter","undefined","handler","encode","marktype","channels","swap","x2","width","xc","y2","height","yc","adjustSpatial"],"mappings":"8RAAe,IAAAA,EAAA,CACbC,IAAYA,IACZC,EAAYC,KAAKD,EACjBE,IAAYD,KAAKC,IACjBC,KAAYF,KAAKE,KACjBC,MAAYH,KAAKG,MACjBC,OAAYJ,KAAKI,OACjBC,GAAYL,KAAKK,GACjBC,QAAYN,KAAKM,QACjBC,MAAYP,KAAKO,MACjBC,UAAYC,OAAOD,UACnBE,UAAYD,OAAOC,WCXNC,EAAA,CACb,IAAKC,CAACC,EAAGC,IAAMD,EAAIC,EACnB,IAAKC,CAACF,EAAGC,IAAMD,EAAIC,EACnB,IAAKE,CAACH,EAAGC,IAAMD,EAAIC,EACnB,IAAKG,CAACJ,EAAGC,IAAMD,EAAIC,EACnB,IAAKI,CAACL,EAAGC,IAAMD,EAAIC,EACnB,IAAKK,CAACN,EAAGC,IAAMD,EAAIC,EACnB,IAAKM,CAACP,EAAGC,IAAMD,EAAIC,EACnB,KAAMO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,CAAC,CAEZ"}
|
|
@@ -1,310 +0,0 @@
|
|
|
1
|
-
import { ascending, DisallowedObjectProperties } from 'vega-util';
|
|
2
|
-
|
|
3
|
-
function adjustSpatial (item, encode, swap) {
|
|
4
|
-
let t;
|
|
5
|
-
if (encode.x2) {
|
|
6
|
-
if (encode.x) {
|
|
7
|
-
if (swap && item.x > item.x2) {
|
|
8
|
-
t = item.x;
|
|
9
|
-
item.x = item.x2;
|
|
10
|
-
item.x2 = t;
|
|
11
|
-
}
|
|
12
|
-
item.width = item.x2 - item.x;
|
|
13
|
-
} else {
|
|
14
|
-
item.x = item.x2 - (item.width || 0);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
if (encode.xc) {
|
|
18
|
-
item.x = item.xc - (item.width || 0) / 2;
|
|
19
|
-
}
|
|
20
|
-
if (encode.y2) {
|
|
21
|
-
if (encode.y) {
|
|
22
|
-
if (swap && item.y > item.y2) {
|
|
23
|
-
t = item.y;
|
|
24
|
-
item.y = item.y2;
|
|
25
|
-
item.y2 = t;
|
|
26
|
-
}
|
|
27
|
-
item.height = item.y2 - item.y;
|
|
28
|
-
} else {
|
|
29
|
-
item.y = item.y2 - (item.height || 0);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
if (encode.yc) {
|
|
33
|
-
item.y = item.yc - (item.height || 0) / 2;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
var Constants = {
|
|
38
|
-
NaN: NaN,
|
|
39
|
-
E: Math.E,
|
|
40
|
-
LN2: Math.LN2,
|
|
41
|
-
LN10: Math.LN10,
|
|
42
|
-
LOG2E: Math.LOG2E,
|
|
43
|
-
LOG10E: Math.LOG10E,
|
|
44
|
-
PI: Math.PI,
|
|
45
|
-
SQRT1_2: Math.SQRT1_2,
|
|
46
|
-
SQRT2: Math.SQRT2,
|
|
47
|
-
MIN_VALUE: Number.MIN_VALUE,
|
|
48
|
-
MAX_VALUE: Number.MAX_VALUE
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
var Ops = {
|
|
52
|
-
'*': (a, b) => a * b,
|
|
53
|
-
'+': (a, b) => a + b,
|
|
54
|
-
'-': (a, b) => a - b,
|
|
55
|
-
'/': (a, b) => a / b,
|
|
56
|
-
'%': (a, b) => a % b,
|
|
57
|
-
'>': (a, b) => a > b,
|
|
58
|
-
'<': (a, b) => a < b,
|
|
59
|
-
'<=': (a, b) => a <= b,
|
|
60
|
-
'>=': (a, b) => a >= b,
|
|
61
|
-
'==': (a, b) => a == b,
|
|
62
|
-
'!=': (a, b) => a != b,
|
|
63
|
-
'===': (a, b) => a === b,
|
|
64
|
-
'!==': (a, b) => a !== b,
|
|
65
|
-
'&': (a, b) => a & b,
|
|
66
|
-
'|': (a, b) => a | b,
|
|
67
|
-
'^': (a, b) => a ^ b,
|
|
68
|
-
'<<': (a, b) => a << b,
|
|
69
|
-
'>>': (a, b) => a >> b,
|
|
70
|
-
'>>>': (a, b) => a >>> b
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
var Unary = {
|
|
74
|
-
'+': a => +a,
|
|
75
|
-
'-': a => -a,
|
|
76
|
-
'~': a => ~a,
|
|
77
|
-
'!': a => !a
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
const slice = Array.prototype.slice;
|
|
81
|
-
const apply = (m, args, cast) => {
|
|
82
|
-
const obj = cast ? cast(args[0]) : args[0];
|
|
83
|
-
return obj[m].apply(obj, slice.call(args, 1));
|
|
84
|
-
};
|
|
85
|
-
const datetime = (y, m, d, H, M, S, ms) => new Date(y, m || 0, d != null ? d : 1, H || 0, M || 0, S || 0, ms || 0);
|
|
86
|
-
var Functions = {
|
|
87
|
-
// math functions
|
|
88
|
-
isNaN: Number.isNaN,
|
|
89
|
-
isFinite: Number.isFinite,
|
|
90
|
-
abs: Math.abs,
|
|
91
|
-
acos: Math.acos,
|
|
92
|
-
asin: Math.asin,
|
|
93
|
-
atan: Math.atan,
|
|
94
|
-
atan2: Math.atan2,
|
|
95
|
-
ceil: Math.ceil,
|
|
96
|
-
cos: Math.cos,
|
|
97
|
-
exp: Math.exp,
|
|
98
|
-
floor: Math.floor,
|
|
99
|
-
log: Math.log,
|
|
100
|
-
max: Math.max,
|
|
101
|
-
min: Math.min,
|
|
102
|
-
pow: Math.pow,
|
|
103
|
-
random: Math.random,
|
|
104
|
-
round: Math.round,
|
|
105
|
-
sin: Math.sin,
|
|
106
|
-
sqrt: Math.sqrt,
|
|
107
|
-
tan: Math.tan,
|
|
108
|
-
clamp: (a, b, c) => Math.max(b, Math.min(c, a)),
|
|
109
|
-
// date functions
|
|
110
|
-
now: Date.now,
|
|
111
|
-
utc: Date.UTC,
|
|
112
|
-
datetime: datetime,
|
|
113
|
-
date: d => new Date(d).getDate(),
|
|
114
|
-
day: d => new Date(d).getDay(),
|
|
115
|
-
year: d => new Date(d).getFullYear(),
|
|
116
|
-
month: d => new Date(d).getMonth(),
|
|
117
|
-
hours: d => new Date(d).getHours(),
|
|
118
|
-
minutes: d => new Date(d).getMinutes(),
|
|
119
|
-
seconds: d => new Date(d).getSeconds(),
|
|
120
|
-
milliseconds: d => new Date(d).getMilliseconds(),
|
|
121
|
-
time: d => new Date(d).getTime(),
|
|
122
|
-
timezoneoffset: d => new Date(d).getTimezoneOffset(),
|
|
123
|
-
utcdate: d => new Date(d).getUTCDate(),
|
|
124
|
-
utcday: d => new Date(d).getUTCDay(),
|
|
125
|
-
utcyear: d => new Date(d).getUTCFullYear(),
|
|
126
|
-
utcmonth: d => new Date(d).getUTCMonth(),
|
|
127
|
-
utchours: d => new Date(d).getUTCHours(),
|
|
128
|
-
utcminutes: d => new Date(d).getUTCMinutes(),
|
|
129
|
-
utcseconds: d => new Date(d).getUTCSeconds(),
|
|
130
|
-
utcmilliseconds: d => new Date(d).getUTCMilliseconds(),
|
|
131
|
-
// sequence functions
|
|
132
|
-
length: x => x.length,
|
|
133
|
-
join: function () {
|
|
134
|
-
return apply('join', arguments);
|
|
135
|
-
},
|
|
136
|
-
indexof: function () {
|
|
137
|
-
return apply('indexOf', arguments);
|
|
138
|
-
},
|
|
139
|
-
lastindexof: function () {
|
|
140
|
-
return apply('lastIndexOf', arguments);
|
|
141
|
-
},
|
|
142
|
-
slice: function () {
|
|
143
|
-
return apply('slice', arguments);
|
|
144
|
-
},
|
|
145
|
-
reverse: x => x.slice().reverse(),
|
|
146
|
-
sort: x => x.slice().sort(ascending),
|
|
147
|
-
// string functions
|
|
148
|
-
parseFloat: parseFloat,
|
|
149
|
-
parseInt: parseInt,
|
|
150
|
-
upper: x => String(x).toUpperCase(),
|
|
151
|
-
lower: x => String(x).toLowerCase(),
|
|
152
|
-
substring: function () {
|
|
153
|
-
return apply('substring', arguments, String);
|
|
154
|
-
},
|
|
155
|
-
split: function () {
|
|
156
|
-
return apply('split', arguments, String);
|
|
157
|
-
},
|
|
158
|
-
replace: function () {
|
|
159
|
-
return apply('replace', arguments, String);
|
|
160
|
-
},
|
|
161
|
-
trim: x => String(x).trim(),
|
|
162
|
-
// Base64 encode/decode
|
|
163
|
-
// Convert binary string to base64-encoded ascii
|
|
164
|
-
btoa: x => btoa(x),
|
|
165
|
-
// Convert base64-encoded ascii to binary string
|
|
166
|
-
atob: x => atob(x),
|
|
167
|
-
// regexp functions
|
|
168
|
-
regexp: RegExp,
|
|
169
|
-
test: (r, t) => RegExp(r).test(t)
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
const EventFunctions = ['view', 'item', 'group', 'xy', 'x', 'y'];
|
|
173
|
-
const DisallowedMethods = new Set([Function, eval, setTimeout, setInterval]);
|
|
174
|
-
if (typeof setImmediate === 'function') DisallowedMethods.add(setImmediate);
|
|
175
|
-
const Visitors = {
|
|
176
|
-
Literal: ($, n) => n.value,
|
|
177
|
-
Identifier: ($, n) => {
|
|
178
|
-
const id = n.name;
|
|
179
|
-
return $.memberDepth > 0 ? id : id === 'datum' ? $.datum : id === 'event' ? $.event : id === 'item' ? $.item : Constants[id] || $.params['$' + id];
|
|
180
|
-
},
|
|
181
|
-
MemberExpression: ($, n) => {
|
|
182
|
-
const d = !n.computed,
|
|
183
|
-
o = $(n.object);
|
|
184
|
-
if (d) $.memberDepth += 1;
|
|
185
|
-
const p = $(n.property);
|
|
186
|
-
if (d) $.memberDepth -= 1;
|
|
187
|
-
if (DisallowedMethods.has(o[p])) {
|
|
188
|
-
// eslint-disable-next-line no-console
|
|
189
|
-
console.error(`Prevented interpretation of member "${p}" which could lead to insecure code execution`);
|
|
190
|
-
return;
|
|
191
|
-
}
|
|
192
|
-
return o[p];
|
|
193
|
-
},
|
|
194
|
-
CallExpression: ($, n) => {
|
|
195
|
-
const args = n.arguments;
|
|
196
|
-
let name = n.callee.name;
|
|
197
|
-
|
|
198
|
-
// handle special internal functions used by encoders
|
|
199
|
-
// re-route to corresponding standard function
|
|
200
|
-
if (name.startsWith('_')) {
|
|
201
|
-
name = name.slice(1);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
// special case "if" due to conditional evaluation of branches
|
|
205
|
-
return name === 'if' ? $(args[0]) ? $(args[1]) : $(args[2]) : ($.fn[name] || Functions[name]).apply($.fn, args.map($));
|
|
206
|
-
},
|
|
207
|
-
ArrayExpression: ($, n) => n.elements.map($),
|
|
208
|
-
BinaryExpression: ($, n) => Ops[n.operator]($(n.left), $(n.right)),
|
|
209
|
-
UnaryExpression: ($, n) => Unary[n.operator]($(n.argument)),
|
|
210
|
-
ConditionalExpression: ($, n) => $(n.test) ? $(n.consequent) : $(n.alternate),
|
|
211
|
-
LogicalExpression: ($, n) => n.operator === '&&' ? $(n.left) && $(n.right) : $(n.left) || $(n.right),
|
|
212
|
-
ObjectExpression: ($, n) => n.properties.reduce((o, p) => {
|
|
213
|
-
$.memberDepth += 1;
|
|
214
|
-
const k = $(p.key);
|
|
215
|
-
$.memberDepth -= 1;
|
|
216
|
-
const v = $(p.value);
|
|
217
|
-
if (DisallowedObjectProperties.has(k)) {
|
|
218
|
-
// eslint-disable-next-line no-console
|
|
219
|
-
console.error(`Prevented interpretation of property "${k}" which could lead to insecure code execution`);
|
|
220
|
-
} else if (DisallowedMethods.has(v)) {
|
|
221
|
-
// eslint-disable-next-line no-console
|
|
222
|
-
console.error(`Prevented interpretation of method "${v}" which could lead to insecure code execution`);
|
|
223
|
-
} else {
|
|
224
|
-
o[k] = v;
|
|
225
|
-
}
|
|
226
|
-
return o;
|
|
227
|
-
}, {})
|
|
228
|
-
};
|
|
229
|
-
function interpret (ast, fn, params, datum, event, item) {
|
|
230
|
-
const $ = n => Visitors[n.type]($, n);
|
|
231
|
-
$.memberDepth = 0;
|
|
232
|
-
$.fn = Object.create(fn);
|
|
233
|
-
$.params = params;
|
|
234
|
-
$.datum = datum;
|
|
235
|
-
$.event = event;
|
|
236
|
-
$.item = item;
|
|
237
|
-
|
|
238
|
-
// route event functions to annotated vega event context
|
|
239
|
-
EventFunctions.forEach(f => $.fn[f] = function () {
|
|
240
|
-
return event.vega[f](...arguments);
|
|
241
|
-
});
|
|
242
|
-
return $(ast);
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
var expression = {
|
|
246
|
-
/**
|
|
247
|
-
* Parse an expression used to update an operator value.
|
|
248
|
-
*/
|
|
249
|
-
operator(ctx, expr) {
|
|
250
|
-
const ast = expr.ast,
|
|
251
|
-
fn = ctx.functions;
|
|
252
|
-
return _ => interpret(ast, fn, _);
|
|
253
|
-
},
|
|
254
|
-
/**
|
|
255
|
-
* Parse an expression provided as an operator parameter value.
|
|
256
|
-
*/
|
|
257
|
-
parameter(ctx, expr) {
|
|
258
|
-
const ast = expr.ast,
|
|
259
|
-
fn = ctx.functions;
|
|
260
|
-
return (datum, _) => interpret(ast, fn, _, datum);
|
|
261
|
-
},
|
|
262
|
-
/**
|
|
263
|
-
* Parse an expression applied to an event stream.
|
|
264
|
-
*/
|
|
265
|
-
event(ctx, expr) {
|
|
266
|
-
const ast = expr.ast,
|
|
267
|
-
fn = ctx.functions;
|
|
268
|
-
return event => interpret(ast, fn, undefined, undefined, event);
|
|
269
|
-
},
|
|
270
|
-
/**
|
|
271
|
-
* Parse an expression used to handle an event-driven operator update.
|
|
272
|
-
*/
|
|
273
|
-
handler(ctx, expr) {
|
|
274
|
-
const ast = expr.ast,
|
|
275
|
-
fn = ctx.functions;
|
|
276
|
-
return (_, event) => {
|
|
277
|
-
const datum = event.item && event.item.datum;
|
|
278
|
-
return interpret(ast, fn, _, datum, event);
|
|
279
|
-
};
|
|
280
|
-
},
|
|
281
|
-
/**
|
|
282
|
-
* Parse an expression that performs visual encoding.
|
|
283
|
-
*/
|
|
284
|
-
encode(ctx, encode) {
|
|
285
|
-
const {
|
|
286
|
-
marktype,
|
|
287
|
-
channels
|
|
288
|
-
} = encode,
|
|
289
|
-
fn = ctx.functions,
|
|
290
|
-
swap = marktype === 'group' || marktype === 'image' || marktype === 'rect';
|
|
291
|
-
return (item, _) => {
|
|
292
|
-
const datum = item.datum;
|
|
293
|
-
let m = 0,
|
|
294
|
-
v;
|
|
295
|
-
for (const name in channels) {
|
|
296
|
-
v = interpret(channels[name].ast, fn, _, datum, undefined, item);
|
|
297
|
-
if (item[name] !== v) {
|
|
298
|
-
item[name] = v;
|
|
299
|
-
m = 1;
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
if (marktype !== 'rule') {
|
|
303
|
-
adjustSpatial(item, channels, swap);
|
|
304
|
-
}
|
|
305
|
-
return m;
|
|
306
|
-
};
|
|
307
|
-
}
|
|
308
|
-
};
|
|
309
|
-
|
|
310
|
-
export { expression as expressionInterpreter };
|