Local Development
Two places are at work during development: the Vite development server runs in the terminal, and the script manager in the browser loads the development script on matching pages. This page shows how to connect the two and view injection status in the terminal.
Start the Development Server
pnpm devThe project's dev script should be makoo dev. For temporary changes such as a different port, pass arguments directly, for example pnpm exec makoo dev --port 5174; options you don't pass keep the project configuration. For all arguments, see CLI Commands.
Install the Development Script
- Open the local address printed in the terminal and confirm the installation on the page the script manager shows.
- Open a target page matched by
monkey.userscript.match.
The development script loads code from the local development server, so keep pnpm dev running during development. After changing metadata such as @match, confirm in the script manager that the development script has been updated, and reinstall it if necessary.
For how updates work after code changes, see Hot Updates.
View Injection Status in the Terminal
In the plugin list of vite.config.ts, keep makoo(...) and also add makooDev():
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import { makoo, makooDev } from '@makoojs/cli';
export default defineConfig({
plugins: [
vue(),
makoo({
entry: './src/main.ts',
app: { name: 'my-script', version: '0.0.1' },
monkey: { userscript: { match: ['https://example.com/*'] } }
}),
makooDev()
]
});Projects generated by the scaffold don't include makooDev() by default; add it manually when needed. It only takes effect in the development server and doesn't affect the build output. Without it, the terminal only prints Makoo's startup info (version and addresses), followed by Vite's own output and shortcuts. With it, starting with vite directly shows the same terminal as makoo dev.
The page reports status through a separate bridge port, 9999 by default. When another project's dev server is already using it, the terminal prints a warning and shows no injections while Vite keeps running; pass another port with makooDev({ port }). See makooDev() for all options.
After you open the target page, the Runtime line on the terminal home page shows the number of connections. Each Core instance counts as one connection, and one page can have several. Press t to open the injections page:
Runtime 1/1 · Client 1 · Makoo1
Makoo Injections
STATUS NAME KIND
● mounted panel component
● bound └ site-button attached listener
● collecting cards component each
● mounted └ child #1 child
● failed └ child #2 child
MAKOO_MOUNT_FAILED: Failed to mount "cards#2"
● failed shortcut standalone listener
MAKOO_TARGET_WAIT_TIMEOUT: Timed out waiting for listener "shortcut"
5 injections · 2 mounted · 1 collecting · 2 failed- Each top-level injection gets one row, and attached listeners are indented below their owning component.
- An
injectEach()injection shows its group status, followed by one indented row per child injection in document order, labeledchild #1,child #2, and so on. - The first line shows the sequence number and connection identifiers of the instance being viewed.
- When a top-level injection or a child is
failed, the next line shows the error code and message oflastError, truncated if too long. - The last line counts top-level injections and child injections together; attached listeners aren't counted.
- Errors from status subscribers and
observe()callbacks appear in theDiagnosticssection, which keeps at most 5 entries. Event handler errors are not shown here; check the browser console. - When there are several Core instances, press
nto switch to the next one.
When the page reloads, the old connection disconnects and the new page reconnects; the terminal automatically shows the new page's status.
makooDev() only reads and reports status; it never starts, stops, or removes injections. console.log output from business code and full error objects in the browser still need to be viewed in the browser console.
Terminal Shortcuts
With makooDev() added and running in an interactive terminal, just press the key; no Enter needed:
| Key | Action |
|---|---|
i | Open the development script install page (shown when available) |
t | Toggle between the injections page and the home page |
n | View the injections of the next Core instance |
l | Toggle between the logs page and the home page |
c | Open the logs page and clear the screen |
r | Restart the Vite server |
u | Return to the home page to see the addresses |
o | Open the browser the Vite way |
h | Open help; press again to return |
Esc | On the help page, return to the previous page; on other pages, return to the home page |
q / Ctrl+C | Quit |
The home page shows the number of new development logs; press l to view the output of Vite and the toolchain.
Non-Interactive Environments
When output is redirected or running in CI, the interactive pages are not shown. With makooDev() added, the home page is printed once at startup, and after that only changes in the number of connections and development logs are printed as plain text; the injection table is not output.