hyperprop-charting-library 0.1.144 → 0.1.145

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.
@@ -10548,6 +10548,22 @@ function createChart(element, options = {}) {
10548
10548
  if (event.altKey || event.ctrlKey || event.metaKey) {
10549
10549
  return;
10550
10550
  }
10551
+ if (replay && keyboard.replay !== false) {
10552
+ if (event.key === "ArrowRight" || event.key === "ArrowLeft") {
10553
+ const direction = event.key === "ArrowRight" ? 1 : -1;
10554
+ replayStep(direction * (event.shiftKey ? 10 : 1));
10555
+ emit(direction > 0 ? "replay-step-forward" : "replay-step-back");
10556
+ event.preventDefault();
10557
+ return;
10558
+ }
10559
+ if (event.key === " " || event.key === "Spacebar") {
10560
+ if (replay.playing) replayPause();
10561
+ else replayPlay();
10562
+ emit("replay-toggle-play");
10563
+ event.preventDefault();
10564
+ return;
10565
+ }
10566
+ }
10551
10567
  switch (event.key) {
10552
10568
  case "Delete":
10553
10569
  case "Backspace": {
@@ -10959,7 +10975,11 @@ function createChart(element, options = {}) {
10959
10975
  const replayStep = (bars = 1) => {
10960
10976
  if (!replay) return;
10961
10977
  const step = Math.trunc(bars) || 1;
10962
- const next = clamp(replay.cursor + step, 0, replay.fullRaw.length - 1);
10978
+ replaySeek(replay.cursor + step);
10979
+ };
10980
+ const replaySeek = (index) => {
10981
+ if (!replay || !Number.isFinite(index)) return;
10982
+ const next = clamp(Math.round(index), 0, replay.fullRaw.length - 1);
10963
10983
  if (next === replay.cursor) return;
10964
10984
  replay.cursor = next;
10965
10985
  applyReplaySlice();
@@ -11592,6 +11612,7 @@ function createChart(element, options = {}) {
11592
11612
  startReplay,
11593
11613
  stopReplay,
11594
11614
  replayStep,
11615
+ replaySeek,
11595
11616
  replayPlay,
11596
11617
  replayPause,
11597
11618
  setReplaySpeed,
@@ -561,7 +561,7 @@ interface ChartContextMenuEvent {
561
561
  };
562
562
  }
563
563
  /** Built-in keyboard actions, reported after the chart applies them. */
564
- type ChartKeyboardAction = "delete-drawing" | "cancel" | "undo" | "redo" | "pan-left" | "pan-right" | "pan-up" | "pan-down" | "zoom-in" | "zoom-out" | "reset-viewport" | "scroll-to-realtime";
564
+ type ChartKeyboardAction = "delete-drawing" | "cancel" | "undo" | "redo" | "pan-left" | "pan-right" | "pan-up" | "pan-down" | "zoom-in" | "zoom-out" | "reset-viewport" | "scroll-to-realtime" | "replay-step-forward" | "replay-step-back" | "replay-toggle-play";
565
565
  interface ChartKeyboardShortcutEvent {
566
566
  action: ChartKeyboardAction;
567
567
  /** The originating `KeyboardEvent.key`. */
@@ -583,6 +583,12 @@ interface KeyboardOptions {
583
583
  deleteSelectedDrawing?: boolean;
584
584
  /** Ctrl/Cmd+Z and Ctrl/Cmd+Shift+Z (or Ctrl+Y). Default true. */
585
585
  undoRedo?: boolean;
586
+ /**
587
+ * While replay is running, arrows step the tape (Shift steps 10) and Space
588
+ * toggles playback, instead of panning. Only applies during replay.
589
+ * Default true.
590
+ */
591
+ replay?: boolean;
586
592
  }
587
593
  /**
588
594
  * Deep zoom-out rendering. Once bars are narrower than `thresholdPx`, several
@@ -1035,6 +1041,11 @@ interface ChartInstance {
1035
1041
  stopReplay: () => void;
1036
1042
  /** Reveal `bars` more bars (negative rewinds). Default 1. */
1037
1043
  replayStep: (bars?: number) => void;
1044
+ /**
1045
+ * Jump straight to a bar index, for a scrubber or a "replay from here"
1046
+ * action. Clamped to the series; playback continues from where it lands.
1047
+ */
1048
+ replaySeek: (index: number) => void;
1038
1049
  replayPlay: (speed?: number) => void;
1039
1050
  replayPause: () => void;
1040
1051
  /** Bars revealed per second. */
@@ -10512,6 +10512,22 @@ function createChart(element, options = {}) {
10512
10512
  if (event.altKey || event.ctrlKey || event.metaKey) {
10513
10513
  return;
10514
10514
  }
10515
+ if (replay && keyboard.replay !== false) {
10516
+ if (event.key === "ArrowRight" || event.key === "ArrowLeft") {
10517
+ const direction = event.key === "ArrowRight" ? 1 : -1;
10518
+ replayStep(direction * (event.shiftKey ? 10 : 1));
10519
+ emit(direction > 0 ? "replay-step-forward" : "replay-step-back");
10520
+ event.preventDefault();
10521
+ return;
10522
+ }
10523
+ if (event.key === " " || event.key === "Spacebar") {
10524
+ if (replay.playing) replayPause();
10525
+ else replayPlay();
10526
+ emit("replay-toggle-play");
10527
+ event.preventDefault();
10528
+ return;
10529
+ }
10530
+ }
10515
10531
  switch (event.key) {
10516
10532
  case "Delete":
10517
10533
  case "Backspace": {
@@ -10923,7 +10939,11 @@ function createChart(element, options = {}) {
10923
10939
  const replayStep = (bars = 1) => {
10924
10940
  if (!replay) return;
10925
10941
  const step = Math.trunc(bars) || 1;
10926
- const next = clamp(replay.cursor + step, 0, replay.fullRaw.length - 1);
10942
+ replaySeek(replay.cursor + step);
10943
+ };
10944
+ const replaySeek = (index) => {
10945
+ if (!replay || !Number.isFinite(index)) return;
10946
+ const next = clamp(Math.round(index), 0, replay.fullRaw.length - 1);
10927
10947
  if (next === replay.cursor) return;
10928
10948
  replay.cursor = next;
10929
10949
  applyReplaySlice();
@@ -11556,6 +11576,7 @@ function createChart(element, options = {}) {
11556
11576
  startReplay,
11557
11577
  stopReplay,
11558
11578
  replayStep,
11579
+ replaySeek,
11559
11580
  replayPlay,
11560
11581
  replayPause,
11561
11582
  setReplaySpeed,
package/dist/index.cjs CHANGED
@@ -10548,6 +10548,22 @@ function createChart(element, options = {}) {
10548
10548
  if (event.altKey || event.ctrlKey || event.metaKey) {
10549
10549
  return;
10550
10550
  }
10551
+ if (replay && keyboard.replay !== false) {
10552
+ if (event.key === "ArrowRight" || event.key === "ArrowLeft") {
10553
+ const direction = event.key === "ArrowRight" ? 1 : -1;
10554
+ replayStep(direction * (event.shiftKey ? 10 : 1));
10555
+ emit(direction > 0 ? "replay-step-forward" : "replay-step-back");
10556
+ event.preventDefault();
10557
+ return;
10558
+ }
10559
+ if (event.key === " " || event.key === "Spacebar") {
10560
+ if (replay.playing) replayPause();
10561
+ else replayPlay();
10562
+ emit("replay-toggle-play");
10563
+ event.preventDefault();
10564
+ return;
10565
+ }
10566
+ }
10551
10567
  switch (event.key) {
10552
10568
  case "Delete":
10553
10569
  case "Backspace": {
@@ -10959,7 +10975,11 @@ function createChart(element, options = {}) {
10959
10975
  const replayStep = (bars = 1) => {
10960
10976
  if (!replay) return;
10961
10977
  const step = Math.trunc(bars) || 1;
10962
- const next = clamp(replay.cursor + step, 0, replay.fullRaw.length - 1);
10978
+ replaySeek(replay.cursor + step);
10979
+ };
10980
+ const replaySeek = (index) => {
10981
+ if (!replay || !Number.isFinite(index)) return;
10982
+ const next = clamp(Math.round(index), 0, replay.fullRaw.length - 1);
10963
10983
  if (next === replay.cursor) return;
10964
10984
  replay.cursor = next;
10965
10985
  applyReplaySlice();
@@ -11592,6 +11612,7 @@ function createChart(element, options = {}) {
11592
11612
  startReplay,
11593
11613
  stopReplay,
11594
11614
  replayStep,
11615
+ replaySeek,
11595
11616
  replayPlay,
11596
11617
  replayPause,
11597
11618
  setReplaySpeed,
package/dist/index.d.cts CHANGED
@@ -561,7 +561,7 @@ interface ChartContextMenuEvent {
561
561
  };
562
562
  }
563
563
  /** Built-in keyboard actions, reported after the chart applies them. */
564
- type ChartKeyboardAction = "delete-drawing" | "cancel" | "undo" | "redo" | "pan-left" | "pan-right" | "pan-up" | "pan-down" | "zoom-in" | "zoom-out" | "reset-viewport" | "scroll-to-realtime";
564
+ type ChartKeyboardAction = "delete-drawing" | "cancel" | "undo" | "redo" | "pan-left" | "pan-right" | "pan-up" | "pan-down" | "zoom-in" | "zoom-out" | "reset-viewport" | "scroll-to-realtime" | "replay-step-forward" | "replay-step-back" | "replay-toggle-play";
565
565
  interface ChartKeyboardShortcutEvent {
566
566
  action: ChartKeyboardAction;
567
567
  /** The originating `KeyboardEvent.key`. */
@@ -583,6 +583,12 @@ interface KeyboardOptions {
583
583
  deleteSelectedDrawing?: boolean;
584
584
  /** Ctrl/Cmd+Z and Ctrl/Cmd+Shift+Z (or Ctrl+Y). Default true. */
585
585
  undoRedo?: boolean;
586
+ /**
587
+ * While replay is running, arrows step the tape (Shift steps 10) and Space
588
+ * toggles playback, instead of panning. Only applies during replay.
589
+ * Default true.
590
+ */
591
+ replay?: boolean;
586
592
  }
587
593
  /**
588
594
  * Deep zoom-out rendering. Once bars are narrower than `thresholdPx`, several
@@ -1035,6 +1041,11 @@ interface ChartInstance {
1035
1041
  stopReplay: () => void;
1036
1042
  /** Reveal `bars` more bars (negative rewinds). Default 1. */
1037
1043
  replayStep: (bars?: number) => void;
1044
+ /**
1045
+ * Jump straight to a bar index, for a scrubber or a "replay from here"
1046
+ * action. Clamped to the series; playback continues from where it lands.
1047
+ */
1048
+ replaySeek: (index: number) => void;
1038
1049
  replayPlay: (speed?: number) => void;
1039
1050
  replayPause: () => void;
1040
1051
  /** Bars revealed per second. */
package/dist/index.d.ts CHANGED
@@ -561,7 +561,7 @@ interface ChartContextMenuEvent {
561
561
  };
562
562
  }
563
563
  /** Built-in keyboard actions, reported after the chart applies them. */
564
- type ChartKeyboardAction = "delete-drawing" | "cancel" | "undo" | "redo" | "pan-left" | "pan-right" | "pan-up" | "pan-down" | "zoom-in" | "zoom-out" | "reset-viewport" | "scroll-to-realtime";
564
+ type ChartKeyboardAction = "delete-drawing" | "cancel" | "undo" | "redo" | "pan-left" | "pan-right" | "pan-up" | "pan-down" | "zoom-in" | "zoom-out" | "reset-viewport" | "scroll-to-realtime" | "replay-step-forward" | "replay-step-back" | "replay-toggle-play";
565
565
  interface ChartKeyboardShortcutEvent {
566
566
  action: ChartKeyboardAction;
567
567
  /** The originating `KeyboardEvent.key`. */
@@ -583,6 +583,12 @@ interface KeyboardOptions {
583
583
  deleteSelectedDrawing?: boolean;
584
584
  /** Ctrl/Cmd+Z and Ctrl/Cmd+Shift+Z (or Ctrl+Y). Default true. */
585
585
  undoRedo?: boolean;
586
+ /**
587
+ * While replay is running, arrows step the tape (Shift steps 10) and Space
588
+ * toggles playback, instead of panning. Only applies during replay.
589
+ * Default true.
590
+ */
591
+ replay?: boolean;
586
592
  }
587
593
  /**
588
594
  * Deep zoom-out rendering. Once bars are narrower than `thresholdPx`, several
@@ -1035,6 +1041,11 @@ interface ChartInstance {
1035
1041
  stopReplay: () => void;
1036
1042
  /** Reveal `bars` more bars (negative rewinds). Default 1. */
1037
1043
  replayStep: (bars?: number) => void;
1044
+ /**
1045
+ * Jump straight to a bar index, for a scrubber or a "replay from here"
1046
+ * action. Clamped to the series; playback continues from where it lands.
1047
+ */
1048
+ replaySeek: (index: number) => void;
1038
1049
  replayPlay: (speed?: number) => void;
1039
1050
  replayPause: () => void;
1040
1051
  /** Bars revealed per second. */
package/dist/index.js CHANGED
@@ -10512,6 +10512,22 @@ function createChart(element, options = {}) {
10512
10512
  if (event.altKey || event.ctrlKey || event.metaKey) {
10513
10513
  return;
10514
10514
  }
10515
+ if (replay && keyboard.replay !== false) {
10516
+ if (event.key === "ArrowRight" || event.key === "ArrowLeft") {
10517
+ const direction = event.key === "ArrowRight" ? 1 : -1;
10518
+ replayStep(direction * (event.shiftKey ? 10 : 1));
10519
+ emit(direction > 0 ? "replay-step-forward" : "replay-step-back");
10520
+ event.preventDefault();
10521
+ return;
10522
+ }
10523
+ if (event.key === " " || event.key === "Spacebar") {
10524
+ if (replay.playing) replayPause();
10525
+ else replayPlay();
10526
+ emit("replay-toggle-play");
10527
+ event.preventDefault();
10528
+ return;
10529
+ }
10530
+ }
10515
10531
  switch (event.key) {
10516
10532
  case "Delete":
10517
10533
  case "Backspace": {
@@ -10923,7 +10939,11 @@ function createChart(element, options = {}) {
10923
10939
  const replayStep = (bars = 1) => {
10924
10940
  if (!replay) return;
10925
10941
  const step = Math.trunc(bars) || 1;
10926
- const next = clamp(replay.cursor + step, 0, replay.fullRaw.length - 1);
10942
+ replaySeek(replay.cursor + step);
10943
+ };
10944
+ const replaySeek = (index) => {
10945
+ if (!replay || !Number.isFinite(index)) return;
10946
+ const next = clamp(Math.round(index), 0, replay.fullRaw.length - 1);
10927
10947
  if (next === replay.cursor) return;
10928
10948
  replay.cursor = next;
10929
10949
  applyReplaySlice();
@@ -11556,6 +11576,7 @@ function createChart(element, options = {}) {
11556
11576
  startReplay,
11557
11577
  stopReplay,
11558
11578
  replayStep,
11579
+ replaySeek,
11559
11580
  replayPlay,
11560
11581
  replayPause,
11561
11582
  setReplaySpeed,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hyperprop-charting-library",
3
- "version": "0.1.144",
3
+ "version": "0.1.145",
4
4
  "description": "Lightweight TypeScript charting core",
5
5
  "type": "module",
6
6
  "main": "./dist/hyperprop-charting-library.cjs",