@video-lab/vue-config 4.0.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.
- package/LICENSE +21 -0
- package/README.md +24 -0
- package/dist/index.cjs +116 -0
- package/dist/index.d.cts +49 -0
- package/dist/index.d.mts +49 -0
- package/dist/index.mjs +114 -0
- package/package.json +48 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Video Lab Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# @video-lab/vue-config
|
|
2
|
+
|
|
3
|
+
Vue inline 与 Vue Frame 共用的 `PlayerProvider` 注入上下文。业务通常从 `@video-lab/vue` 或 `@video-lab/vue-frame` 导入 `PlayerProvider`、`usePlayerI18n`,无需直接安装本包。
|
|
4
|
+
|
|
5
|
+
公开 API 与示例:[全局播放器配置与语言切换](../../docs/guides/PLAYER-GLOBAL-CONFIG.md)。
|
|
6
|
+
|
|
7
|
+
```vue
|
|
8
|
+
<script setup lang="ts">
|
|
9
|
+
import { PlayerProvider, usePlayerI18n } from '@video-lab/vue-config'
|
|
10
|
+
import { defineComponent, h } from 'vue'
|
|
11
|
+
|
|
12
|
+
const LanguageLabel = defineComponent({
|
|
13
|
+
setup() {
|
|
14
|
+
const { locale } = usePlayerI18n()
|
|
15
|
+
return () => h('span', locale.value)
|
|
16
|
+
},
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<template>
|
|
22
|
+
<PlayerProvider default-locale="zh-CN"><LanguageLabel /></PlayerProvider>
|
|
23
|
+
</template>
|
|
24
|
+
```
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let _video_lab_protocol = require("@video-lab/protocol");
|
|
3
|
+
let vue = require("vue");
|
|
4
|
+
//#region src/index.ts
|
|
5
|
+
const key = Symbol("video-lab-player-config");
|
|
6
|
+
const PlayerProvider = (0, vue.defineComponent)({
|
|
7
|
+
name: "PlayerProvider",
|
|
8
|
+
props: {
|
|
9
|
+
locale: String,
|
|
10
|
+
defaultLocale: String,
|
|
11
|
+
resources: Object,
|
|
12
|
+
messageOverrides: Object,
|
|
13
|
+
fallbackLocales: Array,
|
|
14
|
+
defaults: Object,
|
|
15
|
+
frameDefaults: Object
|
|
16
|
+
},
|
|
17
|
+
emits: { "update:locale": (_locale) => true },
|
|
18
|
+
setup(props, { emit, slots }) {
|
|
19
|
+
const parent = (0, vue.inject)(key, null);
|
|
20
|
+
const instance = (0, vue.getCurrentInstance)();
|
|
21
|
+
const initialLocale = (0, vue.ref)((0, _video_lab_protocol.normalizeLocaleTag)(props.defaultLocale ?? parent?.value.locale ?? "zh-CN"));
|
|
22
|
+
const context = (0, vue.computed)(() => {
|
|
23
|
+
const parentValue = parent?.value;
|
|
24
|
+
const inheritsLocale = props.locale === void 0 && props.defaultLocale === void 0 && !!parentValue;
|
|
25
|
+
return {
|
|
26
|
+
locale: inheritsLocale ? parentValue.locale : (0, _video_lab_protocol.normalizeLocaleTag)(props.locale ?? initialLocale.value),
|
|
27
|
+
resources: (0, _video_lab_protocol.mergeMessageResources)(parentValue?.resources, props.resources),
|
|
28
|
+
messageOverrides: (0, _video_lab_protocol.mergeMessageResources)(parentValue?.messageOverrides, props.messageOverrides),
|
|
29
|
+
fallbackLocales: props.fallbackLocales ?? parentValue?.fallbackLocales ?? [],
|
|
30
|
+
defaults: (0, _video_lab_protocol.mergePlayerDefaults)(parentValue?.defaults, props.defaults),
|
|
31
|
+
frameDefaults: (0, _video_lab_protocol.mergeFrameDefaults)(parentValue?.frameDefaults, props.frameDefaults),
|
|
32
|
+
changeLanguage(next) {
|
|
33
|
+
const normalized = (0, _video_lab_protocol.normalizeLocaleTag)(next);
|
|
34
|
+
if (inheritsLocale) return parentValue.changeLanguage(normalized);
|
|
35
|
+
if (props.locale !== void 0) {
|
|
36
|
+
if (!instance?.vnode.props?.["onUpdate:locale"]) return false;
|
|
37
|
+
emit("update:locale", normalized);
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
initialLocale.value = normalized;
|
|
41
|
+
emit("update:locale", normalized);
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
(0, vue.provide)(key, context);
|
|
47
|
+
return () => slots.default?.() ?? [];
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
/** 播放器组件使用的可选上下文。 */
|
|
51
|
+
function useOptionalPlayerConfig() {
|
|
52
|
+
return (0, vue.inject)(key, null);
|
|
53
|
+
}
|
|
54
|
+
const LIVE_DEFAULTS = [
|
|
55
|
+
"muted",
|
|
56
|
+
"interactive",
|
|
57
|
+
"showErrorOverlay",
|
|
58
|
+
"showDefaultLoadingOverlay",
|
|
59
|
+
"showLoadingText",
|
|
60
|
+
"errorButtonColors"
|
|
61
|
+
];
|
|
62
|
+
/** Vue 组件在 setup 中调用;返回可供 watch 与模板追踪的 props 代理。 */
|
|
63
|
+
function useResolvedPlayerProps(props, frame = false) {
|
|
64
|
+
const configProps = props;
|
|
65
|
+
const context = useOptionalPlayerConfig();
|
|
66
|
+
if (!context) return props;
|
|
67
|
+
const initialDefaults = context.value.defaults;
|
|
68
|
+
const initialFrameDefaults = context.value.frameDefaults;
|
|
69
|
+
let localeCache = null;
|
|
70
|
+
const effective = (0, vue.computed)(() => {
|
|
71
|
+
const current = context.value;
|
|
72
|
+
const defaults = { ...initialDefaults };
|
|
73
|
+
for (const key of LIVE_DEFAULTS) defaults[key] = current.defaults[key];
|
|
74
|
+
const resolved = (0, _video_lab_protocol.applyPlayerDefaults)(configProps, defaults);
|
|
75
|
+
if (frame) {
|
|
76
|
+
for (const field of [
|
|
77
|
+
"origin",
|
|
78
|
+
"iframeVersion",
|
|
79
|
+
"debug"
|
|
80
|
+
]) if (resolved[field] === void 0) resolved[field] = initialFrameDefaults[field];
|
|
81
|
+
}
|
|
82
|
+
const localeKey = JSON.stringify([
|
|
83
|
+
configProps.locale,
|
|
84
|
+
current.locale,
|
|
85
|
+
current.resources,
|
|
86
|
+
current.messageOverrides,
|
|
87
|
+
current.fallbackLocales
|
|
88
|
+
]);
|
|
89
|
+
if (localeCache?.key !== localeKey) localeCache = {
|
|
90
|
+
key: localeKey,
|
|
91
|
+
value: (0, _video_lab_protocol.applyProviderLocale)(configProps.locale, current.locale, current.resources, current.messageOverrides, current.fallbackLocales)
|
|
92
|
+
};
|
|
93
|
+
resolved.locale = localeCache.value;
|
|
94
|
+
return resolved;
|
|
95
|
+
});
|
|
96
|
+
return new Proxy(props, { get(_target, property, receiver) {
|
|
97
|
+
return Reflect.get(effective.value, property, receiver);
|
|
98
|
+
} });
|
|
99
|
+
}
|
|
100
|
+
function usePlayerI18n() {
|
|
101
|
+
const context = (0, vue.inject)(key, null);
|
|
102
|
+
if (!context) throw new Error("usePlayerI18n 必须在 PlayerProvider 内使用");
|
|
103
|
+
return {
|
|
104
|
+
locale: (0, vue.computed)(() => context.value.locale),
|
|
105
|
+
t(key) {
|
|
106
|
+
const value = context.value;
|
|
107
|
+
return (0, _video_lab_protocol.resolveLocaleMessages)((0, _video_lab_protocol.applyProviderLocale)(void 0, value.locale, value.resources, value.messageOverrides, value.fallbackLocales)).messages[key] ?? key;
|
|
108
|
+
},
|
|
109
|
+
changeLanguage: (next) => context.value.changeLanguage(next)
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
//#endregion
|
|
113
|
+
exports.PlayerProvider = PlayerProvider;
|
|
114
|
+
exports.useOptionalPlayerConfig = useOptionalPlayerConfig;
|
|
115
|
+
exports.usePlayerI18n = usePlayerI18n;
|
|
116
|
+
exports.useResolvedPlayerProps = useResolvedPlayerProps;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { FrameDefaults, LocaleConfig, MessageResources, PlayerDefaults } from "@video-lab/protocol";
|
|
2
|
+
import { PropType, Ref } from "vue";
|
|
3
|
+
//#region src/index.d.ts
|
|
4
|
+
interface PlayerConfigContext {
|
|
5
|
+
locale: string;
|
|
6
|
+
resources: MessageResources;
|
|
7
|
+
messageOverrides: MessageResources;
|
|
8
|
+
fallbackLocales: string[];
|
|
9
|
+
defaults: PlayerDefaults;
|
|
10
|
+
frameDefaults: FrameDefaults;
|
|
11
|
+
changeLanguage(next: string): boolean;
|
|
12
|
+
}
|
|
13
|
+
declare const PlayerProvider: import("vue").DefineComponent<{
|
|
14
|
+
locale: StringConstructor;
|
|
15
|
+
defaultLocale: StringConstructor;
|
|
16
|
+
resources: PropType<MessageResources>;
|
|
17
|
+
messageOverrides: PropType<MessageResources>;
|
|
18
|
+
fallbackLocales: PropType<string[]>;
|
|
19
|
+
defaults: PropType<PlayerDefaults>;
|
|
20
|
+
frameDefaults: PropType<FrameDefaults>;
|
|
21
|
+
}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
22
|
+
[key: string]: any;
|
|
23
|
+
}>[], unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
24
|
+
'update:locale': (_locale: string) => true;
|
|
25
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
26
|
+
locale: StringConstructor;
|
|
27
|
+
defaultLocale: StringConstructor;
|
|
28
|
+
resources: PropType<MessageResources>;
|
|
29
|
+
messageOverrides: PropType<MessageResources>;
|
|
30
|
+
fallbackLocales: PropType<string[]>;
|
|
31
|
+
defaults: PropType<PlayerDefaults>;
|
|
32
|
+
frameDefaults: PropType<FrameDefaults>;
|
|
33
|
+
}>> & {
|
|
34
|
+
"onUpdate:locale"?: ((_locale: string) => any) | undefined;
|
|
35
|
+
}, {}, {}>;
|
|
36
|
+
/** 播放器组件使用的可选上下文。 */
|
|
37
|
+
declare function useOptionalPlayerConfig(): Ref<PlayerConfigContext> | null;
|
|
38
|
+
/** Vue 组件在 setup 中调用;返回可供 watch 与模板追踪的 props 代理。 */
|
|
39
|
+
declare function useResolvedPlayerProps<T extends object>(props: T, frame?: boolean): T & {
|
|
40
|
+
locale?: LocaleConfig;
|
|
41
|
+
};
|
|
42
|
+
declare function usePlayerI18n(): {
|
|
43
|
+
locale: Readonly<Ref<string>>;
|
|
44
|
+
t(key: string): string;
|
|
45
|
+
changeLanguage(next: string): boolean;
|
|
46
|
+
};
|
|
47
|
+
//#endregion
|
|
48
|
+
export { PlayerConfigContext, PlayerProvider, useOptionalPlayerConfig, usePlayerI18n, useResolvedPlayerProps };
|
|
49
|
+
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { FrameDefaults, LocaleConfig, MessageResources, PlayerDefaults } from "@video-lab/protocol";
|
|
2
|
+
import { PropType, Ref } from "vue";
|
|
3
|
+
//#region src/index.d.ts
|
|
4
|
+
interface PlayerConfigContext {
|
|
5
|
+
locale: string;
|
|
6
|
+
resources: MessageResources;
|
|
7
|
+
messageOverrides: MessageResources;
|
|
8
|
+
fallbackLocales: string[];
|
|
9
|
+
defaults: PlayerDefaults;
|
|
10
|
+
frameDefaults: FrameDefaults;
|
|
11
|
+
changeLanguage(next: string): boolean;
|
|
12
|
+
}
|
|
13
|
+
declare const PlayerProvider: import("vue").DefineComponent<{
|
|
14
|
+
locale: StringConstructor;
|
|
15
|
+
defaultLocale: StringConstructor;
|
|
16
|
+
resources: PropType<MessageResources>;
|
|
17
|
+
messageOverrides: PropType<MessageResources>;
|
|
18
|
+
fallbackLocales: PropType<string[]>;
|
|
19
|
+
defaults: PropType<PlayerDefaults>;
|
|
20
|
+
frameDefaults: PropType<FrameDefaults>;
|
|
21
|
+
}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
22
|
+
[key: string]: any;
|
|
23
|
+
}>[], unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
24
|
+
'update:locale': (_locale: string) => true;
|
|
25
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
26
|
+
locale: StringConstructor;
|
|
27
|
+
defaultLocale: StringConstructor;
|
|
28
|
+
resources: PropType<MessageResources>;
|
|
29
|
+
messageOverrides: PropType<MessageResources>;
|
|
30
|
+
fallbackLocales: PropType<string[]>;
|
|
31
|
+
defaults: PropType<PlayerDefaults>;
|
|
32
|
+
frameDefaults: PropType<FrameDefaults>;
|
|
33
|
+
}>> & {
|
|
34
|
+
"onUpdate:locale"?: ((_locale: string) => any) | undefined;
|
|
35
|
+
}, {}, {}>;
|
|
36
|
+
/** 播放器组件使用的可选上下文。 */
|
|
37
|
+
declare function useOptionalPlayerConfig(): Ref<PlayerConfigContext> | null;
|
|
38
|
+
/** Vue 组件在 setup 中调用;返回可供 watch 与模板追踪的 props 代理。 */
|
|
39
|
+
declare function useResolvedPlayerProps<T extends object>(props: T, frame?: boolean): T & {
|
|
40
|
+
locale?: LocaleConfig;
|
|
41
|
+
};
|
|
42
|
+
declare function usePlayerI18n(): {
|
|
43
|
+
locale: Readonly<Ref<string>>;
|
|
44
|
+
t(key: string): string;
|
|
45
|
+
changeLanguage(next: string): boolean;
|
|
46
|
+
};
|
|
47
|
+
//#endregion
|
|
48
|
+
export { PlayerConfigContext, PlayerProvider, useOptionalPlayerConfig, usePlayerI18n, useResolvedPlayerProps };
|
|
49
|
+
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { applyPlayerDefaults, applyProviderLocale, mergeFrameDefaults, mergeMessageResources, mergePlayerDefaults, normalizeLocaleTag, resolveLocaleMessages } from "@video-lab/protocol";
|
|
2
|
+
import { computed, defineComponent, getCurrentInstance, inject, provide, ref } from "vue";
|
|
3
|
+
//#region src/index.ts
|
|
4
|
+
const key = Symbol("video-lab-player-config");
|
|
5
|
+
const PlayerProvider = defineComponent({
|
|
6
|
+
name: "PlayerProvider",
|
|
7
|
+
props: {
|
|
8
|
+
locale: String,
|
|
9
|
+
defaultLocale: String,
|
|
10
|
+
resources: Object,
|
|
11
|
+
messageOverrides: Object,
|
|
12
|
+
fallbackLocales: Array,
|
|
13
|
+
defaults: Object,
|
|
14
|
+
frameDefaults: Object
|
|
15
|
+
},
|
|
16
|
+
emits: { "update:locale": (_locale) => true },
|
|
17
|
+
setup(props, { emit, slots }) {
|
|
18
|
+
const parent = inject(key, null);
|
|
19
|
+
const instance = getCurrentInstance();
|
|
20
|
+
const initialLocale = ref(normalizeLocaleTag(props.defaultLocale ?? parent?.value.locale ?? "zh-CN"));
|
|
21
|
+
const context = computed(() => {
|
|
22
|
+
const parentValue = parent?.value;
|
|
23
|
+
const inheritsLocale = props.locale === void 0 && props.defaultLocale === void 0 && !!parentValue;
|
|
24
|
+
return {
|
|
25
|
+
locale: inheritsLocale ? parentValue.locale : normalizeLocaleTag(props.locale ?? initialLocale.value),
|
|
26
|
+
resources: mergeMessageResources(parentValue?.resources, props.resources),
|
|
27
|
+
messageOverrides: mergeMessageResources(parentValue?.messageOverrides, props.messageOverrides),
|
|
28
|
+
fallbackLocales: props.fallbackLocales ?? parentValue?.fallbackLocales ?? [],
|
|
29
|
+
defaults: mergePlayerDefaults(parentValue?.defaults, props.defaults),
|
|
30
|
+
frameDefaults: mergeFrameDefaults(parentValue?.frameDefaults, props.frameDefaults),
|
|
31
|
+
changeLanguage(next) {
|
|
32
|
+
const normalized = normalizeLocaleTag(next);
|
|
33
|
+
if (inheritsLocale) return parentValue.changeLanguage(normalized);
|
|
34
|
+
if (props.locale !== void 0) {
|
|
35
|
+
if (!instance?.vnode.props?.["onUpdate:locale"]) return false;
|
|
36
|
+
emit("update:locale", normalized);
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
initialLocale.value = normalized;
|
|
40
|
+
emit("update:locale", normalized);
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
provide(key, context);
|
|
46
|
+
return () => slots.default?.() ?? [];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
/** 播放器组件使用的可选上下文。 */
|
|
50
|
+
function useOptionalPlayerConfig() {
|
|
51
|
+
return inject(key, null);
|
|
52
|
+
}
|
|
53
|
+
const LIVE_DEFAULTS = [
|
|
54
|
+
"muted",
|
|
55
|
+
"interactive",
|
|
56
|
+
"showErrorOverlay",
|
|
57
|
+
"showDefaultLoadingOverlay",
|
|
58
|
+
"showLoadingText",
|
|
59
|
+
"errorButtonColors"
|
|
60
|
+
];
|
|
61
|
+
/** Vue 组件在 setup 中调用;返回可供 watch 与模板追踪的 props 代理。 */
|
|
62
|
+
function useResolvedPlayerProps(props, frame = false) {
|
|
63
|
+
const configProps = props;
|
|
64
|
+
const context = useOptionalPlayerConfig();
|
|
65
|
+
if (!context) return props;
|
|
66
|
+
const initialDefaults = context.value.defaults;
|
|
67
|
+
const initialFrameDefaults = context.value.frameDefaults;
|
|
68
|
+
let localeCache = null;
|
|
69
|
+
const effective = computed(() => {
|
|
70
|
+
const current = context.value;
|
|
71
|
+
const defaults = { ...initialDefaults };
|
|
72
|
+
for (const key of LIVE_DEFAULTS) defaults[key] = current.defaults[key];
|
|
73
|
+
const resolved = applyPlayerDefaults(configProps, defaults);
|
|
74
|
+
if (frame) {
|
|
75
|
+
for (const field of [
|
|
76
|
+
"origin",
|
|
77
|
+
"iframeVersion",
|
|
78
|
+
"debug"
|
|
79
|
+
]) if (resolved[field] === void 0) resolved[field] = initialFrameDefaults[field];
|
|
80
|
+
}
|
|
81
|
+
const localeKey = JSON.stringify([
|
|
82
|
+
configProps.locale,
|
|
83
|
+
current.locale,
|
|
84
|
+
current.resources,
|
|
85
|
+
current.messageOverrides,
|
|
86
|
+
current.fallbackLocales
|
|
87
|
+
]);
|
|
88
|
+
if (localeCache?.key !== localeKey) localeCache = {
|
|
89
|
+
key: localeKey,
|
|
90
|
+
value: applyProviderLocale(configProps.locale, current.locale, current.resources, current.messageOverrides, current.fallbackLocales)
|
|
91
|
+
};
|
|
92
|
+
resolved.locale = localeCache.value;
|
|
93
|
+
return resolved;
|
|
94
|
+
});
|
|
95
|
+
return new Proxy(props, { get(_target, property, receiver) {
|
|
96
|
+
return Reflect.get(effective.value, property, receiver);
|
|
97
|
+
} });
|
|
98
|
+
}
|
|
99
|
+
function usePlayerI18n() {
|
|
100
|
+
const context = inject(key, null);
|
|
101
|
+
if (!context) throw new Error("usePlayerI18n 必须在 PlayerProvider 内使用");
|
|
102
|
+
return {
|
|
103
|
+
locale: computed(() => context.value.locale),
|
|
104
|
+
t(key) {
|
|
105
|
+
const value = context.value;
|
|
106
|
+
return resolveLocaleMessages(applyProviderLocale(void 0, value.locale, value.resources, value.messageOverrides, value.fallbackLocales)).messages[key] ?? key;
|
|
107
|
+
},
|
|
108
|
+
changeLanguage: (next) => context.value.changeLanguage(next)
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
//#endregion
|
|
112
|
+
export { PlayerProvider, useOptionalPlayerConfig, usePlayerI18n, useResolvedPlayerProps };
|
|
113
|
+
|
|
114
|
+
//# sourceMappingURL=index.mjs.map
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@video-lab/vue-config",
|
|
3
|
+
"version": "4.0.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"description": "Video Lab Player 的 Vue 全局配置与语言上下文",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.cjs",
|
|
8
|
+
"module": "./dist/index.mjs",
|
|
9
|
+
"types": "./dist/index.d.cts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": {
|
|
13
|
+
"types": "./dist/index.d.mts",
|
|
14
|
+
"default": "./dist/index.mjs"
|
|
15
|
+
},
|
|
16
|
+
"require": {
|
|
17
|
+
"types": "./dist/index.d.cts",
|
|
18
|
+
"default": "./dist/index.cjs"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"sideEffects": false,
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"vue": "^3.4.0"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@video-lab/protocol": "4.0.0"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@vue/test-utils": "2.4.6",
|
|
34
|
+
"jsdom": "^24.0.0",
|
|
35
|
+
"tsdown": "^0.22.9",
|
|
36
|
+
"typescript": "~5.9.0",
|
|
37
|
+
"vitest": "^4.1.10",
|
|
38
|
+
"vue": "3.4.0"
|
|
39
|
+
},
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "tsdown src/index.ts --format esm,cjs --dts --clean",
|
|
45
|
+
"test": "vitest run",
|
|
46
|
+
"typecheck": "tsc --noEmit && tsc -p tsconfig.test.json --noEmit"
|
|
47
|
+
}
|
|
48
|
+
}
|