mirror of
https://github.com/zoriya/v10.git
synced 2026-08-16 02:45:09 +00:00
fix(packages): add server-only bundles (#1349)
This commit is contained in:
Vendored
+1
@@ -1 +1,2 @@
|
||||
declare const __DEV__: boolean;
|
||||
declare const __BROWSER__: boolean;
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
export const VideoCSSVars = {} as const;
|
||||
|
||||
export const AudioCSSVars = {} as const;
|
||||
|
||||
export function CustomMediaElement(_tag: string, _MediaHost: any): any {
|
||||
return class {};
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest';
|
||||
import { HTMLAudioElementHost } from '../../audio-host';
|
||||
import { HTMLVideoElementHost } from '../../video-host';
|
||||
import { CustomMediaElement } from '../index';
|
||||
import { CustomMediaElement } from '../browser';
|
||||
|
||||
afterEach(() => {
|
||||
document.body.innerHTML = '';
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
import { HTMLVideoElementHost } from '../video-host';
|
||||
|
||||
export class DashMedia extends HTMLVideoElementHost {
|
||||
engine = null;
|
||||
destroy(): void {}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ vi.mock('dashjs', () => {
|
||||
return { MediaPlayer: () => ({ create }), default: { MediaPlayer: () => ({ create }) } };
|
||||
});
|
||||
|
||||
import { DashMedia } from '../index';
|
||||
import { DashMedia } from '../browser';
|
||||
|
||||
afterEach(() => {
|
||||
document.body.innerHTML = '';
|
||||
|
||||
+10
-22
@@ -1,26 +1,20 @@
|
||||
import { shallowEqual } from '@videojs/utils/object';
|
||||
import Hls from 'hls.js';
|
||||
import { bridgeEvents } from '../../../core/utils/bridge-events';
|
||||
import { NativeHlsMedia } from '../native-hls';
|
||||
import { NativeHlsMedia } from '../native-hls/browser';
|
||||
import { HTMLVideoElementHost } from '../video-host';
|
||||
import { HlsJsMedia } from './hlsjs';
|
||||
|
||||
export type PreloadType = '' | 'none' | 'metadata' | 'auto';
|
||||
import {
|
||||
inferSourceType,
|
||||
type PlaybackType,
|
||||
PlaybackTypes,
|
||||
type PreloadType,
|
||||
type SourceType,
|
||||
SourceTypes,
|
||||
} from './types';
|
||||
|
||||
export { Hls };
|
||||
|
||||
export type PlaybackType = (typeof PlaybackTypes)[keyof typeof PlaybackTypes];
|
||||
export type SourceType = (typeof SourceTypes)[keyof typeof SourceTypes];
|
||||
|
||||
export const PlaybackTypes = {
|
||||
MSE: 'mse',
|
||||
NATIVE: 'native',
|
||||
};
|
||||
|
||||
export const SourceTypes = {
|
||||
M3U8: 'application/vnd.apple.mpegurl',
|
||||
MP4: 'video/mp4',
|
||||
};
|
||||
export * from './types';
|
||||
|
||||
export class HlsMedia extends HTMLVideoElementHost {
|
||||
#delegate: HlsJsMedia | NativeHlsMedia | null = null;
|
||||
@@ -169,9 +163,3 @@ export class HlsMedia extends HTMLVideoElementHost {
|
||||
this.#loadRequested = null;
|
||||
}
|
||||
}
|
||||
|
||||
function inferSourceType(src: string): SourceType {
|
||||
const path = src.split(/[?#]/)[0] ?? '';
|
||||
if (path.endsWith('.mp4')) return SourceTypes.MP4;
|
||||
return SourceTypes.M3U8;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { HTMLVideoElementHost } from '../video-host';
|
||||
|
||||
export * from './types';
|
||||
|
||||
export class HlsMedia extends HTMLVideoElementHost {
|
||||
engine = null;
|
||||
preferPlayback: string | undefined = 'mse';
|
||||
config: Record<string, any> = {};
|
||||
debug = false;
|
||||
preload = 'metadata';
|
||||
load(): void {}
|
||||
destroy(): void {}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest';
|
||||
import { MediaError } from '../../../../core/media/media-error';
|
||||
import { HlsMedia, SourceTypes } from '../index';
|
||||
import { HlsMedia, SourceTypes } from '../browser';
|
||||
|
||||
afterEach(() => {
|
||||
document.body.innerHTML = '';
|
||||
|
||||
@@ -4,3 +4,24 @@ export interface HlsEngineHost extends EventTarget {
|
||||
readonly engine?: Hls | null;
|
||||
readonly target?: HTMLMediaElement | null;
|
||||
}
|
||||
|
||||
export type PreloadType = '' | 'none' | 'metadata' | 'auto';
|
||||
|
||||
export type PlaybackType = (typeof PlaybackTypes)[keyof typeof PlaybackTypes];
|
||||
export type SourceType = (typeof SourceTypes)[keyof typeof SourceTypes];
|
||||
|
||||
export const PlaybackTypes = {
|
||||
MSE: 'mse',
|
||||
NATIVE: 'native',
|
||||
};
|
||||
|
||||
export const SourceTypes = {
|
||||
M3U8: 'application/vnd.apple.mpegurl',
|
||||
MP4: 'video/mp4',
|
||||
};
|
||||
|
||||
export function inferSourceType(src: string): SourceType {
|
||||
const path = src.split(/[?#]/)[0] ?? '';
|
||||
if (path.endsWith('.mp4')) return SourceTypes.MP4;
|
||||
return SourceTypes.M3U8;
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { HlsMedia } from '../hls';
|
||||
import { HlsMedia } from '../hls/browser';
|
||||
import { MuxDataMediaMixin } from './mux-data';
|
||||
|
||||
export class MuxVideoMedia extends MuxDataMediaMixin(HlsMedia) {
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { Mixin } from '@videojs/utils/types';
|
||||
import Mux from 'mux-embed';
|
||||
import type { MediaEngineHost } from '../../../core/media/types';
|
||||
import { Hls, type HlsMedia } from '../hls';
|
||||
import { Hls, type HlsMedia } from '../hls/browser';
|
||||
import { getPlayerVersion } from './env';
|
||||
import type { MuxDataOptions, MuxDataSdk } from './types';
|
||||
|
||||
@@ -198,7 +198,7 @@ export function toPlaybackIdFromSrc(src: string): string | undefined {
|
||||
|
||||
export function isMuxVideoSrc({ src }: MuxVideoIdProps): boolean {
|
||||
if (typeof src !== 'string') return false;
|
||||
const base = window?.location.href;
|
||||
const base = __BROWSER__ ? window.location.href : undefined;
|
||||
const hostname = new URL(src, base).hostname.toLocaleLowerCase();
|
||||
return hostname.includes(MUX_VIDEO_DOMAIN);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import { HlsMedia } from '../hls/server';
|
||||
|
||||
export class MuxVideoMedia extends HlsMedia {
|
||||
static PLAYER_SOFTWARE_NAME = 'mux-video';
|
||||
}
|
||||
|
||||
export class MuxAudioMedia extends HlsMedia {
|
||||
static PLAYER_SOFTWARE_NAME = 'mux-audio';
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { MuxVideoMedia } from '..';
|
||||
import { MuxVideoMedia } from '../browser';
|
||||
|
||||
describe('MuxVideoMedia', () => {
|
||||
it('accepts src directly', () => {
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import { HTMLVideoElementHost } from '../video-host';
|
||||
|
||||
export class NativeHlsMedia extends HTMLVideoElementHost {
|
||||
engine = null;
|
||||
preload = 'metadata';
|
||||
destroy(): void {}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest';
|
||||
import { MediaError } from '../../../../core/media/media-error';
|
||||
import { NativeHlsMedia } from '../index';
|
||||
import { NativeHlsMedia } from '../browser';
|
||||
|
||||
afterEach(() => {
|
||||
document.body.innerHTML = '';
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
import { HTMLVideoElementHost } from '../video-host';
|
||||
|
||||
export class SimpleHlsMedia extends HTMLVideoElementHost {
|
||||
engine = null;
|
||||
destroy(): void {}
|
||||
}
|
||||
@@ -63,7 +63,7 @@ export function createDismissLayer(options: DismissLayerOptions): DismissLayerAp
|
||||
function setupDocumentListeners(): void {
|
||||
cleanupDocumentListeners();
|
||||
|
||||
if (typeof document === 'undefined') return;
|
||||
if (!__BROWSER__) return;
|
||||
|
||||
docAbort = new AbortController();
|
||||
const { signal } = docAbort;
|
||||
|
||||
Vendored
+1
@@ -1 +1,2 @@
|
||||
declare const __DEV__: boolean;
|
||||
declare const __BROWSER__: boolean;
|
||||
|
||||
Reference in New Issue
Block a user