Skip to content

Ugwisha apps

Sean edited this page Jun 23, 2019 · 4 revisions

Ugwisha apps add extra functionality to Ugwisha. This is to:

  1. make extra features optional
  2. allow third-party additions

(note that apps are internally also known as extensions)

Apps are defined by a JavaScript file, which is cached offline; here's an example: https://sheeptester.github.io/hello-world/test-ugwisha-extension.js

Apps are a JavaScript file that gets loaded and is expected to immediately call UgwishaExtensions.register with an object containing app metadata:

  • wrapper is an HTML element that gets added to the DOM when the app is selected
  • name is the display name of the app
  • icon (optional) is an image URL which gets cached offline
  • styles (optional) is the path to a CSS file that can be added along with the app
  • sources (optional) is an array of additional URLs that should be cached offline
  • beforeAdd, afterAdd, beforeRemove, afterRemove (all optional) are fired when the corresponding events happen to the wrapper

The JS file, icon, CSS file, and additional sources are cached offline.

Example extension code

UgwishaExtensions.register((() => {
  const wrapper = document.createElement('div');
  wrapper.innerHTML = `<p>Hello world!</p>`;

  return {
    wrapper: wrapper,
    name: 'Demo',
    icon: './path/to/icon.svg'
  };
})());
Clone this wiki locally