mirror of
https://github.com/zoriya/v10.git
synced 2026-08-16 02:45:09 +00:00
23 lines
994 B
JavaScript
23 lines
994 B
JavaScript
import { defineSlice } from "@videojs/store";
|
|
import { isUndefined } from "@videojs/utils/predicate";
|
|
//#region src/dom/feature.ts
|
|
const definePlayerSlice = defineSlice();
|
|
function definePlayerFeature(config, defaultConfig) {
|
|
if (arguments.length === 1) return definePlayerSlice(config);
|
|
const { name, state, attach } = config;
|
|
const forConfig = (featureConfig) => definePlayerSlice({
|
|
...isUndefined(name) ? {} : { name },
|
|
state: (ctx) => state(ctx, featureConfig),
|
|
...attach ? { attach: (ctx) => attach(ctx, featureConfig) } : {}
|
|
});
|
|
const defaultFeature = forConfig(defaultConfig);
|
|
const feature = ((featureConfig) => isUndefined(featureConfig) ? defaultFeature : forConfig(featureConfig));
|
|
feature.state = defaultFeature.state;
|
|
if (defaultFeature.attach) feature.attach = defaultFeature.attach;
|
|
if (!isUndefined(name)) Object.defineProperty(feature, "name", { value: name });
|
|
return feature;
|
|
}
|
|
//#endregion
|
|
export { definePlayerFeature };
|
|
|
|
//# sourceMappingURL=feature.js.map
|