Skip to content

Commit

Permalink
fix(mux-video, mux-video-react, mux-audio, mux-audio-react, mux-playe…
Browse files Browse the repository at this point in the history
…r, mux-player-react): Expose element name and version via exports and statics for web components. (#1017)
  • Loading branch information
cjpillsbury authored Nov 19, 2024
1 parent e1d17f4 commit 27b6858
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 12 deletions.
4 changes: 2 additions & 2 deletions packages/mux-audio-react/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ export type Props = Omit<
> &
MuxMediaProps;

const playerSoftwareVersion = getPlayerVersion();
const playerSoftwareName = 'mux-audio-react';
export const playerSoftwareVersion = getPlayerVersion();
export const playerSoftwareName = 'mux-audio-react';

const MuxAudio = React.forwardRef<HTMLAudioElement | undefined, Partial<Props>>((props, ref) => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Expand Down
12 changes: 10 additions & 2 deletions packages/mux-audio/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,18 @@ export const Attributes = {

const AttributeNameValues = Object.values(Attributes);

const playerSoftwareVersion = getPlayerVersion();
const playerSoftwareName = 'mux-audio';
export const playerSoftwareVersion = getPlayerVersion();
export const playerSoftwareName = 'mux-audio';

class MuxAudioElement extends CustomAudioElement implements Partial<MuxMediaProps> {
static get NAME() {
return playerSoftwareName;
}

static get VERSION() {
return playerSoftwareVersion;
}

static get observedAttributes() {
return [...AttributeNameValues, ...(CustomAudioElement.observedAttributes ?? [])];
}
Expand Down
4 changes: 2 additions & 2 deletions packages/mux-player-react/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,8 @@ const usePlayer = (
return [remainingProps];
};

const playerSoftwareVersion = getPlayerVersion();
const playerSoftwareName = 'mux-player-react';
export const playerSoftwareVersion = getPlayerVersion();
export const playerSoftwareName = 'mux-player-react';

const MuxPlayer = React.forwardRef<
MuxPlayerRefAttributes,
Expand Down
13 changes: 11 additions & 2 deletions packages/mux-player/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,9 @@ function getMetadataFromAttrs(el: MuxPlayerElement) {
const MuxVideoAttributeNames = Object.values(MuxVideoAttributes);
const VideoAttributeNames = Object.values(VideoAttributes);
const PlayerAttributeNames = Object.values(PlayerAttributes);
const playerSoftwareVersion = getPlayerVersion();
const playerSoftwareName = 'mux-player';

export const playerSoftwareVersion = getPlayerVersion();
export const playerSoftwareName = 'mux-player';

const initialState = {
dialog: undefined,
Expand Down Expand Up @@ -295,6 +296,14 @@ class MuxPlayerElement extends VideoApiElement implements MuxPlayerElement {
},
};

static get NAME() {
return playerSoftwareName;
}

static get VERSION() {
return playerSoftwareVersion;
}

static get observedAttributes() {
return [
...(VideoApiElement.observedAttributes ?? []),
Expand Down
4 changes: 2 additions & 2 deletions packages/mux-video-react/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ export type Props = Omit<
> &
MuxMediaProps;

const playerSoftwareVersion = getPlayerVersion();
const playerSoftwareName = 'mux-video-react';
export const playerSoftwareVersion = getPlayerVersion();
export const playerSoftwareName = 'mux-video-react';

const MuxVideo = React.forwardRef<HTMLVideoElement | undefined, Partial<Props>>((props, ref) => {
const {
Expand Down
12 changes: 10 additions & 2 deletions packages/mux-video/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,18 @@ export const Attributes = {

const AttributeNameValues = Object.values(Attributes);

const playerSoftwareVersion = getPlayerVersion();
const playerSoftwareName = 'mux-video';
export const playerSoftwareVersion = getPlayerVersion();
export const playerSoftwareName = 'mux-video';

class MuxVideoBaseElement extends CustomVideoElement implements Partial<MuxMediaProps> {
static get NAME() {
return playerSoftwareName;
}

static get VERSION() {
return playerSoftwareVersion;
}

static get observedAttributes() {
return [...AttributeNameValues, ...(CustomVideoElement.observedAttributes ?? [])];
}
Expand Down

0 comments on commit 27b6858

Please sign in to comment.