mikuru 1.0.36 → 1.0.38

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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.38 - 2026-05-17
4
+
5
+ - Fixed `MikuruVideoPlayer` speed and skip settings so option active states follow the selected value without reactive menu churn, preventing settings menu crashes in consuming apps while keeping speed highlights and skip actions in sync.
6
+
7
+ ## 1.0.37 - 2026-05-17
8
+
9
+ - Fixed `MikuruVideoPlayer` speed and skip settings so option records avoid `.value` template access, preventing crashes in consuming apps when selecting playback rate or keyboard skip seconds.
10
+
3
11
  ## 1.0.36 - 2026-05-17
4
12
 
5
13
  - Stabilized `MikuruVideoPlayer` settings interactions so playback speed and keyboard skip selections defer UI updates out of the click stack, matching the other media controls and avoiding recursive update freezes.
@@ -108,11 +108,11 @@
108
108
  <span class="settings-label">Speed</span>
109
109
  <button
110
110
  m-for="rate in rateOptions"
111
- :key="rate.value"
111
+ :key="rate.rate"
112
112
  type="button"
113
113
  class="settings-option"
114
- :class="{ active: rate.value === playbackRateValue }"
115
- @click="setPlaybackRate(rate.value)"
114
+ :class="{ active: isPlaybackRateActive(rate.rate) }"
115
+ @click="setPlaybackRate($event, rate.rate)"
116
116
  >
117
117
  {{ rate.label }}
118
118
  </button>
@@ -122,11 +122,11 @@
122
122
  <span class="settings-label">Skip</span>
123
123
  <button
124
124
  m-for="option in skipOptions"
125
- :key="option.value"
125
+ :key="option.seconds"
126
126
  type="button"
127
127
  class="settings-option"
128
- :class="{ active: option.value === skipSeconds }"
129
- @click="setSkipSeconds(option.value)"
128
+ :class="{ active: isSkipSecondsActive(option.seconds) }"
129
+ @click="setSkipSeconds($event, option.seconds)"
130
130
  >
131
131
  {{ option.label }}
132
132
  </button>
@@ -195,8 +195,6 @@ const isFullscreen = ref(false);
195
195
  const isSeeking = ref(false);
196
196
  const settingsOpen = ref(false);
197
197
  const selectedQualityId = ref("auto");
198
- const playbackRateValue = ref(1);
199
- const skipSeconds = ref(5);
200
198
  const pointerInside = ref(false);
201
199
  const controlsVisible = ref(true);
202
200
  const settingsEl = ref(null);
@@ -206,6 +204,8 @@ const activeControls = ref(new Set(allControls));
206
204
  const normalizedQualityOptions = ref([]);
207
205
  let controlsSignature = "";
208
206
  let qualityOptionsSignature = "";
207
+ let playbackRateValue = 1;
208
+ let skipSeconds = 5;
209
209
 
210
210
  watch(controls, syncControls, { immediate: true });
211
211
  watch([qualityOptions, src, poster], syncQualityOptions, { immediate: true });
@@ -268,17 +268,17 @@ const playIconClass = computed(() => isPlaying.value ? "icon-pause" : "icon-play
268
268
  const fullscreenIconClass = computed(() => isFullscreen.value ? "icon-minimize" : "icon-maximize");
269
269
  const statusText = computed(() => isLive.value ? "LIVE" : subtitle.value);
270
270
  const rateOptions = [
271
- { value: 0.75, label: "0.75x" },
272
- { value: 1, label: "1x" },
273
- { value: 1.25, label: "1.25x" },
274
- { value: 1.5, label: "1.5x" },
275
- { value: 2, label: "2x" }
271
+ { rate: 0.75, label: "0.75x" },
272
+ { rate: 1, label: "1x" },
273
+ { rate: 1.25, label: "1.25x" },
274
+ { rate: 1.5, label: "1.5x" },
275
+ { rate: 2, label: "2x" }
276
276
  ];
277
277
  const skipOptions = [
278
- { value: 5, label: "5s" },
279
- { value: 10, label: "10s" },
280
- { value: 15, label: "15s" },
281
- { value: 30, label: "30s" }
278
+ { seconds: 5, label: "5s" },
279
+ { seconds: 10, label: "10s" },
280
+ { seconds: 15, label: "15s" },
281
+ { seconds: 30, label: "30s" }
282
282
  ];
283
283
  const showPlayControl = computed(() => hasControl("play"));
284
284
  const showSeekControl = computed(() => hasControl("seek"));
@@ -436,7 +436,7 @@ function applyAudioSettings() {
436
436
  if (!media) return;
437
437
  media.volume = volume.value;
438
438
  media.muted = muted.value;
439
- media.playbackRate = playbackRateValue.value;
439
+ media.playbackRate = playbackRateValue;
440
440
  }
441
441
 
442
442
  function markPlaying(event) {
@@ -497,6 +497,17 @@ function seekTo(nextTime) {
497
497
  }
498
498
  }
499
499
 
500
+ function skipBy(seconds) {
501
+ if (isDisposed) return;
502
+ const media = getMedia();
503
+ const baseTime = media?.currentTime ?? currentTime.value;
504
+ const maxTime = Number.isFinite(media?.duration) && media.duration > 0 ? media.duration : safeDuration.value;
505
+ const nextTime = maxTime > 0
506
+ ? Math.min(Math.max(baseTime + seconds, 0), maxTime)
507
+ : Math.max(baseTime + seconds, 0);
508
+ seekTo(nextTime);
509
+ }
510
+
500
511
  function seekFromPointer(event) {
501
512
  seekTo(getPointerTime(event));
502
513
  }
@@ -552,7 +563,7 @@ function seekWithKeyboard(event) {
552
563
  return;
553
564
  }
554
565
 
555
- const offset = event.key === "ArrowRight" ? skipSeconds.value : -skipSeconds.value;
566
+ const offset = event.key === "ArrowRight" ? skipSeconds : -skipSeconds;
556
567
  const nextTime = Math.min(Math.max(currentTime.value + offset, 0), safeDuration.value);
557
568
  seekTo(nextTime);
558
569
  }
@@ -606,7 +617,7 @@ function selectQuality(id) {
606
617
  nextMedia.currentTime = Math.min(previousTime, safeDuration.value);
607
618
  currentTime.value = nextMedia.currentTime;
608
619
  }
609
- nextMedia.playbackRate = playbackRateValue.value;
620
+ nextMedia.playbackRate = playbackRateValue;
610
621
  if (wasPlaying) {
611
622
  nextMedia.play().catch((error) => {
612
623
  if (error?.name !== "AbortError") {
@@ -617,11 +628,13 @@ function selectQuality(id) {
617
628
  }, 0);
618
629
  }
619
630
 
620
- function setPlaybackRate(nextRate) {
631
+ function setPlaybackRate(event, nextRate) {
621
632
  if (isDisposed) return;
633
+ playbackRateValue = nextRate;
634
+ const button = event.currentTarget;
635
+ markSettingsOptionActive(button);
622
636
  window.setTimeout(() => {
623
637
  if (isDisposed) return;
624
- playbackRateValue.value = nextRate;
625
638
  settingsOpen.value = false;
626
639
  const media = getMedia();
627
640
  if (!media) return;
@@ -630,15 +643,33 @@ function setPlaybackRate(nextRate) {
630
643
  }, 0);
631
644
  }
632
645
 
633
- function setSkipSeconds(nextSeconds) {
646
+ function setSkipSeconds(event, nextSeconds) {
634
647
  if (isDisposed) return;
648
+ skipSeconds = nextSeconds;
649
+ const button = event.currentTarget;
650
+ markSettingsOptionActive(button);
635
651
  window.setTimeout(() => {
636
652
  if (isDisposed) return;
637
- skipSeconds.value = nextSeconds;
653
+ skipBy(nextSeconds);
638
654
  settingsOpen.value = false;
639
655
  }, 0);
640
656
  }
641
657
 
658
+ function isPlaybackRateActive(rate) {
659
+ return rate === playbackRateValue;
660
+ }
661
+
662
+ function isSkipSecondsActive(seconds) {
663
+ return seconds === skipSeconds;
664
+ }
665
+
666
+ function markSettingsOptionActive(button) {
667
+ const group = button?.closest?.(".settings-group");
668
+ group?.querySelectorAll?.(".settings-option").forEach((optionButton) => {
669
+ optionButton.classList.toggle("active", optionButton === button);
670
+ });
671
+ }
672
+
642
673
  function handleDocumentPointerDown(event) {
643
674
  if (isDisposed || !settingsOpen.value) return;
644
675
  const menu = settingsEl.value;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mikuru",
3
- "version": "1.0.36",
3
+ "version": "1.0.38",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "A compile-first JavaScript framework with Vue-like authoring and Svelte-like generated DOM updates.",