biduul-hello-world

Hello world example plugin for Biduul


License
Other
Install
npm install biduul-hello-world@0.3.10

Documentation

altamoon-plugins

monorepo for official Altamoon plugins and plugin examples.

image

Overview

Altamoon plugins are published at NPM via npm publish, therefore every plugin has its own version. By the time being the latest plugin version is used once installed but later we're going to need to restrict that to avoid incompatibility issues and improve Altamoon's security (in case the author's NPM package access is corrupted). We also may want to add a "compatibility" field to package.json to make developers define which versions of Altamoon are compatible with the plugin (Altamoon is going to need to follow Semantic Versioning).

The package.json file of any plugin needs to include a "main" field that points to the plugin code bundled as a single JavaScript file or/and a "style" field that points to a single CSS file.

{
  "name": "altamoon-awesome-plugin",
  "description": "My awesome plugin!",
  "main": "dist/bundle.js",
  "style": "dist/style.css",
  ...

This means that a plugin can be either a functional script to create widgets and run any custom JavaScript code or provide custom CSS styles without affecting Altamoon's functionality.

Once a plugin is installed, it's going to be loaded via <script> tag using UNPKG CDN if "main" is provided and it's going to be loaded as <link rel="stylesheet"> if "style" is provided. For example "Hello World" plugin is published as altamoon-hello-world NPM package and loaded in the app as <script src="https://unpkg.com/altamoon-hello-world"></script>.

Every JavaScript plugin (plugins with "main" field in package.json) has full access to Altamoon features (current symbol, trading functions, stats, etc.) and can create any number of widgets (including none). Plugins are created with a global variable window.altamoonPlugin that accepts a function that is going to be called by Altamoon once the app is loaded.

The Altamoon API itself is going to be documented later.

window.altamoonPlugin((store) => {
  const widget = store.customization.createWidget({
    ...
  });

  const createOrder = async (side, quantity) => {
    await store.trading.marketOrder({
      quantity, side, symbol: store.persistent.symbol,
    });
  };

...

Widgets can be disabled and enabled again without stopping their plugin via the Widgets menu. If a widget is disabled, its plugin still has access to the app and personal data.

image

Third-party plugins

Some officially supported plugins may have "Third-party" label.

image

The label means that the plugin wasn't made by Altamoon team, therefore we can't guarantee that the plugin is safe to use. Users are going to see a warning once such plugin is disabled via Plugins menu that says that even though the plugin was turned off it still can control application and personal data (such as API keys).

image

Custom plugins

Besides enabling official plugins, it is possible to add a plugin using its name on NPM,

image

provide direct URL to a JavaScript file.

image

or provide direct URL to a CSS file.

image

TypeScript

Altamoon plugins can be implemented with TypeScript. Types are published as altamoon-types package.

import * as t from 'altamoon-types';

window.altamoonPlugin((store: t.RootStore) => {
  const widget = store.customization.createWidget({
    ...
  });

  const createOrder = async (side: 'BUY' | 'SELL', quantity: number) => {
    await store.trading.marketOrder({
      quantity, side, symbol: store.persistent.symbol,
    });
  };

...

React and Hot Module Replacement

All official Altamoon plugins are implemented with React but it's not a requirement. An example of such plugin can be found at hello-world-react. The example also demonstrates hot module replacement: a feature for development environment that allows to re-render components at runtime after code changes without needing to reload the whole application.