/extension-typescript-template

Sample Moosync extension

Primary LanguageTypeScriptMIT LicenseMIT

Moosync Extension boilerplate

Quick Overview

This is a minimal starter app that benefits of the strong typing of the Typescript compiler plus all the latest ES6, ES7+ features.

Usage

Installation

Clone the repository then:

bun install

To install all dependencies.

Writing code

Custom types should be defined under src/types

Functionality of the extension can be implemented in src/index.ts

Package details

Details of the package can be changed inside package.json

Inside package.json

name is the unique package name of the extension. Can not contain whitespace.

version is the version of the extension.

moosyncExtension is the file which is read when extension is loaded in Moosync.

displayName is the Name of the extension. May contain whitespace.

author is the name of the author of the extension.

Extension Lifecycle

The extension system in Moosync makes use of Event Commands to listener functions.

Event Commands

Available event commands can be found here

The basic event commands for Streaming extensions are:

  • getProviderScopes: Fired when extension is started, defines which Event Commands the extension will accept from the client.
  • songFromUrl: Fired when a user sends a URL to the app to resolve and begin playback on.

It is recommended to create an instance of your required code inside your entry function.

Example for implementation of most Streaming extension events can be found here.

API

You may also make use of the on demand API to fetch data from Moosync.

Documentation for the API can be found here.

Creating the extension

To Build and pack the extension for Moosync using extism-js & Moosync packer

bun run build

To test how your extension responds to Event Commands you can use moodriver to setup a test harness.

A testing script and some sample tests are provided in this template. Note: an extension output (log) is required for tests to pass

bun run test