@maas/vue-equipment 1.0.0-beta.43 → 1.0.0-beta.45
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.js +1 -0
- package/dist/composables/useScrollLockPadding/index.js.map +1 -1
- package/dist/nuxt/module.json +1 -1
- package/dist/nuxt/module.mjs +1 -1
- 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/MagicCommandItem.d.vue.ts +2 -2
- package/dist/plugins/MagicCommand/src/components/MagicCommandItem.vue.d.ts +2 -2
- 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/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 +28 -11
- 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 +11 -3
- package/dist/plugins/MagicDrawer/src/components/MagicDrawer.vue.d.ts +2 -2
- 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/MagicMenuItem.d.vue.ts +2 -2
- package/dist/plugins/MagicMenu/src/components/MagicMenuItem.vue.d.ts +2 -2
- package/dist/plugins/MagicMenu/src/components/MagicMenuProvider.vue +2 -6
- package/dist/plugins/MagicMenu/src/composables/private/useMenuCursor.mjs +13 -1
- 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/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 +13 -1
- 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 +31 -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
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { reactive, toValue, onScopeDispose } from "vue";
|
|
2
2
|
import { defu } from "defu";
|
|
3
|
+
import { createStateStore } from "@maas/vue-equipment/utils";
|
|
3
4
|
import { defaultOptions } from "../../utils/defaultOptions.mjs";
|
|
4
|
-
const
|
|
5
|
+
const getMarqueeStateStore = createStateStore(
|
|
6
|
+
"MagicMarquee",
|
|
7
|
+
() => []
|
|
8
|
+
);
|
|
5
9
|
export function useMarqueeState(instanceId) {
|
|
10
|
+
const marqueeStateStore = getMarqueeStateStore();
|
|
11
|
+
let scopeCounted = false;
|
|
6
12
|
function createState(id) {
|
|
7
13
|
const state = {
|
|
8
14
|
id,
|
|
15
|
+
refCount: 0,
|
|
9
16
|
options: { ...defaultOptions },
|
|
10
17
|
playing: true
|
|
11
18
|
};
|
|
@@ -16,12 +23,21 @@ export function useMarqueeState(instanceId) {
|
|
|
16
23
|
marqueeStateStore.value = [...marqueeStateStore.value, state];
|
|
17
24
|
return state;
|
|
18
25
|
}
|
|
26
|
+
function deleteState() {
|
|
27
|
+
const currentId = toValue(instanceId);
|
|
28
|
+
marqueeStateStore.value = marqueeStateStore.value.filter(
|
|
29
|
+
(x) => x.id !== currentId
|
|
30
|
+
);
|
|
31
|
+
}
|
|
19
32
|
function initializeState(options) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
});
|
|
33
|
+
const currentId = toValue(instanceId);
|
|
34
|
+
let state = marqueeStateStore.value.find((entry) => entry.id === currentId);
|
|
23
35
|
if (!state) {
|
|
24
|
-
state = addState(
|
|
36
|
+
state = addState(currentId);
|
|
37
|
+
}
|
|
38
|
+
if (!scopeCounted) {
|
|
39
|
+
state.refCount++;
|
|
40
|
+
scopeCounted = true;
|
|
25
41
|
}
|
|
26
42
|
if (options) {
|
|
27
43
|
const mappedOptions = defu(options, defaultOptions);
|
|
@@ -29,14 +45,23 @@ export function useMarqueeState(instanceId) {
|
|
|
29
45
|
}
|
|
30
46
|
return state;
|
|
31
47
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
48
|
+
onScopeDispose(() => {
|
|
49
|
+
if (!scopeCounted) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const currentId = toValue(instanceId);
|
|
53
|
+
const state = marqueeStateStore.value.find(
|
|
54
|
+
(entry) => entry.id === currentId
|
|
35
55
|
);
|
|
36
|
-
|
|
56
|
+
if (state) {
|
|
57
|
+
state.refCount--;
|
|
58
|
+
if (state.refCount <= 0) {
|
|
59
|
+
deleteState();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
});
|
|
37
63
|
return {
|
|
38
64
|
initializeState,
|
|
39
|
-
deleteState,
|
|
40
65
|
marqueeStateStore
|
|
41
66
|
};
|
|
42
67
|
}
|
|
@@ -10,11 +10,11 @@ type __VLS_Slots = {} & {
|
|
|
10
10
|
default?: (props: typeof __VLS_1) => any;
|
|
11
11
|
};
|
|
12
12
|
declare const __VLS_base: import("vue").DefineComponent<MagicMenuItemProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
13
|
-
enter: () => any;
|
|
14
13
|
click: (event: MouseEvent) => any;
|
|
14
|
+
enter: () => any;
|
|
15
15
|
}, string, import("vue").PublicProps, Readonly<MagicMenuItemProps> & Readonly<{
|
|
16
|
-
onEnter?: (() => any) | undefined;
|
|
17
16
|
onClick?: ((event: MouseEvent) => any) | undefined;
|
|
17
|
+
onEnter?: (() => any) | undefined;
|
|
18
18
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
19
19
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
20
20
|
declare const _default: typeof __VLS_export;
|
|
@@ -10,11 +10,11 @@ type __VLS_Slots = {} & {
|
|
|
10
10
|
default?: (props: typeof __VLS_1) => any;
|
|
11
11
|
};
|
|
12
12
|
declare const __VLS_base: import("vue").DefineComponent<MagicMenuItemProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
13
|
-
enter: () => any;
|
|
14
13
|
click: (event: MouseEvent) => any;
|
|
14
|
+
enter: () => any;
|
|
15
15
|
}, string, import("vue").PublicProps, Readonly<MagicMenuItemProps> & Readonly<{
|
|
16
|
-
onEnter?: (() => any) | undefined;
|
|
17
16
|
onClick?: ((event: MouseEvent) => any) | undefined;
|
|
17
|
+
onEnter?: (() => any) | undefined;
|
|
18
18
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
19
19
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
20
20
|
declare const _default: typeof __VLS_export;
|
|
@@ -15,8 +15,7 @@ import {
|
|
|
15
15
|
shallowRef,
|
|
16
16
|
provide,
|
|
17
17
|
watch,
|
|
18
|
-
toValue
|
|
19
|
-
onBeforeUnmount
|
|
18
|
+
toValue
|
|
20
19
|
} from "vue";
|
|
21
20
|
import { onClickOutside, onKeyStroke, usePointer } from "@vueuse/core";
|
|
22
21
|
import { VuePrimitive } from "@maas/vue-primitive";
|
|
@@ -33,7 +32,7 @@ const { id, options } = defineProps({
|
|
|
33
32
|
});
|
|
34
33
|
const elRef = useTemplateRef("el");
|
|
35
34
|
const mappedOptions = defu(options, defaultOptions);
|
|
36
|
-
const { initializeState
|
|
35
|
+
const { initializeState } = useMenuState(id);
|
|
37
36
|
const state = initializeState(mappedOptions);
|
|
38
37
|
const lastX = shallowRef(0);
|
|
39
38
|
const lastY = shallowRef(0);
|
|
@@ -87,9 +86,6 @@ onClickOutside(
|
|
|
87
86
|
]
|
|
88
87
|
}
|
|
89
88
|
);
|
|
90
|
-
onBeforeUnmount(() => {
|
|
91
|
-
deleteState();
|
|
92
|
-
});
|
|
93
89
|
provide(MagicMenuInstanceId, id);
|
|
94
90
|
</script>
|
|
95
91
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ref, shallowRef } from "vue";
|
|
1
|
+
import { onScopeDispose, ref, shallowRef } from "vue";
|
|
2
2
|
import { useEventListener } from "@vueuse/core";
|
|
3
3
|
export function useMenuCursor(view, debug = false) {
|
|
4
4
|
let cancelListener = new AbortController();
|
|
@@ -116,6 +116,9 @@ export function useMenuCursor(view, debug = false) {
|
|
|
116
116
|
break;
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
|
+
if (!sidePoints[0] || !sidePoints[1]) {
|
|
120
|
+
return [];
|
|
121
|
+
}
|
|
119
122
|
const [a, b, c] = extendTriangle(
|
|
120
123
|
[centerPoint, sidePoints[0], sidePoints[1]],
|
|
121
124
|
16
|
|
@@ -124,6 +127,9 @@ export function useMenuCursor(view, debug = false) {
|
|
|
124
127
|
}
|
|
125
128
|
function triangleOverlap(cursor, fromBounding, toBounding) {
|
|
126
129
|
const [a, b, c] = getTriangle(fromBounding, toBounding);
|
|
130
|
+
if (!a || !b || !c) {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
127
133
|
return isPointInTriangle({
|
|
128
134
|
p: cursor,
|
|
129
135
|
a,
|
|
@@ -167,6 +173,9 @@ export function useMenuCursor(view, debug = false) {
|
|
|
167
173
|
from.forEach((trigger) => {
|
|
168
174
|
const fromBounding = trigger.getBoundingClientRect();
|
|
169
175
|
const [a, b, c] = getTriangle(fromBounding, toBounding);
|
|
176
|
+
if (!a || !b || !c) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
170
179
|
allCoords.push(a, b, c);
|
|
171
180
|
});
|
|
172
181
|
coords.value = allCoords;
|
|
@@ -187,6 +196,9 @@ export function useMenuCursor(view, debug = false) {
|
|
|
187
196
|
isInsideTriangle.value = false;
|
|
188
197
|
cancelListener.abort();
|
|
189
198
|
}
|
|
199
|
+
onScopeDispose(() => {
|
|
200
|
+
destroy();
|
|
201
|
+
});
|
|
190
202
|
return {
|
|
191
203
|
coords,
|
|
192
204
|
isInsideFrom,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type MaybeRef } from 'vue';
|
|
2
2
|
import type { MenuState, MagicMenuOptions } from '../../types/index.js';
|
|
3
3
|
export declare function useMenuState(instanceId: MaybeRef<string>): {
|
|
4
4
|
initializeState: (options?: MagicMenuOptions) => MenuState;
|
|
5
|
-
|
|
6
|
-
menuStateStore: Ref<MenuState[], MenuState[]>;
|
|
5
|
+
menuStateStore: import("vue").Ref<MenuState[], MenuState[]>;
|
|
7
6
|
};
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { reactive, toValue, onScopeDispose } from "vue";
|
|
2
2
|
import { defu } from "defu";
|
|
3
|
+
import { createStateStore } from "@maas/vue-equipment/utils";
|
|
3
4
|
import { defaultOptions } from "../../utils/defaultOptions.mjs";
|
|
4
|
-
const
|
|
5
|
+
const getMenuStateStore = createStateStore("MagicMenu", () => []);
|
|
5
6
|
export function useMenuState(instanceId) {
|
|
7
|
+
const menuStateStore = getMenuStateStore();
|
|
8
|
+
let scopeCounted = false;
|
|
6
9
|
function createState(id) {
|
|
7
10
|
const state = {
|
|
8
11
|
id,
|
|
12
|
+
refCount: 0,
|
|
9
13
|
options: { ...defaultOptions },
|
|
10
14
|
views: [],
|
|
11
15
|
active: false,
|
|
@@ -22,12 +26,21 @@ export function useMenuState(instanceId) {
|
|
|
22
26
|
menuStateStore.value = [...menuStateStore.value, state];
|
|
23
27
|
return state;
|
|
24
28
|
}
|
|
29
|
+
function deleteState() {
|
|
30
|
+
const currentId = toValue(instanceId);
|
|
31
|
+
menuStateStore.value = menuStateStore.value.filter(
|
|
32
|
+
(x) => x.id !== currentId
|
|
33
|
+
);
|
|
34
|
+
}
|
|
25
35
|
function initializeState(options) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
});
|
|
36
|
+
const currentId = toValue(instanceId);
|
|
37
|
+
let state = menuStateStore.value.find((entry) => entry.id === currentId);
|
|
29
38
|
if (!state) {
|
|
30
|
-
state = addState(
|
|
39
|
+
state = addState(currentId);
|
|
40
|
+
}
|
|
41
|
+
if (!scopeCounted) {
|
|
42
|
+
state.refCount++;
|
|
43
|
+
scopeCounted = true;
|
|
31
44
|
}
|
|
32
45
|
if (options) {
|
|
33
46
|
const mappedOptions = defu(options, defaultOptions);
|
|
@@ -35,14 +48,21 @@ export function useMenuState(instanceId) {
|
|
|
35
48
|
}
|
|
36
49
|
return state;
|
|
37
50
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
51
|
+
onScopeDispose(() => {
|
|
52
|
+
if (!scopeCounted) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const currentId = toValue(instanceId);
|
|
56
|
+
const state = menuStateStore.value.find((entry) => entry.id === currentId);
|
|
57
|
+
if (state) {
|
|
58
|
+
state.refCount--;
|
|
59
|
+
if (state.refCount <= 0) {
|
|
60
|
+
deleteState();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
});
|
|
43
64
|
return {
|
|
44
65
|
initializeState,
|
|
45
|
-
deleteState,
|
|
46
66
|
menuStateStore
|
|
47
67
|
};
|
|
48
68
|
}
|
|
@@ -80,7 +80,7 @@ export function useMenuTrigger(args) {
|
|
|
80
80
|
if (mappedTrigger.value.includes("right-click") && viewId) {
|
|
81
81
|
e.preventDefault();
|
|
82
82
|
e.stopPropagation();
|
|
83
|
-
if (control
|
|
83
|
+
if (control?.value || shift?.value) {
|
|
84
84
|
onRightClick(
|
|
85
85
|
new MouseEvent(e.type, {
|
|
86
86
|
...e,
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { reactive, toValue, onScopeDispose } from "vue";
|
|
2
|
+
import { createStateStore } from "@maas/vue-equipment/utils";
|
|
3
|
+
const getModalStateStore = createStateStore(
|
|
4
|
+
"MagicModal",
|
|
5
|
+
() => []
|
|
6
|
+
);
|
|
7
|
+
export function useModalState(id) {
|
|
8
|
+
const modalStateStore = getModalStateStore();
|
|
9
|
+
let scopeCounted = false;
|
|
10
|
+
function createState(id2) {
|
|
11
|
+
const state = {
|
|
12
|
+
id: id2,
|
|
13
|
+
refCount: 0,
|
|
14
|
+
active: false
|
|
15
|
+
};
|
|
16
|
+
return reactive(state);
|
|
17
|
+
}
|
|
18
|
+
function addState(id2) {
|
|
19
|
+
const state = createState(id2);
|
|
20
|
+
modalStateStore.value = [...modalStateStore.value, state];
|
|
21
|
+
return state;
|
|
22
|
+
}
|
|
23
|
+
function deleteState() {
|
|
24
|
+
const currentId = toValue(id);
|
|
25
|
+
modalStateStore.value = modalStateStore.value.filter(
|
|
26
|
+
(x) => x.id !== currentId
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
function initializeState() {
|
|
30
|
+
const currentId = toValue(id);
|
|
31
|
+
let state = modalStateStore.value.find((entry) => entry.id === currentId);
|
|
32
|
+
if (!state) {
|
|
33
|
+
state = addState(currentId);
|
|
34
|
+
}
|
|
35
|
+
if (!scopeCounted) {
|
|
36
|
+
state.refCount++;
|
|
37
|
+
scopeCounted = true;
|
|
38
|
+
}
|
|
39
|
+
return state;
|
|
40
|
+
}
|
|
41
|
+
onScopeDispose(() => {
|
|
42
|
+
if (!scopeCounted) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const currentId = toValue(id);
|
|
46
|
+
const state = modalStateStore.value.find((entry) => entry.id === currentId);
|
|
47
|
+
if (state) {
|
|
48
|
+
state.refCount--;
|
|
49
|
+
if (state.refCount <= 0) {
|
|
50
|
+
deleteState();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
return {
|
|
55
|
+
initializeState,
|
|
56
|
+
modalStateStore
|
|
57
|
+
};
|
|
58
|
+
}
|
|
@@ -1,15 +1 @@
|
|
|
1
|
-
|
|
2
|
-
const modalStore = ref([]);
|
|
3
|
-
export function useModalStore() {
|
|
4
|
-
function addInstance(id) {
|
|
5
|
-
modalStore.value.push(id);
|
|
6
|
-
}
|
|
7
|
-
function removeInstance(id) {
|
|
8
|
-
modalStore.value = modalStore.value.filter((x) => x !== id);
|
|
9
|
-
}
|
|
10
|
-
return {
|
|
11
|
-
modalStore,
|
|
12
|
-
addInstance,
|
|
13
|
-
removeInstance
|
|
14
|
-
};
|
|
15
|
-
}
|
|
1
|
+
export { useModalState } from "./useModalState.mjs";
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { computed
|
|
2
|
-
import {
|
|
1
|
+
import { computed } from "vue";
|
|
2
|
+
import { useModalState } from "./private/useModalState.mjs";
|
|
3
3
|
export function useMagicModal(id) {
|
|
4
|
-
const {
|
|
5
|
-
const
|
|
4
|
+
const { initializeState } = useModalState(id);
|
|
5
|
+
const state = initializeState();
|
|
6
|
+
const isActive = computed(() => state.active);
|
|
6
7
|
function open() {
|
|
7
|
-
|
|
8
|
+
state.active = true;
|
|
8
9
|
}
|
|
9
10
|
function close() {
|
|
10
|
-
|
|
11
|
+
state.active = false;
|
|
11
12
|
}
|
|
12
13
|
return {
|
|
13
14
|
isActive,
|
|
@@ -8,7 +8,13 @@
|
|
|
8
8
|
</template>
|
|
9
9
|
|
|
10
10
|
<script setup>
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
onMounted,
|
|
13
|
+
onUnmounted,
|
|
14
|
+
watch,
|
|
15
|
+
useTemplateRef,
|
|
16
|
+
onBeforeUnmount
|
|
17
|
+
} from "vue";
|
|
12
18
|
import { useResizeObserver, useDebounceFn } from "@vueuse/core";
|
|
13
19
|
import { useNoiseApi } from "../composables/private/useNoiseApi";
|
|
14
20
|
const { pause = false, options } = defineProps({
|
|
@@ -30,7 +36,10 @@ const {
|
|
|
30
36
|
throttledRotateAndTransfer,
|
|
31
37
|
isReady
|
|
32
38
|
} = noiseApi;
|
|
33
|
-
useResizeObserver(
|
|
39
|
+
const resizeObserver = useResizeObserver(
|
|
40
|
+
canvasRef,
|
|
41
|
+
useDebounceFn(initialize, 100)
|
|
42
|
+
);
|
|
34
43
|
watch(
|
|
35
44
|
() => pause,
|
|
36
45
|
(pause2) => {
|
|
@@ -47,6 +56,9 @@ onMounted(() => {
|
|
|
47
56
|
throttledDraw();
|
|
48
57
|
throttledRotateAndTransfer();
|
|
49
58
|
});
|
|
59
|
+
onBeforeUnmount(() => {
|
|
60
|
+
resizeObserver.stop();
|
|
61
|
+
});
|
|
50
62
|
onUnmounted(() => {
|
|
51
63
|
isReady.value = false;
|
|
52
64
|
transferControls.value?.pause();
|
|
@@ -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);
|