Take control over your live stream video by running it yourself. Streaming + chat out of the box.
HTML activitypubbroadcastingchatdecentralizedfederationfediversegolanghacktoberfesthlslivelivestreamowncastrtmpself-hostedstreaming-videovideo
Layer plugin styles below admin appearance settings so admin colors win
Gabe Kangasfc67112a3fb0
diff --git a/web/components/theme/Theme.tsx b/web/components/theme/Theme.tsxindex 0ef79927e2..42c481318a 100644--- a/web/components/theme/Theme.tsx+++ b/web/components/theme/Theme.tsx@@ -7,7 +7,7 @@ import { clientConfigStateAtom } from '../stores/ClientConfigStore';export const Theme: FC = () => {const clientConfig = useRecoilValue<ClientConfig>(clientConfigStateAtom);- const { appearanceVariables, customStyles } = clientConfig;+ const { appearanceVariables, customStyles, pluginStyles } = clientConfig;const appearanceVars = Object.keys(appearanceVariables || {}).filter(variable => !!appearanceVariables[variable])@@ -27,6 +27,24 @@ export const Theme: FC = () => {<Head><meta name="theme-color" content={themeColor} /></Head>+ {/*+ Appearance cascade, low to high priority (the later style block+ wins): plugin styles (baseline), then admin appearance+ variables, then admin custom CSS. So a plugin theme provides a+ baseline and the admin's explicit colors and CSS layer on top+ and win on overlap.++ pluginStyles is every loaded plugin's manifest.styles followed+ by its on_page_styles output, concatenated server-side with a+ per-plugin delimiter comment for devtools attribution.+ */}+ <style+ dangerouslySetInnerHTML={{+ __html: `+ ${pluginStyles}+ `,+ }}+ /><styledangerouslySetInnerHTML={{__html: `@@ -36,11 +54,7 @@ export const Theme: FC = () => {`,}}/>- {/*- customStyles is the admin's CSS followed by every loaded- plugin's manifest.styles content (concatenated server-side).- One inline <style> block carries both.- */}+ {/* customStyles is the admin's own custom CSS, rendered last. */}<styledangerouslySetInnerHTML={{__html: `diff --git a/web/components/ui/PluginTabFrame/PluginStylesheet.stories.tsx b/web/components/ui/PluginTabFrame/PluginStylesheet.stories.tsxindex 222767503b..79b8d3a624 100644--- a/web/components/ui/PluginTabFrame/PluginStylesheet.stories.tsx+++ b/web/components/ui/PluginTabFrame/PluginStylesheet.stories.tsx@@ -10,7 +10,8 @@ const PLUGIN_STYLESHEET = '/styles/plugin.css';// A self-contained mirror of PluginTabFrame's rendering: a srcdoc iframe with// the baseline linked into its head, a transparent background so the host// panel shows through, and auto-sizing to content. It deliberately omits-// PluginTabFrame's Recoil reads (appearanceVariables / customStyles) so the+// PluginTabFrame's Recoil reads (pluginStyles / appearanceVariables /+// customStyles) so the// story has no store dependency and stays a pure stylesheet preview.const PluginFramePreview: FC<{ html: string }> = ({ html }) => {const frameRef = useRef<HTMLIFrameElement>(null);diff --git a/web/components/ui/PluginTabFrame/PluginTabFrame.tsx b/web/components/ui/PluginTabFrame/PluginTabFrame.tsxindex 0344d5b927..e441331898 100644--- a/web/components/ui/PluginTabFrame/PluginTabFrame.tsx+++ b/web/components/ui/PluginTabFrame/PluginTabFrame.tsx@@ -15,19 +15,34 @@ const PLUGIN_STYLESHEET = '/styles/plugin.css';// The cascade we want inside the frame, bottom to top:// 1. plugin.css — element baseline + token defaults.// 2. author's own styles — in their HTML, so they override the baseline.-// 3. appearanceVariables — the admin's :root variable overrides.-// 4. customStyles — the admin's custom CSS.+// 3. pluginStyles — other loaded plugins' page CSS (e.g. a theme),+// so the tab inherits the same baseline theming+// as the main page.+// 4. appearanceVariables — the admin's :root variable overrides.+// 5. customStyles — the admin's custom CSS.//-// All four are injected by the host (the author writes none of it). We inject+// All of it is injected by the host (the author writes none of it). We inject// into the DOM rather than string-templating the srcdoc because the author's// HTML may be a full document with its own <head>: the parser always// synthesizes exactly one <head>, so inserting at head.firstChild reliably// places plugin.css ahead of the author's own head styles (lowest layer)-// regardless of how their markup is shaped. The runtime layers (3, 4) are-// appended last so they win, and set via textContent so a stray </style> in-// customStyles can't break out of the tag.-const injectStyles = (doc: Document, appearanceVars: string, customStyles: string) => {- // Appended after the author's content → highest priority.+// regardless of how their markup is shaped. The runtime layers (3, 4, 5) are+// appended last so they win, in priority order, and set via textContent so a+// stray </style> in any of them can't break out of the tag. Admin layers+// (4, 5) come after plugin styles (3) so the admin wins on overlap, matching+// the main-page cascade.+const injectStyles = (+ doc: Document,+ pluginStyles: string,+ appearanceVars: string,+ customStyles: string,+) => {+ // Appended after the author's content, low to high priority.+ if (pluginStyles) {+ const plugins = doc.createElement('style');+ plugins.textContent = pluginStyles;+ doc.head.appendChild(plugins);+ }if (appearanceVars) {const vars = doc.createElement('style');vars.textContent = `:root { ${appearanceVars} }`;@@ -70,7 +85,7 @@ export const PluginTabFrame: FC<PluginTabFrameProps> = ({ content }) => {const observerRef = useRef<ResizeObserver | null>(null);const clientConfig = useRecoilValue<ClientConfig>(clientConfigStateAtom);- const { appearanceVariables, customStyles } = clientConfig;+ const { appearanceVariables, customStyles, pluginStyles } = clientConfig;const appearanceVars = Object.keys(appearanceVariables || {}).filter(variable => !!appearanceVariables[variable]).map(variable => `--${variable}: ${appearanceVariables[variable]}`)@@ -85,7 +100,7 @@ export const PluginTabFrame: FC<PluginTabFrameProps> = ({ content }) => {if (!iframe || !doc || !win) return;applyBase(doc);- injectStyles(doc, appearanceVars, customStyles);+ injectStyles(doc, pluginStyles, appearanceVars, customStyles);// The container behind the frame paints the panel background; let it// show through.doc.documentElement.style.background = 'transparent';diff --git a/web/interfaces/client-config.model.ts b/web/interfaces/client-config.model.tsindex 931e576f24..00e058854b 100644--- a/web/interfaces/client-config.model.ts+++ b/web/interfaces/client-config.model.ts@@ -11,11 +11,15 @@ export interface ClientConfig {chatDisabled: boolean;chatRequireAuthentication: boolean;externalActions: any[];- // customStyles is the admin's CSS plus the concatenated content of- // every loaded plugin's manifest.styles entries (the host- // pre-merges them server-side). Theme.tsx renders this as one- // inline <style> block.+ // customStyles is the admin's custom CSS. Theme.tsx renders it last+ // in the appearance cascade (after pluginStyles and the appearance+ // variables), so it wins over plugin styling on overlap.customStyles: string;+ // pluginStyles is the concatenated CSS contributed by loaded plugins+ // (manifest.styles + on_page_styles output). Theme.tsx renders it as+ // a baseline <style> block before the appearance variables and+ // customStyles, so admin appearance settings layer on top.+ pluginStyles: string;// pluginTabs is the list of viewer-page tabs contributed by// loaded plugins via manifest.tabs. DesktopContent / MobileContent// render one tab per entry alongside the built-in tabs.@@ -76,6 +80,7 @@ export function makeEmptyClientConfig(): ClientConfig {chatRequireAuthentication: false,externalActions: [],customStyles: '',+ pluginStyles: '',pluginTabs: [],appearanceVariables: new Map(),maxSocketPayloadSize: 0,diff --git a/web/stories/ReadwriteChat.stories.tsx b/web/stories/ReadwriteChat.stories.tsxindex 054a0bc077..b397cd1e10 100644--- a/web/stories/ReadwriteChat.stories.tsx+++ b/web/stories/ReadwriteChat.stories.tsx@@ -41,6 +41,7 @@ const Page = () => {socialHandles: [],externalActions: [],customStyles: '',+ pluginStyles: '',pluginTabs: [],maxSocketPayloadSize: 0,federation: undefined,diff --git a/webserver/handlers/config.go b/webserver/handlers/config.goindex 25c7e66670..25502e2fb5 100644--- a/webserver/handlers/config.go+++ b/webserver/handlers/config.go@@ -18,13 +18,18 @@ import (type webConfigResponse struct {AppearanceVariables map[string]string `json:"appearanceVariables"`Name string `json:"name"`- // CustomStyles is the admin-configured CSS plus the concatenated- // content of every loaded plugin's manifest.styles entries (each- // preceded by a `/* plugin: <slug> ... */` delimiter for- // devtools attribution). The viewer renders this as one inline- // <style> block so plugins can theme the page without each plugin- // needing its own <link> tag.- CustomStyles string `json:"customStyles"`+ // CustomStyles is the admin-configured custom CSS. The viewer+ // renders it last in the appearance cascade (after plugin styles+ // and the appearance-variable block), so an admin's explicit CSS+ // wins over a plugin's styling.+ CustomStyles string `json:"customStyles"`+ // PluginStyles is the concatenated CSS contributed by every loaded+ // plugin: each plugin's manifest.styles entries followed by its+ // on_page_styles output, each preceded by a `/* plugin: <slug> ... */`+ // delimiter for devtools attribution. The viewer renders this as a+ // baseline <style> block *before* the admin's appearance variables+ // and custom CSS, so admin settings layer on top and win on overlap.+ PluginStyles string `json:"pluginStyles"`StreamTitle string `json:"streamTitle,omitempty"` // What's going on with the current streamOfflineMessage string `json:"offlineMessage"`Logo string `json:"logo"`@@ -148,7 +153,8 @@ func (h *Handlers) getConfigResponse(r *http.Request) webConfigResponse {ChatRequireAuthentication: configRepository.GetChatRequireAuthentication(),ExternalActions: mergePluginActions(configRepository.GetExternalActions(), h.pluginActions),PluginTabs: pluginTabsOrEmpty(r, h.pluginTabs),- CustomStyles: mergePluginCSS(configRepository.GetCustomStyles(), h.pluginCSSContent),+ CustomStyles: configRepository.GetCustomStyles(),+ PluginStyles: pluginStylesString(h.pluginCSSContent),MaxSocketPayloadSize: config.MaxSocketPayloadSize,Federation: federationResponse,Notifications: notificationsResponse,@@ -197,27 +203,17 @@ func prependPluginPageContent(admin string, r *http.Request, pluginHTML func(*htreturn prefix + admin}-// mergePluginCSS appends plugin-contributed CSS bytes to the admin's-// custom CSS so the viewer renders one inline <style> block covering-// both. A nil getter (no plugin host) or empty contribution leaves-// the admin's value untouched. A newline separates the two sources-// so a stylesheet that doesn't terminate in one can't trail into the-// plugin block.-func mergePluginCSS(admin string, pluginCSS func() []byte) string {+// pluginStylesString returns the plugin-contributed CSS bytes as a+// string for the viewer's pluginStyles field. The viewer renders this+// as a baseline <style> block ahead of the admin's appearance+// variables and custom CSS, so admin settings layer on top. A nil+// getter (no plugin host) or empty contribution yields an empty+// string.+func pluginStylesString(pluginCSS func() []byte) string {if pluginCSS == nil {- return admin- }- bytes := pluginCSS()- if len(bytes) == 0 {- return admin- }- if admin == "" {- return string(bytes)- }- if admin[len(admin)-1] != '\n' {- admin += "\n"+ return ""}- return admin + string(bytes)+ return string(pluginCSS())}// mergePluginActions appends plugin-contributed action buttons to the