@smart-instruments/sdk v2.0.5
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 theprimary
or thesecondary
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
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago