@spider-analyzer/timeline 5.0.8 → 5.0.9
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/CHANGELOG.md +14 -0
- package/dist/index.js +22 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/TimeLine.tsx +24 -10
- package/src/timeLineElements/Histogram.jsx +4 -2
- package/src/timeLineElements/XAxis.jsx +4 -2
- package/src/timeLineElements/XGrid.jsx +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## 5.0.9
|
|
2
|
+
|
|
3
|
+
- Perf: cursor edge now tracks the pointer during drag/resize/draw, as
|
|
4
|
+
it did in the pre-hooks class component. Drag/resize hot paths
|
|
5
|
+
(`moveTimeLine`, `onDragCursor`, `onResizeLeftCursor`,
|
|
6
|
+
`onResizeRightCursor`, `onDrawCursor`) commit state via a
|
|
7
|
+
`flushSync`-wrapped `patchStateSync`. React 18 otherwise batches
|
|
8
|
+
updates from d3-drag's native listeners to its scheduler, adding ~1
|
|
9
|
+
frame of latency between pointer and cursor border. Also wrapped
|
|
10
|
+
`Histogram`, `XAxis`, `XGrid` in `React.memo` so the synchronous
|
|
11
|
+
per-event render only reconciles the Cursor subtree; heavy
|
|
12
|
+
histogram/axis/grid trees are skipped when only `start`/`stop`
|
|
13
|
+
change.
|
|
14
|
+
|
|
1
15
|
## 5.0.8
|
|
2
16
|
|
|
3
17
|
- Perf: memoize the per-render histogram bar list and vertical scale.
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var react = require('react');
|
|
6
|
+
var reactDom = require('react-dom');
|
|
6
7
|
var luxon = require('luxon');
|
|
7
8
|
var d3Scale = require('d3-scale');
|
|
8
9
|
var PropTypes11 = require('prop-types');
|
|
@@ -1429,6 +1430,7 @@ Histogram.propTypes = {
|
|
|
1429
1430
|
barHovered: PropTypes11__default.default.number,
|
|
1430
1431
|
tooltipVisible: PropTypes11__default.default.bool
|
|
1431
1432
|
};
|
|
1433
|
+
var Histogram_default = react.memo(Histogram);
|
|
1432
1434
|
|
|
1433
1435
|
// src/timeLineElements/axesStyles.jsx
|
|
1434
1436
|
var arrow = `m 0,-5 5,5 -5,5`;
|
|
@@ -1514,6 +1516,7 @@ XAxis.propTypes = {
|
|
|
1514
1516
|
arrowPath: PropTypes11__default.default.string,
|
|
1515
1517
|
onFormatTimeLegend: PropTypes11__default.default.func.isRequired
|
|
1516
1518
|
};
|
|
1519
|
+
var XAxis_default = react.memo(XAxis);
|
|
1517
1520
|
function YAxis({ classes, marks, yAxis, onFormatMetricLegend, maxHeight, origin, arrowPath = arrow }) {
|
|
1518
1521
|
const className = (n) => cn(n, classes);
|
|
1519
1522
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -1968,6 +1971,7 @@ XAxis2.propTypes = {
|
|
|
1968
1971
|
xAxis: PropTypes11__default.default.func,
|
|
1969
1972
|
yAxisHeight: PropTypes11__default.default.number
|
|
1970
1973
|
};
|
|
1974
|
+
var XGrid_default = react.memo(XAxis2);
|
|
1971
1975
|
|
|
1972
1976
|
// src/time.ts
|
|
1973
1977
|
function toMoment(x, zone) {
|
|
@@ -1990,8 +1994,8 @@ function timeSpanToMoments(t, zone) {
|
|
|
1990
1994
|
return { start: toMomentOpt(t.start, zone), stop: toMomentOpt(t.stop, zone) };
|
|
1991
1995
|
}
|
|
1992
1996
|
var Cursor2 = Cursor;
|
|
1993
|
-
var Histogram2 =
|
|
1994
|
-
var XAxis3 =
|
|
1997
|
+
var Histogram2 = Histogram_default;
|
|
1998
|
+
var XAxis3 = XAxis_default;
|
|
1995
1999
|
var YAxis3 = YAxis;
|
|
1996
2000
|
var Legend2 = Legend;
|
|
1997
2001
|
var Tools2 = Tools;
|
|
@@ -2086,6 +2090,11 @@ var TimeLineInner = react.forwardRef(function TimeLine(props, ref) {
|
|
|
2086
2090
|
const patchState = react.useCallback((patch) => {
|
|
2087
2091
|
setStateRaw((s) => ({ ...s, ...typeof patch === "function" ? patch(s) : patch }));
|
|
2088
2092
|
}, []);
|
|
2093
|
+
const patchStateSync = react.useCallback((patch) => {
|
|
2094
|
+
reactDom.flushSync(() => {
|
|
2095
|
+
setStateRaw((s) => ({ ...s, ...typeof patch === "function" ? patch(s) : patch }));
|
|
2096
|
+
});
|
|
2097
|
+
}, []);
|
|
2089
2098
|
const checkAndCorrectDomain = react.useCallback(({ domain: domain2 }) => {
|
|
2090
2099
|
return checkAndCorrectDomainPure({
|
|
2091
2100
|
domain: domain2,
|
|
@@ -2329,9 +2338,9 @@ var TimeLineInner = react.forwardRef(function TimeLine(props, ref) {
|
|
|
2329
2338
|
movedSinceLastFetchedRef.current = 0;
|
|
2330
2339
|
getItems(p, { min, max: max2 });
|
|
2331
2340
|
}
|
|
2332
|
-
|
|
2341
|
+
patchStateSync({ domain: { min, max: max2 }, minTime, maxTime, ticks: ticks2 });
|
|
2333
2342
|
}
|
|
2334
|
-
}, [moveTimeLineCore, getItems,
|
|
2343
|
+
}, [moveTimeLineCore, getItems, patchStateSync]);
|
|
2335
2344
|
const onResizeLeftCursor = react.useCallback((delta, mouse) => {
|
|
2336
2345
|
const xAxis = xAxisRef.current;
|
|
2337
2346
|
const s = stateRef.current;
|
|
@@ -2351,9 +2360,9 @@ var TimeLineInner = react.forwardRef(function TimeLine(props, ref) {
|
|
|
2351
2360
|
}
|
|
2352
2361
|
handleAutoSliding(mouse, onResizeLeftCursor);
|
|
2353
2362
|
if (newStop !== s.stop && newStop.isSameOrBefore(s.domain.max) || newStart.isSameOrAfter(s.domain.min)) {
|
|
2354
|
-
|
|
2363
|
+
patchStateSync({ start: newStart, stop: newStop, maxTimespan: maxTimespan2 });
|
|
2355
2364
|
}
|
|
2356
|
-
}, [handleAutoSliding,
|
|
2365
|
+
}, [handleAutoSliding, patchStateSync]);
|
|
2357
2366
|
const onResizeRightCursor = react.useCallback((delta, mouse) => {
|
|
2358
2367
|
const xAxis = xAxisRef.current;
|
|
2359
2368
|
const s = stateRef.current;
|
|
@@ -2373,9 +2382,9 @@ var TimeLineInner = react.forwardRef(function TimeLine(props, ref) {
|
|
|
2373
2382
|
}
|
|
2374
2383
|
handleAutoSliding(mouse, onResizeRightCursor);
|
|
2375
2384
|
if (newStop.isSameOrBefore(s.domain.max) && newStart.isSameOrAfter(s.domain.min)) {
|
|
2376
|
-
|
|
2385
|
+
patchStateSync({ start: newStart, stop: newStop, maxTimespan: maxTimespan2 });
|
|
2377
2386
|
}
|
|
2378
|
-
}, [handleAutoSliding,
|
|
2387
|
+
}, [handleAutoSliding, patchStateSync]);
|
|
2379
2388
|
const onDragCursor = react.useCallback((delta, mouse) => {
|
|
2380
2389
|
const xAxis = xAxisRef.current;
|
|
2381
2390
|
const s = stateRef.current;
|
|
@@ -2389,8 +2398,8 @@ var TimeLineInner = react.forwardRef(function TimeLine(props, ref) {
|
|
|
2389
2398
|
if (maxDomain.min && newStart.isBefore(maxDomain.min)) newStart = moment_shim_default(maxDomain.min);
|
|
2390
2399
|
if (maxDomain.max && newStop.isAfter(maxDomain.max)) newStop = moment_shim_default(maxDomain.max);
|
|
2391
2400
|
handleAutoSliding(mouse, onDragCursor);
|
|
2392
|
-
|
|
2393
|
-
}, [handleAutoSliding,
|
|
2401
|
+
patchStateSync({ start: newStart, stop: newStop });
|
|
2402
|
+
}, [handleAutoSliding, patchStateSync]);
|
|
2394
2403
|
const onStartDrawCursor = react.useCallback((pos) => {
|
|
2395
2404
|
const xAxis = xAxisRef.current;
|
|
2396
2405
|
patchState({
|
|
@@ -2418,9 +2427,9 @@ var TimeLineInner = react.forwardRef(function TimeLine(props, ref) {
|
|
|
2418
2427
|
}
|
|
2419
2428
|
handleAutoSliding(mouse, onDrawCursor);
|
|
2420
2429
|
if (newStop.isSameOrBefore(s.domain.max) && newStart.isSameOrAfter(s.domain.min)) {
|
|
2421
|
-
|
|
2430
|
+
patchStateSync({ start: newStart, stop: newStop, maxTimespan: maxTimespan2 });
|
|
2422
2431
|
}
|
|
2423
|
-
}, [handleAutoSliding,
|
|
2432
|
+
}, [handleAutoSliding, patchStateSync]);
|
|
2424
2433
|
const onEndDrawCursor = react.useCallback(() => {
|
|
2425
2434
|
stopAutoMove();
|
|
2426
2435
|
const { onCustomRange, selectBarOnClick } = propsRef.current;
|
|
@@ -2613,7 +2622,7 @@ var TimeLineInner = react.forwardRef(function TimeLine(props, ref) {
|
|
|
2613
2622
|
}
|
|
2614
2623
|
),
|
|
2615
2624
|
xAxisProp.showGrid && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2616
|
-
|
|
2625
|
+
XGrid_default,
|
|
2617
2626
|
{
|
|
2618
2627
|
classes,
|
|
2619
2628
|
origin: pointZero,
|