Skip to content

Commit f978d9a

Browse files
committed
Initial commit
0 parents  commit f978d9a

23 files changed

+9026
-0
lines changed

.github/workflows_/deploy.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
deploy:
10+
name: Deploy to GitHub Pages
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
- uses: actions/setup-node@v3
15+
with:
16+
node-version: 18
17+
cache: pnpm
18+
19+
- name: Install dependencies
20+
run: pnpm install --frozen-lockfile
21+
- name: Build website
22+
run: pnpm run build
23+
24+
- name: Deploy to GitHub Pages
25+
uses: peaceiris/actions-gh-pages@v3
26+
with:
27+
github_token: ${{ secrets.GITHUB_TOKEN }}
28+
publish_dir: ./build
29+
user_name: github-actions[bot]
30+
user_email: 41898282+github-actions[bot]@users.noreply.github.com

.gitignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Dependencies
2+
/node_modules
3+
4+
# Production
5+
/build
6+
7+
# Generated files
8+
.docusaurus
9+
.cache-loader
10+
11+
# Misc
12+
.DS_Store
13+
.env.local
14+
.env.development.local
15+
.env.test.local
16+
.env.production.local
17+
18+
npm-debug.log*
19+
yarn-debug.log*
20+
yarn-error.log*

.prettierrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"printWidth": 80,
3+
"trailingComma": "none",
4+
"tabWidth": 2,
5+
"singleQuote": false
6+
}

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# moonlight-mod.github.io
2+
3+
The official website and documentation for [moonlight](https://github.com/moonlight-mod/moonlight).

babel.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
presets: [require.resolve("@docusaurus/core/lib/babel/preset")]
3+
};

docs/dev/_category_.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"label": "moonlight developers",
3+
"position": 3
4+
}

docs/dev/setup.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Project setup
2+
3+
## Building from source
4+
5+
You will need [pnpm](https://pnpm.io), as moonlight uses it for dependency and workspace management.
6+
7+
- Clone the repository.
8+
- Install dependencies with `pnpm i`.
9+
- Build the project with `pnpm run build`.
10+
- For working on moonlight, a watch mode is available with `pnpm run dev`.
11+
12+
## Project structure
13+
14+
moonlight is split into a [pnpm workspace](https://pnpm.io/workspaces). The project is comprised of multiple packages:
15+
16+
- `core`: core code and utilities responsible for loading extensions
17+
- `injector`: the entrypoint for moonlight loaded by the patched Discord client
18+
- loads the config and detected extensions from disk and forwards them to the other stages
19+
- loads host modules
20+
- sets up `node-preload` to be ran when the browser window is created
21+
- `node-preload`: ran before Discord's code on the Node side
22+
- receives the config/detected extensions from `injector` and forwards it to `web-preload`
23+
- loads node modules
24+
- loads `web-preload` and forwards some inforation to it
25+
- `web-preload`: ran before Discord's code on the web side
26+
- receives the loaded config and detected extensions from `node-preload`
27+
- loads extensions and installs their Webpack modules and patches
28+
- `core-extensions`: built-in extensions that come with every moonlight install, mostly libraries
29+
- `types`: types for moonlight's core, core extensions, and plugin manifests/exports
30+
31+
## Build system
32+
33+
moonlight uses [esbuild](https://esbuild.github.io) as its build system (`build.mjs`). This script is responsible for outputting `injector`, `node-preload`, and `web-preload` into `dist`, along with all core extensions.

docs/ext-dev/_category_.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"label": "Extension developers",
3+
"position": 2
4+
}

docs/ext-dev/getting-started.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Getting started
2+
3+
## Sample extension
4+
5+
A sample extension is provided to start development quickly:
6+
7+
- Pre-configured build system (esbuild)
8+
- TypeScript support
9+
- Both web and Node.js entrypoints
10+
- Example patch & Webpack modules
11+
12+
You can view it [here](https://github.com/moonlight-mod/sample-extension).

docs/ext-dev/helpful-exts.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Helpful extensions
2+
3+
This is a list of helpful extensions that can be used to aid extension development.
4+
5+
## Config options
6+
7+
These aren't extensions, but rather options in the moonlight config:
8+
9+
- `devSearchPaths`: An array of directories to recursively search for built extensions (`manifest.json`).
10+
- When developing extensions, use the `dist` folder instead of the root folder. This is because the `manifest.json` resides in the root of the source code, but does not have the built files, which wastes time resolving files that will never exist.
11+
- `loggerLevel`: The level to log at. If not set, defaults to `info`.
12+
- `patchAll`: Set to `true` to wrap every Webpack module in a function. This slows down client starts significantly, but can make debugging easier.
13+
14+
## Common
15+
16+
Common exposes multiple Webpack modules useful for development:
17+
18+
- `common_react`: Discord's version of React (required to be in scope for JSX)
19+
- `common_flux`: Discord's version of Flux
20+
- `common_stores`: A proxy around Discord's Flux stores
21+
- Access stores as properties, e.g. `require("common_stores").UserStore`
22+
- `common_http`: A small HTTP client
23+
24+
## Disable Sentry & No Track
25+
26+
Both of these extensions do not provide any utilities, but prevent your client from sending metrics to Discord, which lessens the risk of moonlight related errors being reported. These should always be enabled. These are not magical tools to prevent account suspension, and you should always consider safety when writing an extension (especially one that makes requests automatically).
27+
28+
## Spacepack
29+
30+
Spacepack allows you to find and inspect Webpack modules. The "Add to global scope" setting is suggested, so you can use Spacepack from within DevTools.
31+
32+
- `require`: Standard Webpack require.
33+
- `inspect`: Fetch a Webpack module by its ID and return an isolated copy of it, which can be double-clicked in DevTools to inspect the source code.
34+
- `findByCode`, `findByExports`: Returns an array of Webpack modules that has code/exports that match the arguments.
35+
- `findObjectFromKey`, `findObjectFromValue`, `findObjectFromKeyValuePair`, `findFunctionByStrings`: Search the exports of a Webpack module to find an object or function using the given arguments.
36+
- `modules`, `cache`: The Webpack modules and cache objects.

0 commit comments

Comments
 (0)