This document introduces the plugins involved in the development of GenUI and how to configure them. Plugins play an important role in extending the functionality of GenUI, providing developers with a more flexible development experience.
The plugins here refer to the dependency libraries required in the development of GenUI. The official plugins are stored in the GenUI Plugins repository.
The current official plugins include:
gen_makepad_http
: A plugin that provides HTTP network request support.In the GenUI project, plugins consist of the following two parts:
token.toml
file)Each plugin needs to include a file called token.toml
. The GenUI compiler provides syntax enhancements for Rust scripts by dynamically loading this file.
Here is an example of a complete token.toml
configuration file:
The following is the specific configuration of the [plugin]
section in the token.toml
file:
Field | Type | Description |
---|---|---|
name | String | Plugin name (unique identifier). |
authors | Vec<String> | Plugin author list. |
version | String | Plugin version number. |
description | String | Plugin functional description. |
category | String | Plugin category (such as network, UI, etc.). |
repo | Object | Plugin code repository information. |
The [macros]
section defines the dynamic code block of the plugin. When the GenUI compiler encounters the specified macro, it will call the corresponding code for processing.
Field | Type | Description |
---|---|---|
category | String | Indicates the category of the macro, such as prop_macro . |
stmts | String | Dynamic code block used to process the logic of the macro. |
Functional Description:
When the compiler encounters the http_get!
macro in the script, it will execute the code in stmts
for dynamic processing. The purpose of the above code is to expand a cx
parameter to the syntax tree (tt) inside the macro, and return true
if the processing is successful.
The [dependencies]
section declares the dependencies of the plugin.
Field | Type | Description |
---|---|---|
serde | String | Library for serialization and deserialization. |
lazy_static | String | Library for defining static variables. |
serde_json | String | Library for processing JSON data. |
token.toml
must contain [plugin]
, [macros]
, and [dependencies]
sections.stmts
) meets the project requirements to avoid potential compilation errors.Through the above configuration and usage instructions, developers can efficiently integrate and use GenUI's plugin system.