Home Reference Source

Function

Static Public Summary
public

adapter(core: Core, options: object): {"readdir": *}

Application VFS adapter

public

adapter(core: Core, options: object): *

System VFS adapter

public

applyBackgroundStyles(core: *, background: *)

Creates a set of styles based on background settings

public

Get basename of a file

public

Returns the navigator language

public

Get vfs capabilities

public

Copies a file or directory (move)

public

create(core: *, $element: *): *

Search UI Adapter

public

create(options: *, login: *, startHidden: *, $container: *): *

Login UI Adapter

public

Serialize an object to CSS

public

Creates data attributes for window DOM

public

Creates styles for window DOM

public

Creates a file iter for scandir

public

createNativeNotification(options: object, onclick: Function): Promise<window.Notification>

Creates a native notification

public

createPanelSubtraction(panel: *, panels: *): *

Creates a rectangle with the realestate panels takes up

public

createWatchEvents(method: *, args: *): object[]

Creates a list of VFS events to simulate server-side file watching

public

Creates a double-tap event handler

public

download(path: string | VFSFile, options: VFSDownloadOptions): Promise<any>

Initiates a native browser download of the file

public

draggable(el: Element, options: DraggableOptions): DraggableInstance

Creates a "draggable" element

public

droppable(el: Element, options: DroppableOptions): DroppableInstance

Creates a "droppable" element

public

Escape text so it is "safe" for HTML usage

public

Checks if path exists

public

fetch(url: string, options: Options, type: string): Promise<*>

Make a HTTP request

public

filterMountByGroups(userGroups: *): boolean

Filters a mountpoint by user groups

public

format(date: Date, fmt: string): string

Formats a given Date to a specified format

public

Normalizes event input (position)

public

Gets an icon from file stat

public

getLocale(core: Core, key: string): object

Gest the set localization

public

handleTabOnTextarea(ev: Event)

Inserts a tab in the given event target

public

Converts a number (bytez) into human-readable string

public

Inverts a HEX color

public

Check if droppable data contains image

public

loadOptionsFromConfig(config: *, appName: *, windowId: *): *

Loads [certain] window options from configuration

public

localStorageAuth(core: Core, options: object)

LocalStorage Auth adapter

public

localStorageSettings(core: Core, options: object): *

LocalStorage Settings adapter

public

matchKeyCombo(combo: string, ev: Event): boolean

Checks if keycombo matches

public

Creates a directory

public

Get parent directory

public

Gets prefix from vfs path

public

pathJoin(args: string[]): string

Joins paths

public

playSound(src: string, options: object): Promise<HTMLAudioElement>

Plays a sound

public

Read a directory

public

Reads a file

public

Renames a file or directory (move)

public

script(root: Element, src: string, options: Object): Promise<StyleElement>

Creates a new Script DOM element

public

search(root: string | VFSFile, pattern: string, options: VFSMethodOptions): Promise<object[]>

Searches for files and folders

public

serverAuth(core: Core, options: object): {"register": *, "login": *, "logout": *}

Server Auth adapter

public

serverSettings(core: Core, options: object)

Server Settings adapter

public

Gets the stats of the file or directory

public

style(root: Element, src: string): Promise<ScriptElement>

Creates a new CSS DOM element

public

Gets supported media types

public

Touches a file

public

transformArrayBuffer(ab: ArrayBuffer, mime: string, type: string): DOMString | string | Blob | ArrayBuffer

Transform an ArrayBuffer

public

transformReaddir(root: object, options: object): Object[]

Transforms a readdir result

public

translatable(k: string, Format: ...args): Function

Translates a given tree of locales.

public

translatableFlat(list: object, defaultValue: string): string

Translates a given flat tree of locales

public

Removes a file or directory

public

Gets an URL to a resource defined by file

public

urlResolver(configuration: CoreConfig): *

Resolves an URL

public

validVfsDrop(data: *): boolean

Check if droppable data is a VFS type

public

writefile(path: string | VFSFile, data: ArrayBuffer | Blob | string, options: VFSMethodOptions): Promise<number>

Writes a file

Static Private Summary
private

translate(list: object, ul: string, dl: string, k: string, args: ...*): string

Translates a key + arguments from a tree of translations

Static Public

public adapter(core: Core, options: object): {"readdir": *} source

Application VFS adapter

Params:

NameTypeAttributeDescription
core Core

Core reference

options object
  • optional

Adapter options

Return:

{"readdir": *}

public adapter(core: Core, options: object): * source

System VFS adapter

Params:

NameTypeAttributeDescription
core Core

Core reference

options object
  • optional

Adapter options

Return:

*

public applyBackgroundStyles(core: *, background: *) source

import {applyBackgroundStyles} from '@osjs/client/src/utils/desktop.js'

Creates a set of styles based on background settings

Params:

NameTypeAttributeDescription
core *
background *

public basename(path: string): string source

import {basename} from '@osjs/client/src/utils/vfs.js'

Get basename of a file

Params:

NameTypeAttributeDescription
path string

The path

Return:

string

public browserLocale(nav: object): string source

import {browserLocale} from '@osjs/client/src/utils/locale.js'

Returns the navigator language

Params:

NameTypeAttributeDescription
nav object
  • optional

Return:

string

public capabilities(path: string | VFSFile, options: VFSMethodOptions): Promise<object[]> source

import {capabilities} from '@osjs/client/src/vfs.js'

Get vfs capabilities

Params:

NameTypeAttributeDescription
path string | VFSFile

The path of a file

options VFSMethodOptions
  • optional

Options

Return:

Promise<object[]>

An object of capabilities

public copy(from: string | VFSFile, to: string | VFSFile, options: VFSMethodOptions): Promise<boolean> source

import {copy} from '@osjs/client/src/vfs.js'

Copies a file or directory (move)

Params:

NameTypeAttributeDescription
from string | VFSFile

The source (from)

to string | VFSFile

The destination (to)

options VFSMethodOptions
  • optional

Options

Return:

Promise<boolean>

public create(core: *, $element: *): * source

Search UI Adapter

Params:

NameTypeAttributeDescription
core *
$element *

Return:

*

public create(options: *, login: *, startHidden: *, $container: *): * source

Login UI Adapter

Params:

NameTypeAttributeDescription
options *
login *
startHidden *
$container *

Return:

*

public createCssText(obj: object): string source

import {createCssText} from '@osjs/client/src/utils/dom.js'

Serialize an object to CSS

Params:

NameTypeAttributeDescription
obj object

Object

Return:

string

CSS text

public createDOMAttributes(id: string, state: WindowState, attributes: WindowAttributes): object source

import {createDOMAttributes} from '@osjs/client/src/utils/windows.js'

Creates data attributes for window DOM

Params:

NameTypeAttributeDescription
id string
state WindowState
attributes WindowAttributes

Return:

object

public createDOMStyles(state: WindowState, attributes: WindowAttributes): object source

import {createDOMStyles} from '@osjs/client/src/utils/windows.js'

Creates styles for window DOM

Params:

NameTypeAttributeDescription
state WindowState
attributes WindowAttributes

Return:

object

public createFileIter(stat: object): object source

import {createFileIter} from '@osjs/client/src/utils/vfs.js'

Creates a file iter for scandir

Params:

NameTypeAttributeDescription
stat object

file stat

Return:

object

public createNativeNotification(options: object, onclick: Function): Promise<window.Notification> source

import {createNativeNotification} from '@osjs/client/src/utils/dom.js'

Creates a native notification

Params:

NameTypeAttributeDescription
options object

Notification options

onclick Function
  • optional

Callback on click

Return:

Promise<window.Notification>

public createPanelSubtraction(panel: *, panels: *): * source

import {createPanelSubtraction} from '@osjs/client/src/utils/desktop.js'

Creates a rectangle with the realestate panels takes up

Params:

NameTypeAttributeDescription
panel *
panels *

Return:

*

public createWatchEvents(method: *, args: *): object[] source

import {createWatchEvents} from '@osjs/client/src/utils/vfs.js'

Creates a list of VFS events to simulate server-side file watching

Params:

NameTypeAttributeDescription
method *
args *

Return:

object[]

public doubleTap(timeout: number): Function source

import {doubleTap} from '@osjs/client/src/utils/input.js'

Creates a double-tap event handler

Params:

NameTypeAttributeDescription
timeout number
  • optional
  • default: 250

Timeout

Return:

Function

Handler with => (ev, cb)

public download(path: string | VFSFile, options: VFSDownloadOptions): Promise<any> source

import {download} from '@osjs/client/src/vfs.js'

Initiates a native browser download of the file

Params:

NameTypeAttributeDescription
path string | VFSFile

The file

options VFSDownloadOptions
  • optional

Options

Return:

Promise<any>

public draggable(el: Element, options: DraggableOptions): DraggableInstance source

import {draggable} from '@osjs/client/src/utils/dnd.js'

Creates a "draggable" element

Params:

NameTypeAttributeDescription
el Element

The DOM element to apply to

options DraggableOptions
  • optional
  • default: {}

Options

public droppable(el: Element, options: DroppableOptions): DroppableInstance source

import {droppable} from '@osjs/client/src/utils/dnd.js'

Creates a "droppable" element

Params:

NameTypeAttributeDescription
el Element

The DOM element to apply to

options DroppableOptions
  • optional
  • default: {}

Options

public escapeHtml(text: string): string source

import {escapeHtml} from '@osjs/client/src/utils/dom.js'

Escape text so it is "safe" for HTML usage

Params:

NameTypeAttributeDescription
text string

Input text

Return:

string

public exists(path: string | VFSFile, options: VFSMethodOptions): Promise<boolean> source

import {exists} from '@osjs/client/src/vfs.js'

Checks if path exists

Params:

NameTypeAttributeDescription
path string | VFSFile

The path to check

options VFSMethodOptions
  • optional

Options

Return:

Promise<boolean>

public fetch(url: string, options: Options, type: string): Promise<*> source

import {fetch} from '@osjs/client/src/utils/fetch.js'

Make a HTTP request

Params:

NameTypeAttributeDescription
url string

The endpoint

options Options
  • optional

fetch options

type string
  • optional

Request / Response type

Return:

Promise<*>

public filterMountByGroups(userGroups: *): boolean source

import {filterMountByGroups} from '@osjs/client/src/utils/vfs.js'

Filters a mountpoint by user groups

Params:

NameTypeAttributeDescription
userGroups *

Return:

boolean

public format(date: Date, fmt: string): string source

import {format} from '@osjs/client/src/utils/locale.js'

Formats a given Date to a specified format

Will automatically detect the current locale from the user.

Formats are 'shortDate', 'mediumDate', 'longDate', 'fullDate', 'shortTime' and 'longTime'

Params:

NameTypeAttributeDescription
date Date

Date object

fmt string

Format

Return:

string

public getEvent(ev: Event): NormalizedEventPosition source

import {getEvent} from '@osjs/client/src/utils/input.js'

Normalizes event input (position)

Params:

NameTypeAttributeDescription
ev Event

Event

public getFileIcon(file: object): string | object source

import {getFileIcon} from '@osjs/client/src/utils/vfs.js'

Gets an icon from file stat

Params:

NameTypeAttributeDescription
file object

The file stat object

Return:

string | object

public getLocale(core: Core, key: string): object source

import {getLocale} from '@osjs/client/src/utils/locale.js'

Gest the set localization

Params:

NameTypeAttributeDescription
core Core

OS.js Core IoC

key string

Settings key (locales.*)

Return:

object

An object with defaultLocale and userLocale

public handleTabOnTextarea(ev: Event) source

import {handleTabOnTextarea} from '@osjs/client/src/utils/dom.js'

Inserts a tab in the given event target

Params:

NameTypeAttributeDescription
ev Event

DOM Event

public humanFileSize(bytes: Number, si: Boolean): string source

import {humanFileSize} from '@osjs/client/src/utils/vfs.js'

Converts a number (bytez) into human-readable string

Params:

NameTypeAttributeDescription
bytes Number

Input

si Boolean
  • optional
  • default: false

Use SI units

Return:

string

public invertHex(hex: string): string source

import {invertHex} from '@osjs/client/src/utils/colors.js'

Inverts a HEX color

Params:

NameTypeAttributeDescription
hex string

Color hex code

Return:

string

Inverted hex code

public isDroppingImage(data: *): boolean source

import {isDroppingImage} from '@osjs/client/src/utils/desktop.js'

Check if droppable data contains image

Params:

NameTypeAttributeDescription
data *

Return:

boolean

public loadOptionsFromConfig(config: *, appName: *, windowId: *): * source

import {loadOptionsFromConfig} from '@osjs/client/src/utils/windows.js'

Loads [certain] window options from configuration

Params:

NameTypeAttributeDescription
config *
appName *
windowId *

Return:

*

public localStorageAuth(core: Core, options: object) source

import localStorageAuth from '@osjs/client/src/adapters/auth/localstorage.js'

LocalStorage Auth adapter

Params:

NameTypeAttributeDescription
core Core

Core reference

options object
  • optional

Adapter options

public localStorageSettings(core: Core, options: object): * source

import localStorageSettings from '@osjs/client/src/adapters/settings/localstorage.js'

LocalStorage Settings adapter

Params:

NameTypeAttributeDescription
core Core

Core reference

options object
  • optional

Adapter options

Return:

*

public matchKeyCombo(combo: string, ev: Event): boolean source

import {matchKeyCombo} from '@osjs/client/src/utils/input.js'

Checks if keycombo matches

Params:

NameTypeAttributeDescription
combo string

Key combo

ev Event

Event

Return:

boolean

public mkdir(path: string | VFSFile, options: VFSMethodOptions): Promise<boolean> source

import {mkdir} from '@osjs/client/src/vfs.js'

Creates a directory

Params:

NameTypeAttributeDescription
path string | VFSFile

The path to new directory

options VFSMethodOptions
  • optional

Options

Return:

Promise<boolean>

public parentDirectory(path: string): string source

import {parentDirectory} from '@osjs/client/src/utils/vfs.js'

Get parent directory

Params:

NameTypeAttributeDescription
path string

Directory

Return:

string

Parent directory

public parseMountpointPrefix(str: string): string source

import {parseMountpointPrefix} from '@osjs/client/src/utils/vfs.js'

Gets prefix from vfs path

Params:

NameTypeAttributeDescription
str string

Input

Return:

string

public pathJoin(args: string[]): string source

import {pathJoin} from '@osjs/client/src/utils/vfs.js'

Joins paths

Params:

NameTypeAttributeDescription
args string[]

paths

Return:

string

public playSound(src: string, options: object): Promise<HTMLAudioElement> source

import {playSound} from '@osjs/client/src/utils/dom.js'

Plays a sound

Params:

NameTypeAttributeDescription
src string

Sound source

options object
  • optional

Options

Return:

Promise<HTMLAudioElement>

public readdir(path: string | VFSFile, options: VFSMethodOptions): Promise<object[]> source

import {readdir} from '@osjs/client/src/vfs.js'

Read a directory

Params:

NameTypeAttributeDescription
path string | VFSFile

The path to read

options VFSMethodOptions
  • optional

Options

Return:

Promise<object[]>

A list of files

public readfile(path: string | VFSFile, type: string, options: VFSMethodOptions): Promise<ArrayBuffer> source

import {readfile} from '@osjs/client/src/vfs.js'

Reads a file

Available types are 'arraybuffer', 'blob', 'uri' and 'string'

Params:

NameTypeAttributeDescription
path string | VFSFile

The path to read

type string
  • optional
  • default: string

Return this content type

options VFSMethodOptions
  • optional

Options

Return:

Promise<ArrayBuffer>

public rename(from: string | VFSFile, to: string | VFSFile, options: VFSMethodOptions): Promise<boolean> source

import {rename} from '@osjs/client/src/vfs.js'

Renames a file or directory (move)

Params:

NameTypeAttributeDescription
from string | VFSFile

The source (from)

to string | VFSFile

The destination (to)

options VFSMethodOptions
  • optional

Options

Return:

Promise<boolean>

public script(root: Element, src: string, options: Object): Promise<StyleElement> source

import {script} from '@osjs/client/src/utils/dom.js'

Creates a new Script DOM element

Params:

NameTypeAttributeDescription
root Element

Root node

src string

Source

options Object
  • optional
  • default: {}

Options

Return:

Promise<StyleElement>
import {search} from '@osjs/client/src/vfs.js'

Searches for files and folders

Params:

NameTypeAttributeDescription
root string | VFSFile

The root

pattern string

Search pattern

options VFSMethodOptions
  • optional

Options

Return:

Promise<object[]>

A list of files

public serverAuth(core: Core, options: object): {"register": *, "login": *, "logout": *} source

Server Auth adapter

Params:

NameTypeAttributeDescription
core Core

Core reference

options object
  • optional

Adapter options

Return:

{"register": *, "login": *, "logout": *}

public serverSettings(core: Core, options: object) source

Server Settings adapter

Params:

NameTypeAttributeDescription
core Core

Core reference

options object
  • optional

Adapter options

public stat(path: string | VFSFile, options: VFSMethodOptions): Promise<object> source

import {stat} from '@osjs/client/src/vfs.js'

Gets the stats of the file or directory

Params:

NameTypeAttributeDescription
path string | VFSFile

The path to check

options VFSMethodOptions
  • optional

Options

Return:

Promise<object>

public style(root: Element, src: string): Promise<ScriptElement> source

import {style} from '@osjs/client/src/utils/dom.js'

Creates a new CSS DOM element

Params:

NameTypeAttributeDescription
root Element

Root node

src string

Source

Return:

Promise<ScriptElement>

public supportedMedia(): object source

import {supportedMedia} from '@osjs/client/src/utils/dom.js'

Gets supported media types

Return:

object

public touch(path: string | VFSFile): Promise<boolean> source

import {touch} from '@osjs/client/src/vfs.js'

Touches a file

Params:

NameTypeAttributeDescription
path string | VFSFile

File path

Return:

Promise<boolean>

public transformArrayBuffer(ab: ArrayBuffer, mime: string, type: string): DOMString | string | Blob | ArrayBuffer source

import {transformArrayBuffer} from '@osjs/client/src/utils/vfs.js'

Transform an ArrayBuffer

Params:

NameTypeAttributeDescription
ab ArrayBuffer

The ArrayBuffer

mime string

The MIME type

type string

Transform to this type

Return:

DOMString | string | Blob | ArrayBuffer

public transformReaddir(root: object, options: object): Object[] source

import {transformReaddir} from '@osjs/client/src/utils/vfs.js'

Transforms a readdir result

Params:

NameTypeAttributeDescription
root object

The path to the readdir root

Object[] *

files An array of readdir results

options object

Options

options.showHiddenFiles Boolean
  • optional
  • default: false

Show hidden files

options.filter Function
  • optional

A filter

options.sortBy string
  • optional
  • default: 'filename'

Sort by this attribute

options.sortDir string
  • optional
  • default: 'asc'

Sort in this direction

Return:

Object[]

public translatable(k: string, Format: ...args): Function source

import {translatable} from '@osjs/client/src/utils/locale.js'

Translates a given tree of locales.

Will automatically detect the current locale from the user.

Returns a translate function that takes a key and list of arguments.

Params:

NameTypeAttributeDescription
k string

List key

Format ...args

arguments

Return:

Function

A translation function

Example:

 translatable({en_EN: {foo: 'Hello {0}'}})
   ('foo', 'World'); // => 'Hello World'

See:

public translatableFlat(list: object, defaultValue: string): string source

import {translatableFlat} from '@osjs/client/src/utils/locale.js'

Translates a given flat tree of locales

Will automatically detect the current locale from the user.

Returns a function that takes a key and returns the correct string.

Params:

NameTypeAttributeDescription
list object

The tree of translations

defaultValue string

Default value if none found

Return:

string

The translated string

Example:

 translatableFlat({en_EN: 'Hello World'}); // => 'Hello World'
import {unlink} from '@osjs/client/src/vfs.js'

Removes a file or directory

Params:

NameTypeAttributeDescription
path string | VFSFile

The path to remove

options VFSMethodOptions
  • optional

Options

Return:

Promise<boolean>

public url(path: string | VFSFile, options: VFSMethodOptions): Promise<string> source

import {url} from '@osjs/client/src/vfs.js'

Gets an URL to a resource defined by file

Params:

NameTypeAttributeDescription
path string | VFSFile

The file

options VFSMethodOptions
  • optional

Options

Return:

Promise<string>

public urlResolver(configuration: CoreConfig): * source

import {urlResolver} from '@osjs/client/src/utils/url.js'

Resolves an URL

Params:

NameTypeAttributeDescription
configuration CoreConfig

Return:

*

public validVfsDrop(data: *): boolean source

import {validVfsDrop} from '@osjs/client/src/utils/desktop.js'

Check if droppable data is a VFS type

Params:

NameTypeAttributeDescription
data *

Return:

boolean

public writefile(path: string | VFSFile, data: ArrayBuffer | Blob | string, options: VFSMethodOptions): Promise<number> source

import {writefile} from '@osjs/client/src/vfs.js'

Writes a file

Params:

NameTypeAttributeDescription
path string | VFSFile

The path to write

data ArrayBuffer | Blob | string

The data

options VFSMethodOptions
  • optional

Options

Return:

Promise<number>

File size

Static Private

private translate(list: object, ul: string, dl: string, k: string, args: ...*): string source

import {translate} from '@osjs/client/src/utils/locale.js'

Translates a key + arguments from a tree of translations

Params:

NameTypeAttributeDescription
list object

The tree of translations

ul string

User locale name

dl string

Default locale name

k string

The key to translate from tree

args ...*

A list of arguments that are defined in the translation string

Return:

string

The translated string

Example:

 translate({en_EN: {foo: 'Hello {0}'}}, 'nb_NO', 'en_EN', 'foo', 'World') => 'Hello World'