### Basic JavaScript 'Hello World' Example
Source: https://github.com/steamclienthomebrew/steambrew/blob/main/apps/docs/src/themes/advanced/scripting.md
A simple JavaScript snippet to verify correct setup by logging 'Hello, World!' to the console. This is a fundamental test for any scripting environment.
```javascript
console.log('Hello, World!');
```
--------------------------------
### Install Millennium on Windows (PowerShell)
Source: https://github.com/steamclienthomebrew/steambrew/blob/main/apps/docs/src/users/getting-started/installation.md
Installs Millennium on Windows using a PowerShell script. This method is automatic and does not alter system configurations. It fetches the installation script directly from a URL and executes it.
```powershell
iwr -useb "https://steambrew.app/install.ps1" | iex
```
--------------------------------
### Example CSS for Theme Colors - CSS
Source: https://github.com/steamclienthomebrew/steambrew/blob/main/apps/docs/src/themes/intermediate/colors.md
This CSS example demonstrates how to define theme colors using various formats (RGB, RGBA, Hex) within a `:root` block. It also shows how to add custom names and descriptions using `@name` and `@description` selectors for better usability in the theme editor.
```css
:root {
/*
* @name this is a name
* @description this is a description
*/
--raw-rgb: 123, 123, 123;
/*
* @name this is a name 1
*/
--raw-rgba: 123, 123, 123, 0.5;
--rgb: rgb(123, 123, 123);
--rgba: rgba(123, 123, 123, 0.5);
--hex: #123456;
/* these are examples of invalid, unparsable colors */
--invalid-1: hsl(123, 50%, 50%);
--invalid-2: blue;
}
```
--------------------------------
### HTML Structure for Selectors Examples
Source: https://github.com/steamclienthomebrew/steambrew/blob/main/apps/docs/src/themes/basics/selectors.md
This HTML snippet provides the basic structure used in the following CSS examples to demonstrate selector specificity. It includes a main container, a main content area, and a heading.
```html
Text
```
--------------------------------
### Clone Theme Template (Linux Bash)
Source: https://github.com/steamclienthomebrew/steambrew/blob/main/apps/docs/src/themes/introduction/quick-start.md
This script navigates to the Steam skins directory on Linux, clones the ThemeTemplate repository, and optionally opens it in VSCode.
```bash
# cd into Steam skins folder
cd ~/.steam/steam/steamui/skins
# clone the repository
git clone "https://github.com/SteamClientHomebrew/ThemeTemplate"
cd ThemeTemplate
# Optional: Open VSCode
code .
```
--------------------------------
### Clone Theme Template (Windows PowerShell)
Source: https://github.com/steamclienthomebrew/steambrew/blob/main/apps/docs/src/themes/introduction/quick-start.md
This script navigates to the Steam skins directory on Windows using a registry key, clones the ThemeTemplate repository, and optionally opens it in VSCode.
```powershell
# Note: this is a PowerShell script
# cd into Steam skins folder
cd "$(gp 'HKLM:\SOFTWARE\Wow6432Node\Valve\Steam' | % InstallPath)\steamui\skins"
# clone the repository
git clone "https://github.com/SteamClientHomebrew/ThemeTemplate"
cd ThemeTemplate
# Optional: Open VSCode
code .
```
--------------------------------
### Basic logging examples at different severity levels in Lua
Source: https://github.com/steamclienthomebrew/steambrew/blob/main/apps/docs/src/plugins/lua-module-docs/logger.md
Provides examples of logging messages at info, warn, and error levels to demonstrate basic logging patterns.
```lua
-- Log at different severity levels
logger:info("Starting data processing")
logger:warn("Cache is getting full")
logger:error("Failed to save data")
```
--------------------------------
### GET /api/v1/plugins/
Source: https://context7.com/steamclienthomebrew/steambrew/llms.txt
Retrieves a complete list of all available plugins with their associated metadata, download counts, and file sizes. This endpoint utilizes a 30-minute cache for performance.
```APIDOC
## GET /api/v1/plugins/
### Description
Retrieves a complete list of all available plugins with metadata, download counts, and file sizes.
### Method
GET
### Endpoint
/api/v1/plugins/
### Parameters
#### Query Parameters
None
#### Request Body
None
### Request Example
```bash
# Fetch all plugins
curl https://steambrew.app/api/v1/plugins/
```
### Response
#### Success Response (200)
Returns an array of plugin objects, each containing:
- **id** (string) - Unique identifier for the plugin.
- **commitId** (string) - The commit ID of the plugin's source code.
- **initCommitId** (string) - The initial commit ID for the plugin.
- **repoOwner** (string) - The GitHub repository owner.
- **repoName** (string) - The GitHub repository name.
- **commitDate** (string) - The date and time of the last commit (ISO 8601 format).
- **pluginJson** (object) - Contains common plugin metadata:
- **common_name** (string) - The common name of the plugin.
- **description** (string) - A brief description of the plugin.
- **tags** (array) - An array of tags associated with the plugin.
- **downloadCount** (integer) - The total number of downloads for the plugin.
- **downloadSize** (string) - The size of the plugin download (e.g., "245.67 KB").
#### Response Example
```json
[
{
"id": "a1b2c3d4e5f6",
"commitId": "a1b2c3d4e5f6789012345678901234567890abcd",
"initCommitId": "a1b2c3d4e5f6789012345678901234567890abcd",
"repoOwner": "username",
"repoName": "my-steam-plugin",
"commitDate": "2024-01-15T10:30:00Z",
"pluginJson": {
"common_name": "My Steam Plugin",
"description": "Adds awesome features to Steam",
"tags": ["ui", "enhancement"]
},
"downloadCount": 1234,
"downloadSize": "245.67 KB"
}
]
```
### Notes
- This API aggregates data from plugin lists, metadata.json, Cloud Storage, and Firestore download records.
- The endpoint response is cached for 30 minutes.
```
--------------------------------
### Install Millennium on Other Linux Distributions (Shell)
Source: https://github.com/steamclienthomebrew/steambrew/blob/main/apps/docs/src/users/getting-started/installation.md
Installs Millennium on Linux distributions other than Arch or NixOS using a pre-built binary via a shell script. The installation script is open-source and can be audited. After installation, a patch command is required.
```bash
curl -fsSL "https://raw.githubusercontent.com/SteamClientHomebrew/Millennium/main/scripts/install.sh" | sudo sh
```
--------------------------------
### Custom Patch Example for Steambrew
Source: https://github.com/steamclienthomebrew/steambrew/blob/main/apps/docs/src/themes/intermediate/custom-structure.md
This JSON object demonstrates a single custom patch configuration. It specifies a regular expression to match the '.FullModalOverlay' class in the DOM body. If matched, it instructs Millennium to load 'libraryroot.custom.js' and 'libraryroot.custom.css' into the matching Steam window. This is an example of how to target specific elements for custom theming.
```json
{
"MatchRegexString": ".FullModalOverlay",
"TargetCss": "libraryroot.custom.css",
"TargetJs": "libraryroot.custom.js"
}
```
--------------------------------
### Get Steam Installation Path (Lua)
Source: https://github.com/steamclienthomebrew/steambrew/blob/main/apps/docs/src/plugins/lua-module-docs/millennium.md
Provides a Lua snippet to get the installation path of Steam. It includes a warning that this path is not guaranteed to be where Millennium itself is installed.
```lua
millennium.steam_path()
```
--------------------------------
### Get Millennium Installation Path (Lua)
Source: https://github.com/steamclienthomebrew/steambrew/blob/main/apps/docs/src/plugins/lua-module-docs/millennium.md
Shows how to retrieve the installation path of the Millennium module itself. A warning is included stating this may differ from the Steam installation path.
```lua
millennium.get_install_path()
```
--------------------------------
### GET /api/v2/
Source: https://context7.com/steamclienthomebrew/steambrew/llms.txt
Fetches featured themes and plugins, including their GitHub repository data and configuration files. This endpoint is filtered to exclude disabled themes and uses GraphQL batching for efficient GitHub data retrieval.
```APIDOC
## GET /api/v2/
### Description
Fetches featured themes and plugins with GitHub repository data and configuration files. Excludes disabled themes and uses efficient GitHub data fetching.
### Method
GET
### Endpoint
/api/v2/
### Parameters
#### Query Parameters
None
#### Request Body
None
### Request Example
```bash
# Get featured content
curl https://steambrew.app/api/v2/
```
### Response
#### Success Response (200)
Returns an array of featured content objects, each containing:
- **name** (string) - The name of the theme or plugin.
- **description** (string) - A description of the theme or plugin.
- **version** (string) - The version number.
- **header_image** (string) - URL to the header image.
- **splash_image** (string) - URL to the splash image.
- **tags** (array) - An array of tags.
- **download** (string) - Direct download URL for the content.
- **commit_data** (object) - Data related to the GitHub commit:
- **oid** (string) - The commit object ID.
- **committedDate** (string) - The date and time of the commit (ISO 8601 format).
- **commitUrl** (string) - URL to the commit on GitHub.
- **data** (object) - Additional platform-specific data:
- **id** (string) - The Firestore document ID.
- **create_time** (string) - The creation time in Firestore (ISO 8601 format).
- **github** (object) - GitHub repository information:
- **owner** (string) - The repository owner.
- **repo** (string) - The repository name.
#### Response Example
```json
[
{
"name": "Dark Modern Theme",
"description": "A sleek dark theme for Steam",
"version": "1.2.3",
"header_image": "https://example.com/header.png",
"splash_image": "https://example.com/splash.png",
"tags": ["dark", "modern", "minimal"],
"download": "https://github.com/owner/repo/archive/refs/heads/main.zip",
"commit_data": {
"oid": "abc123...",
"committedDate": "2024-01-20T14:25:00Z",
"commitUrl": "https://github.com/owner/repo/commit/abc123"
},
"data": {
"id": "theme-doc-id",
"create_time": "2024-01-01T00:00:00Z",
"github": {
"owner": "username",
"repo": "my-theme"
}
}
}
]
```
### Notes
- This endpoint filters out themes that have been disabled by administrators.
- It employs GraphQL batching to efficiently retrieve data from the GitHub API.
```
--------------------------------
### Core Functions and Utilities - FetchPlugins()
Source: https://context7.com/steamclienthomebrew/steambrew/llms.txt
Describes the `FetchPlugins()` function, which is the main aggregation function used to build the complete plugin catalog by combining data from multiple sources. This function is called by the `GET /api/v1/plugins/` route.
```APIDOC
## Core Functions and Utilities - FetchPlugins()
### Description
Main aggregation function that combines data from multiple sources to build a complete plugin catalog. This function is called internally by the `GET /api/v1/plugins/` route.
### Method
Internal Function (Called via API)
### Endpoint
(Internal - Called by GET /api/v1/plugins/)
### Parameters
None directly exposed via API. Internally takes dependencies for data fetching.
### Request Example
(Internal function call, not directly from API client)
```typescript
import { FetchPlugins } from './GetPlugins';
async function getPluginCatalog() {
const result = await FetchPlugins();
return result.pluginData;
}
```
### Response
#### Success Response
- **pluginData** (array) - An array of complete plugin objects.
- **metadata** (object) - Build metadata, including commit IDs.
#### Response Example
```json
{
"pluginData": [
{
"name": "Example Plugin",
"version": "1.0.0",
"description": "A sample plugin.",
"githubUrl": "https://github.com/user/repo",
"commitId": "abcdef123456"
// ... other plugin properties
}
],
"metadata": {
"commitId": "abcdef123456",
"buildDate": "2023-10-27T12:00:00Z"
}
}
```
### Implementation Flow
1. Check `PluginCache` collection for a valid 30-minute cache.
2. On cache miss:
a. Fetch plugin list from `github.com/shdwmtr/plugdb`.
b. Get metadata from `metadata.json` (commit IDs, build info).
c. Retrieve file sizes from Cloud Storage (`plugins/*.zip`).
d. Get download counts from Firestore `downloads` collection.
e. Merge all data sources by commit ID.
3. Cache the result in Firestore with a timestamp.
4. Return the combined dataset.
### Cache Structure
```typescript
interface PluginCacheEntry {
data: PluginDataTable;
timestamp: Timestamp; // When cached
expiresAt: Timestamp; // 30 minutes from timestamp
}
```
### Notes
- Automatic cache invalidation on expiry.
- Fire-and-forget cache updates (non-blocking).
```
--------------------------------
### Dropdown Configuration Example (JSON)
Source: https://github.com/steamclienthomebrew/steambrew/blob/main/apps/docs/src/themes/intermediate/user.md
This JSON snippet demonstrates how to define a dropdown configuration option for a Steam theme. It includes a description, default value, and multiple selectable values, each associated with a CSS file to be loaded based on the user's selection. This is useful for allowing users to choose visual styles like color themes.
```json
{
"Conditions": {
"A ComboBox Item": {
"description": "A simple combo box",
"tab": "Theme",
"default": "Dark",
"values": {
"Dark": {
"TargetCss": {
"affects": ["^Steam$", "^Steam Big Picture Mode$"],
"src": "dark.css"
}
},
"Amoled": {
"TargetCss": {
"affects": [".*"],
"src": "amoled.css"
}
},
"Nord": {
"TargetCss": {
"affects": [".*"],
"src": "nord.css"
}
}
}
}
}
}
```
--------------------------------
### Millennium Steam Information Functions
Source: https://github.com/steamclienthomebrew/steambrew/blob/main/apps/docs/src/plugins/lua-module-docs/millennium.md
Functions to retrieve the Steam installation path and the Millennium installation path.
```APIDOC
## `millennium.steam_path()`
### Description
Returns the detected path to the Steam installation directory. Note: This path is not guaranteed to be where Millennium itself is installed.
### Method
`millennium.steam_path(): string
### Parameters
None
### Returns
* **path** (string) - The absolute path to the Steam installation directory.
### Usage
```lua
local steam_dir = millennium.steam_path()
print("Steam is installed at: " .. steam_dir)
```
## `millennium.get_install_path()`
### Description
Returns the installation path of the Millennium module. This may differ from the Steam installation path.
### Method
`millennium.get_install_path(): string
### Parameters
None
### Returns
* **path** (string) - The absolute path where Millennium is installed.
### Usage
```lua
local millennium_dir = millennium.get_install_path()
print("Millennium is installed at: " .. millennium_dir)
```
```
--------------------------------
### Make HTTP GET Request in Lua
Source: https://github.com/steamclienthomebrew/steambrew/blob/main/apps/docs/src/plugins/lua-module-docs/http.md
Illustrates how to make an HTTP GET request using the `http.get` function. This is a convenient shortcut for common GET operations and supports additional request options like custom headers and timeouts.
```lua
-- Simple GET request
local response, err = http.get("https://api.example.com/users")
if response then
print("Status:", response.status)
print("Body:", response.body)
else
print("Error:", err)
end
-- GET with custom headers
local response, err = http.get("https://api.example.com/data", {
headers = {
["Accept"] = "application/json",
["X-API-Key"] = "your-api-key"
},
timeout = 5
})
-- GET with query parameters (encode them in the URL)
local response, err = http.get("https://api.example.com/search?q=lua&limit=10")
```
--------------------------------
### Load CSS and JS into Steam Windows (JSON Example)
Source: https://github.com/steamclienthomebrew/steambrew/blob/main/apps/docs/src/themes/intermediate/user.md
This configuration demonstrates how to load a CSS file into all Steam windows and a JavaScript file into the main Steam UI and community pages. It uses regular expressions to define which windows the assets should be applied to. The `affects` field takes a list of regex strings, and the `src` field specifies the relative path to the asset.
```json
{
"TargetCss": {
"affects": [" விளம்பர"],
"src": "some.css"
},
"TargetJs": {
"affects": ["^Steam$", "https:\/\/steamcommunity.com\/ விளம்பர"],
"src": "some.js"
}
}
```
--------------------------------
### Add Millennium to NixOS Flake Configuration
Source: https://github.com/steamclienthomebrew/steambrew/blob/main/apps/docs/src/users/getting-started/installation.md
Configures Millennium for NixOS by adding it as an input to your flake and applying its overlay. This allows Millennium to be used as a package within your NixOS system. It requires updating the flake to fetch the latest commit.
```nix
inputs.millennium.url = "git+https://github.com/SteamClientHomebrew/Millennium";
```
```nix
nixpkgs.overlays = [ inputs.millennium.overlays.default ];
```
```nix
programs.steam = {
enable = true;
package = pkgs.steam-millennium;
};
```
```nix
environment.systemPackages = with pkgs;
[
# Your other packages...
steam-millennium
];
```
--------------------------------
### Require and Use Millennium Module (Lua)
Source: https://github.com/steamclienthomebrew/steambrew/blob/main/apps/docs/src/plugins/lua-module-docs/millennium.md
Demonstrates how to load and use the Millennium module in Lua. It shows a basic example of calling the `steam_path` function.
```lua
local millennium = require("millennium")
-- Ex. use Millennium module to get Steam path
millennium.steam_path()
```
--------------------------------
### POST /api/v2/checkupdates
Source: https://context7.com/steamclienthomebrew/steambrew/llms.txt
Checks for available updates across multiple plugins or themes in a single request. This is useful for batch checking updates for installed add-ons.
```APIDOC
## POST /api/v2/checkupdates
### Description
Checks for available updates across multiple plugins/themes in a single request.
### Method
POST
### Endpoint
/api/v2/checkupdates
### Parameters
#### Request Body
- **installedAddons** (array of objects) - Required - An array of installed add-ons to check for updates.
- **owner** (string) - Required - The GitHub owner of the repository.
- **repo** (string) - Required - The GitHub repository name.
- **commit** (string) - Required - The current commit SHA of the installed add-on.
### Request Example
```json
[
{
"owner": "user1",
"repo": "dark-theme",
"commit": "abc123old"
},
{
"owner": "user2",
"repo": "compact-ui",
"commit": "def456old"
}
]
```
### Response
#### Success Response (200)
- Returns an array of objects, where each object represents an add-on with available updates.
- **name** (string) - The name of the repository.
- **latestCommit** (string) - The latest commit SHA.
- **commitUrl** (string) - The URL to the latest commit.
- **committedDate** (string) - The date and time the latest commit was made.
- **commitMessage** (string) - The commit message of the latest commit.
- **hasUpdate** (boolean) - True if an update is available, false otherwise.
#### Response Example
```json
[
{
"name": "dark-theme",
"latestCommit": "xyz789new",
"commitUrl": "https://github.com/.../commit/xyz789new",
"committedDate": "2023-10-27T10:00:00Z",
"commitMessage": "Feat: Add new feature",
"hasUpdate": true
}
]
```
```
--------------------------------
### GET /api/millennium/stats
Source: https://context7.com/steamclienthomebrew/steambrew/llms.txt
Returns aggregate download statistics and the latest version for the Millennium project itself. Useful for displaying project metrics.
```APIDOC
## GET /api/millennium/stats
### Description
Returns aggregate download statistics and latest version for Millennium itself.
### Method
GET
### Endpoint
/api/millennium/stats
### Parameters
None
### Request Example
```bash
curl https://steambrew.app/api/millennium/stats
```
### Response
#### Success Response (200)
- **downloadCount** (integer) - The total number of downloads for Millennium.
- **latestVersion** (string) - The latest released version of Millennium.
#### Response Example
```json
{
"downloadCount": 234567,
"latestVersion": "v1.5.2"
}
```
### Notes
- Includes historical downloads (174,452) from legacy CDN.
- Paginated through all GitHub releases with rate limiting.
- Cached for 30 minutes (revalidate: 1800).
```
--------------------------------
### Checkbox Configuration Example (JSON)
Source: https://github.com/steamclienthomebrew/steambrew/blob/main/apps/docs/src/themes/intermediate/user.md
This JSON snippet illustrates the configuration for a checkbox option in a Steam theme. It sets a default value ('yes' or 'no') and links different CSS files to each option. This allows users to toggle features or styles on or off, such as enabling or disabling specific visual elements.
```json
{
"Conditions": {
"A Boolean Checkbox": {
"default": "yes",
"description": "A simple boolean checkbox",
"tab": "General",
"values": {
"no": {
"TargetCss": {
"affects": ["Recoil"],
"src": "no.css"
}
},
"yes": {
"TargetCss": {
"affects": ["Recoil"],
"src": "yes.css"
}
}
}
}
}
}
```
--------------------------------
### JavaScript DOM Element Finder Helper Function
Source: https://github.com/steamclienthomebrew/steambrew/blob/main/apps/docs/src/themes/advanced/scripting.md
Demonstrates using the `window.opener.Millennium.findElement` helper function to reliably find DOM elements, even when Steam's UI is not fully loaded. It includes an example with a timeout to prevent infinite waiting.
```javascript
// No matter how long the DOM or Steam's UI takes to load, this helper function will find target DOM element (if it exists)
const elements = await window.opener.Millennium.findElement(window.document, 'body');
// Timeout and reject the promise if the element isn't found within 3 seconds
const timeoutElements = await window.opener.Millennium.findElement(window.document, 'body', 3000);
console.log(elements, timeoutElements); // the