Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ For information on new releases of the Extensibility API see:

## Introduction

Extensions are self-contained modules which users can add to Studio Pro. This means that with extensibility you can add new features and functionality to Studio Pro. The Extensibility API is an API that allows developers to interact with a curated list of internal systems of Studio Pro. This documentation provides guides and reference documentation for the Extensibility API.
Extensions are self-contained modules that enhance Studio Pro by adding new features and functionality. The Extensibility API allows you to interact with a curated set of internal systems, extending Studio Pro’s capabilities with functionality you can define yourself.

The API is provided in two flavors, depending which language you are developing in. C# and web based (via Typescript):
The API is provided in two versions, depending on the language you are developing in:
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,32 @@ url: /apidocs-mxsdk/apidocs/extensibility-api-10/packaging-your-extension
weight: 30
---

# Packaging your extension
# Packaging Your Extension

Once you have finished development on your extension, you might want to package it into an add-on module so that others can start using it. Once you have created the add-on module, it can then be published to the Mendix Marketplace for your extension users to download into their Studio Pro app.
After completing development on your extension, you can package it into an add-on module so others can use it. Once packaged, the module can be published to the Mendix Marketplace, allowing other users to download it into their Studio Pro apps.

To package your extension, you will still need the `--enable-extension-development` command line option turned on. Create a new module in your Studio Pro app containing your dev extension, give it an appropriate name. Open the module's settings form and set it to be an Add-on module. In the `Extension name` dropdown, select the extension you want to package into it.
To package your extension, follow the steps below:

1. Make sure the `--enable-extension-development` command-line option is enabled.
2. In your Studio Pro app, create a new module and include your development extension.
3. Give the module a name.
4. Open the module's settings and in the **Export** tab, choose **Add-on module**.
5. In the **Extension name** drop-down, select the extension you want to package into it.

![Extension Add-on Module](/attachments/apidocs-mxsdk/apidocs/extensibility-api/extensionAddOnModule.png)

After you've created your add-on module with its extension, you can now export it, by right-clicking the module in the App Explorer and choosing `Export add-on module package`, as shown below.
After you have created your add-on module with its extension, you can export it by right-clicking the module in the App Explorer and selecting **Export add-on module package**.

![Export Module](/attachments/apidocs-mxsdk/apidocs/extensibility-api/exportAddOnModule.png)

You can now save the add-on module to a location of your choice.

# Importing the extension add-on module
# Importing the Extension Add-on Module

Once the add-on module is available to a Studio Pro user, they are now able to add it in their application. They can so so by right-clicking the app in the App Explorer and choosing `Import module package`, as shown below.
When the add-on module is available to a Studio Pro user, they are now able to add it in their application. This is done by right-clicking the app in the **App Explorer** and selecting **Import module package**.

![Import Module](/attachments/apidocs-mxsdk/apidocs/extensibility-api/importAddOnModule.png)

Once an add-on module containing an extension is imported in the app, Studio Pro will show a warning to the user, asking to trust the extension contained in it. If the user does not choose to trust, the module will still be imported but the extension inside it won't be loaded.
When an add-on module containing an extension is imported in the app, Studio Pro will show a warning to the user, asking to trust the extension contained in it. If the user does not choose to trust, the module will still be imported but the extension inside it will not be loaded.

![Trust Extension](/attachments/apidocs-mxsdk/apidocs/extensibility-api/trustExtension.png)
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,25 @@ weight: 20

## Introduction

Extensions can be written in Typescript or other web languages, described here, or using a C# API which is documented separately in [Extensibility API for C# Developers](/apidocs-mxsdk/apidocs/csharp-extensibility-api-10/).
Extensions can be written in TypeScript or other web languages, described here, or using a C# API, which is documented in [Extensibility API for C# Developers](/apidocs-mxsdk/apidocs/csharp-extensibility-api-10/).

For more detailed information on the web API, see the [Mendix Studio Pro Web Extensibility API reference documentation](http://apidocs.rnd.mendix.com/10/extensions-api/index.html).

## Prerequisites

* You need at least a basic understanding of the Mendix platform.
* You need some understanding of the Mendix Model.
* You need to have some TypeScript development experience.
To use the Web Extensibility API, you must have:

* A basic understanding of the Mendix platform
* Some understanding of the Mendix Model
* Some TypeScript development experience

## Getting Started

For detailed explanation on how to get started with extensions, check out [Get Started with the Web Extensibility API](/apidocs-mxsdk/apidocs/web-extensibility-api-10/getting-started/).
For detailed information on how to get started with extensions, see [Get Started with the Web Extensibility API](/apidocs-mxsdk/apidocs/web-extensibility-api-10/getting-started/).

## How-tos

Here is a list of how-tos for you to begin with:
Below is a list of how-tos for you to begin with:

* [How to Create a Dockable Pane Using Web API](/apidocs-mxsdk/apidocs/web-extensibility-api-10/dockable-pane-api/)
* [How to Interact With Local App Files Using Web API](/apidocs-mxsdk/apidocs/web-extensibility-api-10/local-app-files-api/)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,17 @@ weight: 2

## Introduction

Studio Pro extensions can be developed using typescript and use standard web development technologies to extend the Studio Pro development environment. This guide shows you how to set up a basic development environment for building an extension using the web extensibility API.
Studio Pro extensions can be developed using TypeScript and use standard web development technologies to extend the Studio Pro development environment. This document describes how to set up a basic development environment for building an extension using the web extensibility API.

For more information see the [Mendix Studio Pro Web Extensibility API](http://apidocs.rnd.mendix.com/10/extensions-api/index.html).

### Prerequisites

You will need the following prerequisites:

* Mendix Studio Pro version 10.21.0 or higher [Mendix Studio Pro](https://marketplace.mendix.com/link/studiopro).
* Install the latest Studio Pro version from the Mendix [Marketplace](https://marketplace.mendix.com/link/studiopro/).
* A development IDE to develop your extensions. We recommend using [Visual Studio Code](https://code.visualstudio.com/).
* Install the latest version 22.x.x of Node: https://nodejs.org/en/download.
* [Mendix Studio Pro](https://marketplace.mendix.com/link/studiopro) version 10.21.0 or higher
* A development IDE to develop your extensions. Mendix recommends using [Visual Studio Code](https://code.visualstudio.com/)
* Install the latest version 22.x.x of Node: https://nodejs.org/en/download

{{% alert color="info" %}}
Extensions can be built on any operating system as the underlying framework is cross-platform.
Expand All @@ -35,96 +34,84 @@ This section will show you how to build and test an extension.

### Building the Extension

From within Visual Studio Code:
Follow the below steps from within Visual Studio Code.

1. Select **File** -> **Open Folder**
1. Navigate to the folder you just extracted your extension source code to.
1. Click **Select Folder**.
1. Select **Yes** if you are asked whether you trust this folder.
1. Now open a Terminal by selecting **Terminal** -> **New Terminal** from the top menu.
1. From the Terminal type `npm install`. This installs all dependencies for the extension
1. Build your extension using the command `npm run build` in the terminal.
1. Select **File** > **Open Folder**.
2. Navigate to the folder where you created your extension.
3. Click **Select Folder**.
4. Select **Yes** if you are asked whether you trust this folder.
5. Open a Terminal from the top menu by clicking **Terminal** > **New Terminal**.
6. From the Terminal, type `npm install`. This installs all dependencies for the extension.
7. Build your extension using the command `npm run build` in the terminal.

Once completed you should now have a build artifact which we can deploy to your Mendix app.
Once completed, you should now have a build artifact which we can deploy to your Mendix app.

You can explore the extension a bit more to understand what it will do when it is installed. Do the following:
### Exploring the Created Extension

1. From the Explorer window navigate to `src/main/index.ts` select it to open the file.
You can explore the extension to understand what it does when it is installed. Do the following:

1. From the Explorer window, navigate to `src/main/index.ts` and select it to open the file.

Reading through the source code you should see the following:

1. Line 7 adds a menu

```typescript
await studioPro.ui.extensionsMenu.add({
menuId: "myextension.MainMenu",
caption: "MyExtension Menu",
subMenus: [{ menuId: "myextension.ShowTabMenuItem", caption: "Show tab" }],
});
```

1. Line 14 opens a tab

```typescript
// Open a tab when the menu item is clicked
studioPro.ui.extensionsMenu.addEventListener("menuItemActivated", (args) => {
if (args.menuId === "myextension.ShowTabMenuItem") {
studioPro.ui.tabs.open(
{
title: "My Extension Tab",
},
{
componentName: "extension/myextension",
uiEntrypoint: "tab",
a. Line 7 adds a menu

```typescript
await studioPro.ui.extensionsMenu.add({
menuId: "myextension.MainMenu",
caption: "MyExtension Menu",
subMenus: [{ menuId: "myextension.ShowTabMenuItem", caption: "Show tab" }],
});
```

2. Line 14 opens a tab

```typescript
// Open a tab when the menu item is clicked
studioPro.ui.extensionsMenu.addEventListener("menuItemActivated", (args) => {
if (args.menuId === "myextension.ShowTabMenuItem") {
studioPro.ui.tabs.open(
{
title: "My Extension Tab",
},
{
componentName: "extension/myextension",
uiEntrypoint: "tab",
}
);
}
);
}
});
```
});
```

When you install the extension you will see a new menu item within Studio Pro.
When you install the extension, you will see a new menu item within Studio Pro.

### Testing the Extension

To test the extension, do the following in File Explorer.

1. Navigate to the folder where you extracted the extension source code.
1. Open the `dist` folder.
1. Copy the `myextension` folder.
1. Navigate to the folder where you created your app.
1. Create a new folder called `webextensions`.
1. Paste the `myextension` folder into the `webextensions` folder you just created.

The extension files have now been added to the app.

1. Start Studio Pro with the following command line parameters to tell it to use the extensions in the folder.
2. Open the `dist` folder.
3. Copy the `myextension` folder.
4. Navigate to the folder where you created your app.
5. Create a new folder called `webextensions`.
6. Paste the `myextension` folder into the `webextensions` folder you just created. This adds the extension files to the app.
7. Start Studio Pro with the following command-line parameters to tell it to use the extensions in the folder:

`--enable-extension-development --webview-remote-debugging`

These flags instruct Studio Pro to do the following:

* Load extensions from the `webextensions` folder
* Enable web debugging tools which will be useful when developing your extension

1. In Studio Pro, open the new app.
* Enable web debugging tools

You will see a new `Extensions` item in the top menu.
8. In Studio Pro, open the new app. You will see a new `Extensions` item in the top menu.

{{% alert color="warning" %}}
Extension names used in place of `myextension` must only contain digits, letters, dashes, and underscores. Extensions with an invalid name will not be loaded and will display an error.
{{% /alert %}}

## Conclusion

Using this guide we have:

* Created a new app
* Downloaded a new extension from GitHub
* Built the extension and installed it in our app
* Tested our extension from within Studio Pro.

## Extensibility Feedback

If you would like to provide us with some additional feedback you can complete a small [Survey](https://survey.alchemer.eu/s3/90801191/Extensibility-Feedback)
If you would like to provide additional feedback, you can complete a small [survey](https://survey.alchemer.eu/s3/90801191/Extensibility-Feedback).

Any feedback is much appreciated.
Any feedback is appreciated.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ weight: 10

## Introduction

This guide explains how to create and manage a dockable pane using the web extensions API. A Dockable pane allows you to create a web view that can be docked and moved within the Studio Pro user interface. Examples of dockable panes in Studio Pro are:
This how-to describes how to create and manage a dockable pane using the web extensions API. A dockable pane allows you to create a web view that can be docked and moved within the Studio Pro user interface. Examples of dockable panes in Studio Pro are:

* Marketplace
* Errors
Expand All @@ -16,11 +16,11 @@ This guide explains how to create and manage a dockable pane using the web exten

## Prerequisites

This guide uses the app created in [Get Started with the Web Extensibility API](/apidocs-mxsdk/apidocs/web-extensibility-api-10/getting-started/). Please complete that how-to before starting this one.
This guide uses the app created in [Get Started with the Web Extensibility API](/apidocs-mxsdk/apidocs/web-extensibility-api-10/getting-started/). Make sure to complete that how-to before starting this one.

## Creating a Dockable Pane

To open a dockable pane you must first register the dockable pane handle with the API. To do this, add a call to register the pane to the extension loaded method in the `src/main/index.ts`.
To open a dockable pane you must first register the dockable pane handle with the API. To do this, add a call to register the pane to the extension loaded method in the `src/main/index.ts`. Use the `paneHandle` you registered to interact with the dockable pane.

```typescript
const paneHandle = await studioPro.ui.panes.register(
Expand All @@ -34,9 +34,7 @@ To open a dockable pane you must first register the dockable pane handle with th
});
```

Use the 'paneHandle' you registered to interact with the dockable pane.

After adding this call the `loaded()` method looks like this:
After adding this call, the `loaded()` method looks like this:

```typescript {hl_lines=["11-19"]}
async loaded() {
Expand Down Expand Up @@ -81,9 +79,9 @@ After adding this call the `loaded()` method looks like this:

## Adding a Menu To Open the Dockable Pane

You will now add a menu that will open the pane when it is selected.
Add a menu that will open the pane when it is selected.

1. Add a new submenu to the existing `extensionsMenu.add()` method on line 10.
1. Add a new sub-menu to the existing `extensionsMenu.add()` method on line 10.

```typescript {linenos=table linenostart=10}
// Add a menu item to the Extensions menu
Expand All @@ -97,7 +95,7 @@ You will now add a menu that will open the pane when it is selected.
});
```

1. Add lines to the `addEventListener()` call to handle opening the dockable pane once the menu has been selected, as follows:
2. Add lines to the `addEventListener()` call that will open the pane when the menu is selected.

```typescript
// Open a tab when the menu item is clicked
Expand Down Expand Up @@ -173,10 +171,10 @@ Your `loaded()` method should now look like this:

### Adding New Endpoint Handlers

You must now create a new web view endpoint where the user interface to be rendered within the pane is defined. You can use the existing endpoint and rename it to something more appropriate.
Create a new web view endpoint where you define the user interface that will be rendered within the pane. You can use and rename the existing endpoint. Follow the steps below:

1. Rename `ui/index.tsx` to `ui/tab.tsx`
1. Add the new endpoint file, `ui/dockablepane.tsx` by copying `ui/tab.tsx`.
1. Rename `ui/index.tsx` to `ui/tab.tsx`.
1. Add the new endpoint file, `ui/dockablepane.tsx`, by copying `ui/tab.tsx`.

You must also alter the `vite.config.ts` and `manifest.json` files to bind to the correct endpoint, as described in the following sections:

Expand All @@ -192,7 +190,7 @@ Replace the entry section of `vite.config.js` with the following:
}
```

This instructs vite that the tab endpoint is connected to `src/ui/tab.tsx` and the dockable pane endpoint is connected to `src/ui/dockablepane.tsx`.
This tells vite that the tab endpoint is connected to `src/ui/tab.tsx` and the dockable pane endpoint is connected to `src/ui/dockablepane.tsx`.

`vite.config.js` should now look like this:

Expand All @@ -219,9 +217,12 @@ export default defineConfig({

### Altering `public/manifest.json`

You also need to instruct Studio Pro to load the endpoint that you just created. To do this, modify the manifest file `public/manifest.json`.
You also musr instruct Studio Pro to load the endpoint that you just created. To do this, modify the manifest file `public/manifest.json`.

Alter the "ui" section by:

Alter the "ui" section by changing the `tab` endpoint and adding the `dockablepane` endpoint.
* Changing the `tab` endpoint
* Adding the `dockablepane` endpoint.

```typescript
"ui": {
Expand All @@ -248,17 +249,17 @@ The `manifest.json file` should now look like this:

## Closing the Dockable Pane

Now that you have registered a pane and can open, it would also be a good idea to close it.
Now that you have registered a pane and created a way to open it, it is important to provide a way to close it, too.

You will close your pane using a new menu item.
You will close your pane using a new menu item. Follow the steps below:

First add a new sub menu item to the menu on line 11.
1. Add a new sub-menu item to the menu on line 11.

```typescript {linenos=table linenostart=11}
{ menuId: "myextension.HideDockMenuItem", caption: "Hide dock pane" },
```

You must also alter the event handler for the new menu at the end of the loaded method:
2. Alter the event handler for the new menu at the end of the loaded method:

```typescript
// Open a tab when the menu item is clicked
Expand Down Expand Up @@ -337,13 +338,8 @@ The loaded method should now look like this:
}
```

## Conclusion

You now have a new dockable pane with its own user interface which you can modify as you like.
You can also open and close the dockable pane from a menu.

## Extensibility Feedback

If you would like to provide us with some additional feedback you can complete a small [Survey](https://survey.alchemer.eu/s3/90801191/Extensibility-Feedback)
If you would like to provide additional feedback, you can complete a small [survey](https://survey.alchemer.eu/s3/90801191/Extensibility-Feedback).

Any feedback is much appreciated.
Any feedback is appreciated.
Loading