Client

The Edgemesh Client's Public API.

new Edgemesh(opts)

Creates an instance of the Edgemesh Client.

Returns: Edgemesh - Instance of the Edgemesh class.

Param

Type

Default

Description

opts

Object

{}

Client configuration options.

opts.lite

boolean

false

Lite mode disables the Edgemesh service worker. Customers that want to use Edgemesh only for its B2B Analyzer and Real User Metrics will want to set this to true.

opts.externalMount

boolean

false

External Mount mode instructs the Edgemesh client that it should skip registration of its own service worker and instead look for an externally mounted, Edgemesh compatible service worker. This is used by our partners to integrate Edgemesh into their services.

opts.swUrl

string

"/sw.js"

URL of the Edgemesh service worker. This options is used by Edgemesh integrations. You can add your service worker to a sub-directory and set this option, just make sure you know what you are doing.

opts.scope

string

"/"

Scope of the Edgemesh service worker. Change the scope at which the service worker is allowed to service. More on that here.

opts.host

string

"https://api.edgeme.sh"

Host of the Edgemesh back end. Don't change this unless instructed by your dedicated Edgemesh Engineer (Enterprise feature).

setLogLevel(level)

Set the Edgemesh log level.

Param

Type

Description

level

number

The integer representation of the Edgemesh log level.

Example

// Disable Logging.
window.edgemesh.setLogLevel(window.edgemesh.LOG_LEVELS.silent)
// Error Logging.
window.edgemesh.setLogLevel(window.edgemesh.LOG_LEVELS.error)
// Warning Logging.
window.edgemesh.setLogLevel(window.edgemesh.LOG_LEVELS.warn)
// Info Logging.
window.edgemesh.setLogLevel(window.edgemesh.LOG_LEVELS.log)
// Verbose Logging.
window.edgemesh.setLogLevel(window.edgemesh.LOG_LEVELS.debug)

devmode(enabled)

Enable and disable developer mode. Developer mode disables the Edgemesh service worker for your browser, preventing new assets from being registered.

Param

Type

Description

enabled

boolean

Enable or disable devmode.

Example

// Enable devmode.
window.edgemesh.devmode(true)
// Disable devmode.
window.edgemesh.devmode(false)

sync(type)

Calling the sync method will instruct the Edgemesh client to perform a background sync. By default, Edgemesh initates a background sync when the DOM has completed loading all it's required content. This method is provided if you want to hook background sync functionality into your own application or perform a sync on your own browser from the javascript console.

Param

Type

Default

Description

type

string

"all"

The type of sync operation. One of all, add or del.

// Perform a full Edgemesh backround sync.
edgemesh.sync()
// Perform a sync that removes all stale assets
edgemesh.sync('del')
// Perform a sync that adds new assets
edgemseh.sync('add')

LogLevels : Object

Edgemesh Log Levels

Name

Type

Description

Default

debug

number

Log everything.

0

log

number

Log info, warnings and errors.

1

warn

number

Log warnings and errors.

2

error

number

Log errors.

3

silent

number

Disable logs.

4