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

A list of cached preloads

public

The lost of loaded package metadata

public

A list of registered packages

public

Mainly used for singleton awareness

Method Summary

Public Methods
public

Destroy package manager

public

Gets a list of packages compatible with the given mime type

public

Gets a list of packages (metadata)

public

init(): *

Initializes package manager

public

launch(name: String, args: Object, options: Object): Promise<Application, Error>

Launches a (application) package

public

preload(list: Array, force: Boolean): String[]

Loads all resources required for a package

public

register(name: String, callback: Function)

Registers a package

Private Methods
private

_launch(name: String, args: Object, options: Object): Application

Wrapper for launching a (application) package

private

_launchApplication(name: String, metadata: Metadata, args: Array, options: Object): *

Launches an application package

private

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 loaded: String[] source

A list of cached preloads

public metadata: PackageMetadata[] source

The lost of loaded package metadata

public packages: PackageReference[] source

A list of registered packages

public running: String[] source

Mainly used for singleton awareness

Public Methods

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(): * source

Initializes package manager

Return:

*

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 preload(list: Array, force: Boolean): String[] source

Loads all resources required for a package

Params:

NameTypeAttributeDescription
list Array

A list of resources

force Boolean
  • optional
  • default: false

Force loading even though previously cached

Return:

String[]

A list of failed resources

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 _launch(name: String, args: Object, options: Object): Application source

Wrapper for launching a (application) package

Params:

NameTypeAttributeDescription
name String

Package name

args Object

Launch arguments

options Object

Launch options

Return:

Application

private _launchApplication(name: String, metadata: Metadata, args: Array, options: Object): * source

Launches an application package

Params:

NameTypeAttributeDescription
name String

Application package name

metadata Metadata

Application metadata

args Array

Launch arguments

options Object

Launch options

Return:

*

private _launchTheme(name: String, type: String): Promise<Object, Error> source

Launches a (theme) package

Params:

NameTypeAttributeDescription
name String

Package name

type String

Package type

Return:

Promise<Object, Error>

Throw:

Error