Home Reference Source
import Packages from '@osjs/client/src/packages.js'
public class | source

Packages

Handles indexing, loading and launching of OS.js packages

Constructor Summary

Public Constructor
public

constructor(core: Core)

Create package manage

Member Summary

Public Members
public

Core instance reference

public

If inited

public

The lost of loaded package metadata

public

A list of registered packages

public

Preloader

public

Mainly used for singleton awareness

Method Summary

Public Methods
public

Adds a set of packages

public

Destroy package manager

public

Gets a list of packages compatible with the given mime type

public

Gets a list of packages (metadata)

public

Initializes package manager

public

launch(name: string, args: object, options: object): Promise<Application, Error>

Launches a (application) package

public

register(name: string, callback: Function)

Registers a package

Private Methods
private

Autostarts tagged packages

private

_launch(name: string, args: object, options: object): Promise<Application>

Wrapper for launching a (application) package

private

_launchApplication(name: string, metadata: Metadata, args: Map<string, *>, options: object): *

Launches an application package

private

_launchTheme(name: string, metadata: Metadata): Promise<object, Error>

Launches a (theme) package

Public Constructors

public constructor(core: Core) source

Create package manage

Params:

NameTypeAttributeDescription
core Core

Core reference

Public Members

public core: Core source

Core instance reference

public inited: boolean source

If inited

public metadata: PackageMetadata[] source

The lost of loaded package metadata

public packages: PackageReference[] source

A list of registered packages

public preloader: Preloader source

Preloader

public running: string[] source

Mainly used for singleton awareness

Public Methods

public addPackages(list: PackageMetadata[]): PackageMetadata[] source

Adds a set of packages

Params:

NameTypeAttributeDescription
list PackageMetadata[]

Package list

Return:

PackageMetadata[]

Current list of packages

public destroy() source

Destroy package manager

public getCompatiblePackages(mimeType: string): PackageMetadata[] source

Gets a list of packages compatible with the given mime type

Params:

NameTypeAttributeDescription
mimeType string

MIME Type

Return:

PackageMetadata[]

See:

public getPackages(filter: Function): PackageMetadata[] source

Gets a list of packages (metadata)

Params:

NameTypeAttributeDescription
filter Function
  • optional

A filter function

Return:

PackageMetadata[]

public init(): Promise<boolean, Error> source

Initializes package manager

Return:

Promise<boolean, Error>

public launch(name: string, args: object, options: object): Promise<Application, Error> source

Launches a (application) package

Params:

NameTypeAttributeDescription
name string

Package name

args object
  • optional

Launch arguments

options object
  • optional

Launch options

options.forcePreload boolean
  • optional
  • default: false

Force preload reloading

Throw:

Error

See:

public register(name: string, callback: Function) source

Registers a package

Params:

NameTypeAttributeDescription
name string

Package name

callback Function

Callback function to construct application instance

Throw:

Error

Private Methods

private _autostart() source

Autostarts tagged packages

private _launch(name: string, args: object, options: object): Promise<Application> source

Wrapper for launching a (application) package

Params:

NameTypeAttributeDescription
name string

Package name

args object

Launch arguments

options object

Launch options

Return:

Promise<Application>

private _launchApplication(name: string, metadata: Metadata, args: Map<string, *>, options: object): * source

Launches an application package

Params:

NameTypeAttributeDescription
name string

Application package name

metadata Metadata

Application metadata

args Map<string, *>

Launch arguments

options object

Launch options

Return:

*

private _launchTheme(name: string, metadata: Metadata): Promise<object, Error> source

Launches a (theme) package

Params:

NameTypeAttributeDescription
name string

Package name

metadata Metadata

Application metadata

Return:

Promise<object, Error>

Throw:

Error