@hema-to/regl-scatterplot 1.14.1-hemato.3 → 1.16.0-hemato.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.
package/src/kdbush.js CHANGED
@@ -1,8 +1,6 @@
1
- // biome-ignore lint/style/useNamingConvention: KDBush is a library name
2
1
  import createKDBushClass from './kdbush-class.js';
3
2
  import workerFn from './kdbush-worker.js';
4
3
 
5
- // biome-ignore lint/style/useNamingConvention: KDBush is a library name
6
4
  const KDBush = createKDBushClass();
7
5
  const WORKER_THRESHOLD = 1000000;
8
6
 
@@ -10,7 +8,6 @@ const createWorker = (fn) => {
10
8
  const kdbushStr = createKDBushClass.toString();
11
9
  const fnStr = fn.toString();
12
10
  const workerStr =
13
- // biome-ignore lint/style/useTemplate: Prefer one assignment per line
14
11
  `const createKDBushClass = ${kdbushStr};` +
15
12
  'KDBush = createKDBushClass();' +
16
13
  `const createWorker = ${fnStr};` +
@@ -66,4 +63,6 @@ const createKdbush = (
66
63
  }
67
64
  });
68
65
 
66
+ export const kdbushFrom = (buffer) => KDBush.from(buffer);
67
+
69
68
  export default createKdbush;
@@ -9,7 +9,12 @@ import {
9
9
  withConstructor,
10
10
  withStaticProperty,
11
11
  } from '@flekschas/utils';
12
-
12
+ import {
13
+ DEFAULT_LASSO_LONG_PRESS_AFTER_EFFECT_TIME,
14
+ DEFAULT_LASSO_LONG_PRESS_EFFECT_DELAY,
15
+ DEFAULT_LASSO_LONG_PRESS_REVERT_EFFECT_TIME,
16
+ DEFAULT_LASSO_LONG_PRESS_TIME,
17
+ } from '../constants.js';
13
18
  import {
14
19
  DEFAULT_BRUSH_SIZE,
15
20
  DEFAULT_LASSO_MIN_DELAY,
@@ -20,13 +25,6 @@ import {
20
25
  LASSO_SHOW_START_INITIATOR_TIME,
21
26
  } from './constants.js';
22
27
 
23
- import {
24
- DEFAULT_LASSO_LONG_PRESS_AFTER_EFFECT_TIME,
25
- DEFAULT_LASSO_LONG_PRESS_EFFECT_DELAY,
26
- DEFAULT_LASSO_LONG_PRESS_REVERT_EFFECT_TIME,
27
- DEFAULT_LASSO_LONG_PRESS_TIME,
28
- } from '../constants.js';
29
-
30
28
  import {
31
29
  createLongPressInAnimations,
32
30
  createLongPressOutAnimations,
package/src/renderer.js CHANGED
@@ -65,10 +65,8 @@ export const createRenderer = (
65
65
  blend: {
66
66
  enable: true,
67
67
  func: {
68
- // biome-ignore lint/style/useNamingConvention: Regl internal
69
68
  srcRGB: 'one',
70
69
  srcAlpha: 'one',
71
- // biome-ignore lint/style/useNamingConvention: Regl internal
72
70
  dstRGB: 'one minus src alpha',
73
71
  dstAlpha: 'one minus src alpha',
74
72
  },
@@ -106,7 +106,6 @@ const worker = function worker() {
106
106
  * @param {[type]} simplified [description]
107
107
  * @return {[type]} [description]
108
108
  */
109
- // biome-ignore lint/style/useNamingConvention: DP stands for Douglas Peucker
110
109
  const simplifyDPStep = (points, first, last, tolerance, simplified) => {
111
110
  let maxDist = tolerance;
112
111
  let index;
@@ -214,7 +213,6 @@ const worker = function worker() {
214
213
  const groupedPoints = {};
215
214
 
216
215
  const isOrdered = !Number.isNaN(+points[0][5]);
217
- // biome-ignore lint/complexity/noForEach: somehow for .. of does not work in a worker
218
216
  points.forEach((point) => {
219
217
  const segId = point[4];
220
218
 
@@ -230,7 +228,6 @@ const worker = function worker() {
230
228
  });
231
229
 
232
230
  // The filtering ensures that non-existing array entries are removed
233
- // biome-ignore lint/complexity/noForEach: somehow for .. of does not work in a worker
234
231
  Object.entries(groupedPoints).forEach((idPoints) => {
235
232
  groupedPoints[idPoints[0]] = idPoints[1].filter((v) => v);
236
233
  // Store the first point as the reference
package/src/types.d.ts CHANGED
@@ -17,7 +17,6 @@ type MouseMode = 'panZoom' | 'lasso' | 'rotate';
17
17
 
18
18
  type PointScaleMode = 'constant' | 'asinh' | 'linear';
19
19
 
20
- // biome-ignore lint/style/useNamingConvention: ZWData are three words, z, w, and data
21
20
  type ZWDataType = 'continuous' | 'categorical';
22
21
 
23
22
  // biome-ignore lint/suspicious/noExplicitAny: Untyped external library
@@ -96,14 +95,12 @@ interface BaseAnnotation {
96
95
  lineWidth?: number;
97
96
  }
98
97
 
99
- // biome-ignore lint/style/useNamingConvention: HLine stands for HorizontalLine
100
98
  interface AnnotationHLine extends BaseAnnotation {
101
99
  y: number;
102
100
  x1?: number;
103
101
  x2?: number;
104
102
  }
105
103
 
106
- // biome-ignore lint/style/useNamingConvention: HLine stands for VerticalLine
107
104
  interface AnnotationVLine extends BaseAnnotation {
108
105
  x: number;
109
106
  y1?: number;
@@ -156,13 +153,13 @@ interface BaseOptions {
156
153
  aspectRatio: number;
157
154
  annotationLineColor: Color;
158
155
  annotationLineWidth: number;
159
- // biome-ignore lint/style/useNamingConvention: HVLine stands for HorizontalVerticalLine
160
156
  annotationHVLineLimit: number;
161
157
  // Nullifiable
162
158
  backgroundImage: null | import('regl').Texture2D | string;
163
159
  colorBy: null | DataEncoding;
164
160
  sizeBy: null | DataEncoding;
165
161
  opacityBy: null | DataEncoding;
162
+ pointOrder: null | number[] | Int32Array | Uint32Array;
166
163
  xScale: null | Scale;
167
164
  yScale: null | Scale;
168
165
  pointScaleMode: PointScaleMode;
@@ -171,7 +168,6 @@ interface BaseOptions {
171
168
  pixelAligned: boolean;
172
169
  }
173
170
 
174
- // biome-ignore lint/style/useNamingConvention: KDBush is a library name
175
171
  export interface CreateKDBushOptions {
176
172
  node: number;
177
173
  useWorker: boolean;
@@ -295,7 +291,10 @@ export type Events = import('pub-sub-es').Event<
295
291
  { coordinates: number[] }
296
292
  > &
297
293
  import('pub-sub-es').Event<'pointOver' | 'pointOut', number> &
298
- import('pub-sub-es').Event<'select' | 'focus', { points: number[]; lassoMode: LassoOptions["mode"]; }> &
294
+ import('pub-sub-es').Event<
295
+ 'select' | 'focus',
296
+ { points: number[]; lassoMode: LassoOptions['mode'] }
297
+ > &
299
298
  import('pub-sub-es').Event<'points', { points: number[][] }> &
300
299
  import('pub-sub-es').Event<'transitionEnd', import('regl').Regl> &
301
300
  import('pub-sub-es').Event<
package/src/utils.js CHANGED
@@ -85,7 +85,6 @@ export const dist = (x1, y1, x2, y2) =>
85
85
  * @return {array} Quadruple of form `[xMin, yMin, xMax, yMax]` defining the
86
86
  * bounding box
87
87
  */
88
- // biome-ignore lint/style/useNamingConvention: BBox stands for BoundingBox
89
88
  export const getBBox = (positions2d) => {
90
89
  let xMin = Number.POSITIVE_INFINITY;
91
90
  let xMax = Number.NEGATIVE_INFINITY;
@@ -107,7 +106,6 @@ export const getBBox = (positions2d) => {
107
106
  * @param {array} bBox The bounding box to be checked
108
107
  * @return {array} `true` if the bounding box is valid
109
108
  */
110
- // biome-ignore lint/style/useNamingConvention: BBox stands for BoundingBox
111
109
  export const isValidBBox = ([xMin, yMin, xMax, yMax]) =>
112
110
  Number.isFinite(xMin) &&
113
111
  Number.isFinite(yMin) &&
@@ -496,7 +494,6 @@ export const toArrayOrientedPoints = (points) =>
496
494
  (Array.isArray(points.line) || ArrayBuffer.isView(points.line)) &&
497
495
  ((i) => points.line[i]);
498
496
 
499
- // biome-ignore lint/style/useNamingConvention: LO stands for line and order
500
497
  const getLO =
501
498
  (Array.isArray(points.lineOrder) ||
502
499
  ArrayBuffer.isView(points.lineOrder)) &&
@@ -578,9 +575,48 @@ export const isRect = (annotation) =>
578
575
  Number.isFinite(annotation.x2) &&
579
576
  Number.isFinite(annotation.x2);
580
577
 
581
- export const isPolygon = (annotation) =>
578
+ export const isPolygonAnnotation = (annotation) =>
582
579
  'vertices' in annotation && annotation.vertices.length > 1;
583
580
 
581
+ /**
582
+ * Check if an array is a valid list of 2D vertices
583
+ * @param {any} arg - The argument to check
584
+ * @returns {boolean} True if argument is an array of [x, y] coordinate pairs
585
+ */
586
+ export const isVertices = (arg) => {
587
+ if (!Array.isArray(arg) || arg.length < 3) {
588
+ return false;
589
+ }
590
+
591
+ for (const vertex of arg) {
592
+ if (
593
+ !Array.isArray(vertex) ||
594
+ vertex.length !== 2 ||
595
+ typeof vertex[0] !== 'number' ||
596
+ typeof vertex[1] !== 'number'
597
+ ) {
598
+ return false;
599
+ }
600
+ }
601
+
602
+ return true;
603
+ };
604
+
605
+ /**
606
+ * Ensure a list of vertices forms a closed polygon
607
+ * @param {Array<[number, number]>} vertices - Array of [x, y] coordinates
608
+ * @returns {Array<[number, number]>} Closed polygon (first vertex repeated at end if needed)
609
+ */
610
+ export const verticesToPolygon = (vertices) => {
611
+ const polygon = [...vertices];
612
+ const firstVertex = vertices.at(0);
613
+ const lastVertex = vertices.at(-1);
614
+ if (firstVertex[0] !== lastVertex[0] || firstVertex[1] !== lastVertex[1]) {
615
+ polygon.push(firstVertex);
616
+ }
617
+ return polygon;
618
+ };
619
+
584
620
  export const insertionSort = (array) => {
585
621
  const end = array.length;
586
622
  for (let i = 1; i < end; i++) {