Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies. #321

Merged
merged 2 commits into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .prettierrc.common.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = {
editorconfig: true,
singleQuote: false,
trailingComma: "es5"
};
32 changes: 16 additions & 16 deletions p2p-media-loader-demo/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
module.exports = {
env: {es2020: true},
extends: ["../.eslintrc.common.cjs", "plugin:react-hooks/recommended"],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
project: "tsconfig.json",
tsconfigRootDir: __dirname,
},
plugins: ["react-refresh"],
rules: {
"react-refresh/only-export-components": "warn",
"@typescript-eslint/ban-ts-comment": 0,
"react-hooks/exhaustive-deps": 0,
"@typescript-eslint/no-explicit-any": 0
},
env: { es2020: true },
extends: ["../.eslintrc.common.cjs", "plugin:react-hooks/recommended"],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
project: "tsconfig.json",
tsconfigRootDir: __dirname,
},
plugins: ["react-refresh"],
rules: {
"react-refresh/only-export-components": "warn",
"@typescript-eslint/ban-ts-comment": 0,
"react-hooks/exhaustive-deps": 0,
"@typescript-eslint/no-explicit-any": 0,
},
};
39 changes: 26 additions & 13 deletions p2p-media-loader-demo/index.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/clappr@latest"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/clappr/clappr-level-selector-plugin@latest/dist/level-selector.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/shaka-player@~4.4.0/dist/shaka-player.compiled.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/clappr/dash-shaka-playback@latest/dist/dash-shaka-playback.external.js"></script>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/hls.js@latest/dist/hls.min.js"></script>
<script
type="text/javascript"
src="https://cdn.jsdelivr.net/npm/clappr@latest"
></script>
<script
type="text/javascript"
src="https://cdn.jsdelivr.net/gh/clappr/clappr-level-selector-plugin@latest/dist/level-selector.min.js"
></script>
<script
type="text/javascript"
src="https://cdn.jsdelivr.net/npm/shaka-player@latest/dist/shaka-player.compiled.min.js"
></script>
<script
type="text/javascript"
src="https://cdn.jsdelivr.net/gh/clappr/dash-shaka-playback@latest/dist/dash-shaka-playback.external.js"
></script>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
13 changes: 6 additions & 7 deletions p2p-media-loader-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,19 @@
},
"dependencies": {
"dplayer": "^1.27.1",
"hls.js": "^1.4.5",
"mux.js": "^6.3.0",
"p2p-media-loader-hlsjs": "workspace:*",
"p2p-media-loader-shaka": "workspace:*",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/dplayer": "^1.25.2",
"@types/react": "^18.2.9",
"@types/react-dom": "^18.2.4",
"@vitejs/plugin-react": "^4.0.0",
"@types/dplayer": "^1.25.5",
"@types/react": "^18.2.45",
"@types/react-dom": "^18.2.18",
"@vitejs/plugin-react": "^4.2.1",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.1",
"vite-plugin-node-polyfills": "^0.14.1"
"eslint-plugin-react-refresh": "^0.4.5",
"vite-plugin-node-polyfills": "^0.18.0"
}
}
34 changes: 17 additions & 17 deletions p2p-media-loader-demo/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { useCallback, useEffect, useRef, useState } from "react";
import { Engine as HlsJsEngine } from "p2p-media-loader-hlsjs";
import { Engine as ShakaEngine } from "p2p-media-loader-shaka";
import Hls from "hls.js";
import DPlayer from "dplayer";
import muxjs from "mux.js";
import debug from "debug";
Expand Down Expand Up @@ -50,11 +49,11 @@ const streamUrls = {

function App() {
const [playerType, setPlayerType] = useState<Player | undefined>(
localStorage.player
localStorage.player,
);
const [streamUrl, setStreamUrl] = useState<string>(localStorage.streamUrl);
const shakaInstance = useRef<shaka.Player>();
const hlsInstance = useRef<Hls>();
const hlsInstance = useRef<any>();
const containerRef = useRef<HTMLDivElement>(null);
const videoRef = useRef<HTMLVideoElement>(null);
const [httpLoaded, setHttpLoaded] = useState<number>(0);
Expand All @@ -63,13 +62,13 @@ function App() {
"httpLoaded",
0,
(v) => v.toString(),
(v) => (v !== null ? +v : 0)
(v) => (v !== null ? +v : 0),
);
const [p2pLoadedGlob, setP2PLoadedGlob] = useLocalStorageItem<number>(
"p2pLoaded",
0,
(v) => v.toString(),
(v) => (v !== null ? +v : 0)
(v) => (v !== null ? +v : 0),
);

const hlsEngine = useRef<HlsJsEngine>();
Expand Down Expand Up @@ -97,7 +96,7 @@ function App() {

useEffect(() => {
if (
!Hls.isSupported() ||
!window.Hls.isSupported() ||
(window as unknown as ExtendedWindow).videoPlayer
) {
return;
Expand All @@ -113,15 +112,16 @@ function App() {
createNewPlayer();
}, [playerType]);

const setPlayerToWindow = (player: DPlayer | ShakaPlayer | Hls) => {
const setPlayerToWindow = (
player: DPlayer | ShakaPlayer | typeof window.Hls,
) => {
(window as unknown as ExtendedWindow).videoPlayer = player;
};

const initHlsJsPlayer = (url: string) => {
if (!videoRef.current) return;
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const engine = hlsEngine.current!;
const hls = new Hls({
if (!videoRef.current || !hlsEngine.current) return;
const engine = hlsEngine.current;
const hls = new window.Hls({
...engine.getConfig(),
});
engine.setHls(hls);
Expand All @@ -132,7 +132,7 @@ function App() {
};

const initHlsDPlayer = (url: string) => {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
if (!hlsEngine.current) return;
const engine = hlsEngine.current!;
const player = new DPlayer({
container: containerRef.current,
Expand All @@ -141,7 +141,7 @@ function App() {
type: "customHls",
customType: {
customHls: (video: HTMLVideoElement) => {
const hls = new Hls({
const hls = new window.Hls({
...engine.getConfig(),
liveSyncDurationCount: 7,
});
Expand Down Expand Up @@ -406,12 +406,12 @@ function LoggersSelect() {
setTimeout(() => debug.enable(localStorage.debug), 0);
if (!storageItem) return [];
return storageItem.split(",");
}
},
);

const onChange = (event: React.ChangeEvent<HTMLSelectElement>) => {
setActiveLoggers(
Array.from(event.target.selectedOptions, (option) => option.value)
Array.from(event.target.selectedOptions, (option) => option.value),
);
};

Expand Down Expand Up @@ -452,10 +452,10 @@ function useLocalStorageItem<T>(
prop: string,
initValue: T,
valueToStorageItem: (value: T) => string | null,
storageItemToValue: (storageItem: string | null) => T
storageItemToValue: (storageItem: string | null) => T,
): [T, React.Dispatch<React.SetStateAction<T>>] {
const [value, setValue] = useState<T>(
storageItemToValue(localStorage[prop]) ?? initValue
storageItemToValue(localStorage[prop]) ?? initValue,
);
const setValueExternal = useCallback((value: T | ((prev: T) => T)) => {
setValue(value);
Expand Down
2 changes: 2 additions & 0 deletions p2p-media-loader-demo/src/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ declare global {
LevelSelector: any;
DashShakaPlayback: any;
shaka: any;
muxjs: any;
Hls: any;
}
}

Expand Down
2 changes: 1 addition & 1 deletion p2p-media-loader-demo/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import App from "./App";
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
<React.StrictMode>
<App />
</React.StrictMode>
</React.StrictMode>,
);
23 changes: 9 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,17 @@
"type-check": "pnpm --recursive run type-check"
},
"devDependencies": {
"@types/debug": "^4.1.8",
"@typescript-eslint/eslint-plugin": "^5.59.2",
"@typescript-eslint/parser": "^5.59.2",
"eslint": "^8.39.0",
"eslint-plugin-prettier": "^4.2.1",
"prettier": "^2.8.8",
"rimraf": "^5.0.0",
"typescript": "^5.0.2",
"vite": "^4.3.2"
"@types/debug": "^4.1.12",
"@typescript-eslint/eslint-plugin": "^6.15.0",
"@typescript-eslint/parser": "^6.15.0",
"eslint": "^8.56.0",
"eslint-plugin-prettier": "^5.1.2",
"prettier": "^3.1.1",
"rimraf": "^5.0.5",
"typescript": "^5.3.3",
"vite": "^5.0.10"
},
"dependencies": {
"debug": "^4.3.4"
},
"pnpm": {
"patchedDependencies": {
"[email protected]": "patches/[email protected]"
}
}
}
4 changes: 1 addition & 3 deletions packages/p2p-media-loader-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@
"type-check": "npx tsc --noEmit"
},
"dependencies": {
"bittorrent-tracker": "10.0.12",
"bittorrent-tracker": "^11.0.0",
"nano-md5": "^1.0.5"
},
"devDependencies": {
}
}
2 changes: 1 addition & 1 deletion packages/p2p-media-loader-core/src/event-dispatcher.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export class EventDispatcher<
// eslint-disable-next-line @typescript-eslint/no-explicit-any
T extends { [key: string]: (...args: any[]) => void | Promise<void> },
K extends keyof T = keyof T
K extends keyof T = keyof T,
> {
private readonly listeners = new Map<keyof T, Set<T[K]>>();

Expand Down
7 changes: 5 additions & 2 deletions packages/p2p-media-loader-core/src/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,12 @@ type RequestErrorType =
| HttpRequestErrorType;

export class RequestError<
T extends RequestErrorType = RequestErrorType
T extends RequestErrorType = RequestErrorType,
> extends Error {
constructor(readonly type: T, message?: string) {
constructor(
readonly type: T,
message?: string
) {
super(message);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/p2p-media-loader-core/src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export type StreamWithSegments<
TMap extends ReadonlyLinkedMap<string, SegmentBase> = LinkedMap<
string,
Segment
>
>,
> = TStream & {
readonly segments: TMap;
};
Expand Down
2 changes: 1 addition & 1 deletion packages/p2p-media-loader-core/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"compilerOptions": {
"outDir": "lib",
"rootDir": "src",
"tsBuildInfoFile": "./build/.tsbuildinfo",
"tsBuildInfoFile": "./build/.tsbuildinfo"
},
"include": ["src/**/*"]
}
2 changes: 1 addition & 1 deletion packages/p2p-media-loader-hlsjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"type-check": "npx tsc --noEmit"
},
"dependencies": {
"hls.js": "^1.4.5",
"hls.js": "^1.4.14",
"p2p-media-loader-core": "workspace:*"
}
}
2 changes: 1 addition & 1 deletion packages/p2p-media-loader-shaka/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@
},
"dependencies": {
"p2p-media-loader-core": "workspace:*",
"shaka-player": "^4.3.7"
"shaka-player": "^4.7.1"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ export class ManifestParserDecorator implements shaka.extern.ManifestParser {
return this.originalManifestParser.configure(config);
}

banLocation(uri: string): unknown {
return this.originalManifestParser.banLocation(uri);
}

onInitialVariantChosen(variant: shaka.extern.Variant): unknown {
return this.originalManifestParser.onInitialVariantChosen(variant);
}

private setP2PMediaLoaderData(p2pml?: P2PMLShakaData) {
if (!p2pml) return;
this.segmentManager = p2pml.segmentManager;
Expand Down
Loading