API Reference

Table of Contents

Platform

This interface provides information about the OS or runtime platform on which the app is running.

getType

Returns string PlatformType ('web' | 'server' | 'ios' | 'android' | 'windows' | 'electron')

setServerMode

Set the Platform to 'server'. Useful to see if the app is rendering on server due to SSR.

Parameters

  • mode boolean (optional, default false)

filtersObj

This is the main BlueRain context. Works as a backbone of whole system.

Properties

  • Apps AppRegistry Instance object of AppRegistry.

  • Components ComponentRegistry Instance object of ComponentRegistry.

  • Configs ConfigRegistry Instance object of ConfigRegistry.

  • Events EventRegistry Instance object of EventRegistry.

  • Filters FilterRegistry Instance object of FilterRegistry.

  • Plugins PluginRegistry Instance object of PluginRegistry.

  • Utils Object Contains utility methods.

    • Utils.parseJsonSchema Function Converts JSON schema to React Component tree

  • refs Object Contains references of objects created by different apps and plugins

  • boot Function Function to boot the OS.

BootOptions

Options object that boot and bootOnServer methods expect.

Type: {apps: Array<BR.App>?, config: ConfigType?, renderApp: boolean?, plugins: Array<BR.Plugin>?, serverMode: boolean?}

Properties

  • apps Array<BR.App> An array of apps to load

  • config ConfigType Configuration object

  • renderApp boolean If set to false, BlueRain will not render the main app, instead it is up to the developer to render it. The App is returned from the boot function.

  • plugins Array<BR.Plugin> An array of plugins to load

  • serverMode boolean Set this flag to true when rendering during Server Side Rendering

  • apps Array<BR.App>?

  • config ConfigType?

  • renderApp boolean?

  • plugins Array<BR.Plugin>?

  • serverMode boolean?

boot

Boots the OS and renders the main UI. Use it on the client side

Parameters

  • options BootOptions (optional, default {serverMode:false,renderApp:true})

Returns ComponentType<any>

Config

This is the default configuration set that is used at boot time.

Type: ConfigType

Properties

  • apps Object Configurations for apps

  • appRoutePrefix string [default: "/app"] This route will be prependded to all app routes

  • debug boolean [default: true, false if NODE_ENV="production"] Debug mode

  • development boolean [default: true, false if NODE_ENV="production"] Development mode

  • locale string [default: "en"] App locale

  • plugins Object Configurations for plugins

  • title string [default: "BlueRain OS"] Main title of the app

  • theme string Theme to customize styling

ResponsiveLayout

ResponsiveLayout component to create responsive layouts.

Parameters

  • props ResponsiveLayoutProps

Properties

  • windowSize string The window size i.e. (xs|sm|md|lg|xl)

  • default React.Component The default component to render, if a current size component is not given.

  • xs React.Component The component to render when the screen size is extra-small.

  • sm React.Component The component to render when the screen size is small.

  • md React.Component The component to render when the screen size is medium.

  • lg React.Component The component to render when the screen size is large.

  • xl React.Component The component to render when the screen size is extra-large.

onLayout

Whenever the screen/window size changes, notify redux to update state.bluerain.window object.

App

Extends RX.Component

A BlueRain App base class

Properties

  • appName String Name of the app

  • slug String App's slug, used in to build URL

  • category String Category the App belongs to

  • description String App description

  • version String App version

  • appRoutePrefix String Path that will be prepended before slug to build URL.

  • path String Path of the app's home page

Plugin

Base class of a plugin which is to be extended.

Properties

  • pluginName String Name of the app

  • slug String App's slug, used in to build URL

  • config object Plugin configurations

  • category String Category the App belongs to

  • description String App description

  • version String App version

IndexPage

Returns the Index Page layout.

Returns React.Component The layout react component

NotFoundPage

Returns the 404 Page layout.

Returns React.Component The layout react component

WindowState

The state of current window or screen. Stored in bluerain.window in the redux store.

Type: {width: number, height: number, size: ("xs" | "sm" | "md" | "lg" | "xl")}

Properties

  • width number The window width

  • height number The window height

  • size ("xs" | "sm" | "md" | "lg" | "xl") The window size i.e. (xs|sm|md|lg|xl)

  • width number

  • height number

  • size ("xs" | "sm" | "md" | "lg" | "xl")

AppRegistry

Extends MapRegistry

All system apps are stored in this registry

Properties

register

Register an App To be deprecated in 2.0.0

Parameters

  • app App The BlueRain app to register

set

Register an App

Parameters

  • app App The BlueRain app to register

registerMany

Register many apps at once

Parameters

  • apps Array<App> The BlueRain apps to register

initializeAll

Initialize all the registered apps

getComponentSchema

Returns the JSON schema of the main APPs component. This component renders all the routes of apps.To be deprecated in 2.0.0

Returns Object JSON Schema

getAllRoutes

Returns the JSON schema of the main APPs component. This component renders all the routes of apps.

Returns Object JSON Schema

ComponentRegistry

Extends MapRegistry

All system components are stored in this registry

Properties

register

Register a component with a name, a raw component than can be extended and one or more optional higher order components.To be deprecated in 2.0.0

Parameters

  • name String The name of the component to register.

  • rawComponent ReactElement<any> Interchangeable/extendable component.

  • hocs Array<ComponentRegistryHocItem> The HOCs to compose with the raw component.

set

Register a component with a name, a raw component than can be extended and one or more optional higher order components.

Parameters

  • name String The name of the component to register.

  • rawComponent ReactElement<any> Interchangeable/extendable component.

  • hocs Array<ComponentRegistryHocItem> The HOCs to compose with the raw component.Note: when a component is registered without higher order component, hocs will be

    an empty array, and it's ok!

    See https://lodash.com/docs/4.17.4#flowRight

addHocs

Adds higher order component to the registered component

Parameters

  • name string The name of the registered component to whom hocs are to added

  • hocs Array<ComponentRegistryHocItem> The HOCs to compose with the raw component.

get

Get a component registered with set(name, component, ...hocs). Its accepts multiple component names.It iterates arguments and returns first found registered component.

Parameters

  • name String The name of the component to get.

Returns (Function | ReactElement<any>) A (wrapped) React component

getRawComponent

Get the raw (original) component registered with registerComponent without the possible HOCs wrapping it.

Parameters

  • name String The name of the component to get.

Returns (Function | ReactElement<any>) An interchangeable/extendable React component

replace

Replace a component with the same name with a new component or an extension of the raw component and one or more optional higher order components. This function keeps track of the previous HOCs and wrap the new HOCs around previous ones

Parameters

  • name String The name of the component to register.

  • newComponent ReactElement<any>

  • newHocs ...Array<Function>

  • rawComponent ReactElement<any> Interchangeable/extendable component.

  • hocs ...Function The HOCs to compose with the raw component.

Returns (Function | ReactElement<any>) A component callable with Components[name]Note: when a component is registered without higher order component, hocs will be an empty array, and it's ok! See https://lodash.com/docs/4.17.4#flowRight

ConfigRegistry

All system configs are stored in this registry

Properties

  • ConfigsTable Object Storage table of all configs

set

Set a Config

Parameters

get

Get a config value

Parameters

Returns any

register

Register a Config To be deprecated in 2.0.0

Parameters

  • configs {}

registerMany

Register many configs at once

Parameters

  • configs {}

EventEmitter

All system events are stored in this registry.It is using event emitter to emit and add events.

FilterRegistry

Extends MapRegistry

All system filters are stored in this registry

Properties

add

Add a filter function to a hook.To be deprecated in 2.0.0

Parameters

  • hook String The name of the hook

  • name (String | function) The name of filter function

  • filter Function The filter function

  • index number The index where function should be placed in array of functions against the hook

set

Add a filter function to a hook.

Parameters

  • hook String The name of the hook

  • name (String | function) The name of filter function

  • filter Function The filter function

  • index number The index where function should be placed in array of functions against the hook

remove

Remove a filter from a hook

Parameters

run

Successively run all of a hook's filters on an item

Parameters

  • hook String First argument: the name of the hook

  • item Object Second argument: the post, comment, modifier, etc.

    on which to run the filters

  • args Any Other arguments will be passed to each successive iteration

Returns Object Returns the item after it's been through all the filters for this hook

HookRegistry

All system hooks are stored in this registry

Parameters

  • filters

  • events

add

Add a filter function to a hook.

Parameters

run

Successively run all of a hook's functions on an item

Parameters

  • hook String First argument: the name of the hook

  • mode ("async" | "sync" | "both") Second argument: mode in which hook will run. If not given mode will be sync (optional, default 'sync')

  • args Any Other arguments will be passed to each successive iteration

Returns Object Returns the item after it's been through all the filters for this hook

Registry

A generic Registry class in the BlueRain OS. Used to store data.

Parameters

set

Add an item to the Registry.

Parameters

  • key string The key of the item

  • item any The item to add

  • rest ...Array<any>

replace

Replace an item in the Registry.

Parameters

  • key string The key of the item

  • item any The item to add

get

Get an item from the Registry by its key.

Parameters

  • key string The key of the item

Returns any

has

Check if an item is registered.

Parameters

Returns boolean

remove

Remove a plugin from the registry

Parameters

PluginRegistry

Extends MapRegistry

All system plugins are stored in this registry

Properties

register

Register a Plugin To be deprecated in 2.0.0

Parameters

  • plugin Plugin The plugin to register

set

Register a Plugin

Parameters

  • plugin Plugin The plugin to register

registerMany

Register many plugins at once

Parameters

initializeAll

Initialize all the registered plugins

Last updated