@spider-analyzer/timeline 5.0.5 → 5.0.8
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 +34 -0
- package/dist/index.js +44 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +44 -22
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/Cursor.jsx +3 -3
- package/src/TimeLine.tsx +29 -9
- package/src/cursorElements/CursorSelection.jsx +3 -3
- package/src/cursorElements/DragOverlay.jsx +3 -3
- package/src/moment-shim.ts +25 -0
- package/src/timeLineElements/HistoToolTip.jsx +3 -3
- package/src/timeLineElements/Histogram.jsx +3 -3
- package/src/timeLineElements/QualityLine.jsx +2 -2
- package/src/timeLineElements/XAxis.jsx +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,37 @@
|
|
|
1
|
+
## 5.0.8
|
|
2
|
+
|
|
3
|
+
- Perf: memoize the per-render histogram bar list and vertical scale.
|
|
4
|
+
Previously every cursor drag / resize / draw event (60×/sec) rebuilt
|
|
5
|
+
the entire bar list (~550 bars in Network-View's default view) from
|
|
6
|
+
scratch. Under the Luxon-backed shim each rebuild allocated 550 new
|
|
7
|
+
DateTime/MomentLike objects and re-ran d3's time scale — ~150 ms per
|
|
8
|
+
render, i.e. ≈6 fps drag. Wrap `prepareHistogram` and
|
|
9
|
+
`prepareVerticalScale` with `useMemo` keyed on the actual dependencies
|
|
10
|
+
(`domain`, `histoWidth`, `histo`) so they only recompute when those
|
|
11
|
+
change. Cursor drag returns to single-digit-ms render time.
|
|
12
|
+
|
|
13
|
+
## 5.0.7
|
|
14
|
+
|
|
15
|
+
- Fix: silence the `Invalid prop 'time' of type '_MomentLike', expected
|
|
16
|
+
instance of 'moment2'` React warnings that internal components
|
|
17
|
+
(Histogram, Cursor, XAxis, QualityLine, DragOverlay, CursorSelection,
|
|
18
|
+
HistoToolTip) emitted under every render. The Luxon-backed moment
|
|
19
|
+
shim is a factory function, not a class, so `PropTypes.instanceOf` is
|
|
20
|
+
the wrong check. Replaced with a `momentType` validator that uses
|
|
21
|
+
`moment.isMoment()`. No runtime behavior change — warnings only.
|
|
22
|
+
|
|
23
|
+
## 5.0.6
|
|
24
|
+
|
|
25
|
+
- Fix: don't issue the first `onLoadHisto` with a stale `intervalMs`
|
|
26
|
+
when the consumer hasn't measured a valid width yet. `getItems` now
|
|
27
|
+
short-circuits the fetch while `histoWidth <= 0`, and the width-change
|
|
28
|
+
effect re-runs `getItems` whenever a domain exists (not only when the
|
|
29
|
+
prior call marked `isActive=true`). Previously the first call fired
|
|
30
|
+
with `histoWidth=0`, fell back to `domainSpan / 1 tick` and divided by
|
|
31
|
+
`barsBetweenTicks` — giving a coarse interval like 3 h over a 24 h
|
|
32
|
+
window; the subsequent width arrival then never retriggered the load
|
|
33
|
+
because `isActive` was already true and the delta check failed.
|
|
34
|
+
|
|
1
35
|
## 5.0.5
|
|
2
36
|
|
|
3
37
|
- Fix: compute intervalMs defensively in `getItems`. When d3's
|
package/dist/index.js
CHANGED
|
@@ -172,6 +172,25 @@ moment.tz = (x, zone) => {
|
|
|
172
172
|
const base = toDT(x);
|
|
173
173
|
return new MomentLike(base.setZone(zone));
|
|
174
174
|
};
|
|
175
|
+
function validate(props, propName, componentName) {
|
|
176
|
+
const v = props[propName];
|
|
177
|
+
if (v == null) return null;
|
|
178
|
+
if (moment.isMoment(v)) return null;
|
|
179
|
+
return new Error(
|
|
180
|
+
`Invalid prop \`${propName}\` supplied to \`${componentName}\`, expected a moment-like object.`
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
var required = (props, propName, componentName) => {
|
|
184
|
+
const v = props[propName];
|
|
185
|
+
if (v == null) {
|
|
186
|
+
return new Error(
|
|
187
|
+
`The prop \`${propName}\` is marked as required in \`${componentName}\`, but its value is \`${v}\`.`
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
return validate(props, propName, componentName);
|
|
191
|
+
};
|
|
192
|
+
var momentType = validate;
|
|
193
|
+
momentType.isRequired = required;
|
|
175
194
|
var moment_shim_default = moment;
|
|
176
195
|
|
|
177
196
|
// src/utils.ts
|
|
@@ -375,8 +394,8 @@ DragOverlay.propTypes = {
|
|
|
375
394
|
width: PropTypes11__default.default.number.isRequired,
|
|
376
395
|
marginBottom: PropTypes11__default.default.number,
|
|
377
396
|
items: PropTypes11__default.default.arrayOf(PropTypes11__default.default.shape({
|
|
378
|
-
start:
|
|
379
|
-
end:
|
|
397
|
+
start: momentType.isRequired,
|
|
398
|
+
end: momentType.isRequired,
|
|
380
399
|
x1: PropTypes11__default.default.number,
|
|
381
400
|
x2: PropTypes11__default.default.number,
|
|
382
401
|
metrics: PropTypes11__default.default.arrayOf(PropTypes11__default.default.number).isRequired,
|
|
@@ -686,8 +705,8 @@ CursorSelection.propTypes = {
|
|
|
686
705
|
showToolTipLeft: PropTypes11__default.default.func.isRequired,
|
|
687
706
|
showToolTipRight: PropTypes11__default.default.func.isRequired,
|
|
688
707
|
items: PropTypes11__default.default.arrayOf(PropTypes11__default.default.shape({
|
|
689
|
-
start:
|
|
690
|
-
end:
|
|
708
|
+
start: momentType.isRequired,
|
|
709
|
+
end: momentType.isRequired,
|
|
691
710
|
x1: PropTypes11__default.default.number,
|
|
692
711
|
x2: PropTypes11__default.default.number,
|
|
693
712
|
metrics: PropTypes11__default.default.arrayOf(PropTypes11__default.default.number).isRequired,
|
|
@@ -1273,8 +1292,8 @@ Cursor.propTypes = {
|
|
|
1273
1292
|
overlayHeight: PropTypes11__default.default.number.isRequired,
|
|
1274
1293
|
overlayWidth: PropTypes11__default.default.number.isRequired,
|
|
1275
1294
|
items: PropTypes11__default.default.arrayOf(PropTypes11__default.default.shape({
|
|
1276
|
-
start:
|
|
1277
|
-
end:
|
|
1295
|
+
start: momentType.isRequired,
|
|
1296
|
+
end: momentType.isRequired,
|
|
1278
1297
|
x1: PropTypes11__default.default.number,
|
|
1279
1298
|
x2: PropTypes11__default.default.number,
|
|
1280
1299
|
metrics: PropTypes11__default.default.arrayOf(PropTypes11__default.default.number).isRequired,
|
|
@@ -1383,8 +1402,8 @@ function Histogram({
|
|
|
1383
1402
|
Histogram.propTypes = {
|
|
1384
1403
|
classes: PropTypes11__default.default.object,
|
|
1385
1404
|
items: PropTypes11__default.default.arrayOf(PropTypes11__default.default.shape({
|
|
1386
|
-
start:
|
|
1387
|
-
end:
|
|
1405
|
+
start: momentType.isRequired,
|
|
1406
|
+
end: momentType.isRequired,
|
|
1388
1407
|
x1: PropTypes11__default.default.number,
|
|
1389
1408
|
x2: PropTypes11__default.default.number,
|
|
1390
1409
|
metrics: PropTypes11__default.default.arrayOf(PropTypes11__default.default.number).isRequired,
|
|
@@ -1484,8 +1503,8 @@ function XAxis({ min, max: max2, origin, axisWidth, marks, xAxis, classes, arrow
|
|
|
1484
1503
|
XAxis.propTypes = {
|
|
1485
1504
|
axisWidth: PropTypes11__default.default.number.isRequired,
|
|
1486
1505
|
classes: PropTypes11__default.default.object,
|
|
1487
|
-
min:
|
|
1488
|
-
max:
|
|
1506
|
+
min: momentType,
|
|
1507
|
+
max: momentType,
|
|
1489
1508
|
origin: PropTypes11__default.default.shape({
|
|
1490
1509
|
x: PropTypes11__default.default.number.isRequired,
|
|
1491
1510
|
y: PropTypes11__default.default.number.isRequired
|
|
@@ -1810,8 +1829,8 @@ function HistoTooltip({ metricsDefinition, item, onFormatTimeToolTips, onFormatM
|
|
|
1810
1829
|
HistoTooltip.propTypes = {
|
|
1811
1830
|
classes: PropTypes11__default.default.object,
|
|
1812
1831
|
item: PropTypes11__default.default.shape({
|
|
1813
|
-
start:
|
|
1814
|
-
end:
|
|
1832
|
+
start: momentType.isRequired,
|
|
1833
|
+
end: momentType.isRequired,
|
|
1815
1834
|
x1: PropTypes11__default.default.number,
|
|
1816
1835
|
x2: PropTypes11__default.default.number,
|
|
1817
1836
|
metrics: PropTypes11__default.default.arrayOf(PropTypes11__default.default.number).isRequired,
|
|
@@ -1879,7 +1898,7 @@ QualityLine.propTypes = {
|
|
|
1879
1898
|
xAxis: PropTypes11__default.default.func.isRequired,
|
|
1880
1899
|
quality: PropTypes11__default.default.shape({
|
|
1881
1900
|
items: PropTypes11__default.default.arrayOf(PropTypes11__default.default.shape({
|
|
1882
|
-
time:
|
|
1901
|
+
time: momentType.isRequired,
|
|
1883
1902
|
quality: PropTypes11__default.default.number.isRequired,
|
|
1884
1903
|
tip: PropTypes11__default.default.node
|
|
1885
1904
|
})),
|
|
@@ -2089,7 +2108,7 @@ var TimeLineInner = react.forwardRef(function TimeLine(props, ref) {
|
|
|
2089
2108
|
propsRef.current.smallestResolution.asMilliseconds()
|
|
2090
2109
|
]);
|
|
2091
2110
|
patchState({ histoWidth: histoWidth2, isActive: true, ticks: ticks2 });
|
|
2092
|
-
if (shouldReload && intervalMs) {
|
|
2111
|
+
if (shouldReload && intervalMs && histoWidth2 > 0) {
|
|
2093
2112
|
widthOfLastUpdateRef.current = p.width;
|
|
2094
2113
|
patchState({ waitForLoad: true });
|
|
2095
2114
|
p.onLoadHisto(intervalMs, domain2.min, domain2.max);
|
|
@@ -2119,12 +2138,11 @@ var TimeLineInner = react.forwardRef(function TimeLine(props, ref) {
|
|
|
2119
2138
|
return;
|
|
2120
2139
|
}
|
|
2121
2140
|
const s = stateRef.current;
|
|
2122
|
-
|
|
2141
|
+
patchState(computeMarginAndWidth(props));
|
|
2142
|
+
if (s.domain) {
|
|
2123
2143
|
const big = widthOfLastUpdateRef.current !== null && Math.abs((props.width ?? 0) - (widthOfLastUpdateRef.current ?? 0)) > 30;
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
} else {
|
|
2127
|
-
patchState(computeMarginAndWidth(props));
|
|
2144
|
+
const shouldReload = !s.isActive || big || widthOfLastUpdateRef.current === null;
|
|
2145
|
+
getItems(props, s.domain, shouldReload);
|
|
2128
2146
|
}
|
|
2129
2147
|
if (stateRef.current.domain) {
|
|
2130
2148
|
const res = checkAndCorrectDomain({ domain: stateRef.current.domain });
|
|
@@ -2565,13 +2583,17 @@ var TimeLineInner = react.forwardRef(function TimeLine(props, ref) {
|
|
|
2565
2583
|
ticks,
|
|
2566
2584
|
dragging
|
|
2567
2585
|
} = state;
|
|
2586
|
+
const verticalScaleData = react.useMemo(() => prepareVerticalScale(), [prepareVerticalScale]);
|
|
2587
|
+
const items = react.useMemo(
|
|
2588
|
+
() => prepareHistogram({ domain, verticalScale: verticalScaleData.verticalScale }),
|
|
2589
|
+
[prepareHistogram, domain, verticalScaleData, histoWidth]
|
|
2590
|
+
);
|
|
2591
|
+
itemsRef.current = items;
|
|
2568
2592
|
const xAxisHeight = xAxisProp.height || xAxisDefault.height;
|
|
2569
2593
|
const pointZero = { x: 0, y: height - margin.bottom - xAxisHeight };
|
|
2570
2594
|
const originCursor = { x: 0, y: margin.top - 5 };
|
|
2571
2595
|
if (!isFunction(xAxisRef.current)) return null;
|
|
2572
|
-
const { verticalScale, verticalMarks, maxHeight } =
|
|
2573
|
-
const items = prepareHistogram({ domain, verticalScale });
|
|
2574
|
-
itemsRef.current = items;
|
|
2596
|
+
const { verticalScale, verticalMarks, maxHeight } = verticalScaleData;
|
|
2575
2597
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2576
2598
|
"svg",
|
|
2577
2599
|
{
|