Skip to content

Commit bf46c88

Browse files
committed
feat: add console banner
fix #102
1 parent d39dbc4 commit bf46c88

File tree

4 files changed

+45
-0
lines changed

4 files changed

+45
-0
lines changed

packages/html/src/media/video-provider.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ import type { MediaStore } from '@videojs/core/store';
44
import { ProviderMixin } from '@open-wc/context-protocol';
55
import { createMediaStore } from '@videojs/core/store';
66

7+
import { yieldConsoleBanner } from '@videojs/utils';
8+
import { version } from '../../package.json';
9+
10+
yieldConsoleBanner(version);
11+
712
const ProviderHTMLElement: Constructor<CustomElement & HTMLElement> = ProviderMixin(HTMLElement);
813

914
export class VideoProviderElement extends ProviderHTMLElement {

packages/react/src/store/video-provider.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,14 @@ import type { ReactNode } from 'react';
33

44
import { createMediaStore } from '@videojs/core/store';
55

6+
import { yieldConsoleBanner } from '@videojs/utils';
67
import { useMemo } from 'react';
8+
9+
import { version } from '../../package.json';
710
import { MediaContext } from './context';
811

12+
yieldConsoleBanner(version);
13+
914
export function VideoProvider({ children }: { children: ReactNode }): JSX.Element {
1015
const value = useMemo(() => createMediaStore(), []);
1116

packages/utils/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
export * from './shared/console';
12
export * from './shared/crypto';
23
export * from './shared/state';
34
export * from './shared/time';
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
export function yieldConsoleBanner(version: string): void {
2+
// eslint-disable-next-line no-console
3+
console.info(
4+
`%c Video.js %c v${version}`,
5+
`border-radius: 9999px;
6+
background: #393836;
7+
font: bold 1.5em/1.5em monospace;
8+
color: #ebe4c1;
9+
text-shadow: 1px 1px 0 #fcb116,
10+
2px 2px 0 #f26222,
11+
3px 3px 0 #ea3837,
12+
4px 4px 0 #a83b71`,
13+
`font: 1em monospace;`,
14+
);
15+
16+
const prereleaseType = version.includes('preview') ? 'preview' : version.includes('alpha') ? 'alpha' : null;
17+
if (prereleaseType) {
18+
console.warn(
19+
`%c This is a ${prereleaseType} release. Please use with caution.`,
20+
`color: #f26222;`,
21+
);
22+
}
23+
24+
// eslint-disable-next-line no-console
25+
console.info(
26+
'%cReport a Bug, Issue or Feature Request - https://github.com/videojs/v10/issues/new/choose',
27+
'color: #aaa; font-size: .9em;',
28+
);
29+
// eslint-disable-next-line no-console
30+
console.info(
31+
'%cReach out on Discord - https://discord.gg/JBqHh485uF',
32+
'color: #aaa; font-size: .9em;',
33+
);
34+
}

0 commit comments

Comments
 (0)