Skip to content

Commit 9c142c1

Browse files
committed
Rename to establish order, add DevTools doc
1 parent 8d98840 commit 9c142c1

12 files changed

+45
-0
lines changed
File renamed without changes.
File renamed without changes.

docs/ext-dev/getting-started.md renamed to docs/02-ext-dev/01-getting-started.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
---
2+
description: Information on getting started with the sample extension
3+
---
4+
15
# Getting started
26

37
A sample extension is provided to start development quickly:
File renamed without changes.
File renamed without changes.
File renamed without changes.

docs/ext-dev/pitfalls.md renamed to docs/02-ext-dev/05-pitfalls.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Pitfalls
22

3+
There are some important pitfalls you may encounter when writing moonlight extensions.
4+
35
## Web vs Node.js
46

57
Because of the Electron process model, extensions have two entrypoints: one on the web side (where the actual Discord app runs) and one on the Node.js side (where DiscordNative and such live).
File renamed without changes.

docs/02-ext-dev/07-devtools.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Using DevTools
2+
3+
The Chrome DevTools is a panel/window that offers several utilities for web development. Normally, it is intended for the creators of the target application, but it also serves as an excellent tool for client modders.
4+
5+
## Enabling DevTools
6+
7+
In some branches of Discord, the following is required in the `settings.json` file (*not* the moonlight config file):
8+
9+
```json
10+
"DANGEROUS_ENABLE_DEVTOOLS_ONLY_ENABLE_IF_YOU_KNOW_WHAT_YOURE_DOING": true
11+
```
12+
13+
## Reading module sources
14+
15+
See the [helpful extensions](/docs/ext-dev/helpful-exts) page first for `patchAll` and how to use Spacepack.
16+
17+
To see the source of a module, print the function with `spacepack.inspect`:
18+
19+
```js
20+
spacepack.inspect(/* module ID */)
21+
```
22+
23+
The returned value will be a function you can double click to see the module source. The bottom left "Pretty print" button can be used to make the output more readable. It is suggested to disable pretty printing temporarily when writing patches.
24+
25+
You can chain `inspect` with `findByCode` (or an equivalent) when trying to find the source of a patch in a rush:
26+
27+
```js
28+
spacepack.inspect(spacepack.findByCode(/* finds */)[0].id)
29+
```
30+
31+
The pattern `n(/* some number */)` represents a require, and is another module ID inside of the argument. You can pass that module ID to `spacepack.inspect` to read the required module source.
32+
33+
## Using the debugger
34+
35+
You can set breakpoints on Webpack modules to inspect the variables at runtime. Click on the left sidebar to set a breakpoint.
File renamed without changes.

0 commit comments

Comments
 (0)