Skip to content

Commit 569799d

Browse files
authored
feat: debug stats (#759)
1 parent 44cfccf commit 569799d

38 files changed

+3157
-12
lines changed

bun.lock

Lines changed: 54 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deno.lock

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/hang-ui/package.json

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,35 @@
77
"repository": "github:moq-dev/moq",
88
"exports": {
99
"./publish/element": "./src/Components/publish/element.tsx",
10-
"./watch/element": "./src/Components/watch/element.tsx"
10+
"./watch/element": "./src/Components/watch/element.tsx",
11+
"./stats": "./src/Components/stats/index.ts"
1112
},
1213
"sideEffects": [
1314
"./src/Components/publish/element.tsx",
14-
"./src/Components/watch/element.tsx"
15+
"./src/Components/watch/element.tsx",
16+
"./src/Components/stats/element.ts"
1517
],
1618
"scripts": {
1719
"build": "bun run clean && rollup -c && bun ../scripts/package.ts",
1820
"check": "tsc --noEmit",
1921
"clean": "rimraf dist",
22+
"fix": "biome check src --fix",
23+
"test": "vitest",
2024
"release": "bun ../scripts/release.ts"
2125
},
2226
"peerDependencies": {
23-
"@moq/hang": "workspace:^0.1.0"
27+
"@moq/hang": "workspace:^0.1.0",
28+
"@moq/signals": "workspace:^0.1.0"
2429
},
2530
"devDependencies": {
2631
"@rollup/plugin-node-resolve": "^16.0.3",
32+
"happy-dom": "^13.3.5",
2733
"rimraf": "^6.0.1",
2834
"rollup": "^4.53.3",
2935
"rollup-plugin-esbuild": "^6.2.1",
3036
"solid-element": "^1.9.1",
3137
"solid-js": "^1.9.10",
32-
"unplugin-solid": "^1.0.0"
38+
"unplugin-solid": "^1.0.0",
39+
"vitest": "^3.2.4"
3340
}
3441
}

js/hang-ui/rollup.config.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// rollup.config.mjs / rollup.config.js
21
import { readFileSync } from "node:fs";
32
import nodeResolve from "@rollup/plugin-node-resolve";
43
import esbuild from "rollup-plugin-esbuild";
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Stats Component
2+
3+
Real-time statistics display for monitoring media streaming performance (network, video, audio, buffer).
4+
5+
## Usage
6+
7+
```tsx
8+
<Stats
9+
context={WatchUIContext}
10+
getElement={(ctx) => ctx?.hangWatch()}
11+
/>
12+
```
13+
14+
## Props
15+
16+
- **context** - SolidJS context to read from
17+
- **getElement** - Function that extracts the media element from context
18+
19+
The component displays four metrics: network, video, audio, and buffer statistics.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { type Context, Show, useContext } from "solid-js";
2+
import { StatsPanel } from "./components/StatsPanel";
3+
import styles from "./style.css?inline";
4+
import type { ProviderProps } from "./types";
5+
6+
interface StatsProps<T = unknown> {
7+
context: Context<T>;
8+
getElement: (ctx: T) => ProviderProps | undefined;
9+
}
10+
11+
/**
12+
* Stats component for displaying real-time media streaming metrics
13+
* Accepts a generic context and a function to extract the media element
14+
*/
15+
export const Stats = <T = unknown>(props: StatsProps<T>) => {
16+
const contextValue = useContext(props.context);
17+
18+
return (
19+
<Show when={props.getElement(contextValue)}>
20+
{(_element) => (
21+
<div class="stats">
22+
<style>{styles}</style>
23+
<StatsPanel audio={_element().audio} video={_element().video} />
24+
</div>
25+
)}
26+
</Show>
27+
);
28+
};

0 commit comments

Comments
 (0)