@maas/vue-equipment 0.11.5 → 0.12.0

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.
Files changed (44) hide show
  1. package/dist/nuxt/module.json +1 -1
  2. package/dist/nuxt/module.mjs +1 -1
  3. package/dist/plugins/MagicModal/src/composables/private/useModalStore.d.ts +2 -2
  4. package/dist/plugins/MagicModal/src/composables/private/useModalStore.mjs +4 -4
  5. package/dist/plugins/MagicModal/src/composables/useModalApi.mjs +3 -3
  6. package/dist/plugins/MagicPlayer/index.d.ts +2 -7
  7. package/dist/plugins/MagicPlayer/index.mjs +4 -25
  8. package/dist/plugins/MagicPlayer/nuxt.mjs +1 -13
  9. package/dist/plugins/MagicPlayer/src/components/MagicPlayer.vue +21 -16
  10. package/dist/plugins/MagicPlayer/src/components/MagicPlayer.vue.d.ts +10 -29
  11. package/dist/plugins/MagicPlayer/src/components/MagicPlayerControls.vue +73 -91
  12. package/dist/plugins/MagicPlayer/src/components/MagicPlayerControls.vue.d.ts +16 -16
  13. package/dist/plugins/MagicPlayer/src/components/MagicPlayerMuxPopover.vue +11 -11
  14. package/dist/plugins/MagicPlayer/src/components/MagicPlayerMuxPopover.vue.d.ts +8 -0
  15. package/dist/plugins/MagicPlayer/src/components/MagicPlayerOverlay.vue +97 -0
  16. package/dist/plugins/MagicPlayer/src/components/MagicPlayerOverlay.vue.d.ts +21 -0
  17. package/dist/plugins/MagicPlayer/src/components/MagicPlayerTimeline.vue +25 -15
  18. package/dist/plugins/MagicPlayer/src/components/MagicPlayerTimeline.vue.d.ts +11 -1
  19. package/dist/plugins/MagicPlayer/src/components/icons/Waiting.vue +1 -1
  20. package/dist/plugins/MagicPlayer/src/composables/{useControlsApi.d.ts → private/useControlsApi.d.ts} +8 -8
  21. package/dist/plugins/MagicPlayer/src/composables/{useControlsApi.mjs → private/useControlsApi.mjs} +23 -20
  22. package/dist/plugins/MagicPlayer/src/composables/{useMediaApi.d.ts → private/useMediaApi.d.ts} +2 -2
  23. package/dist/plugins/MagicPlayer/src/composables/{useMediaApi.mjs → private/useMediaApi.mjs} +29 -28
  24. package/dist/plugins/MagicPlayer/src/composables/private/usePlayerInternalApi.d.ts +18 -0
  25. package/dist/plugins/MagicPlayer/src/composables/private/usePlayerInternalApi.mjs +63 -0
  26. package/dist/plugins/MagicPlayer/src/composables/private/usePlayerStore.d.ts +18 -0
  27. package/dist/plugins/MagicPlayer/src/composables/private/usePlayerStore.mjs +36 -0
  28. package/dist/plugins/MagicPlayer/src/composables/{useRuntimeSourceProvider.d.ts → private/useRuntimeSourceProvider.d.ts} +1 -3
  29. package/dist/plugins/MagicPlayer/src/composables/usePlayerApi.d.ts +2 -17
  30. package/dist/plugins/MagicPlayer/src/composables/usePlayerApi.mjs +62 -43
  31. package/dist/plugins/MagicPlayer/src/types/index.d.ts +14 -3
  32. package/dist/plugins/MagicToast/src/components/MagicToast.vue +14 -13
  33. package/dist/plugins/MagicToast/src/components/MagicToastComponent.vue +4 -4
  34. package/dist/plugins/MagicToast/src/composables/private/useToastCallback.d.ts +6 -2
  35. package/dist/plugins/MagicToast/src/composables/private/useToastCallback.mjs +9 -1
  36. package/dist/plugins/MagicToast/src/types/index.d.ts +4 -0
  37. package/package.json +1 -1
  38. package/dist/plugins/MagicPlayer/src/composables/useControls.d.ts +0 -8
  39. package/dist/plugins/MagicPlayer/src/composables/useControls.mjs +0 -15
  40. package/dist/plugins/MagicPlayer/src/composables/usePlayer.d.ts +0 -12
  41. package/dist/plugins/MagicPlayer/src/composables/usePlayer.mjs +0 -33
  42. package/dist/plugins/MagicPlayer/src/symbols/index.d.ts +0 -45
  43. package/dist/plugins/MagicPlayer/src/symbols/index.mjs +0 -10
  44. /package/dist/plugins/MagicPlayer/src/composables/{useRuntimeSourceProvider.mjs → private/useRuntimeSourceProvider.mjs} +0 -0
@@ -1,50 +1,69 @@
1
- import { ref, watch } from "vue";
2
- import { useFullscreen } from "@vueuse/core";
3
- import { isIOS } from "@maas/vue-equipment/utils";
1
+ import { uuid } from "@maas/vue-equipment/utils";
2
+ import { computed, onUnmounted, toValue } from "vue";
3
+ import { usePlayerStore } from "./private/usePlayerStore.mjs";
4
+ import { usePlayerInternalApi } from "./private/usePlayerInternalApi.mjs";
5
+ import { useMediaApi } from "./private/useMediaApi.mjs";
6
+ import { useControlsApi } from "./private/useControlsApi.mjs";
7
+ import { useRuntimeSourceProvider } from "./private/useRuntimeSourceProvider.mjs";
4
8
  export function usePlayerApi(args) {
5
- const touched = ref(false);
6
- const fullscreenTarget = isIOS() ? args.videoRef : args.playerRef;
7
- const { currentTime, playing, muted } = args.mediaApi;
8
- const {
9
- isFullscreen,
10
- enter: enterFullscreen,
11
- exit: exitFullscreen,
12
- toggle: toggleFullscreen
13
- } = useFullscreen(fullscreenTarget);
14
- function play() {
15
- playing.value = true;
16
- }
17
- function pause() {
18
- playing.value = false;
19
- }
20
- function togglePlay() {
21
- playing.value = !playing.value;
22
- }
23
- function seek(time) {
24
- currentTime.value = time;
25
- }
26
- function mute() {
27
- muted.value = true;
9
+ const { findInstance, addInstance, removeInstance } = usePlayerStore();
10
+ const mappedId = computed(() => {
11
+ if (typeof args === "string") {
12
+ return toValue(args) || uuid();
13
+ } else if ("id" in args) {
14
+ return toValue(args.id) || uuid();
15
+ } else {
16
+ return uuid();
17
+ }
18
+ });
19
+ const instance = computed(() => findInstance(toValue(mappedId)));
20
+ function initialize() {
21
+ const id = toValue(mappedId);
22
+ let instance2 = findInstance(id);
23
+ if (!instance2) {
24
+ instance2 = addInstance(id);
25
+ }
26
+ if (typeof args !== "string") {
27
+ if ("mediaRef" in args) {
28
+ instance2.mediaApi = useMediaApi({ mediaRef: args.mediaRef });
29
+ } else if ("videoRef" in args) {
30
+ instance2.mediaApi = useMediaApi({ mediaRef: args.videoRef });
31
+ }
32
+ if ("videoRef" in args && "playerRef" in args) {
33
+ instance2.playerApi = usePlayerInternalApi({
34
+ id,
35
+ playerRef: args.playerRef,
36
+ videoRef: args.videoRef
37
+ });
38
+ }
39
+ if ("videoRef" in args && "srcType" in args && "src" in args) {
40
+ instance2.runtimeProvider = useRuntimeSourceProvider({
41
+ videoRef: args.videoRef,
42
+ srcType: args.srcType,
43
+ src: args.src
44
+ });
45
+ }
46
+ if ("barRef" in args && "trackRef" in args) {
47
+ instance2.controlsApi = useControlsApi({
48
+ id,
49
+ barRef: args.barRef,
50
+ trackRef: args.trackRef,
51
+ popoverRef: args.popoverRef
52
+ });
53
+ }
54
+ }
55
+ return instance2;
28
56
  }
29
- function unmute() {
30
- muted.value = false;
57
+ function destroy(id) {
58
+ if (!id)
59
+ return;
60
+ removeInstance(toValue(id));
31
61
  }
32
- watch(playing, () => {
33
- if (!touched.value) {
34
- touched.value = true;
35
- }
62
+ onUnmounted(() => {
63
+ destroy(toValue(mappedId));
36
64
  });
65
+ initialize();
37
66
  return {
38
- isFullscreen,
39
- touched,
40
- play,
41
- pause,
42
- togglePlay,
43
- seek,
44
- mute,
45
- unmute,
46
- enterFullscreen,
47
- exitFullscreen,
48
- toggleFullscreen
67
+ instance
49
68
  };
50
69
  }
@@ -1,14 +1,25 @@
1
1
  import { type MaybeRef } from 'vue';
2
2
  type SourceType = 'native' | 'hls';
3
- type UseControlsArgs = {
3
+ type UseMediaApiArgs = {
4
+ mediaRef: MaybeRef<HTMLMediaElement | undefined>;
5
+ };
6
+ type UseControlsApiArgs = {
7
+ id: MaybeRef<string>;
4
8
  barRef?: MaybeRef<HTMLDivElement | undefined>;
5
9
  trackRef: MaybeRef<HTMLDivElement | undefined>;
6
10
  popoverRef?: MaybeRef<HTMLDivElement | undefined>;
7
11
  };
8
- type UsePlayerArgs = {
12
+ type UsePlayerInternalApiArgs = {
13
+ id: MaybeRef<string>;
9
14
  playerRef: MaybeRef<HTMLElement | undefined>;
10
15
  videoRef: MaybeRef<HTMLVideoElement | undefined>;
16
+ };
17
+ type UseRuntimeSourceProviderArgs = {
18
+ videoRef: MaybeRef<HTMLVideoElement | undefined>;
11
19
  srcType: SourceType;
12
20
  src: string;
13
21
  };
14
- export type { SourceType, UseControlsArgs, UsePlayerArgs };
22
+ type UsePlayerApiArgs = MaybeRef<string> | (Partial<UseMediaApiArgs & UseControlsApiArgs & UsePlayerInternalApiArgs & UseRuntimeSourceProviderArgs> & {
23
+ id: MaybeRef<string>;
24
+ });
25
+ export type { SourceType, UseMediaApiArgs, UsePlayerApiArgs, UseControlsApiArgs, UsePlayerInternalApiArgs, UseRuntimeSourceProviderArgs, };
@@ -130,7 +130,8 @@ watch(
130
130
  --magic-toast-padding-x: 1rem;
131
131
  --magic-toast-padding-y: 1rem;
132
132
 
133
- --mt-multiplier: 1;
133
+ --mt-multiplier-x: 1;
134
+ --mt-multiplier-y: 1;
134
135
  --mt-align-items: flex-start;
135
136
  --mt-justify-content: center;
136
137
  }
@@ -170,10 +171,10 @@ watch(
170
171
  .magic-toast.-top-right {
171
172
  --magic-toast-transform-y: 10;
172
173
  --magic-toast-enter-animation: slide-ttb-in 300ms ease;
173
- --mt-multiplier: 1;
174
- & .magic-toast__inner {
174
+ --mt-multiplier-y: 1;
175
+ --mt-align-items: flex-start;
176
+ & .magic-toast-component {
175
177
  padding-top: var(--magic-toast-padding-y, 1rem);
176
- --mt-align-items: flex-start;
177
178
  }
178
179
  }
179
180
 
@@ -182,26 +183,26 @@ watch(
182
183
  .magic-toast.-bottom-right {
183
184
  --magic-toast-transform-y: 10;
184
185
  --magic-toast-enter-animation: slide-btt-in 300ms ease;
185
- --mt-multiplier: -1;
186
- & .magic-toast__inner {
186
+ --mt-multiplier-y: -1;
187
+ --mt-align-items: flex-end;
188
+ & .magic-toast-component {
187
189
  padding-bottom: var(--magic-toast-padding-y, 1rem);
188
- --mt-align-items: flex-end;
189
190
  }
190
191
  }
191
192
 
192
193
  .magic-toast.-top-left,
193
194
  .magic-toast.-bottom-left {
194
- & .magic-toast__inner {
195
+ --mt-justify-content: flex-start;
196
+ & .magic-toast-component {
195
197
  padding-left: var(--magic-toast-padding-x, 1rem);
196
- --mt-justify-content: flex-start;
197
198
  }
198
199
  }
199
200
 
200
201
  .magic-toast.-top-right,
201
202
  .magic-toast.-bottom-right {
202
- & .magic-toast__inner {
203
+ --mt-justify-content: flex-end;
204
+ & .magic-toast-component {
203
205
  padding-right: var(--magic-toast-padding-x, 1rem);
204
- --mt-justify-content: flex-end;
205
206
  }
206
207
  }
207
208
 
@@ -209,14 +210,14 @@ watch(
209
210
  --magic-toast-enter-animation: slide-ltr-in 300ms ease;
210
211
  --magic-toast-transform-y: 0;
211
212
  --magic-toast-transform-x: 30;
212
- --mt-multiplier: 1;
213
+ --mt-multiplier-x: 1;
213
214
  }
214
215
 
215
216
  .magic-toast.-from-right {
216
217
  --magic-toast-enter-animation: slide-rtl-in 300ms ease;
217
218
  --magic-toast-transform-y: 0;
218
219
  --magic-toast-transform-x: 30;
219
- --mt-multiplier: -1;
220
+ --mt-multiplier-x: -1;
220
221
  }
221
222
 
222
223
  .magic-toast--list-enter-active {
@@ -39,7 +39,7 @@ function setIndex() {
39
39
 
40
40
  function setOffset() {
41
41
  const offset = newerSiblings.value.reduce((acc, curr) => {
42
- return acc + curr.height
42
+ return acc + curr.height - curr.padding.top - curr.padding.bottom
43
43
  }, 0)
44
44
  elRef.value?.style.setProperty('--mt-offset', `${offset}`)
45
45
  }
@@ -65,10 +65,10 @@ watchEffect(() => {
65
65
  --mt-offset: 0;
66
66
  --mt-matrix-scale: calc(1 - (var(--magic-toast-scale) * var(--mt-index, 0)));
67
67
  --mt-matrix-transform-x: calc(
68
- var(--magic-toast-transform-x) * var(--mt-index, 0) * var(--mt-multiplier)
68
+ var(--magic-toast-transform-x) * var(--mt-index, 0) * var(--mt-multiplier-x)
69
69
  );
70
70
  --mt-matrix-transform-y: calc(
71
- var(--magic-toast-transform-y) * var(--mt-index, 0) * var(--mt-multiplier)
71
+ var(--magic-toast-transform-y) * var(--mt-index, 0) * var(--mt-multiplier-y)
72
72
  );
73
73
  position: absolute;
74
74
  list-style: none;
@@ -91,7 +91,7 @@ watchEffect(() => {
91
91
 
92
92
  .magic-toast-component.expanded {
93
93
  --mt-matrix-scale: 1;
94
- --mt-matrix-transform-y: calc(var(--mt-offset) * var(--mt-multiplier));
94
+ --mt-matrix-transform-y: calc(var(--mt-offset) * var(--mt-multiplier-y));
95
95
  --mt-matrix-transform-x: 0;
96
96
  &:not(:last-child) {
97
97
  & .magic-toast-component__inner {
@@ -1,8 +1,8 @@
1
1
  import { type Ref, type MaybeRef } from 'vue';
2
- import type { Options, Toast } from './../../types.js';
2
+ import type { ToastOptions, Toast } from './../../types.js';
3
3
  type Args = {
4
4
  id: MaybeRef<string>;
5
- mappedOptions: Options;
5
+ mappedOptions: ToastOptions;
6
6
  count: Ref<number | undefined>;
7
7
  oldest: Ref<Toast | undefined>;
8
8
  };
@@ -16,6 +16,10 @@ export declare function useToastCallback({ id, mappedOptions, count, oldest }: A
16
16
  activeElements: Ref<{
17
17
  id: string;
18
18
  height: number;
19
+ padding: {
20
+ top: number;
21
+ bottom: number;
22
+ };
19
23
  }[]>;
20
24
  };
21
25
  export {};
@@ -14,9 +14,17 @@ export function useToastCallback({ id, mappedOptions, count, oldest }) {
14
14
  function onAfterEnter(el) {
15
15
  useToastEmitter().emit("afterEnter", toValue(id));
16
16
  const mappedEl = el;
17
+ const style = window.getComputedStyle(mappedEl);
17
18
  activeElements.value = [
18
19
  ...activeElements.value,
19
- { id: el.id, height: mappedEl.offsetHeight }
20
+ {
21
+ id: el.id,
22
+ height: mappedEl.offsetHeight,
23
+ padding: {
24
+ top: parseInt(style.paddingTop),
25
+ bottom: parseInt(style.paddingBottom)
26
+ }
27
+ }
20
28
  ];
21
29
  }
22
30
  function onBeforeLeave(_el) {
@@ -28,6 +28,10 @@ type ToastOptions = {
28
28
  type ActiveElement = {
29
29
  id: string;
30
30
  height: number;
31
+ padding: {
32
+ top: number;
33
+ bottom: number;
34
+ };
31
35
  };
32
36
  type ToastEvents = {
33
37
  beforeEnter: string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@maas/vue-equipment",
3
3
  "description": "A magic collection of Vue composables, plugins, components and directives",
4
- "version": "0.11.5",
4
+ "version": "0.12.0",
5
5
  "author": "Robin Scholz <https://github.com/robinscholz>, Christoph Jeworutzki <https://github.com/ChristophJeworutzki>",
6
6
  "devDependencies": {
7
7
  "@antfu/ni": "^0.21.5",
@@ -1,8 +0,0 @@
1
- import { type UseControlsApiReturn } from './useControlsApi.js';
2
- import type { UseControlsArgs } from '../types.js';
3
- type UseControlsReturn = {
4
- controlsApi: UseControlsApiReturn;
5
- };
6
- export declare function useProvideControls(args: UseControlsArgs): UseControlsReturn;
7
- export declare function useInjectControls(): UseControlsReturn;
8
- export {};
@@ -1,15 +0,0 @@
1
- import { provide, inject } from "vue";
2
- import { useControlsApi } from "./useControlsApi.mjs";
3
- import { ControlsApiInjectionKey } from "./../symbols/index.mjs";
4
- export function useProvideControls(args) {
5
- const controlsApi = useControlsApi(args);
6
- provide(ControlsApiInjectionKey, controlsApi);
7
- return {
8
- controlsApi
9
- };
10
- }
11
- export function useInjectControls() {
12
- return {
13
- controlsApi: inject(ControlsApiInjectionKey)
14
- };
15
- }
@@ -1,12 +0,0 @@
1
- import { type UseMediaApiReturn } from './useMediaApi.js';
2
- import { type UsePlayerApiReturn } from './usePlayerApi.js';
3
- import { type UseRuntimeSourceProviderReturn } from './useRuntimeSourceProvider.js';
4
- import type { UsePlayerArgs } from './../types.js';
5
- type UsePlayerReturn = {
6
- playerApi: UsePlayerApiReturn;
7
- mediaApi: UseMediaApiReturn;
8
- runtimeProvider: UseRuntimeSourceProviderReturn;
9
- };
10
- export declare function useProvidePlayer(args: UsePlayerArgs): UsePlayerReturn;
11
- export declare function useInjectPlayer(): UsePlayerReturn;
12
- export {};
@@ -1,33 +0,0 @@
1
- import { provide, inject } from "vue";
2
- import { useMediaApi } from "./useMediaApi.mjs";
3
- import { usePlayerApi } from "./usePlayerApi.mjs";
4
- import {
5
- useRuntimeSourceProvider
6
- } from "./useRuntimeSourceProvider.mjs";
7
- import {
8
- MediaApiInjectionKey,
9
- PlayerApiInjectionKey,
10
- RuntimeSourceProviderInjectionKey
11
- } from "./../symbols/index.mjs";
12
- export function useProvidePlayer(args) {
13
- const mediaApi = useMediaApi(args.videoRef);
14
- provide(MediaApiInjectionKey, mediaApi);
15
- const playerApi = usePlayerApi({ ...args, mediaApi });
16
- provide(PlayerApiInjectionKey, playerApi);
17
- const runtimeProvider = useRuntimeSourceProvider(args);
18
- provide(RuntimeSourceProviderInjectionKey, runtimeProvider);
19
- return {
20
- playerApi,
21
- mediaApi,
22
- runtimeProvider
23
- };
24
- }
25
- export function useInjectPlayer() {
26
- return {
27
- playerApi: inject(PlayerApiInjectionKey),
28
- mediaApi: inject(MediaApiInjectionKey),
29
- runtimeProvider: inject(
30
- RuntimeSourceProviderInjectionKey
31
- )
32
- };
33
- }
@@ -1,45 +0,0 @@
1
- import type { InjectionKey } from 'vue';
2
- import type { UseRuntimeSourceProviderReturn } from '../composables/useRuntimeSourceProvider.js';
3
- declare const MediaApiInjectionKey: InjectionKey<{
4
- currentTime: import("vue").Ref<number>;
5
- duration: import("vue").Ref<number>;
6
- waiting: import("vue").Ref<boolean>;
7
- seeking: import("vue").Ref<boolean>;
8
- ended: import("vue").Ref<boolean>;
9
- stalled: import("vue").Ref<boolean>;
10
- buffered: import("vue").Ref<[number, number][]>;
11
- playing: import("vue").Ref<boolean>;
12
- rate: import("vue").Ref<number>;
13
- volume: import("vue").Ref<number>;
14
- muted: import("vue").Ref<boolean>;
15
- }>;
16
- declare const PlayerApiInjectionKey: InjectionKey<{
17
- isFullscreen: import("vue").Ref<boolean>;
18
- touched: import("vue").Ref<boolean>;
19
- play: () => void;
20
- pause: () => void;
21
- togglePlay: () => void;
22
- seek: (time: number) => void;
23
- mute: () => void;
24
- unmute: () => void;
25
- enterFullscreen: () => Promise<void>;
26
- exitFullscreen: () => Promise<void>;
27
- toggleFullscreen: () => Promise<void>;
28
- }>;
29
- declare const RuntimeSourceProviderInjectionKey: InjectionKey<UseRuntimeSourceProviderReturn>;
30
- declare const ControlsApiInjectionKey: InjectionKey<{
31
- entered: import("vue").Ref<boolean>;
32
- dragging: import("vue").Ref<boolean>;
33
- seekedTime: import("vue").Ref<number>;
34
- seekedPercentage: import("vue").Ref<number>;
35
- scrubbedPercentage: import("vue").Ref<number>;
36
- bufferedPercentage: import("vue").ComputedRef<any>;
37
- thumbPercentage: import("vue").Ref<number>;
38
- popoverOffsetX: import("vue").Ref<number>;
39
- onMouseEnter: () => void;
40
- onMouseLeave: () => void;
41
- onPointerDown: (e: MouseEvent | TouchEvent) => void;
42
- onPointerUp: () => void;
43
- onPointerMove: (e: MouseEvent | TouchEvent) => void;
44
- }>;
45
- export { MediaApiInjectionKey, PlayerApiInjectionKey, RuntimeSourceProviderInjectionKey, ControlsApiInjectionKey, };
@@ -1,10 +0,0 @@
1
- const MediaApiInjectionKey = Symbol();
2
- const PlayerApiInjectionKey = Symbol();
3
- const RuntimeSourceProviderInjectionKey = Symbol();
4
- const ControlsApiInjectionKey = Symbol();
5
- export {
6
- MediaApiInjectionKey,
7
- PlayerApiInjectionKey,
8
- RuntimeSourceProviderInjectionKey,
9
- ControlsApiInjectionKey
10
- };