gloomberb 0.19.4 → 0.19.5
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/package.json +3 -1
- package/src/cli/commands/command-utils.ts +4 -0
- package/src/cli/commands/market.ts +119 -27
- package/src/cli/commands/search.ts +1 -1
- package/src/cli/commands/ticker.ts +10 -6
- package/src/cli/currency-name-hint.ts +60 -0
- package/src/cli/history-rows.ts +18 -1
- package/src/cli/known-gaps.ts +17 -2
- package/src/cli/not-a-ticker.ts +5 -3
- package/src/cli/pane-functions/catalog.ts +9 -1
- package/src/cli/pane-functions/headless.ts +7 -3
- package/src/cli/pane-functions/market-session.ts +6 -7
- package/src/cli/series-search.ts +4 -5
- package/src/components/chart/composite/panel-bitmap.ts +28 -2
- package/src/components/chart/composite/time-axis.ts +17 -2
- package/src/components/layout/shell/active-drag.ts +38 -7
- package/src/components/layout/shell/drag/magnets.ts +106 -0
- package/src/components/layout/window-controls.tsx +96 -35
- package/src/components/layout/window-fullscreen.ts +20 -0
- package/src/components/quote-flash.ts +36 -32
- package/src/market-data/coordinator/events.ts +17 -1
- package/src/market-data/frame-scheduler.ts +47 -10
- package/src/market-data/frame-wake.ts +74 -0
- package/src/market-data/futures-board.ts +7 -6
- package/src/market-data/hooks.tsx +12 -3
- package/src/market-data/performance.ts +78 -9
- package/src/market-data/request-types.ts +6 -3
- package/src/plugins/builtin/alerts/cli.ts +2 -1
- package/src/plugins/builtin/analytics/risk-evidence.ts +1 -0
- package/src/plugins/builtin/attention/evidence.ts +1 -1
- package/src/plugins/builtin/awards/client.ts +1 -1
- package/src/plugins/builtin/awards/evidence.ts +1 -1
- package/src/plugins/builtin/awards/pane.tsx +2 -1
- package/src/plugins/builtin/bond-calculator/math.ts +1 -1
- package/src/plugins/builtin/broker-manager/footer.ts +3 -2
- package/src/plugins/builtin/broker-manager/index.tsx +2 -1
- package/src/plugins/builtin/broker-manager/keyboard.ts +2 -1
- package/src/plugins/builtin/catalysts/evidence.ts +1 -1
- package/src/plugins/builtin/catalysts/pane.tsx +2 -1
- package/src/plugins/builtin/chart-composer/headless.ts +40 -1
- package/src/plugins/builtin/cloud-tweets/table.tsx +3 -2
- package/src/plugins/builtin/comment-letters/client.ts +2 -1
- package/src/plugins/builtin/company-kpis/client.ts +1 -1
- package/src/plugins/builtin/company-kpis/pane.tsx +2 -1
- package/src/plugins/builtin/company-kpis/screenshot-evidence.ts +3 -2
- package/src/plugins/builtin/cot/headless.ts +9 -3
- package/src/plugins/builtin/cot/model.ts +44 -3
- package/src/plugins/builtin/credit-documents/client.ts +1 -1
- package/src/plugins/builtin/credit-documents/evidence.ts +1 -1
- package/src/plugins/builtin/credit-documents/pane.tsx +2 -1
- package/src/plugins/builtin/earnings-calls/pane.tsx +1 -1
- package/src/plugins/builtin/earnings-ripple/index.tsx +6 -1
- package/src/plugins/builtin/econ/calendar-model.ts +2 -0
- package/src/plugins/builtin/econ/fred-catalog.ts +5 -5
- package/src/plugins/builtin/econ/print-watch.ts +3 -1
- package/src/plugins/builtin/futures/series.ts +16 -1
- package/src/plugins/builtin/fx-matrix/headless.ts +4 -2
- package/src/plugins/builtin/fx-matrix/index.tsx +37 -3
- package/src/plugins/builtin/fx-matrix/pairs.ts +15 -0
- package/src/plugins/builtin/gpu/headless.ts +2 -1
- package/src/plugins/builtin/help/function-card.tsx +2 -1
- package/src/plugins/builtin/help/index.tsx +2 -1
- package/src/plugins/builtin/insider/display.ts +45 -6
- package/src/plugins/builtin/ipo-calendar/model.ts +2 -0
- package/src/plugins/builtin/iv-history/client.ts +2 -1
- package/src/plugins/builtin/iv-history/headless.ts +2 -1
- package/src/plugins/builtin/jobs/pages.ts +4 -4
- package/src/plugins/builtin/kelly-sizer/headless.ts +2 -1
- package/src/plugins/builtin/market-heatmap/index.tsx +2 -1
- package/src/plugins/builtin/members/client.ts +1 -1
- package/src/plugins/builtin/mna/distress/client.ts +1 -0
- package/src/plugins/builtin/mna/pane.tsx +4 -1
- package/src/plugins/builtin/options/market-reference.ts +1 -1
- package/src/plugins/builtin/options/open-interest-as-of.ts +3 -1
- package/src/plugins/builtin/options/view.tsx +2 -1
- package/src/plugins/builtin/options-calculator/evidence.ts +1 -1
- package/src/plugins/builtin/options-scenario/csp-screen-pane.tsx +1 -1
- package/src/plugins/builtin/options-scenario/csp-screen.ts +8 -4
- package/src/plugins/builtin/options-scenario/csp.ts +28 -9
- package/src/plugins/builtin/options-scenario/evidence.ts +5 -4
- package/src/plugins/builtin/options-scenario/pane.tsx +2 -1
- package/src/plugins/builtin/perps/client.ts +1 -1
- package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +2 -1
- package/src/plugins/builtin/portfolio-list/pane/index.tsx +7 -3
- package/src/plugins/builtin/portfolio-list/use-throttled-memo.ts +10 -19
- package/src/plugins/builtin/research/analyst-model.ts +1 -0
- package/src/plugins/builtin/research/equity-diagnostic-pane.tsx +2 -1
- package/src/plugins/builtin/research/index.tsx +1 -0
- package/src/plugins/builtin/research/relative-valuation-currency.ts +1 -1
- package/src/plugins/builtin/research/relative-valuation-peers.ts +2 -1
- package/src/plugins/builtin/research-search/command-bar-search.ts +3 -1
- package/src/plugins/builtin/research-search/snippet.ts +1 -0
- package/src/plugins/builtin/revenue-breakdown/client.ts +3 -2
- package/src/plugins/builtin/seasonality/headless.ts +2 -1
- package/src/plugins/builtin/sec/command-bar-search.ts +3 -2
- package/src/plugins/builtin/sec/index.tsx +7 -4
- package/src/plugins/builtin/sec/row-summaries.ts +28 -12
- package/src/plugins/builtin/short-interest/watch-client.ts +2 -1
- package/src/plugins/builtin/social-mentions/client.ts +2 -1
- package/src/plugins/builtin/supply-chain/client.ts +1 -1
- package/src/plugins/builtin/supply-chain/evidence.ts +1 -1
- package/src/plugins/builtin/supply-chain/graph-pane.tsx +2 -1
- package/src/plugins/builtin/supply-chain/pane.tsx +2 -1
- package/src/plugins/builtin/ticker-detail/adr-pair/headless.ts +1 -1
- package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +24 -4
- package/src/plugins/builtin/ticker-detail/adr-pair/tab.tsx +1 -1
- package/src/plugins/builtin/time-sales/client.ts +1 -0
- package/src/plugins/builtin/vol-surface/client.ts +2 -1
- package/src/plugins/builtin/yield-curve/headless.ts +3 -1
- package/src/portfolio/column-values.ts +76 -10
- package/src/renderers/dom/host/box.tsx +204 -176
- package/src/renderers/dom/host/style.ts +49 -20
- package/src/renderers/dom/host/text.tsx +3 -2
- package/src/renderers/electrobun/bun/desktop/backend.ts +2 -0
- package/src/renderers/electrobun/bun/desktop/host-requests.ts +25 -1
- package/src/renderers/electrobun/bun/desktop/relaunch.ts +9 -1
- package/src/renderers/electrobun/bun/desktop/windows-script.ts +9 -6
- package/src/renderers/electrobun/bun/window/windows-native.ts +26 -1
- package/src/renderers/electrobun/shared/protocol.ts +6 -0
- package/src/renderers/electrobun/view/ui-host.tsx +7 -0
- package/src/renderers/electrobun/view/window-fullscreen.ts +10 -3
- package/src/sources/provider-router/index.ts +7 -1
- package/src/time-series/price-units.ts +11 -0
- package/src/ui/host.tsx +2 -0
- package/src/utils/currency-names.ts +20 -0
- package/src/utils/currency-pair.ts +6 -0
- package/src/utils/exchange-rate-snapshot.ts +20 -2
- package/src/utils/fx-market-hours.ts +43 -0
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
nextRegularSessionOpen,
|
|
9
9
|
} from "../../market-data/market/freshness";
|
|
10
10
|
import { futuresWeekendClosure } from "../../market-data/market/futures-week";
|
|
11
|
-
import { currentFxClosureStart, isFxMarketOpen } from "../../utils/fx-market-hours";
|
|
11
|
+
import { currentFxClosureStart, isFxMarketOpen, isFxWeekClosePrint } from "../../utils/fx-market-hours";
|
|
12
12
|
import { zonedDateKey } from "../../utils/zoned-date-time";
|
|
13
13
|
import type { ReportTime } from "../../utils/utc-time";
|
|
14
14
|
import type { QuoteIndexSession } from "../../types/financials";
|
|
@@ -118,7 +118,6 @@ function quotedSessions({ timeZone, current, regular }: QuoteIndexSession, now:
|
|
|
118
118
|
|
|
119
119
|
/** The venue spot FX pairs trade on. It has no session calendar here; its week is in `fx-market-hours`. */
|
|
120
120
|
const FX_VENUE = "CCY";
|
|
121
|
-
const DAY_MS = 24 * 60 * 60_000;
|
|
122
121
|
|
|
123
122
|
/**
|
|
124
123
|
* The newest observation is its venue's latest close: the venue has not
|
|
@@ -128,13 +127,13 @@ const DAY_MS = 24 * 60 * 60_000;
|
|
|
128
127
|
function closeDateOf(observation: SessionObservation, session: VenueSession, now: number): string | null {
|
|
129
128
|
const time = observation.time;
|
|
130
129
|
if (!time || time.dateOnly) return null;
|
|
131
|
-
// FX closes once a week, Friday 17:00 New York time
|
|
132
|
-
//
|
|
133
|
-
//
|
|
134
|
-
//
|
|
130
|
+
// FX closes once a week, Friday 17:00 New York time: a print in its last
|
|
131
|
+
// minute is that Friday's close. An earlier print of the day (20:39Z) is no
|
|
132
|
+
// close, and a tick after it, over the weekend, is no price of the week:
|
|
133
|
+
// both keep their own time.
|
|
135
134
|
const weekClose = canonicalExchange(observation.exchange) === FX_VENUE ? currentFxClosureStart(now) : null;
|
|
136
135
|
if (weekClose != null) {
|
|
137
|
-
return time.time
|
|
136
|
+
return isFxWeekClosePrint(time.time, weekClose) ? zonedDateKey(weekClose - 1, "America/New_York") : null;
|
|
138
137
|
}
|
|
139
138
|
if (session.last && session.timeZone) {
|
|
140
139
|
if (session.last.open != null && time.time < session.last.open) return null;
|
package/src/cli/series-search.ts
CHANGED
|
@@ -82,27 +82,26 @@ function shellArgument(expression: string): string {
|
|
|
82
82
|
|
|
83
83
|
/**
|
|
84
84
|
* The series part of `catalog` or `search`: a table of the first `limit`
|
|
85
|
-
* matches with the expression `fn G` charts, and how to see the rest
|
|
85
|
+
* matches with the expression `fn G` charts, and how to see the rest:
|
|
86
|
+
* `catalog <words> --all`, which lists every one.
|
|
86
87
|
*/
|
|
87
88
|
export function renderSeriesMatches(
|
|
88
89
|
query: string,
|
|
89
90
|
matches: readonly SeriesMatch[],
|
|
90
91
|
limit: number,
|
|
91
92
|
width: number,
|
|
92
|
-
/** Where the rest are listed: `shot CAT` from the catalog, the catalog from a search. */
|
|
93
|
-
rest: "catalog" | "data-catalog" = "data-catalog",
|
|
94
93
|
): string {
|
|
95
94
|
if (matches.length === 0) return "";
|
|
96
95
|
const shown = matches.slice(0, limit);
|
|
97
96
|
const count = shown.length < matches.length ? `${shown.length} of ${matches.length}` : String(matches.length);
|
|
98
|
-
const
|
|
97
|
+
const words = query.replace(/"/g, "").trim();
|
|
99
98
|
// A FRED series named by its id is also one `gloom fred` prints.
|
|
100
99
|
const asked = query.trim().toUpperCase().replace(/^FRED:/, "");
|
|
101
100
|
const fred = matches.find((match) => match.exact && fredSeriesIdOf(match.expression) === asked);
|
|
102
101
|
const hint = fred
|
|
103
102
|
? `Print it with gloom fred ${asked}; chart it with gloom fn G ${fred.expression}.`
|
|
104
103
|
: shown.length < matches.length
|
|
105
|
-
? `Chart one with gloom fn G <chart>; gloom
|
|
104
|
+
? `Chart one with gloom fn G <chart>; gloom catalog ${shellArgument(words)} --all lists all ${matches.length}.`
|
|
106
105
|
: "Chart one with gloom fn G <chart>.";
|
|
107
106
|
return [
|
|
108
107
|
`${renderSection(`Series for "${query}"`)} ${cliStyles.muted(`(${count})`)}`,
|
|
@@ -77,6 +77,13 @@ export function useCompositePanelBitmap({
|
|
|
77
77
|
const desktopRenderedSizeRef = useRef<{ pixelWidth: number; pixelHeight: number } | null>(null);
|
|
78
78
|
const desktopCancelRenderRef = useRef<(() => void) | null>(null);
|
|
79
79
|
const desktopActiveRef = useRef(false);
|
|
80
|
+
/** What the current desktop bitmap was drawn from. */
|
|
81
|
+
const desktopDrawnRef = useRef<{
|
|
82
|
+
panel: CompositePanelScene;
|
|
83
|
+
pixelWidth: number;
|
|
84
|
+
pixelHeight: number;
|
|
85
|
+
colors: CompositeChartColors;
|
|
86
|
+
} | null>(null);
|
|
80
87
|
const pixelWidth = bitmapSize?.pixelWidth ?? null;
|
|
81
88
|
const pixelHeight = bitmapSize?.pixelHeight ?? null;
|
|
82
89
|
|
|
@@ -84,6 +91,18 @@ export function useCompositePanelBitmap({
|
|
|
84
91
|
? { panel, pixelWidth, pixelHeight, colors }
|
|
85
92
|
: null;
|
|
86
93
|
|
|
94
|
+
// New data at the size and palette already drawn (a live quote moving the
|
|
95
|
+
// last bar) is drawn in this render. Drawn in the layout effect, its state
|
|
96
|
+
// update would render the panel a second time, a commit per tick; the paint
|
|
97
|
+
// is the same either way, since the effect also draws before it.
|
|
98
|
+
const drawn = desktopDrawnRef.current;
|
|
99
|
+
if (isDesktopWeb && desktopActiveRef.current && desktopBitmapRef.current && drawn && drawn.panel !== panel
|
|
100
|
+
&& drawn.pixelWidth === pixelWidth && drawn.pixelHeight === pixelHeight && drawn.colors === colors
|
|
101
|
+
&& desktopCancelRenderRef.current === null && !desktopUnpaintedRef.current && !revealed) {
|
|
102
|
+
desktopBitmapRef.current = renderPanelBitmap(panel, { pixelWidth, pixelHeight }, colors);
|
|
103
|
+
desktopDrawnRef.current = { panel, pixelWidth, pixelHeight, colors };
|
|
104
|
+
}
|
|
105
|
+
|
|
87
106
|
// The cursor is drawn as a separate overlay, so the plot raster stays cached
|
|
88
107
|
// (and resident in the terminal) while the crosshair moves.
|
|
89
108
|
const terminalBitmap = useMemo(() => {
|
|
@@ -114,6 +133,7 @@ export function useCompositePanelBitmap({
|
|
|
114
133
|
};
|
|
115
134
|
desktopRenderedColorsRef.current = input.colors;
|
|
116
135
|
desktopBitmapRef.current = next;
|
|
136
|
+
desktopDrawnRef.current = input;
|
|
117
137
|
setDesktopBitmap(next);
|
|
118
138
|
// A chart that fills its box when it opens takes its measured size
|
|
119
139
|
// before its first paint, by the end of the frame after next. Later
|
|
@@ -140,6 +160,7 @@ export function useCompositePanelBitmap({
|
|
|
140
160
|
desktopRequestedSizeRef.current = null;
|
|
141
161
|
desktopRenderedSizeRef.current = null;
|
|
142
162
|
desktopBitmapRef.current = null;
|
|
163
|
+
desktopDrawnRef.current = null;
|
|
143
164
|
setDesktopBitmap((current) => current === null ? current : null);
|
|
144
165
|
return;
|
|
145
166
|
}
|
|
@@ -158,7 +179,11 @@ export function useCompositePanelBitmap({
|
|
|
158
179
|
|
|
159
180
|
if (!desktopBitmapRef.current || sizeAlreadyRendered || desktopRenderedColorsRef.current !== colors || desktopUnpaintedRef.current || revealed) {
|
|
160
181
|
cancelRender();
|
|
161
|
-
|
|
182
|
+
const current = desktopDrawnRef.current;
|
|
183
|
+
// The render drew this data already.
|
|
184
|
+
const drawnNow = !!desktopBitmapRef.current && current?.panel === panel && current.colors === colors
|
|
185
|
+
&& current.pixelWidth === pixelWidth && current.pixelHeight === pixelHeight;
|
|
186
|
+
if (!drawnNow) render();
|
|
162
187
|
return;
|
|
163
188
|
}
|
|
164
189
|
|
|
@@ -176,5 +201,6 @@ export function useCompositePanelBitmap({
|
|
|
176
201
|
}, []);
|
|
177
202
|
|
|
178
203
|
if (!bitmapSize) return null;
|
|
179
|
-
|
|
204
|
+
// The state only renders the panel again; the ref also holds what this render drew.
|
|
205
|
+
return isDesktopWeb ? desktopBitmapRef.current ?? desktopBitmap : terminalBitmap;
|
|
180
206
|
}
|
|
@@ -492,6 +492,17 @@ function addCandidate(
|
|
|
492
492
|
if (!duplicate) candidates.push(candidate);
|
|
493
493
|
}
|
|
494
494
|
|
|
495
|
+
/**
|
|
496
|
+
* Blank cells a regular tick keeps from the start and end labels: half the
|
|
497
|
+
* room between two ticks, from 3 to 5 cells. Those two are the longest labels
|
|
498
|
+
* on the axis (a date with its year), and a tick closer than that reads as a
|
|
499
|
+
* part of one ("Oct Oct 29 2026") instead of a mark of its own.
|
|
500
|
+
*/
|
|
501
|
+
function endpointLabelGap(interval: CompositeTimeAxisInterval, span: number, axisWidth: number): number {
|
|
502
|
+
const tickRoom = (axisWidth * interval.approximateMs) / span;
|
|
503
|
+
return clamp(Math.round(tickRoom / 2), 3, 5);
|
|
504
|
+
}
|
|
505
|
+
|
|
495
506
|
function layoutTimeAxis({
|
|
496
507
|
startTime,
|
|
497
508
|
endTime,
|
|
@@ -641,6 +652,9 @@ function layoutTimeAxis({
|
|
|
641
652
|
const minimumGap = interval.unit === "month" || interval.unit === "year" ? 2 : 1;
|
|
642
653
|
let previousTimestamp = firstTimestamp;
|
|
643
654
|
let previousEnd = startLabel.length - 1;
|
|
655
|
+
const endpointGap = endpointLabelGap(interval, span, axisWidth);
|
|
656
|
+
// The first tick follows the start label, the rest follow a tick.
|
|
657
|
+
let previousGap = endpointGap;
|
|
644
658
|
for (const candidate of candidates.filter((entry) => !entry.boundary)) {
|
|
645
659
|
const label = formatInteriorLabel(candidate.timestamp, previousTimestamp, interval, clock);
|
|
646
660
|
// A year boundary inside the final year would repeat the right endpoint's year.
|
|
@@ -648,8 +662,8 @@ function layoutTimeAxis({
|
|
|
648
662
|
const center = candidate.ratio * Math.max(axisWidth - 1, 0);
|
|
649
663
|
const start = resolveLabelStart(center, label, axisWidth);
|
|
650
664
|
const end = start + label.length - 1;
|
|
651
|
-
if (start <= previousEnd +
|
|
652
|
-
if (end >= endStart -
|
|
665
|
+
if (start <= previousEnd + previousGap) continue;
|
|
666
|
+
if (end >= endStart - endpointGap) continue;
|
|
653
667
|
writeLabel(axis, start, label);
|
|
654
668
|
placed.push({
|
|
655
669
|
timestamp: candidate.timestamp,
|
|
@@ -660,6 +674,7 @@ function layoutTimeAxis({
|
|
|
660
674
|
});
|
|
661
675
|
previousTimestamp = candidate.timestamp;
|
|
662
676
|
previousEnd = end;
|
|
677
|
+
previousGap = minimumGap;
|
|
663
678
|
}
|
|
664
679
|
|
|
665
680
|
writeLabel(axis, endStart, endLabel);
|
|
@@ -31,7 +31,15 @@ import {
|
|
|
31
31
|
} from "./drag";
|
|
32
32
|
import type { ShellDragRuntimeState, ShellMouseEvent } from "./drag/runtime";
|
|
33
33
|
import type { WindowEditState } from "../window-edit/mode";
|
|
34
|
-
import {
|
|
34
|
+
import {
|
|
35
|
+
createMagnetPace,
|
|
36
|
+
NO_LATCH,
|
|
37
|
+
snapMovedRect,
|
|
38
|
+
snapResizedRect,
|
|
39
|
+
type MagnetDistances,
|
|
40
|
+
type MagnetLatch,
|
|
41
|
+
type MagnetPace,
|
|
42
|
+
} from "./drag/magnets";
|
|
35
43
|
import { paneHeaderRows } from "../pane/sizing";
|
|
36
44
|
|
|
37
45
|
/** A join the pointer has lined up: armed once it has held for JOIN_DWELL_MS. */
|
|
@@ -100,8 +108,10 @@ export function useShellActiveDrag({
|
|
|
100
108
|
} = dragRuntime;
|
|
101
109
|
// What one drag keeps between moves: a docked pane's floating size, the
|
|
102
110
|
// last drop it simulated, so a move over the same target computes nothing,
|
|
103
|
-
// the edges its magnets hold, with the other panes' rects they hold to,
|
|
104
|
-
//
|
|
111
|
+
// the edges its magnets hold, with the other panes' rects they hold to, the
|
|
112
|
+
// join it is holding still for, and on the desktop where the pointer has
|
|
113
|
+
// been lately (the magnets wait for it to slow down) with the check that
|
|
114
|
+
// catches once it rests.
|
|
105
115
|
const memoRef = useRef<{
|
|
106
116
|
drag: unknown;
|
|
107
117
|
baseRect: FloatingRect | null;
|
|
@@ -110,10 +120,16 @@ export function useShellActiveDrag({
|
|
|
110
120
|
latch: MagnetLatch;
|
|
111
121
|
magnetTargets: LayoutBounds[] | null;
|
|
112
122
|
join: PendingJoin | null;
|
|
113
|
-
|
|
114
|
-
|
|
123
|
+
pace: MagnetPace;
|
|
124
|
+
}>({ drag: null, baseRect: null, dropKey: null, drop: null, latch: NO_LATCH, magnetTargets: null, join: null, pace: createMagnetPace() });
|
|
125
|
+
useEffect(() => () => {
|
|
126
|
+
dropPendingJoin(memoRef.current);
|
|
127
|
+
memoRef.current.pace.reset();
|
|
128
|
+
}, []);
|
|
129
|
+
// The handler as it is now, for the rest check to run again.
|
|
130
|
+
const handleRef = useRef<(event: ShellMouseEvent) => void>(() => {});
|
|
115
131
|
|
|
116
|
-
|
|
132
|
+
const handle = useCallback((event: ShellMouseEvent) => {
|
|
117
133
|
const shellY = event.y - appHeaderHeight;
|
|
118
134
|
const preciseX = event.preciseX ?? event.x;
|
|
119
135
|
const preciseShellY = (event.preciseY ?? event.y) - appHeaderHeight;
|
|
@@ -135,8 +151,11 @@ export function useShellActiveDrag({
|
|
|
135
151
|
memo.drop = null;
|
|
136
152
|
memo.latch = NO_LATCH;
|
|
137
153
|
memo.magnetTargets = null;
|
|
154
|
+
memo.pace.reset();
|
|
138
155
|
dropPendingJoin(memo);
|
|
139
156
|
}
|
|
157
|
+
// Any later event supersedes the rest check of an earlier move.
|
|
158
|
+
memo.pace.cancel();
|
|
140
159
|
// Every other pane on screen, docked or floating, whose edges a floating
|
|
141
160
|
// pane's edges stick to. Alt (Option) lets it go anywhere.
|
|
142
161
|
const magnetTargets = (paneId: string) => {
|
|
@@ -150,6 +169,16 @@ export function useShellActiveDrag({
|
|
|
150
169
|
};
|
|
151
170
|
const magnetsOff = event.modifiers?.alt === true;
|
|
152
171
|
const magnetArea = { x: 0, y: 0, width, height: contentHeight };
|
|
172
|
+
// Desktop: while the pointer travels, a moving pane follows it exactly;
|
|
173
|
+
// its magnets catch once it slows down near a line, or rests there (the
|
|
174
|
+
// rest check runs the last move again once the pointer has stopped). What
|
|
175
|
+
// they hold to still follows every move, so it rests where it would have.
|
|
176
|
+
const travelling = () => {
|
|
177
|
+
if (!nativePaneChrome || drag.type !== "pane-drag") return false;
|
|
178
|
+
// A release lands where the pane is drawn: no catch after it.
|
|
179
|
+
const rest = event.type === "drag" ? () => { if (dragRef.current === drag) handleRef.current(event); } : undefined;
|
|
180
|
+
return memo.pace.travelling({ t: performance.now(), x: preciseX, y: preciseShellY }, magnetDistances, rest);
|
|
181
|
+
};
|
|
153
182
|
const snapMove = (paneId: string, rect: FloatingRect): FloatingRect => {
|
|
154
183
|
if (magnetsOff) {
|
|
155
184
|
memo.latch = NO_LATCH;
|
|
@@ -157,7 +186,7 @@ export function useShellActiveDrag({
|
|
|
157
186
|
}
|
|
158
187
|
const snapped = snapMovedRect(rect, magnetTargets(paneId), magnetArea, magnetDistances, memo.latch);
|
|
159
188
|
memo.latch = snapped.latch;
|
|
160
|
-
return snapped.rect;
|
|
189
|
+
return travelling() ? rect : snapped.rect;
|
|
161
190
|
};
|
|
162
191
|
const snapResize = (paneId: string, rect: FloatingRect, edges: { x: -1 | 0 | 1; y: -1 | 0 | 1 }): FloatingRect => {
|
|
163
192
|
if (magnetsOff) {
|
|
@@ -364,4 +393,6 @@ export function useShellActiveDrag({
|
|
|
364
393
|
windowMode,
|
|
365
394
|
width,
|
|
366
395
|
]);
|
|
396
|
+
handleRef.current = handle;
|
|
397
|
+
return handle;
|
|
367
398
|
}
|
|
@@ -36,6 +36,112 @@ const MAGNET_RELEASE_PX = 12;
|
|
|
36
36
|
/** Terminal magnets, in cells: the next cell catches, two let go. */
|
|
37
37
|
const TERMINAL_MAGNETS: MagnetDistances = { catchX: 1, catchY: 1, releaseX: 2, releaseY: 2 };
|
|
38
38
|
|
|
39
|
+
/**
|
|
40
|
+
* Desktop: a moving pane's magnets act while the pointer slows down or rests
|
|
41
|
+
* near a line; faster than this, in catch distances a second (300 px/s), the
|
|
42
|
+
* pane follows the pointer exactly. Holding an edge on every line a window
|
|
43
|
+
* crossed on its way stopped it for 20 px at each one and then jumped it,
|
|
44
|
+
* which read as a drag that lags and stutters.
|
|
45
|
+
*/
|
|
46
|
+
const MAGNET_TRAVEL_SPEED = 300 / MAGNET_CATCH_PX;
|
|
47
|
+
/** How far back the pointer's speed is read, ms: a few frames. */
|
|
48
|
+
const SPEED_WINDOW_MS = 64;
|
|
49
|
+
/** How long the pointer rests before the magnets catch where it stopped, ms. */
|
|
50
|
+
export const MAGNET_REST_MS = 80;
|
|
51
|
+
|
|
52
|
+
/** Where the pointer was during a move, in cells, and when (ms). */
|
|
53
|
+
interface PointerSample {
|
|
54
|
+
t: number;
|
|
55
|
+
x: number;
|
|
56
|
+
y: number;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Adds where the pointer is now, keeping only what the speed reads. */
|
|
60
|
+
function trackPointer(track: PointerSample[], sample: PointerSample): void {
|
|
61
|
+
track.push(sample);
|
|
62
|
+
const oldest = sample.t - SPEED_WINDOW_MS * 2;
|
|
63
|
+
while (track.length > 2 && track[1]!.t <= oldest) track.shift();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Desktop: when a moving pane's magnets act, over one drag. `travelling`
|
|
68
|
+
* takes each move and says whether the pointer is on its way somewhere; while
|
|
69
|
+
* it is, the pane follows it exactly, and `rest` (the move run again) is set
|
|
70
|
+
* to run once the pointer has stopped for MAGNET_REST_MS, so the magnets
|
|
71
|
+
* catch where it stopped. Any later move drops that check, travelling or not:
|
|
72
|
+
* run after a slower move, it would put the pane back where the pointer was.
|
|
73
|
+
* The check runs at the start of a frame, after the moves that frame brings,
|
|
74
|
+
* so a page drawing fewer frames than 1 / MAGNET_REST_MS still sees a
|
|
75
|
+
* pointer that moves on every frame as travelling.
|
|
76
|
+
*/
|
|
77
|
+
export interface MagnetPace {
|
|
78
|
+
travelling(sample: PointerSample, distances: MagnetDistances, rest?: () => void): boolean;
|
|
79
|
+
/** Drops the rest check: another event of the drag came first. */
|
|
80
|
+
cancel(): void;
|
|
81
|
+
/** Forgets the pointer's path, for a new drag. */
|
|
82
|
+
reset(): void;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function createMagnetPace(): MagnetPace {
|
|
86
|
+
let track: PointerSample[] = [];
|
|
87
|
+
let rest: ReturnType<typeof setTimeout> | null = null;
|
|
88
|
+
let frame: number | null = null;
|
|
89
|
+
const cancel = () => {
|
|
90
|
+
if (rest) clearTimeout(rest);
|
|
91
|
+
if (frame !== null) cancelAnimationFrame(frame);
|
|
92
|
+
rest = null;
|
|
93
|
+
frame = null;
|
|
94
|
+
};
|
|
95
|
+
return {
|
|
96
|
+
travelling(sample, distances, onRest) {
|
|
97
|
+
cancel();
|
|
98
|
+
const last = track[track.length - 1];
|
|
99
|
+
// The same place again (a rest check, a repeated event) is not a move.
|
|
100
|
+
if (!last || last.x !== sample.x || last.y !== sample.y) trackPointer(track, sample);
|
|
101
|
+
if (!pointerTravelling(track, sample.t, distances)) return false;
|
|
102
|
+
if (onRest) {
|
|
103
|
+
rest = setTimeout(() => {
|
|
104
|
+
rest = null;
|
|
105
|
+
if (typeof requestAnimationFrame !== "function") return onRest();
|
|
106
|
+
frame = requestAnimationFrame(() => {
|
|
107
|
+
frame = null;
|
|
108
|
+
onRest();
|
|
109
|
+
});
|
|
110
|
+
}, MAGNET_REST_MS);
|
|
111
|
+
}
|
|
112
|
+
return true;
|
|
113
|
+
},
|
|
114
|
+
cancel,
|
|
115
|
+
reset() {
|
|
116
|
+
cancel();
|
|
117
|
+
track = [];
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Whether the pointer is on its way somewhere rather than placing the pane:
|
|
124
|
+
* how far it went over the last few frames, in catch distances a second,
|
|
125
|
+
* against the travel speed. A move with nothing before it (the first of a
|
|
126
|
+
* drag) is travel, so a pane leaves its spot without catching the lines it
|
|
127
|
+
* sits on.
|
|
128
|
+
*/
|
|
129
|
+
function pointerTravelling(track: readonly PointerSample[], now: number, distances: MagnetDistances): boolean {
|
|
130
|
+
const latest = track[track.length - 1];
|
|
131
|
+
if (!latest) return false;
|
|
132
|
+
const since = now - SPEED_WINDOW_MS;
|
|
133
|
+
let from = track[0]!;
|
|
134
|
+
for (const sample of track) {
|
|
135
|
+
if (sample.t > since) break;
|
|
136
|
+
from = sample;
|
|
137
|
+
}
|
|
138
|
+
const span = Math.min(SPEED_WINDOW_MS, now - from.t);
|
|
139
|
+
if (from === latest) return track.length === 1 && span <= 0;
|
|
140
|
+
if (span <= 0) return true;
|
|
141
|
+
const catches = Math.hypot((latest.x - from.x) / distances.catchX, (latest.y - from.y) / distances.catchY);
|
|
142
|
+
return (catches / span) * 1000 > MAGNET_TRAVEL_SPEED;
|
|
143
|
+
}
|
|
144
|
+
|
|
39
145
|
/**
|
|
40
146
|
* The magnets in cells: the desktop's px over its cell size (`cell`), or the
|
|
41
147
|
* terminal's whole cells, also for a cell size not measured yet (zero), which
|
|
@@ -3,6 +3,7 @@ import { useCallback } from "react";
|
|
|
3
3
|
import { t } from "../../i18n";
|
|
4
4
|
import { useAppLanguage } from "../../i18n/react";
|
|
5
5
|
import { TITLEBAR_OVERLAY_HEIGHT_PX } from "./titlebar-overlay";
|
|
6
|
+
import { useWindowMaximized } from "./window-fullscreen";
|
|
6
7
|
|
|
7
8
|
const WINDOWS_CONTROL_SIZE_PX = TITLEBAR_OVERLAY_HEIGHT_PX;
|
|
8
9
|
export const WINDOWS_CONTROL_GROUP_WIDTH_PX = WINDOWS_CONTROL_SIZE_PX * 3;
|
|
@@ -47,58 +48,118 @@ function WindowControlIcon({ action }: { action: WindowControlAction }) {
|
|
|
47
48
|
);
|
|
48
49
|
}
|
|
49
50
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
/**
|
|
52
|
+
* The page covers the top of its window's frame, so the strip along its top
|
|
53
|
+
* stands in for the frame's top edge: a press there resizes the window, and at
|
|
54
|
+
* either end diagonally, as Windows does from a native frame.
|
|
55
|
+
*/
|
|
56
|
+
const TOP_EDGE_HEIGHT_PX = 4;
|
|
57
|
+
const TOP_CORNER_WIDTH_PX = 16;
|
|
53
58
|
|
|
54
|
-
|
|
55
|
-
useAppLanguage();
|
|
56
|
-
const rendererHost = useRendererHost();
|
|
59
|
+
type TopEdge = "top" | "top-left" | "top-right";
|
|
57
60
|
|
|
58
|
-
|
|
61
|
+
const TOP_EDGES: Array<{ edge: TopEdge; cursor: string; width?: number }> = [
|
|
62
|
+
{ edge: "top-left", cursor: "nwse-resize", width: TOP_CORNER_WIDTH_PX },
|
|
63
|
+
{ edge: "top", cursor: "ns-resize" },
|
|
64
|
+
{ edge: "top-right", cursor: "nesw-resize", width: TOP_CORNER_WIDTH_PX },
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
function WindowTopEdge() {
|
|
68
|
+
const rendererHost = useRendererHost();
|
|
69
|
+
// A maximized window has no edge to pull, and its buttons must take a press
|
|
70
|
+
// at the screen's very top.
|
|
71
|
+
const maximized = useWindowMaximized();
|
|
72
|
+
const startResize = useCallback((edge: TopEdge, event: { stopPropagation?: () => void; preventDefault?: () => void }) => {
|
|
59
73
|
stopMouse(event);
|
|
60
|
-
void rendererHost.
|
|
74
|
+
void rendererHost.startWindowResize?.(edge);
|
|
61
75
|
}, [rendererHost]);
|
|
62
76
|
|
|
77
|
+
if (maximized) return null;
|
|
63
78
|
return (
|
|
64
79
|
<Box
|
|
65
80
|
flexDirection="row"
|
|
66
|
-
|
|
67
|
-
flexShrink={0}
|
|
68
|
-
width={`${WINDOWS_CONTROL_GROUP_WIDTH_PX}px`}
|
|
69
|
-
data-gloom-role="window-controls"
|
|
70
|
-
data-window-kind={windowKind}
|
|
71
|
-
aria-hidden={false}
|
|
81
|
+
data-gloom-role="window-top-edge"
|
|
72
82
|
style={{
|
|
73
83
|
position: "fixed",
|
|
74
84
|
top: 0,
|
|
85
|
+
left: 0,
|
|
75
86
|
right: 0,
|
|
76
|
-
|
|
77
|
-
//
|
|
78
|
-
|
|
79
|
-
zIndex: 1000,
|
|
80
|
-
backgroundColor: "inherit",
|
|
87
|
+
height: `${TOP_EDGE_HEIGHT_PX}px`,
|
|
88
|
+
// Over the buttons too: a native frame's top edge runs above them.
|
|
89
|
+
zIndex: 1001,
|
|
81
90
|
}}
|
|
82
91
|
>
|
|
83
|
-
{
|
|
92
|
+
{TOP_EDGES.map(({ edge, cursor, width }) => (
|
|
84
93
|
<Box
|
|
85
|
-
key={
|
|
86
|
-
alignItems="center"
|
|
87
|
-
justifyContent="center"
|
|
88
|
-
flexShrink={0}
|
|
89
|
-
width={`${WINDOWS_CONTROL_SIZE_PX}px`}
|
|
94
|
+
key={edge}
|
|
90
95
|
height="100%"
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
>
|
|
99
|
-
<WindowControlIcon action={control.action} />
|
|
100
|
-
</Box>
|
|
96
|
+
flexGrow={width ? 0 : 1}
|
|
97
|
+
flexShrink={0}
|
|
98
|
+
width={width ? `${width}px` : undefined}
|
|
99
|
+
data-window-edge={edge}
|
|
100
|
+
style={{ cursor }}
|
|
101
|
+
onMouseDown={(event: { stopPropagation?: () => void; preventDefault?: () => void }) => startResize(edge, event)}
|
|
102
|
+
/>
|
|
101
103
|
))}
|
|
102
104
|
</Box>
|
|
103
105
|
);
|
|
104
106
|
}
|
|
107
|
+
|
|
108
|
+
interface WindowControlsProps {
|
|
109
|
+
windowKind?: "main" | "detached";
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export function WindowControls({ windowKind = "main" }: WindowControlsProps) {
|
|
113
|
+
useAppLanguage();
|
|
114
|
+
const rendererHost = useRendererHost();
|
|
115
|
+
|
|
116
|
+
const controlWindow = useCallback((action: WindowControlAction, event: { stopPropagation?: () => void; preventDefault?: () => void }) => {
|
|
117
|
+
stopMouse(event);
|
|
118
|
+
void rendererHost.controlWindow?.(action);
|
|
119
|
+
}, [rendererHost]);
|
|
120
|
+
|
|
121
|
+
return (
|
|
122
|
+
<>
|
|
123
|
+
<WindowTopEdge />
|
|
124
|
+
<Box
|
|
125
|
+
flexDirection="row"
|
|
126
|
+
alignItems="stretch"
|
|
127
|
+
flexShrink={0}
|
|
128
|
+
width={`${WINDOWS_CONTROL_GROUP_WIDTH_PX}px`}
|
|
129
|
+
data-gloom-role="window-controls"
|
|
130
|
+
data-window-kind={windowKind}
|
|
131
|
+
aria-hidden={false}
|
|
132
|
+
style={{
|
|
133
|
+
position: "fixed",
|
|
134
|
+
top: 0,
|
|
135
|
+
right: 0,
|
|
136
|
+
// A popped-out window's title bar is its pane header, which ends in a
|
|
137
|
+
// 1px rule; the buttons stop above it so the rule runs the full width.
|
|
138
|
+
height: `${WINDOWS_CONTROL_SIZE_PX - (windowKind === "detached" ? 1 : 0)}px`,
|
|
139
|
+
zIndex: 1000,
|
|
140
|
+
backgroundColor: "inherit",
|
|
141
|
+
}}
|
|
142
|
+
>
|
|
143
|
+
{WINDOWS_CONTROLS.map((control) => (
|
|
144
|
+
<Box
|
|
145
|
+
key={control.action}
|
|
146
|
+
alignItems="center"
|
|
147
|
+
justifyContent="center"
|
|
148
|
+
flexShrink={0}
|
|
149
|
+
width={`${WINDOWS_CONTROL_SIZE_PX}px`}
|
|
150
|
+
height="100%"
|
|
151
|
+
data-gloom-role="window-control"
|
|
152
|
+
data-window-control-action={control.action}
|
|
153
|
+
data-gloom-interactive="true"
|
|
154
|
+
role="button"
|
|
155
|
+
aria-label={t(control.labelKey)}
|
|
156
|
+
title={t(control.labelKey)}
|
|
157
|
+
onMouseDown={(event: { stopPropagation?: () => void; preventDefault?: () => void }) => controlWindow(control.action, event)}
|
|
158
|
+
>
|
|
159
|
+
<WindowControlIcon action={control.action} />
|
|
160
|
+
</Box>
|
|
161
|
+
))}
|
|
162
|
+
</Box>
|
|
163
|
+
</>
|
|
164
|
+
);
|
|
165
|
+
}
|
|
@@ -30,3 +30,23 @@ function subscribeWindowFullscreen(listener: () => void): () => void {
|
|
|
30
30
|
export function useWindowFullscreen(): boolean {
|
|
31
31
|
return useSyncExternalStore(subscribeWindowFullscreen, isWindowFullscreen, () => false);
|
|
32
32
|
}
|
|
33
|
+
|
|
34
|
+
let windowMaximized = false;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Whether the window hosting this view is maximized. On Windows it then has
|
|
38
|
+
* no edge to resize from, and its buttons run to the screen's top edge.
|
|
39
|
+
*/
|
|
40
|
+
export function setWindowMaximized(next: boolean): void {
|
|
41
|
+
if (windowMaximized === next) return;
|
|
42
|
+
windowMaximized = next;
|
|
43
|
+
for (const listener of [...listeners]) listener();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function isWindowMaximized(): boolean {
|
|
47
|
+
return windowMaximized;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function useWindowMaximized(): boolean {
|
|
51
|
+
return useSyncExternalStore(subscribeWindowFullscreen, isWindowMaximized, () => false);
|
|
52
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { useEffect, useRef
|
|
1
|
+
import { useEffect, useRef } from "react";
|
|
2
2
|
import type { TickerFinancials } from "../types/financials";
|
|
3
3
|
import { getActiveQuoteDisplay } from "../market-data/market/status";
|
|
4
|
+
import { useDataFrameWake } from "../market-data/frame-wake";
|
|
4
5
|
|
|
5
6
|
export type QuoteFlashDirection = "up" | "down" | "flat";
|
|
6
7
|
|
|
@@ -99,47 +100,50 @@ function sameFlashes(left: Map<string, QuoteFlashDirection>, right: Map<string,
|
|
|
99
100
|
|
|
100
101
|
const EMPTY_FLASHES = new Map<string, QuoteFlashDirection>();
|
|
101
102
|
|
|
103
|
+
function sameDeps(left: readonly unknown[] | null, right: readonly unknown[]): boolean {
|
|
104
|
+
return !!left && left.length === right.length && left.every((value, index) => Object.is(value, right[index]));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* The flashes to show. New prices are observed while rendering, so a price and
|
|
109
|
+
* its flash reach the screen in the same commit, and a flash ends in the first
|
|
110
|
+
* market data frame after it is due, with whatever quotes that frame brings:
|
|
111
|
+
* neither costs a commit (in the terminal, a full redraw) of its own.
|
|
112
|
+
*/
|
|
102
113
|
function useFlashTracker(
|
|
103
114
|
collect: (tracker: QuoteFlashTracker, now: number) => void,
|
|
104
115
|
enabled: boolean,
|
|
105
116
|
deps: readonly unknown[],
|
|
106
117
|
): Map<string, QuoteFlashDirection> {
|
|
107
|
-
const [flashes, setFlashes] = useState<Map<string, QuoteFlashDirection>>(EMPTY_FLASHES);
|
|
108
118
|
const trackerRef = useRef<QuoteFlashTracker | null>(null);
|
|
109
119
|
trackerRef.current ??= new QuoteFlashTracker();
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
120
|
+
const tracker = trackerRef.current;
|
|
121
|
+
const observedRef = useRef<readonly unknown[] | null>(null);
|
|
122
|
+
const shownRef = useRef<Map<string, QuoteFlashDirection>>(EMPTY_FLASHES);
|
|
123
|
+
const clock = useDataFrameWake();
|
|
124
|
+
|
|
125
|
+
const now = clock.now();
|
|
126
|
+
// Once per set of inputs: a render for any other reason (or a repeated one) observes nothing.
|
|
127
|
+
if (!sameDeps(observedRef.current, deps)) {
|
|
128
|
+
observedRef.current = deps;
|
|
129
|
+
collect(tracker, now);
|
|
130
|
+
}
|
|
131
|
+
let flashes = EMPTY_FLASHES;
|
|
132
|
+
if (!enabled) {
|
|
133
|
+
tracker.clear();
|
|
134
|
+
} else {
|
|
115
135
|
tracker.prune(now);
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
if (nextAt != null) {
|
|
122
|
-
timeoutRef.current = setTimeout(publish, Math.max(0, nextAt - Date.now()));
|
|
123
|
-
}
|
|
124
|
-
};
|
|
136
|
+
const active = tracker.active(now);
|
|
137
|
+
flashes = sameFlashes(shownRef.current, active) ? shownRef.current : active.size === 0 ? EMPTY_FLASHES : active;
|
|
138
|
+
}
|
|
139
|
+
shownRef.current = flashes;
|
|
140
|
+
const endsAt = enabled ? tracker.nextChangeAt(now) : null;
|
|
125
141
|
|
|
142
|
+
// Booked after every render that still shows a flash.
|
|
126
143
|
useEffect(() => {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
if (!enabled) {
|
|
131
|
-
tracker.clear();
|
|
132
|
-
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
133
|
-
timeoutRef.current = null;
|
|
134
|
-
setFlashes(EMPTY_FLASHES);
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
publish();
|
|
138
|
-
}, [enabled, ...deps]);
|
|
139
|
-
|
|
140
|
-
useEffect(() => () => {
|
|
141
|
-
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
142
|
-
}, []);
|
|
144
|
+
if (endsAt != null) clock.wakeAt(endsAt);
|
|
145
|
+
else clock.cancel();
|
|
146
|
+
});
|
|
143
147
|
|
|
144
148
|
return flashes;
|
|
145
149
|
}
|