2.0.5 • Published 4 years ago

@smart-instruments/sdk v2.0.5

Weekly downloads
35
License
UNLICENSED
Repository
-
Last release
4 years ago

Muzilator SDK

Use the Musilator SDK to build Muzilator plugins

Plugin Types

There are two types of plugins, Applications and Libraries

Applications

Libraries

API

Types

View

export type View = 'primary' | 'secondary'

Endpoiny

export interface Endpoint {
  libraryName: string
  channelName: string
}

Library Platform

export interface LibraryPlatform {
  createChannel(channelName: string): Promise<MessagePort>
  getUserId(): Promise<string>
  setSessionTerminationListener(onSessionTermination: () => Promise<void>): Promise<void>
}

Application Platform

export interface AppPlatform extends LibraryPlatform {
  loadLibrary(pluginId: string, libraryName: string, view?: View): Promise<void>
  connectChannels(source: Endpoint, target: Endpoint): Promise<void>
  disconnectChannels(source: Endpoint, target: Endpoint): Promise<void>
}

Functions

The platform SDK exposes two functions: initializeApplication and initializePlugnn. Use initializeApplication when you are developing an aplpication and initializeLibrary when you are developing a library

Platform functions

Initialize Application
export const initializeApplication = (): Promise<AppPlatform> =>

Call this function in your application as early as possible.

Initialize Library
export const initializeLibrary = (): Promise<LibraryPlatform> =>

Call this function in your library as early as possible.

Library and Application functions

Create Channel
createChannel(channelName: string): Promise<MessagePort>

Create a channel with a given name and returns a Port through which you can send and receive messages.

Get User ID
getUserId(): Promise<string>

Returns the user id of the user which is currently signed in with the platform

Set Session Termination Listener
setSessionTerminationListener(onSessionTermination: () => Promise<void>): Promise<void>

Registers a callback function which will be called before the session is terminated. The platform will terminate the session only after the callback function returns.

Application functions

Load Library

loadLibrary(pluginId: string, libraryName: string, view?: View): Promise<void>

Loads a library in the platform.

  • The pluginId is the ID of the plugin in the platform
  • The libraryName is used to refer to this library instance when connecting channels
  • The optinal view is used to open the library UI in either the primary or the secondary view

Connect Channel

connectChannels(source: Endpoint, target: Endpoint): Promise<void>

Connects a source channel to a target channel. When calling the connectChannel function from an application, you can use the helper Self function to denote a channel of the application itself.

Disconnect Channel

disconnectChannels(source: Endpoint, target: Endpoint): Promise<void>

Disconnects a previously connected channel

2.0.5

4 years ago

2.0.4

4 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.3.3

5 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.7

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.16

5 years ago

1.0.15

5 years ago

1.0.13

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago