@maas/vue-equipment 1.0.0-beta.42 → 1.0.0-beta.44
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/dist/composables/useScrollLockPadding/index.d.ts +9 -0
- package/dist/composables/useScrollLockPadding/index.js +57 -0
- package/dist/composables/useScrollLockPadding/index.js.map +1 -0
- package/dist/nuxt/module.json +1 -1
- package/dist/nuxt/module.mjs +7 -0
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionProvider.vue +2 -5
- package/dist/plugins/MagicAccordion/src/composables/private/useAccordionState.d.ts +2 -3
- package/dist/plugins/MagicAccordion/src/composables/private/useAccordionState.mjs +38 -11
- package/dist/plugins/MagicAccordion/src/types/index.d.ts +1 -0
- package/dist/plugins/MagicCommand/src/components/MagicCommandProvider.vue +2 -5
- package/dist/plugins/MagicCommand/src/components/MagicCommandRenderer.vue +1 -0
- package/dist/plugins/MagicCommand/src/components/MagicCommandView.vue +1 -1
- package/dist/plugins/MagicCommand/src/composables/private/useCommandState.d.ts +2 -3
- package/dist/plugins/MagicCommand/src/composables/private/useCommandState.mjs +36 -11
- package/dist/plugins/MagicCommand/src/types/index.d.ts +1 -0
- package/dist/plugins/MagicCookie/src/composables/private/useCookieState.d.ts +2 -3
- package/dist/plugins/MagicCookie/src/composables/private/useCookieState.mjs +35 -12
- package/dist/plugins/MagicCookie/src/composables/useMagicCookie.mjs +6 -1
- package/dist/plugins/MagicCookie/src/types/index.d.ts +1 -0
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableDrag.mjs +33 -25
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableScrollLock.d.ts +2 -4
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableScrollLock.mjs +11 -51
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableSnap.mjs +11 -1
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableState.d.ts +1 -1
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableState.mjs +41 -11
- package/dist/plugins/MagicDraggable/src/composables/useMagicDraggable.mjs +2 -1
- package/dist/plugins/MagicDraggable/src/types/index.d.ts +1 -0
- package/dist/plugins/MagicDrawer/src/components/MagicDrawer.d.vue.ts +2 -2
- package/dist/plugins/MagicDrawer/src/components/MagicDrawer.vue +15 -19
- package/dist/plugins/MagicDrawer/src/components/MagicDrawer.vue.d.ts +2 -2
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerCallback.d.ts +0 -4
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerCallback.mjs +8 -12
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerDOM.d.ts +2 -4
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerDOM.mjs +15 -58
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerDrag.d.ts +2 -0
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerDrag.mjs +184 -29
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerState.d.ts +2 -3
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerState.mjs +35 -10
- package/dist/plugins/MagicDrawer/src/composables/useMagicDrawer.mjs +2 -1
- package/dist/plugins/MagicDrawer/src/types/index.d.ts +1 -0
- package/dist/plugins/MagicEmitter/src/composables/useMagicEmitter.mjs +10 -5
- package/dist/plugins/MagicMarquee/src/components/MagicMarquee.vue +2 -5
- package/dist/plugins/MagicMarquee/src/composables/private/useMarqueeState.d.ts +2 -3
- package/dist/plugins/MagicMarquee/src/composables/private/useMarqueeState.mjs +36 -11
- package/dist/plugins/MagicMarquee/src/types/index.d.ts +1 -0
- package/dist/plugins/MagicMenu/src/components/MagicMenuContent.vue +4 -12
- package/dist/plugins/MagicMenu/src/components/MagicMenuProvider.vue +2 -6
- package/dist/plugins/MagicMenu/src/composables/private/useMenuCallback.d.ts +1 -4
- package/dist/plugins/MagicMenu/src/composables/private/useMenuCallback.mjs +7 -21
- package/dist/plugins/MagicMenu/src/composables/private/useMenuCursor.mjs +13 -1
- package/dist/plugins/MagicMenu/src/composables/private/useMenuDOM.d.ts +2 -4
- package/dist/plugins/MagicMenu/src/composables/private/useMenuDOM.mjs +13 -51
- package/dist/plugins/MagicMenu/src/composables/private/useMenuState.d.ts +2 -3
- package/dist/plugins/MagicMenu/src/composables/private/useMenuState.mjs +32 -12
- package/dist/plugins/MagicMenu/src/composables/private/useMenuTrigger.mjs +1 -1
- package/dist/plugins/MagicMenu/src/types/index.d.ts +1 -0
- package/dist/plugins/MagicModal/src/components/MagicModal.vue +4 -16
- package/dist/plugins/MagicModal/src/composables/private/useModalCallback.d.ts +0 -4
- package/dist/plugins/MagicModal/src/composables/private/useModalCallback.mjs +9 -19
- package/dist/plugins/MagicModal/src/composables/private/useModalDOM.d.ts +2 -4
- package/dist/plugins/MagicModal/src/composables/private/useModalDOM.mjs +15 -58
- package/dist/plugins/MagicModal/src/composables/private/useModalState.d.ts +6 -0
- package/dist/plugins/MagicModal/src/composables/private/useModalState.mjs +58 -0
- package/dist/plugins/MagicModal/src/composables/private/useModalStore.d.ts +1 -5
- package/dist/plugins/MagicModal/src/composables/private/useModalStore.mjs +1 -15
- package/dist/plugins/MagicModal/src/composables/useMagicModal.mjs +7 -6
- package/dist/plugins/MagicModal/src/types/index.d.ts +5 -0
- package/dist/plugins/MagicNoise/src/components/MagicNoise.vue +14 -2
- package/dist/plugins/MagicPie/src/components/MagicPie.vue +12 -6
- package/dist/plugins/MagicPie/src/composables/private/usePieState.d.ts +1 -1
- package/dist/plugins/MagicPie/src/composables/private/usePieState.mjs +33 -12
- package/dist/plugins/MagicPie/src/types/index.d.ts +1 -0
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerAudio.vue +9 -6
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerAudioControls.vue +4 -8
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerMuxPopover.vue +8 -1
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerProvider.vue +2 -11
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerVideo.vue +10 -6
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerVideoControls.vue +4 -8
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerControlsApi.d.ts +0 -1
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerControlsApi.mjs +20 -9
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerEmitter.mjs +124 -75
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerMediaApi.mjs +100 -32
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerRuntime.d.ts +0 -1
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerRuntime.mjs +33 -13
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerState.d.ts +2 -3
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerState.mjs +35 -10
- package/dist/plugins/MagicPlayer/src/composables/useMagicPlayer.d.ts +0 -2
- package/dist/plugins/MagicPlayer/src/types/index.d.ts +1 -0
- package/dist/plugins/MagicScroll/src/components/MagicScrollCollision.vue +2 -2
- package/dist/plugins/MagicScroll/src/components/MagicScrollMotion.vue +13 -1
- package/dist/plugins/MagicScroll/src/components/MagicScrollScene.vue +9 -5
- package/dist/plugins/MagicScroll/src/composables/private/useCollisionDetection.mjs +2 -1
- package/dist/plugins/MagicToast/src/components/MagicToastProvider.vue +2 -11
- package/dist/plugins/MagicToast/src/components/MagicToastView.vue +1 -0
- package/dist/plugins/MagicToast/src/composables/private/useToastDrag.mjs +18 -15
- package/dist/plugins/MagicToast/src/composables/private/useToastScrollLock.d.ts +2 -4
- package/dist/plugins/MagicToast/src/composables/private/useToastScrollLock.mjs +11 -49
- package/dist/plugins/MagicToast/src/composables/private/useToastState.d.ts +2 -3
- package/dist/plugins/MagicToast/src/composables/private/useToastState.mjs +35 -12
- package/dist/plugins/MagicToast/src/types/index.d.ts +1 -0
- package/dist/utils/index.d.ts +8 -1
- package/dist/utils/index.js +56497 -0
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/plugins/MagicError/src/MagicError.d.ts +0 -0
- package/dist/plugins/MagicError/src/MagicError.mjs +0 -0
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
</template>
|
|
18
18
|
|
|
19
19
|
<script setup>
|
|
20
|
-
import { computed, toRefs
|
|
20
|
+
import { computed, toRefs } from "vue";
|
|
21
21
|
import {
|
|
22
22
|
useMagicError
|
|
23
23
|
} from "@maas/vue-equipment/plugins/MagicError";
|
|
@@ -30,7 +30,7 @@ const magicError = useMagicError({
|
|
|
30
30
|
prefix: "MagicPie",
|
|
31
31
|
source: "MagicPie"
|
|
32
32
|
});
|
|
33
|
-
const { initializeState
|
|
33
|
+
const { initializeState } = usePieState(id);
|
|
34
34
|
const state = initializeState();
|
|
35
35
|
const { percentage } = toRefs(state);
|
|
36
36
|
function generatePath(points) {
|
|
@@ -40,9 +40,18 @@ function generatePath(points) {
|
|
|
40
40
|
errorCode: "missing_points"
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
|
+
if (!points[0]) {
|
|
44
|
+
magicError.throwError({
|
|
45
|
+
message: "Points contain invalid coordinates",
|
|
46
|
+
errorCode: "invalid_points"
|
|
47
|
+
});
|
|
48
|
+
}
|
|
43
49
|
let path2 = `M ${points[0][0]} ${points[0][1]}`;
|
|
44
50
|
for (let i = 1; i < points.length; i++) {
|
|
45
|
-
|
|
51
|
+
if (!points[i]) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
path2 += ` L ${points[i]?.[0]} ${points[i]?.[1]}`;
|
|
46
55
|
}
|
|
47
56
|
return path2;
|
|
48
57
|
}
|
|
@@ -154,9 +163,6 @@ function generatePie(percentage2, flip) {
|
|
|
154
163
|
const path = computed(() => {
|
|
155
164
|
return generatePie(percentage.value, options?.flip);
|
|
156
165
|
});
|
|
157
|
-
onBeforeUnmount(() => {
|
|
158
|
-
deleteState();
|
|
159
|
-
});
|
|
160
166
|
</script>
|
|
161
167
|
|
|
162
168
|
<style>
|
|
@@ -2,5 +2,5 @@ import { type MaybeRef } from 'vue';
|
|
|
2
2
|
import type { PieState } from '../../types/index.js';
|
|
3
3
|
export declare function usePieState(id: MaybeRef<string>): {
|
|
4
4
|
initializeState: () => PieState;
|
|
5
|
-
|
|
5
|
+
pieStateStore: import("vue").Ref<PieState[], PieState[]>;
|
|
6
6
|
};
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { reactive, toValue, onScopeDispose } from "vue";
|
|
2
|
+
import { createStateStore } from "@maas/vue-equipment/utils";
|
|
3
|
+
const getPieStateStore = createStateStore("MagicPie", () => []);
|
|
3
4
|
export function usePieState(id) {
|
|
5
|
+
const pieStateStore = getPieStateStore();
|
|
6
|
+
let scopeCounted = false;
|
|
4
7
|
function createState(id2) {
|
|
5
8
|
const state = {
|
|
6
9
|
id: id2,
|
|
10
|
+
refCount: 0,
|
|
7
11
|
percentage: 0,
|
|
8
12
|
interpolationId: void 0
|
|
9
13
|
};
|
|
@@ -14,22 +18,39 @@ export function usePieState(id) {
|
|
|
14
18
|
pieStateStore.value = [...pieStateStore.value, state];
|
|
15
19
|
return state;
|
|
16
20
|
}
|
|
21
|
+
function deleteState() {
|
|
22
|
+
const currentId = toValue(id);
|
|
23
|
+
pieStateStore.value = pieStateStore.value.filter(
|
|
24
|
+
(x) => x.id !== currentId
|
|
25
|
+
);
|
|
26
|
+
}
|
|
17
27
|
function initializeState() {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
});
|
|
28
|
+
const currentId = toValue(id);
|
|
29
|
+
let state = pieStateStore.value.find((entry) => entry.id === currentId);
|
|
21
30
|
if (!state) {
|
|
22
|
-
state = addState(
|
|
31
|
+
state = addState(currentId);
|
|
32
|
+
}
|
|
33
|
+
if (!scopeCounted) {
|
|
34
|
+
state.refCount++;
|
|
35
|
+
scopeCounted = true;
|
|
23
36
|
}
|
|
24
37
|
return state;
|
|
25
38
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
39
|
+
onScopeDispose(() => {
|
|
40
|
+
if (!scopeCounted) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const currentId = toValue(id);
|
|
44
|
+
const state = pieStateStore.value.find((entry) => entry.id === currentId);
|
|
45
|
+
if (state) {
|
|
46
|
+
state.refCount--;
|
|
47
|
+
if (state.refCount <= 0) {
|
|
48
|
+
deleteState();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
});
|
|
31
52
|
return {
|
|
32
53
|
initializeState,
|
|
33
|
-
|
|
54
|
+
pieStateStore
|
|
34
55
|
};
|
|
35
56
|
}
|
|
@@ -9,9 +9,9 @@ import {
|
|
|
9
9
|
inject,
|
|
10
10
|
watch,
|
|
11
11
|
onMounted,
|
|
12
|
-
onBeforeUnmount,
|
|
13
12
|
shallowRef,
|
|
14
|
-
computed
|
|
13
|
+
computed,
|
|
14
|
+
onBeforeUnmount
|
|
15
15
|
} from "vue";
|
|
16
16
|
import {
|
|
17
17
|
useElementVisibility,
|
|
@@ -38,6 +38,8 @@ const magicError = useMagicError({
|
|
|
38
38
|
const injectedInstanceId = inject(MagicPlayerInstanceId, void 0);
|
|
39
39
|
const injectedOptions = inject(MagicPlayerOptionsKey, void 0);
|
|
40
40
|
const injectedPlayerRef = inject(MagicPlayerRef, void 0);
|
|
41
|
+
let cancelFocus = void 0;
|
|
42
|
+
let cancelBlur = void 0;
|
|
41
43
|
magicError.assert(injectedInstanceId, {
|
|
42
44
|
message: "MagicPlayerAudio must be used within a MagicPlayerProvider",
|
|
43
45
|
errorCode: "missing_instance_id"
|
|
@@ -47,7 +49,7 @@ magicError.assert(injectedOptions, {
|
|
|
47
49
|
errorCode: "missing_options"
|
|
48
50
|
});
|
|
49
51
|
const elRef = useTemplateRef("el");
|
|
50
|
-
const { initialize
|
|
52
|
+
const { initialize } = usePlayerRuntime({
|
|
51
53
|
id: injectedInstanceId,
|
|
52
54
|
mediaRef: elRef,
|
|
53
55
|
src: injectedOptions.src,
|
|
@@ -84,8 +86,8 @@ function onWindowBlur() {
|
|
|
84
86
|
pause();
|
|
85
87
|
}
|
|
86
88
|
if (manageWindow.value) {
|
|
87
|
-
useEventListener(defaultWindow, "focus", onWindowFocus);
|
|
88
|
-
useEventListener(defaultWindow, "blur", onWindowBlur);
|
|
89
|
+
cancelFocus = useEventListener(defaultWindow, "focus", onWindowFocus);
|
|
90
|
+
cancelBlur = useEventListener(defaultWindow, "blur", onWindowBlur);
|
|
89
91
|
}
|
|
90
92
|
if (manageViewport.value) {
|
|
91
93
|
watch(isVisible, (value) => {
|
|
@@ -105,7 +107,8 @@ onMounted(() => {
|
|
|
105
107
|
initialize();
|
|
106
108
|
});
|
|
107
109
|
onBeforeUnmount(() => {
|
|
108
|
-
|
|
110
|
+
cancelFocus?.();
|
|
111
|
+
cancelBlur?.();
|
|
109
112
|
});
|
|
110
113
|
</script>
|
|
111
114
|
|
|
@@ -102,13 +102,7 @@ const trackRef = useTemplateRef("track");
|
|
|
102
102
|
const { play, pause } = usePlayerAudioApi({
|
|
103
103
|
id: mappedInstanceId.value
|
|
104
104
|
});
|
|
105
|
-
const {
|
|
106
|
-
initialize,
|
|
107
|
-
destroy,
|
|
108
|
-
onMouseenter,
|
|
109
|
-
onMouseleave,
|
|
110
|
-
onMouseleaveTimeline
|
|
111
|
-
} = usePlayerControlsApi({
|
|
105
|
+
const { initialize, onMouseenter, onMouseleave, onMouseleaveTimeline } = usePlayerControlsApi({
|
|
112
106
|
id: mappedInstanceId.value,
|
|
113
107
|
barRef,
|
|
114
108
|
trackRef
|
|
@@ -128,7 +122,9 @@ const {
|
|
|
128
122
|
const { idle } = useIdle(injectedOptions?.threshold?.idle);
|
|
129
123
|
initialize();
|
|
130
124
|
onBeforeUnmount(() => {
|
|
131
|
-
|
|
125
|
+
state.controlsBarRect = void 0;
|
|
126
|
+
state.controlsTrackRect = void 0;
|
|
127
|
+
state.controlsPopoverRect = void 0;
|
|
132
128
|
});
|
|
133
129
|
provide(MagicPlayerInstanceId, mappedInstanceId.value);
|
|
134
130
|
provide(MagicPlayerTrackRef, trackRef);
|
|
@@ -79,7 +79,11 @@ function drawFrame(time) {
|
|
|
79
79
|
let closestIndex = -1;
|
|
80
80
|
let minDifference = Infinity;
|
|
81
81
|
for (let i = 0; i < tiles.length; i++) {
|
|
82
|
-
const
|
|
82
|
+
const tile2 = tiles[i];
|
|
83
|
+
if (!tile2) {
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
const { start } = tile2;
|
|
83
87
|
const difference = Math.abs(start - time);
|
|
84
88
|
if (difference < minDifference) {
|
|
85
89
|
minDifference = difference;
|
|
@@ -87,6 +91,9 @@ function drawFrame(time) {
|
|
|
87
91
|
}
|
|
88
92
|
}
|
|
89
93
|
const tile = tiles[closestIndex];
|
|
94
|
+
if (!tile) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
90
97
|
context.drawImage(
|
|
91
98
|
image,
|
|
92
99
|
tile.x,
|
|
@@ -21,13 +21,7 @@
|
|
|
21
21
|
</template>
|
|
22
22
|
|
|
23
23
|
<script setup>
|
|
24
|
-
import {
|
|
25
|
-
toRefs,
|
|
26
|
-
provide,
|
|
27
|
-
onMounted,
|
|
28
|
-
onUnmounted,
|
|
29
|
-
useTemplateRef
|
|
30
|
-
} from "vue";
|
|
24
|
+
import { toRefs, provide, onMounted, useTemplateRef } from "vue";
|
|
31
25
|
import defu from "defu";
|
|
32
26
|
import { usePlayerState } from "../composables/private/usePlayerState";
|
|
33
27
|
import {
|
|
@@ -43,7 +37,7 @@ const { id, options } = defineProps({
|
|
|
43
37
|
options: { type: Object, required: false }
|
|
44
38
|
});
|
|
45
39
|
const mappedOptions = defu(options, defaultOptions);
|
|
46
|
-
const { initializeState
|
|
40
|
+
const { initializeState } = usePlayerState(id);
|
|
47
41
|
const state = initializeState();
|
|
48
42
|
const {
|
|
49
43
|
playing,
|
|
@@ -61,9 +55,6 @@ const { initializeEmitter } = usePlayerEmitter({ id });
|
|
|
61
55
|
onMounted(() => {
|
|
62
56
|
initializeEmitter();
|
|
63
57
|
});
|
|
64
|
-
onUnmounted(() => {
|
|
65
|
-
deleteState();
|
|
66
|
-
});
|
|
67
58
|
provide(MagicPlayerInstanceId, id);
|
|
68
59
|
provide(MagicPlayerOptionsKey, mappedOptions);
|
|
69
60
|
provide(MagicPlayerRef, playerRef);
|
|
@@ -17,9 +17,9 @@ import {
|
|
|
17
17
|
watch,
|
|
18
18
|
onMounted,
|
|
19
19
|
inject,
|
|
20
|
-
onBeforeUnmount,
|
|
21
20
|
shallowRef,
|
|
22
|
-
computed
|
|
21
|
+
computed,
|
|
22
|
+
onBeforeUnmount
|
|
23
23
|
} from "vue";
|
|
24
24
|
import {
|
|
25
25
|
useElementVisibility,
|
|
@@ -46,6 +46,8 @@ const magicError = useMagicError({
|
|
|
46
46
|
const injectedInstanceId = inject(MagicPlayerInstanceId, void 0);
|
|
47
47
|
const injectedOptions = inject(MagicPlayerOptionsKey, void 0);
|
|
48
48
|
const injectedPlayerRef = inject(MagicPlayerRef, void 0);
|
|
49
|
+
let cancelFocus = void 0;
|
|
50
|
+
let cancelBlur = void 0;
|
|
49
51
|
magicError.assert(injectedInstanceId, {
|
|
50
52
|
message: "MagicPlayerVideo must be used within a MagicPlayerProvider",
|
|
51
53
|
errorCode: "missing_instance_id"
|
|
@@ -55,7 +57,7 @@ magicError.assert(injectedOptions, {
|
|
|
55
57
|
errorCode: "missing_options"
|
|
56
58
|
});
|
|
57
59
|
const elRef = useTemplateRef("el");
|
|
58
|
-
const { initialize
|
|
60
|
+
const { initialize } = usePlayerRuntime({
|
|
59
61
|
id: injectedInstanceId,
|
|
60
62
|
mediaRef: elRef,
|
|
61
63
|
src: injectedOptions.src,
|
|
@@ -94,8 +96,8 @@ function onWindowBlur() {
|
|
|
94
96
|
pause();
|
|
95
97
|
}
|
|
96
98
|
if (manageWindow.value) {
|
|
97
|
-
useEventListener(defaultWindow, "focus", onWindowFocus);
|
|
98
|
-
useEventListener(defaultWindow, "blur", onWindowBlur);
|
|
99
|
+
cancelFocus = useEventListener(defaultWindow, "focus", onWindowFocus);
|
|
100
|
+
cancelBlur = useEventListener(defaultWindow, "blur", onWindowBlur);
|
|
99
101
|
}
|
|
100
102
|
if (manageViewport.value) {
|
|
101
103
|
watch(isVisible, (value) => {
|
|
@@ -139,7 +141,9 @@ onMounted(async () => {
|
|
|
139
141
|
}
|
|
140
142
|
});
|
|
141
143
|
onBeforeUnmount(() => {
|
|
142
|
-
|
|
144
|
+
state.fullscreenTarget = null;
|
|
145
|
+
cancelFocus?.();
|
|
146
|
+
cancelBlur?.();
|
|
143
147
|
});
|
|
144
148
|
</script>
|
|
145
149
|
|
|
@@ -158,13 +158,7 @@ const {
|
|
|
158
158
|
dragging
|
|
159
159
|
} = toRefs(state);
|
|
160
160
|
const { play, pause, mute, unmute, enterFullscreen, exitFullscreen } = usePlayerVideoApi({ id: mappedInstanceId.value });
|
|
161
|
-
const {
|
|
162
|
-
initialize,
|
|
163
|
-
destroy,
|
|
164
|
-
onMouseenter,
|
|
165
|
-
onMouseleave,
|
|
166
|
-
onMouseleaveTimeline
|
|
167
|
-
} = usePlayerControlsApi({
|
|
161
|
+
const { initialize, onMouseenter, onMouseleave, onMouseleaveTimeline } = usePlayerControlsApi({
|
|
168
162
|
id: mappedInstanceId.value,
|
|
169
163
|
barRef,
|
|
170
164
|
trackRef,
|
|
@@ -188,7 +182,9 @@ const visible = computed(() => {
|
|
|
188
182
|
});
|
|
189
183
|
initialize();
|
|
190
184
|
onBeforeUnmount(() => {
|
|
191
|
-
|
|
185
|
+
state.controlsBarRect = void 0;
|
|
186
|
+
state.controlsTrackRect = void 0;
|
|
187
|
+
state.controlsPopoverRect = void 0;
|
|
192
188
|
});
|
|
193
189
|
provide(MagicPlayerInstanceId, mappedInstanceId.value);
|
|
194
190
|
provide(MagicPlayerTrackRef, trackRef);
|
|
@@ -7,7 +7,6 @@ export type UsePlayerControlsApiArgs = {
|
|
|
7
7
|
};
|
|
8
8
|
export declare function usePlayerControlsApi(args: UsePlayerControlsApiArgs): {
|
|
9
9
|
initialize: () => void;
|
|
10
|
-
destroy: () => void;
|
|
11
10
|
bufferedPercentage: import("vue").ComputedRef<number>;
|
|
12
11
|
onMouseenter: () => void;
|
|
13
12
|
onMouseleave: () => void;
|
|
@@ -3,7 +3,9 @@ import {
|
|
|
3
3
|
shallowRef,
|
|
4
4
|
computed,
|
|
5
5
|
watch,
|
|
6
|
-
toValue
|
|
6
|
+
toValue,
|
|
7
|
+
onScopeDispose,
|
|
8
|
+
markRaw
|
|
7
9
|
} from "vue";
|
|
8
10
|
import {
|
|
9
11
|
useResizeObserver,
|
|
@@ -49,7 +51,7 @@ export function usePlayerControlsApi(args) {
|
|
|
49
51
|
if (!buffered.value) {
|
|
50
52
|
return 0;
|
|
51
53
|
}
|
|
52
|
-
const endBuffer = buffered.value?.length > 0 ? buffered.value[0][1] : 0;
|
|
54
|
+
const endBuffer = buffered.value?.length > 0 && buffered.value[0] ? buffered.value[0][1] : 0;
|
|
53
55
|
const percentage = endBuffer / duration.value * 100;
|
|
54
56
|
return clampValue(percentage, 0, thumbPercentage.value);
|
|
55
57
|
});
|
|
@@ -69,15 +71,19 @@ export function usePlayerControlsApi(args) {
|
|
|
69
71
|
if (!toValue(trackRef)) {
|
|
70
72
|
return;
|
|
71
73
|
}
|
|
72
|
-
controlsTrackRect.value =
|
|
74
|
+
controlsTrackRect.value = markRaw(
|
|
75
|
+
toValue(trackRef).getBoundingClientRect()
|
|
76
|
+
);
|
|
73
77
|
thumbPercentage.value = 100 - controlsTrackRect.value.height / controlsTrackRect.value.width * 100;
|
|
74
78
|
}
|
|
75
79
|
function getPopoverSizes() {
|
|
76
80
|
if (!toValue(barRef) || !toValue(popoverRef)) {
|
|
77
81
|
return;
|
|
78
82
|
}
|
|
79
|
-
controlsBarRect.value = toValue(barRef).getBoundingClientRect();
|
|
80
|
-
controlsPopoverRect.value =
|
|
83
|
+
controlsBarRect.value = markRaw(toValue(barRef).getBoundingClientRect());
|
|
84
|
+
controlsPopoverRect.value = markRaw(
|
|
85
|
+
toValue(popoverRef).getBoundingClientRect()
|
|
86
|
+
);
|
|
81
87
|
}
|
|
82
88
|
function getSizes() {
|
|
83
89
|
getTimelineTrackSize();
|
|
@@ -174,9 +180,9 @@ export function usePlayerControlsApi(args) {
|
|
|
174
180
|
let windowResizeCleanup = null;
|
|
175
181
|
function initialize() {
|
|
176
182
|
hasControls.value = true;
|
|
177
|
-
watchTrack = watch(() => trackRef, getTimelineTrackSize);
|
|
178
|
-
watchPopover = watch(() => popoverRef, getPopoverSizes);
|
|
179
|
-
watchBar = watch(() => barRef, getPopoverSizes);
|
|
183
|
+
watchTrack = watch(() => trackRef?.value, getTimelineTrackSize);
|
|
184
|
+
watchPopover = watch(() => popoverRef?.value, getPopoverSizes);
|
|
185
|
+
watchBar = watch(() => barRef?.value, getPopoverSizes);
|
|
180
186
|
watchCurrentTime = watch(currentTime, (value) => {
|
|
181
187
|
const percentage = value / duration?.value * 100;
|
|
182
188
|
scrubbedPercentage.value = mapValue(
|
|
@@ -210,10 +216,15 @@ export function usePlayerControlsApi(args) {
|
|
|
210
216
|
resizeObserverPopover?.stop();
|
|
211
217
|
resizeObserverBar?.stop();
|
|
212
218
|
windowResizeCleanup?.();
|
|
219
|
+
cancelPointermove?.();
|
|
220
|
+
cancelPointerup?.();
|
|
221
|
+
cancelTouchend?.();
|
|
213
222
|
}
|
|
223
|
+
onScopeDispose(() => {
|
|
224
|
+
destroy();
|
|
225
|
+
});
|
|
214
226
|
return {
|
|
215
227
|
initialize,
|
|
216
|
-
destroy,
|
|
217
228
|
bufferedPercentage,
|
|
218
229
|
onMouseenter,
|
|
219
230
|
onMouseleave,
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
toRefs,
|
|
3
|
+
watch,
|
|
4
|
+
toValue,
|
|
5
|
+
onScopeDispose
|
|
6
|
+
} from "vue";
|
|
2
7
|
import { useMagicEmitter } from "@maas/vue-equipment/plugins/MagicEmitter";
|
|
3
8
|
import { usePlayerState } from "./usePlayerState.mjs";
|
|
4
9
|
export function usePlayerEmitter(args) {
|
|
5
10
|
const { id } = args;
|
|
11
|
+
let scopeInitialized = false;
|
|
6
12
|
const { initializeState } = usePlayerState(toValue(id));
|
|
7
13
|
const state = initializeState();
|
|
8
14
|
const {
|
|
@@ -20,83 +26,126 @@ export function usePlayerEmitter(args) {
|
|
|
20
26
|
volume,
|
|
21
27
|
waiting
|
|
22
28
|
} = toRefs(state);
|
|
29
|
+
let stops = [];
|
|
23
30
|
const emitter = useMagicEmitter();
|
|
31
|
+
function destroyEmitter() {
|
|
32
|
+
for (const stop of stops) {
|
|
33
|
+
try {
|
|
34
|
+
stop();
|
|
35
|
+
} catch {
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
stops = [];
|
|
39
|
+
}
|
|
24
40
|
function initializeEmitter() {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
41
|
+
if (scopeInitialized) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
scopeInitialized = true;
|
|
45
|
+
stops.push(
|
|
46
|
+
watch(dragging, (newDragging) => {
|
|
47
|
+
if (newDragging) {
|
|
48
|
+
emitter.emit("onDragStart", toValue(id));
|
|
49
|
+
}
|
|
50
|
+
if (!newDragging) {
|
|
51
|
+
emitter.emit("onDragEnd", toValue(id));
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
);
|
|
55
|
+
stops.push(
|
|
56
|
+
watch(ended, (newEnded) => {
|
|
57
|
+
if (newEnded) {
|
|
58
|
+
emitter.emit("onEnd", toValue(id));
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
);
|
|
62
|
+
stops.push(
|
|
63
|
+
watch(fullscreen, (newFullscreen) => {
|
|
64
|
+
if (newFullscreen) {
|
|
65
|
+
emitter.emit("onFullscreenEnter", toValue(id));
|
|
66
|
+
}
|
|
67
|
+
if (!newFullscreen) {
|
|
68
|
+
emitter.emit("onFullscreenLeave", toValue(id));
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
);
|
|
72
|
+
stops.push(
|
|
73
|
+
watch(loaded, (newLoaded) => {
|
|
74
|
+
if (newLoaded) {
|
|
75
|
+
emitter.emit("onLoad", toValue(id));
|
|
76
|
+
}
|
|
77
|
+
})
|
|
78
|
+
);
|
|
79
|
+
stops.push(
|
|
80
|
+
watch(muted, (newMuted) => {
|
|
81
|
+
if (newMuted) {
|
|
82
|
+
emitter.emit("onMute", toValue(id));
|
|
83
|
+
}
|
|
84
|
+
if (!newMuted) {
|
|
85
|
+
emitter.emit("onUnmute", toValue(id));
|
|
86
|
+
}
|
|
87
|
+
})
|
|
88
|
+
);
|
|
89
|
+
stops.push(
|
|
90
|
+
watch(paused, (newPaused) => {
|
|
91
|
+
if (newPaused) {
|
|
92
|
+
emitter.emit("onPause", toValue(id));
|
|
93
|
+
}
|
|
94
|
+
})
|
|
95
|
+
);
|
|
96
|
+
stops.push(
|
|
97
|
+
watch(playing, (newPlaying) => {
|
|
98
|
+
if (newPlaying) {
|
|
99
|
+
emitter.emit("onPlay", toValue(id));
|
|
100
|
+
}
|
|
101
|
+
})
|
|
102
|
+
);
|
|
103
|
+
stops.push(
|
|
104
|
+
watch(rate, (newRate) => {
|
|
105
|
+
if (newRate) {
|
|
106
|
+
emitter.emit("onRateChange", toValue(id));
|
|
107
|
+
}
|
|
108
|
+
})
|
|
109
|
+
);
|
|
110
|
+
stops.push(
|
|
111
|
+
watch(started, (newStarted) => {
|
|
112
|
+
if (newStarted) {
|
|
113
|
+
emitter.emit("onStart", toValue(id));
|
|
114
|
+
}
|
|
115
|
+
})
|
|
116
|
+
);
|
|
117
|
+
stops.push(
|
|
118
|
+
watch(stalled, (newStalled) => {
|
|
119
|
+
if (newStalled) {
|
|
120
|
+
emitter.emit("onStall", toValue(id));
|
|
121
|
+
}
|
|
122
|
+
})
|
|
123
|
+
);
|
|
124
|
+
stops.push(
|
|
125
|
+
watch(touched, (newTouched) => {
|
|
126
|
+
if (newTouched) {
|
|
127
|
+
emitter.emit("onTouch", toValue(id));
|
|
128
|
+
}
|
|
129
|
+
})
|
|
130
|
+
);
|
|
131
|
+
stops.push(
|
|
132
|
+
watch(volume, (newVolume) => {
|
|
133
|
+
if (newVolume) {
|
|
134
|
+
emitter.emit("onVolumeChange", toValue(id));
|
|
135
|
+
}
|
|
136
|
+
})
|
|
137
|
+
);
|
|
138
|
+
stops.push(
|
|
139
|
+
watch(waiting, (newWaiting) => {
|
|
140
|
+
if (newWaiting) {
|
|
141
|
+
emitter.emit("onWait", toValue(id));
|
|
142
|
+
}
|
|
143
|
+
})
|
|
144
|
+
);
|
|
99
145
|
}
|
|
146
|
+
onScopeDispose(() => {
|
|
147
|
+
destroyEmitter();
|
|
148
|
+
});
|
|
100
149
|
return {
|
|
101
150
|
initializeEmitter
|
|
102
151
|
};
|