@genome-spy/core 0.39.0 → 0.41.0

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.
Files changed (49) hide show
  1. package/dist/bundle/index.es.js +3619 -3459
  2. package/dist/bundle/index.js +73 -80
  3. package/dist/schema.json +215 -44
  4. package/dist/src/encoder/accessor.js +4 -2
  5. package/dist/src/genomeSpy.d.ts +2 -0
  6. package/dist/src/genomeSpy.d.ts.map +1 -1
  7. package/dist/src/genomeSpy.js +5 -0
  8. package/dist/src/gl/includes/scales.glsl.js +1 -1
  9. package/dist/src/gl/link.fragment.glsl.js +1 -1
  10. package/dist/src/gl/link.vertex.glsl.js +1 -1
  11. package/dist/src/gl/point.common.glsl.js +2 -0
  12. package/dist/src/gl/point.fragment.glsl.js +1 -1
  13. package/dist/src/gl/point.vertex.glsl.js +1 -1
  14. package/dist/src/gl/rect.vertex.glsl.js +1 -1
  15. package/dist/src/gl/rule.common.glsl.js +2 -0
  16. package/dist/src/gl/rule.fragment.glsl.js +1 -1
  17. package/dist/src/gl/rule.vertex.glsl.js +1 -1
  18. package/dist/src/gl/text.common.glsl.js +2 -0
  19. package/dist/src/gl/text.fragment.glsl.js +1 -1
  20. package/dist/src/gl/text.vertex.glsl.js +1 -1
  21. package/dist/src/marks/link.d.ts.map +1 -1
  22. package/dist/src/marks/link.js +30 -12
  23. package/dist/src/marks/mark.d.ts +35 -4
  24. package/dist/src/marks/mark.d.ts.map +1 -1
  25. package/dist/src/marks/mark.js +84 -1
  26. package/dist/src/marks/pointMark.d.ts.map +1 -1
  27. package/dist/src/marks/pointMark.js +21 -9
  28. package/dist/src/marks/rectMark.d.ts +1 -2
  29. package/dist/src/marks/rectMark.d.ts.map +1 -1
  30. package/dist/src/marks/rectMark.js +28 -17
  31. package/dist/src/marks/rule.d.ts.map +1 -1
  32. package/dist/src/marks/rule.js +17 -6
  33. package/dist/src/marks/text.d.ts.map +1 -1
  34. package/dist/src/marks/text.js +22 -7
  35. package/dist/src/paramBroker.d.ts +30 -0
  36. package/dist/src/paramBroker.d.ts.map +1 -0
  37. package/dist/src/paramBroker.js +102 -0
  38. package/dist/src/spec/mark.d.ts +46 -16
  39. package/dist/src/spec/view.d.ts +2 -1
  40. package/dist/src/types/viewContext.d.ts +2 -0
  41. package/dist/src/utils/expression.d.ts +12 -2
  42. package/dist/src/utils/expression.d.ts.map +1 -1
  43. package/dist/src/utils/expression.js +68 -9
  44. package/dist/src/utils/linearstep.d.ts +7 -0
  45. package/dist/src/utils/linearstep.d.ts.map +1 -0
  46. package/dist/src/utils/linearstep.js +10 -0
  47. package/dist/src/view/view.d.ts.map +1 -1
  48. package/dist/src/view/view.js +6 -0
  49. package/package.json +2 -2
@@ -0,0 +1,102 @@
1
+ import { isString } from "vega-util";
2
+ import createFunction from "./utils/expression.js";
3
+
4
+ /**
5
+ * A class that manages parameters and expressions. Still a work in progress.
6
+ *
7
+ * TODO: Write tests for this class.
8
+ *
9
+ * This should eventually handle the following:
10
+ * - Parameter registration
11
+ * - Dependency tracking
12
+ * - Calling observers when a parameter changes
13
+ * - Somehow saving parameter "state" (in bookmarks)
14
+ * - Maybe something else
15
+ */
16
+ export default class ParamBroker {
17
+ /** @type {Map<string, any>} */
18
+ #params;
19
+
20
+ /** @type {Set<string>} */
21
+ #allocatedSetters;
22
+
23
+ /** @type {Record<string, any>} */
24
+ #proxy;
25
+
26
+ /** @type {Map<string, Set<() => void>>} */
27
+ #paramListeners;
28
+
29
+ constructor() {
30
+ this.#params = new Map();
31
+ this.#allocatedSetters = new Set();
32
+ this.#paramListeners = new Map();
33
+
34
+ this.#proxy = new Proxy(this.#params, {
35
+ get(target, prop) {
36
+ return isString(prop) ? target.get(prop) : undefined;
37
+ },
38
+ });
39
+ }
40
+
41
+ /**
42
+ *
43
+ * @param {string} paramName
44
+ * @returns {(value: any) => void}
45
+ */
46
+ allocateSetter(paramName) {
47
+ if (this.#allocatedSetters.has(paramName)) {
48
+ throw new Error(
49
+ "Setter already allocated for parameter: " + paramName
50
+ );
51
+ }
52
+
53
+ this.#allocatedSetters.add(paramName);
54
+
55
+ return (value) => {
56
+ this.#params.set(paramName, value);
57
+
58
+ const listeners = this.#paramListeners.get(paramName);
59
+ if (listeners) {
60
+ for (const listener of listeners) {
61
+ listener();
62
+ }
63
+ }
64
+ };
65
+ }
66
+
67
+ // TODO: deallocateSetter
68
+
69
+ /**
70
+ * Parse expr and return a function that returns the value of the parameter.
71
+ *
72
+ * @param {string} expr
73
+ */
74
+ createExpression(expr) {
75
+ /** @type {import("./utils/expression.js").ExpressionFunction & { addListener: (listener: () => void) => void}} */
76
+ const fn = /** @type {any} */ (createFunction(expr, this.#proxy));
77
+
78
+ for (const g of fn.globals) {
79
+ if (!this.#allocatedSetters.has(g)) {
80
+ throw new Error(
81
+ `Unknown variable "${g}" in expression: ${expr}`
82
+ );
83
+ }
84
+ }
85
+
86
+ /**
87
+ *
88
+ * @param {() => void} listener
89
+ */
90
+ fn.addListener = (listener) => {
91
+ for (const g of fn.globals) {
92
+ const listeners = this.#paramListeners.get(g) ?? new Set();
93
+ this.#paramListeners.set(g, listeners);
94
+ listeners.add(listener);
95
+ }
96
+ };
97
+
98
+ // TODO: remove listener
99
+
100
+ return fn;
101
+ }
102
+ }
@@ -2,6 +2,15 @@ import { Scalar } from "./channel.js";
2
2
  import { Align, Baseline, FontStyle, FontWeight } from "./font.js";
3
3
  import { Tooltip } from "./tooltip.js";
4
4
 
5
+ // TODO: This may not be the best place for this type.
6
+ // Also, this is now similar to the ExprDef type in channel.d.ts
7
+ export interface ExprRef {
8
+ /**
9
+ * The expression string.
10
+ */
11
+ expr: string;
12
+ }
13
+
5
14
  export type MarkType = "rect" | "point" | "rule" | "text" | "link";
6
15
 
7
16
  export interface FillAndStrokeProps {
@@ -63,7 +72,7 @@ export interface RectProps extends SecondaryPositionProps {
63
72
  * **Default value:** `0`
64
73
  */
65
74
  // TODO: Rename to minCompensatedOpacity or something like that
66
- minOpacity?: number;
75
+ minOpacity?: number | ExprRef;
67
76
 
68
77
  /**
69
78
  * The minimum width of a rectangle in pixels. The property clamps rectangles'
@@ -74,49 +83,49 @@ export interface RectProps extends SecondaryPositionProps {
74
83
  *
75
84
  * **Default value:** `1`
76
85
  */
77
- minWidth?: number;
86
+ minWidth?: number | ExprRef;
78
87
 
79
88
  /**
80
89
  * The minimum height of a rectangle in pixels. The property clamps rectangles' heights.
81
90
  *
82
91
  * **Default value:** `0`
83
92
  */
84
- minHeight?: number;
93
+ minHeight?: number | ExprRef;
85
94
 
86
95
  /**
87
96
  * Radius of the rounded corners.
88
97
  *
89
98
  * **Default value:** `0`
90
99
  */
91
- cornerRadius?: number;
100
+ cornerRadius?: number | ExprRef;
92
101
 
93
102
  /**
94
103
  * Radius of the top left rounded corner. Has higher precedence than `cornerRadius`.
95
104
  *
96
105
  * **Default value:** (None)
97
106
  */
98
- cornerRadiusTopLeft?: number;
107
+ cornerRadiusTopLeft?: number | ExprRef;
99
108
 
100
109
  /**
101
110
  * Radius of the top right rounded corner. Has higher precedence than `cornerRadius`.
102
111
  *
103
112
  * **Default value:** (None)
104
113
  */
105
- cornerRadiusTopRight?: number;
114
+ cornerRadiusTopRight?: number | ExprRef;
106
115
 
107
116
  /**
108
117
  * Radius of the bottom left rounded corner. Has higher precedence than `cornerRadius`.
109
118
  *
110
119
  * **Default value:** (None)
111
120
  */
112
- cornerRadiusBottomLeft?: number;
121
+ cornerRadiusBottomLeft?: number | ExprRef;
113
122
 
114
123
  /**
115
124
  * Radius of the bottom right rounded corner. Has higher precedence than `cornerRadius`.
116
125
  *
117
126
  * **Default value:** (None)
118
127
  */
119
- cornerRadiusBottomRight?: number;
128
+ cornerRadiusBottomRight?: number | ExprRef;
120
129
  }
121
130
 
122
131
  export interface RuleProps extends SecondaryPositionProps {
@@ -126,7 +135,7 @@ export interface RuleProps extends SecondaryPositionProps {
126
135
  *
127
136
  * **Default value:** `0`
128
137
  */
129
- minLength?: number;
138
+ minLength?: number | ExprRef;
130
139
 
131
140
  /**
132
141
  * An array of of alternating stroke and gap lengths or `null` for solid strokes.
@@ -147,7 +156,7 @@ export interface RuleProps extends SecondaryPositionProps {
147
156
  *
148
157
  * **Default value:** `"butt"`
149
158
  */
150
- strokeCap?: "butt" | "square" | "round";
159
+ strokeCap?: "butt" | "square" | "round" | ExprRef;
151
160
  }
152
161
 
153
162
  export interface TextProps
@@ -333,7 +342,7 @@ export interface LinkProps extends SecondaryPositionProps {
333
342
  *
334
343
  * **Default value:** `"arc"`
335
344
  */
336
- linkShape?: "arc" | "diagonal" | "line" | "dome";
345
+ linkShape?: "arc" | "diagonal" | "line" | "dome" | ExprRef;
337
346
 
338
347
  /**
339
348
  * The orientation of the link path. Either `"vertical"` or `"horizontal"`.
@@ -341,7 +350,7 @@ export interface LinkProps extends SecondaryPositionProps {
341
350
  *
342
351
  * **Default value:** `"vertical"`
343
352
  */
344
- orient?: "vertical" | "horizontal";
353
+ orient?: "vertical" | "horizontal" | ExprRef;
345
354
 
346
355
  /**
347
356
  * Whether the apex of the `"dome"` shape is clamped to the viewport edge. When over a
@@ -350,7 +359,7 @@ export interface LinkProps extends SecondaryPositionProps {
350
359
  *
351
360
  * **Default value:** `false`
352
361
  */
353
- clampApex?: boolean;
362
+ clampApex?: boolean | ExprRef;
354
363
 
355
364
  /**
356
365
  * The number of segments in the bézier curve. Affects the rendering quality and performance.
@@ -365,14 +374,35 @@ export interface LinkProps extends SecondaryPositionProps {
365
374
  *
366
375
  * **Default value:** `1.0`
367
376
  */
368
- arcHeightFactor?: number;
377
+ arcHeightFactor?: number | ExprRef;
369
378
 
370
379
  /**
371
380
  * The minimum height of an `"arc"` shape. Makes very short links more clearly visible.
372
381
  *
373
382
  * **Default value:** `1.5`
374
383
  */
375
- minArcHeight?: number;
384
+ minArcHeight?: number | ExprRef;
385
+
386
+ /**
387
+ * The maximum length of `"arc"` shape's chord in pixels. The chord is the line segment
388
+ * between the two points that define the arc. Limiting the chord length serves two purposes
389
+ * when zooming in close enough:
390
+ * 1) it prevents the arc from becoming a straight line and
391
+ * 2) it mitigates the limited precision of floating point numbers in arc rendering.
392
+ *
393
+ * **Default value:** `50000`
394
+ */
395
+ maxChordLength?: number | ExprRef;
396
+
397
+ /**
398
+ * The range of the `"arc"` shape's fading distance in pixels. This property allows for
399
+ * making the arc's opacity fade out as it extends away from the chord. The fading distance
400
+ * is interpolated from one to zero between the interval defined by this property.
401
+ * Both `false` and `[0, 0]` disable fading.
402
+ *
403
+ * **Default value:** `false`
404
+ */
405
+ arcFadingDistance?: [number, number] | false | ExprRef;
376
406
 
377
407
  /**
378
408
  * The minimum stroke width of the links when pointing with the mouse cursor.
@@ -380,7 +410,7 @@ export interface LinkProps extends SecondaryPositionProps {
380
410
  *
381
411
  * **Default value:** `3.0`
382
412
  */
383
- minPickingSize?: number;
413
+ minPickingSize?: number | ExprRef;
384
414
  }
385
415
 
386
416
  // TODO: Mark-specific configs
@@ -7,6 +7,7 @@ import {
7
7
  PrimaryPositionalChannel,
8
8
  } from "./channel.js";
9
9
  import {
10
+ ExprRef,
10
11
  FillAndStrokeProps,
11
12
  MarkConfigAndType,
12
13
  MarkType,
@@ -43,7 +44,7 @@ export interface DynamicOpacity {
43
44
  values: number[];
44
45
  }
45
46
 
46
- export type ViewOpacityDef = number | DynamicOpacity;
47
+ export type ViewOpacityDef = number | DynamicOpacity | ExprRef;
47
48
 
48
49
  export interface Step {
49
50
  step: number;
@@ -11,6 +11,7 @@ import { Datum } from "../data/flowNode.js";
11
11
  import { ImportSpec, ViewSpec } from "../spec/view.js";
12
12
  import ContainerView from "./containerView.js";
13
13
  import { BroadcastEventType } from "../genomeSpy.js";
14
+ import ParamBroker from "../paramBroker.js";
14
15
 
15
16
  export interface Hover {
16
17
  mark: Mark;
@@ -28,6 +29,7 @@ export default interface ViewContext {
28
29
  genomeStore?: GenomeStore;
29
30
  fontManager: BmFontManager;
30
31
 
32
+ paramBroker: ParamBroker;
31
33
  devicePixelRatio: number;
32
34
 
33
35
  requestLayoutReflow: () => void;
@@ -1,9 +1,19 @@
1
1
  /**
2
+ * @typedef { object } ExpressionProps
3
+ * @prop { string[] } fields
4
+ * @prop { string[] } globals
5
+ * @prop { string } code
6
+ *
7
+ * @typedef { ((x: object) => any) & ExpressionProps } ExpressionFunction
2
8
  *
3
9
  * @param {string} expr
10
+ * @returns {ExpressionFunction}
4
11
  */
5
- export default function createFunction(expr: string, globalObject?: {}): {
6
- (x: object): any;
12
+ export default function createFunction(expr: string, globalObject?: {}): ExpressionFunction;
13
+ export type ExpressionProps = {
7
14
  fields: string[];
15
+ globals: string[];
16
+ code: string;
8
17
  };
18
+ export type ExpressionFunction = ((x: object) => any) & ExpressionProps;
9
19
  //# sourceMappingURL=expression.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"expression.d.ts","sourceRoot":"","sources":["../../../src/utils/expression.js"],"names":[],"mappings":"AAEA;;;GAGG;AACH,6CAFW,MAAM;QAqBwB,MAAM;;EAO9C"}
1
+ {"version":3,"file":"expression.d.ts","sourceRoot":"","sources":["../../../src/utils/expression.js"],"names":[],"mappings":"AAyDA;;;;;;;;;;GAUG;AACH,6CAHW,MAAM,sBACJ,kBAAkB,CAyB9B;;YAhCU,MAAM,EAAE;aACR,MAAM,EAAE;UACR,MAAM;;sCAEE,MAAM,KAAK,GAAG"}
@@ -1,17 +1,72 @@
1
- import { parseExpression, codegenExpression } from "vega-expression";
1
+ import { parseExpression, codegenExpression, functions } from "vega-expression";
2
+ import {
3
+ isArray,
4
+ isBoolean,
5
+ isNumber,
6
+ isObject,
7
+ isRegExp,
8
+ isString,
9
+ lerp,
10
+ } from "vega-util";
11
+ import smoothstep from "./smoothstep.js";
12
+ import clamp from "./clamp.js";
13
+ import linearstep from "./linearstep.js";
2
14
 
3
15
  /**
16
+ * Some bits are adapted from https://github.com/vega/vega/blob/main/packages/vega-functions/src/codegen.js
17
+ */
18
+ const functionContext = {
19
+ clamp,
20
+ isArray,
21
+ isBoolean,
22
+ isDefined(/** @type {any} */ _) {
23
+ return _ !== undefined;
24
+ },
25
+ isNumber,
26
+ isObject,
27
+ isRegExp,
28
+ isString,
29
+ isValid(/** @type {any} */ _) {
30
+ // eslint-disable-next-line no-self-compare
31
+ return _ != null && _ === _;
32
+ },
33
+ lerp,
34
+ linearstep,
35
+ smoothstep,
36
+ };
37
+
38
+ /**
39
+ * @param {typeof codegenExpression} codegen
40
+ */
41
+ function buildFunctions(codegen) {
42
+ const fn = functions(codegen);
43
+ // eslint-disable-next-line guard-for-in
44
+ for (const name in functionContext) {
45
+ fn[name] = `this.${name}`;
46
+ }
47
+ return fn;
48
+ }
49
+
50
+ const cg = codegenExpression({
51
+ forbidden: [],
52
+ allowed: ["datum"],
53
+ globalvar: "globalObject",
54
+ fieldvar: "datum",
55
+ functions: buildFunctions,
56
+ });
57
+
58
+ /**
59
+ * @typedef { object } ExpressionProps
60
+ * @prop { string[] } fields
61
+ * @prop { string[] } globals
62
+ * @prop { string } code
63
+ *
64
+ * @typedef { ((x: object) => any) & ExpressionProps } ExpressionFunction
4
65
  *
5
66
  * @param {string} expr
67
+ * @returns {ExpressionFunction}
6
68
  */
7
69
  export default function createFunction(expr, globalObject = {}) {
8
- const cg = codegenExpression({
9
- forbidden: [],
10
- allowed: ["datum"],
11
- globalvar: "globalObject",
12
- fieldvar: "datum",
13
- });
14
-
15
70
  try {
16
71
  const parsed = parseExpression(expr);
17
72
  const generatedCode = cg(parsed);
@@ -21,11 +76,15 @@ export default function createFunction(expr, globalObject = {}) {
21
76
  "datum",
22
77
  "globalObject",
23
78
  `"use strict"; return (${generatedCode.code});`
24
- );
79
+ ).bind(functionContext);
25
80
 
81
+ /** @type { ExpressionFunction } */
26
82
  const exprFunction = /** @param {object} x */ (x) =>
27
83
  fn(x, globalObject);
28
84
  exprFunction.fields = generatedCode.fields;
85
+ exprFunction.globals = generatedCode.globals;
86
+ exprFunction.code = generatedCode.code;
87
+
29
88
  return exprFunction;
30
89
  } catch (e) {
31
90
  throw new Error(`Invalid expression: ${expr}, ${e.message}`);
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @param {number} edge0
3
+ * @param {number} edge1
4
+ * @param {number} x
5
+ */
6
+ export default function linearstep(edge0: number, edge1: number, x: number): number;
7
+ //# sourceMappingURL=linearstep.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"linearstep.d.ts","sourceRoot":"","sources":["../../../src/utils/linearstep.js"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,0CAJW,MAAM,SACN,MAAM,KACN,MAAM,UAIhB"}
@@ -0,0 +1,10 @@
1
+ import clamp from "./clamp.js";
2
+
3
+ /**
4
+ * @param {number} edge0
5
+ * @param {number} edge1
6
+ * @param {number} x
7
+ */
8
+ export default function linearstep(edge0, edge1, x) {
9
+ return clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0);
10
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../../src/view/view.js"],"names":[],"mappings":"AAwBA,oBAAoB;AACpB,sCAAuC;AACvC,0BAA0B;AAC1B,sCAAuC;AAKvC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH;IAeI;;;;;;;;;OASG;IACH,kBARW,OAAO,iBAAiB,EAAE,QAAQ,WAClC,OAAO,yBAAyB,EAAE,OAAO,gBACzC,OAAO,oBAAoB,EAAE,OAAO,cACpC,OAAO,WAAW,EAAE,OAAO,QAC3B,MAAM,YACN,WAAW,EAwCrB;IApDD;;OAEG;IACH,wBAFmB,MAAM,KAAE,MAAM,CAEQ;IAiBrC,mDAAsB;IACtB,mDAAgC;IAChC,iBAA4B;IAC5B,aAA6B;IAC7B,yCAAgB;IAEhB;QACI;;;WAGG;eADO,QAAQ,OAAO,OAAO,oBAAoB,EAAE,gBAAgB,EAAE,OAAO,sBAAsB,EAAE,OAAO,CAAC,CAAC;QAGhH;;;WAGG;cADO,QAAQ,OAAO,OAAO,oBAAoB,EAAE,wBAAwB,EAAE,OAAO,qBAAqB,EAAE,OAAO,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;;;OAIG;IACH,8BAHW,MAAM,cACN,MAAM,GAAG,SAAS,GAAG,WAAW,QAiB1C;IAED,4BAEC;IAED;;;;;OAKG;IACH,iCAFW,OAAO,8BAA8B,EAAE,OAAO,QAIxD;;CACJ;AAqEM,iCAHI,GAAG,0CAGkC;0BAnsBnC,8BAAsB,IAAI;qCAG5B,IAAI,KACF,WAAW;sBAEX,eAAe,GAAG;IAC9B,SAAgB,CAAC,SAAW,IAAI,KAAE,IAAI,CAAC;IACvC,cAAqB,CAAC,SAAW,IAAI,KAAE,IAAI,CAAC;IAC5C,aAAoB,CAAC,SAAW,IAAI,KAAE,IAAI,CAAA;CAAC;;;;;UAIlC,OAAO,iBAAiB,EAAE,kBAAkB;;;;cAC5C,GAAG;;gDAGF,OAAO,uBAAuB,EAAE,OAAO,SAEvC,OAAO,8BAA8B,EAAE,OAAO;;;;;+BAG/C,OAAO;;;;+BAEP,OAAO;;oBArDG,qBAAqB;+BADlC,wBAAwB"}
@@ -16,6 +16,7 @@ import { appendToBaseUrl } from "../utils/url.js";
16
16
  import { isDiscrete, bandSpace } from "vega-scale";
17
17
  import { peek } from "../utils/arrayUtils.js";
18
18
  import ViewError from "./viewError.js";
19
+ import { isExprRef } from "../marks/mark.js";
19
20
 
20
21
  // TODO: View classes have too many responsibilities. Come up with a way
21
22
  // to separate the concerns. However, most concerns are tightly tied to
@@ -723,6 +724,11 @@ function createViewOpacityFunction(view) {
723
724
 
724
725
  return interpolate(unitsPerPixel) * parentOpacity;
725
726
  };
727
+ } else if (isExprRef(opacityDef)) {
728
+ const fn = view.context.paramBroker.createExpression(
729
+ opacityDef.expr
730
+ );
731
+ return (parentOpacity) => fn(null) * parentOpacity;
726
732
  }
727
733
  }
728
734
  return (parentOpacity) => parentOpacity;
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  },
8
8
  "contributors": [],
9
9
  "license": "MIT",
10
- "version": "0.39.0",
10
+ "version": "0.41.0",
11
11
  "jsdelivr": "dist/bundle/index.js",
12
12
  "unpkg": "dist/bundle/index.js",
13
13
  "browser": "dist/bundle/index.js",
@@ -65,5 +65,5 @@
65
65
  "vega-scale": "^7.1.1",
66
66
  "vega-util": "^1.16.0"
67
67
  },
68
- "gitHead": "62718f51e03f665435dd2f3b557e20b42df1410e"
68
+ "gitHead": "b9e91be6b770d888429a3dc970c6468f776c76d4"
69
69
  }