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

Packages

Package Manager

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

Private Members
private

A list of running application names

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 the package metadata for a given package name

public

Gets a list of packages (metadata)

public

Initializes package manager

public

launch(name: string, args: {foo: *}, options: PackageLaunchOptions): Promise<Application>

Launches a (application) package

public

register(name: string, callback: Function)

Registers a package

public

Gets a list of running packages

Private Methods
private

Autostarts tagged packages

private

_getPreloads(metadata: Metadata, fileType: string, packageType: string): string[]

Returns preloads

private

_launch(name: string, args: {foo: *}, options: PackageLaunchOptions): Promise<Application>

Wrapper for launching a (application) package

private

_launchApplication(name: string, metadata: Metadata, args: {foo: *}, options: PackageLaunchOptions): Promise<Application>

Launches an application package

private

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

Launches a (theme) package

private

Preloads background files of a set of packages

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

Private Members

private _running: string[] source

A list of running application names

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 getMetadataFromName(name: string): PackageMetadata source

Gets the package metadata for a given package name

Params:

NameTypeAttributeDescription
name string

Return:

PackageMetadata

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> source

Initializes package manager

Return:

Promise<boolean>

public launch(name: string, args: {foo: *}, options: PackageLaunchOptions): Promise<Application> source

Launches a (application) package

Params:

NameTypeAttributeDescription
name string

Package name

args {foo: *}
  • optional
  • default: {}

Launch arguments

options PackageLaunchOptions
  • optional
  • default: {}

Launch options

Return:

Promise<Application>

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

public running(): string[] source

Gets a list of running packages

Return:

string[]

Private Methods

private _autostart() source

Autostarts tagged packages

private _getPreloads(metadata: Metadata, fileType: string, packageType: string): string[] source

Returns preloads

Params:

NameTypeAttributeDescription
metadata Metadata

Application metadata

fileType string

Files type

packageType string

Package type

Return:

string[]

private _launch(name: string, args: {foo: *}, options: PackageLaunchOptions): Promise<Application> source

Wrapper for launching a (application) package

Params:

NameTypeAttributeDescription
name string

Package name

args {foo: *}

Launch arguments

options PackageLaunchOptions

Launch options

Return:

Promise<Application>

private _launchApplication(name: string, metadata: Metadata, args: {foo: *}, options: PackageLaunchOptions): Promise<Application> source

Launches an application package

Params:

NameTypeAttributeDescription
name string

Application package name

metadata Metadata

Application metadata

args {foo: *}

Launch arguments

options PackageLaunchOptions

Launch options

Return:

Promise<Application>

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

Launches a (theme) package

Params:

NameTypeAttributeDescription
name string

Package name

metadata Metadata

Application metadata

Return:

Promise<object>

Throw:

Error

private _preloadBackgroundFiles(list: PackageMetadata[]): * source

Preloads background files of a set of packages

Params:

NameTypeAttributeDescription
list PackageMetadata[]

Package list

Return:

*