diff --git a/.vitepress/config.mts b/.vitepress/config.mts
index 8a40a56..4c9bcd5 100644
--- a/.vitepress/config.mts
+++ b/.vitepress/config.mts
@@ -244,6 +244,10 @@ export default defineConfig({
text: "Window Resize",
link: "/docs/utilities/window-resize",
},
+ {
+ text: "Fullscreen and Orientation",
+ link: "/docs/utilities/fullscreen-orientation",
+ },
],
},
{
diff --git a/docs/getting-started/create-plugin.md b/docs/getting-started/create-plugin.md
index f972f93..33fdf64 100644
--- a/docs/getting-started/create-plugin.md
+++ b/docs/getting-started/create-plugin.md
@@ -1,201 +1,182 @@
---
lang: en-US
-title: Create Acode Plugin
+title: Create an Acode Plugin
+description: Set up a plugin project from a template, run it on your phone, and publish it.
---
-# Create Acode Plugin
+# Create an Acode Plugin
-## Overview
+Plugins are written in JavaScript (or TypeScript) and run inside Acode. This page takes you from an empty folder to a plugin installed on your device and, when you are ready, published.
-Acode opens up a world of possibilities with its extensibility through plugins. In this guide, you'll learn how to create plugins using JavaScript, with the added option of TypeScript. Whether you're customizing your coding experience or adding entirely new features, creating plugins for Acode is a straightforward and rewarding process.
-
-## Plugin Structure
-
-Acode plugins follow a specific structure within a zip file. The necessary components include:
-
-1. **plugin.json:**
-
- - Contains crucial information about the plugin, such as its name, version, author, and more.
-
-2. **main.js:**
-
- - The heart of the plugin, this file contains the actual plugin code.
+::: tip New to plugins?
+Read [Understanding Plugins](./understanding-plugin.md) after this page. It explains how Acode loads and runs your code.
+:::
-3. **readme.md:**
- - Contains the description or about plugin
+## Plugin structure
-3. **changelogs.md:**
- - contains changelogs of your plugin updates.
+A plugin is a zip file with these files at its root:
-## Plugin Templates
+| File | Required | Purpose |
+| --- | --- | --- |
+| `plugin.json` | Yes | The [manifest](../plugin-essentials/manifest.md): id, name, version and more. |
+| `main.js` | Yes | The [core file](../plugin-essentials/core-file.md) with your plugin code. Its name and location are set by `main` in the manifest. |
+| `readme.md` | Recommended | Description shown in the plugin store. |
+| `icon.png` | Recommended | Icon shown in the plugin store (50 KB or smaller). |
+| `changelogs.md` | No | Release notes. Also list it in `files` in the manifest. |
-To make your journey smoother, we provide comprehensive plugin templates, which are preconfigured and catering to various use cases:
+## Templates
-1. **[JavaScript Template](https://github.com/Acode-Foundation/acode-plugin)** : Javascript based template for plugin development and comes preconfigured
+Start from one of the official templates. Both come preconfigured with a bundler and build script that creates the zip for you.
-2. **[TypeScript Template](https://github.com/Acode-Foundation/AcodeTSTemplate)** : Typescript template for plugin development and comes with type checking and all typescript feature
+| Template | Use it when |
+| --- | --- |
+| [JavaScript template](https://github.com/Acode-Foundation/acode-plugin) | You want the simplest setup. |
+| [TypeScript template](https://github.com/Acode-Foundation/AcodeTSTemplate) | You want type checking and editor autocomplete for the Acode API. |
-## Getting Started
+You can also start from scratch or use a different bundler. The only hard requirement is a zip with `plugin.json` at its root and the file named by `main` at the path it declares.
-1. **Clone the Plugin Template:**
+## Set up the project
- - Choose the template that suits your needs and clone it.
+### 1. Clone a template
-2. **Customize plugin.json:**
+```sh
+git clone https://github.com/Acode-Foundation/acode-plugin.git my-plugin
+cd my-plugin
+```
- - Open the `plugin.json` file and update it with your plugin's information.
+Replace the URL with the TypeScript template if you prefer it.
-3. **Install the dependency:**
+### 2. Edit `plugin.json`
- - Install the required dependency by your package manager but first navigate to the plugin template folder by `cd acode-template`
+Set at least a unique `id`, a `name` and a `version`. Every field is explained in the [manifest reference](../plugin-essentials/manifest.md).
- ::: code-group
- ```sh [npm]
- $ npm install
- ```
+### 3. Install dependencies
- ```sh [pnpm]
- $ pnpm install
- ```
+::: code-group
+```sh [npm]
+$ npm install
+```
- ```sh [yarn]
- $ yarn install
- ```
+```sh [pnpm]
+$ pnpm install
+```
- ```sh [bun]
- $ bun install
- ```
- :::
+```sh [yarn]
+$ yarn install
+```
-4. **Develop Locally:**
+```sh [bun]
+$ bun install
+```
+:::
- - Use given commands to initiate a development server that watches for changes.
- - The development server automatically creates a plugin zip file, ready for installation.
-
- ::: code-group
- ```sh [npm]
- $ npm run dev
- ```
+### 4. Start the development server
- ```sh [pnpm]
- $ pnpm dev
- ```
+::: code-group
+```sh [npm]
+$ npm run dev
+```
- ```sh [yarn]
- $ yarn dev
- ```
+```sh [pnpm]
+$ pnpm dev
+```
- ```sh [bun]
- $ bun run dev
- ```
- :::
+```sh [yarn]
+$ yarn dev
+```
- - Or you can build every time manually on changes using(this will build production build):
+```sh [bun]
+$ bun run dev
+```
+:::
- ::: code-group
- ```sh [npm]
- $ npm run build
- ```
+The server watches your files and rebuilds the plugin zip whenever you save a change.
- ```sh [pnpm]
- $ pnpm build
- ```
+::: info
+The server only rebuilds on file changes. If you start it and change nothing, no zip is created yet.
+:::
- ```sh [yarn]
- $ yarn build
- ```
+If you prefer to build by hand, run the production build instead. It creates a smaller zip:
- ```sh [bun]
- $ bun run build
- ```
- :::
+::: code-group
+```sh [npm]
+$ npm run build
+```
-5. **Install the Plugin:**
+```sh [pnpm]
+$ pnpm build
+```
- - Use the **REMOTE** option in Acode's plugin manager.
- - This option is available on both sidebar extension tab or on Plugin page from settings.
- - Provide the plugin URL (e.g., `http://\:3000/dist.zip`) when prompted.
- - Or if you are building manually then you can use the **Local** option in Acode's plugin manager and select the plugin zip
+```sh [yarn]
+$ yarn build
+```
-:::info
-Development server will only build the zip on file changes
+```sh [bun]
+$ bun run build
+```
:::
-:::tip
-For local development, start a dev server using `npm run dev`. In Acode, use the **Remote** option, either from the **sidebar** or the **plugin page**. Enter the server URL, hit **Install**, and the plugin will be installed.
+### 5. Install the plugin in Acode
-It's more convenient to manage this from the sidebar. When you install a local plugin(either using url or selecting the zip), Acode will add a **reload** icon in the **Extensions** tab of the sidebar. This is useful because the server automatically builds the plugin ZIP when changes are made. Simply press the reload button to apply the latest changes instantly.
+Open Acode's plugin manager from either the **Extensions** tab in the sidebar or **Settings → Plugins**, then pick an install source:
-This makes plugin development a much smoother experience—previously, it was quite frustrating, but this feature was recently added to improve the workflow.
-:::
+- **Remote**: enter the URL of the zip served by your dev server, for example `http://:3000/dist.zip`. Use this while developing.
+- **Local**: choose a zip file on your device. Use this if you built by hand.
-## Creating Plugins with the CLI
+::: tip Reload without reinstalling
+Plugins installed from a URL or a local zip get a **reload** icon in the **Extensions** tab of the sidebar. After the dev server rebuilds the zip, tap reload to load the new version immediately.
+:::
-You can also quickly scaffold new Acode plugins using the [Acode Plugin CLI](https://github.com/itsvks19/acode-plugin-cli). This tool provides an interactive wizard to generate a plugin project from the official JavaScript or TypeScript templates.
+## Create a plugin with the CLI
-### Installation
+The community-maintained [Acode Plugin CLI](https://github.com/itsvks19/acode-plugin-cli) scaffolds a project from the official templates with an interactive wizard.
-If you have Rust installed, you can install the CLI with:
+Install it (requires [Rust](https://www.rust-lang.org/tools/install)):
-```bash
-cargo install acode-plugin-cli
+```sh
+$ cargo install acode-plugin-cli
```
-### Usage
+Run it:
-Run the CLI in your terminal:
-
-```bash
-acode-plugin-cli
+```sh
+$ acode-plugin-cli
```
-The wizard will guide you to:
-
-- Choose plugin name, ID, version, and description
-- Enter author information
-- Pick license and keywords
-- Select JavaScript or TypeScript template
-
-After completion, your plugin folder will be ready to use.
-
-## Building and Publishing
+The wizard asks for the plugin name, id, version and description, author details, license and keywords, and whether to use the JavaScript or TypeScript template. When it finishes, the project is ready to use.
-To share your plugin with the Acode community, follow these steps:
+## Build and publish
-1. **Bundle for production:**
-
- - Use `build` command to create a production build. which will be lower in size
+1. **Create a production build.** It is smaller than the development build.
::: code-group
+ ```sh [npm]
+ $ npm run build
+ ```
- ```sh [npm]
- $ npm run build
- ```
-
- ```sh [pnpm]
- $ pnpm build
- ```
-
- ```sh [yarn]
- $ yarn build
- ```
-
- ```sh [bun]
- $ bun run build
- ```
+ ```sh [pnpm]
+ $ pnpm build
+ ```
-2. **Publish:**
+ ```sh [yarn]
+ $ yarn build
+ ```
- - Publish your release build on [Acode's](https://acode.app) official website, making your plugin accessible to the broader community.
+ ```sh [bun]
+ $ bun run build
+ ```
+ :::
- - Tutorial for publishing a plugin : [Youtube](https://youtube.com/shorts/cxF2pxyN1HM?si=kQ5_BRtIO2RU-zhb)
+2. **Upload the zip** to [acode.app](https://acode.app) to publish it in the plugin store. Watch the [publishing walkthrough](https://youtube.com/shorts/cxF2pxyN1HM?si=kQ5_BRtIO2RU-zhb) if you have not done it before.
-## Tutorial
+To release an update, increase `version` in `plugin.json`, build again and upload the new zip. See [Publishing updates](../plugin-essentials/manifest.md#publishing-updates).
-- Checkout a small tutorial of 👉 [How to create Acode Plugins?](https://youtu.be/ls--txHX3RQ?si=ZSvJMsb1KFeQA8zd)
+## Video tutorial
-## Customization
+[How to create Acode plugins](https://youtu.be/ls--txHX3RQ?si=ZSvJMsb1KFeQA8zd)
-Certainly! You have the flexibility to either utilize your own template or start your plugin from scratch. Additionally, you're free to employ alternative bundlers and tools. We'll delve deeper into these customization possibilities in subsequent sections.
+## Next steps
-Happy coding, and may your plugins bring new dimensions to your Acode experience! 🚀✨
+- [Understanding Plugins](./understanding-plugin.md): the lifecycle of a plugin
+- [Core File](../plugin-essentials/core-file.md): what `main.js` must contain
+- [Acode API](../global-apis/acode.md): the API your plugin talks to
diff --git a/docs/getting-started/intro.md b/docs/getting-started/intro.md
index c160722..d36d995 100644
--- a/docs/getting-started/intro.md
+++ b/docs/getting-started/intro.md
@@ -1,59 +1,36 @@
---
lang: en-US
title: Acode Plugins
+description: What Acode plugins are, how to install them, and where to go to build your own.
---
-# Acode Plugins
-
-> Welcome to the world of Acode plugins! 🚀
-
-
-### What are Acode Plugins?
-
-**Acode** plugins serve as powerful tools to enhance and extend the functionality of your **Acode editor**. Whether you're looking to introduce new features or tweak existing ones, plugins provide a flexible and customizable way to tailor Acode to your specific needs.
-
-### Language Flexibility
-
-Acode plugins are primarily written in JavaScript, offering a familiar and widely-used language for developers. Additionally, for those who prefer TypeScript, **good news 🥳** — Acode supports `TypeScript` for plugin development, providing the benefits of static typing and improved developer experience.
-## Installing Acode Plugins
-
-Discovering and integrating plugins into your Acode editor is a simple and customizable process. There are multiple methods to install plugins, ensuring flexibility and convenience for developers. Before you proceed, it's essential to exercise caution when installing plugins from unknown sources, as they may potentially contain malicious code.
-
-### Installation Methods:
-
-1. **Local Installation:**
- - Download the plugin file(`.zip`) to your device.
- - Open Acode and navigate to **Settings**.
- - Click on **Plugins** and then the `'+'` icon.
- - Select **LOCAL** and choose the downloaded plugin file.
+# Acode Plugins
-2. **Remote Installation:**
- - If you have a plugin file URL (e.g., a plugin file hosted on GitHub):
- - Open Acode and go to **Settings**.
- - Navigate to **Plugins** and click on the `'+'` icon.
- - Choose **REMOTE** and enter the plugin file URL.
+Plugins extend the Acode editor: add commands, themes, languages, formatters, sidebar panels and more, or change how existing features behave.
-3. **Acode Plugins Manager:**
- - Access the Acode **Settings** and click on **Plugins**.
- - Explore the available plugins and select the one you want.
- - Click on **Install** to seamlessly integrate the chosen plugin into your Acode editor.
+Plugins are written in **JavaScript**. **TypeScript** is supported too, and the [official TypeScript template](./create-plugin.md#templates) gives you type checking for the Acode API.
-4. **Acode SideBar:**
- - Click on three horizontal slashes from top left corner
- - Select plugin icon and Explore the plugins
+## Install a plugin
+Open the plugin manager from **Settings → Plugins**, or from the **Extensions** tab of the sidebar (open the sidebar with the menu button at the top left). Then pick one of these ways to install:
-:::info
+| Method | Steps |
+| --- | --- |
+| **From the store** | Browse the list, choose a plugin and tap **Install**. |
+| **Local file** | Download the plugin `.zip` to your device. Tap **+**, choose **LOCAL** and select the file. |
+| **Remote URL** | Tap **+**, choose **REMOTE** and enter the URL of the plugin `.zip`, for example one hosted on GitHub. |
-**Source Persistence:**
-Once installed, plugins remember their source. If you choose to uninstall and reinstall, the plugin will be sourced from the same location, ensuring consistency in your development environment.
+::: info Source persistence
+Acode remembers where a plugin was installed from. If you uninstall and reinstall it, it is fetched from the same source again.
:::
-:::danger
-
-**Exercise Caution:**
-It's crucial to exercise caution when installing plugins, especially from unfamiliar sources. Plugins have the potential to contain malicious code, so be discerning and opt for reputable and well-known plugins whenever possible.
+::: danger Only install plugins you trust
+A plugin runs inside Acode with access to your files and the editor. Install plugins from reputable authors, and be careful with `.zip` files and URLs from unknown sources.
:::
-
-Your Acode journey has just begun. Dive in, experiment, and let your coding adventure flourish in this realm of endless possibilities! 🚀✨
+## Build your own
+
+1. [Create a plugin](./create-plugin.md): set up a project from a template and run it on your device.
+2. [Understanding Plugins](./understanding-plugin.md): how Acode loads and unloads plugin code.
+3. [Manifest](../plugin-essentials/manifest.md) and [Core File](../plugin-essentials/core-file.md): the two files every plugin needs.
+4. [Acode API](../global-apis/acode.md): what your plugin can use.
diff --git a/docs/getting-started/understanding-plugin.md b/docs/getting-started/understanding-plugin.md
index 15e3396..4f3c8e3 100644
--- a/docs/getting-started/understanding-plugin.md
+++ b/docs/getting-started/understanding-plugin.md
@@ -1,3 +1,8 @@
+---
+title: Understanding Plugins
+description: How Acode loads, runs and unloads a plugin.
+---
+
# Understanding How Plugins Work
This page is the practical mental model for writing Acode plugins: what Acode does, what your plugin must do, and what happens during load/unload.
diff --git a/docs/global-apis/acode.md b/docs/global-apis/acode.md
index 04197c2..668fba8 100644
--- a/docs/global-apis/acode.md
+++ b/docs/global-apis/acode.md
@@ -1,3 +1,8 @@
+---
+title: Acode
+description: "The global acode object: register plugins, load modules, and more."
+---
+
# Acode
## window.acode or acode
@@ -6,92 +11,102 @@ The `acode` object is the global object that provides access to the **Acode API*
## Methods
-### `setPluginInit(pluginId: string, init: Function, settings? Object)`
+### `setPluginInit(pluginId, init, settings?)`
-This method is used to register the plugin. This method takes two parameters, `pluginId` and init function. The `pluginId` is the ID of your plugin. The `init` function is the function that will be called when the plugin is loaded.
+Registers the function Acode calls to start your plugin. See [Understanding Plugins](../getting-started/understanding-plugin.md) for when it runs.
-**Example:**
+| Parameter | Type | Description |
+| --- | --- | --- |
+| `pluginId` | `string` | The `id` from your `plugin.json`. |
+| `init` | `(baseUrl, $page, options) => void \| Promise` | Called when the plugin loads. See [`init` arguments](#init-arguments). |
+| `settings` | `PluginSettings` | Optional. Adds a settings page for your plugin. See [Plugin settings](#plugin-settings). |
```js
-acode.setPluginInit('com.example.plugin', (baseUrl, $page, cache) => { // [!code focus]
+acode.setPluginInit("com.example.plugin", async (baseUrl, $page, options) => {
const commands = acode.require("commands");
commands.addCommand({
- name: 'example-plugin',
- bindKey: { win: 'Ctrl-Alt-E', mac: 'Command-Alt-E' },
+ name: "example-plugin",
+ bindKey: { win: "Ctrl-Alt-E", mac: "Command-Alt-E" },
exec: () => {
- $page.innerHTML = `
-
Example Plugin
-
This is an example plugin.
- `;
+ $page.innerHTML = `
Example Plugin
`;
$page.show();
},
});
});
```
-### `init(baseUrl: string, $page: WCPage, options: object)`
-
-When the init function is called, it will receive 3 parameters:
-
-* `baseUrl: string` The base URL of the plugin. You can use this URL to access the files in the plugin directory.
-
-* `$page: WcPage` This page object can be used to show content.
-
-* `options: object` This object can be used to access the cached files.
-
- * `cacheFileUrl: string` Url of the cached file.
-
- * `cacheFile File: object` File object of the cached file. Using this object, you can write/read the file.
- * `firstInit: boolean` If this is the first time the plugin is loaded, this value will be true. Otherwise, it will be `false`.
- * `ctx: PluginContext | null` Your plugin's native context: encrypted secret storage and permission checks. It may be `null` if the trusted native session is unavailable, so guard it before use. See [Plugin Context (`ctx`)](../plugin-essentials/plugin-context.md).
- * `fileIcons` Plugin-bound [File Icons](../utilities/file-icons.md) API. Same instance as `acode.require("fileIcons")` captured in the main script. Available from **versionCode `1012`**.
-
-### `Settings Object`
-
-This parameter is optional. You can use this parameter to define the settings of the plugin. The settings will be displayed in the plugin page.
-
-Settings requires the following properties
-
-* `list: Array