Version: 1.0
Status: ⚫⚪⚪
Spark plugin for Thunder framework.
This document describes purpose and functionality of the Spark plugin. It includes detailed specification about its configuration, methods and properties as well as sent notifications.
All identifiers of the interfaces described in this document are case-sensitive. Thus, unless stated otherwise, all keywords, entities, properties, relations and actions should be treated as such.
The table below provides and overview of acronyms used in this document and their definitions.
| Acronym | Description |
|---|---|
| API | Application Programming Interface |
| HTTP | Hypertext Transfer Protocol |
| JSON | JavaScript Object Notation; a data interchange format |
| JSON-RPC | A remote procedure call protocol encoded in JSON |
The table below provides and overview of terms and abbreviations used in this document and their definitions.
| Term | Description |
|---|---|
| callsign | The name given to an instance of a plugin. One plugin can be instantiated multiple times, but each instance the instance name, callsign, must be unique. |
| Ref ID | Description |
|---|---|
| HTTP | HTTP specification |
| JSON-RPC | JSON-RPC 2.0 specification |
| JSON | JSON specification |
| Thunder | Thunder API Reference |
The Spark plugin provides web browsing functionality based on the Spark engine.
The plugin is designed to be loaded and executed within the Thunder framework. For more information about the framework refer to [Thunder].
The table below lists configuration options of the plugin.
| Name | Type | M/O | Description |
|---|---|---|---|
| callsign | string | mandatory | Plugin instance name (default: Spark) |
| classname | string | mandatory | Class name: Spark |
| locator | string | mandatory | Library name: libThunderSpark.so |
| startmode | string | mandatory | Determines in which state the plugin should be moved to at startup of the framework |
| configuration | object | optional | ... |
| configuration?.url | string | optional | The URL that is loaded upon starting the browser |
This plugin implements the following interfaces:
- Browser.json (version 1.0.0) (uncompliant-extended format)
The following methods are provided by the Spark plugin:
Built-in methods:
| Method | Description |
|---|---|
| versions | Retrieves a list of JSON-RPC interfaces offered by this service |
| exists | Checks if a JSON-RPC method or property exists |
| register | Registers for an asynchronous JSON-RPC notification |
| unregister | Unregisters from an asynchronous JSON-RPC notification |
Browser interface methods:
| Method | Description |
|---|---|
| delete | Removes contents of a directory from the persistent storage |
versions method
Retrieves a list of JSON-RPC interfaces offered by this service.
This method takes no parameters.
| Name | Type | M/O | Description |
|---|---|---|---|
| result | array | mandatory | A list ofsinterfaces with their version numbers Array length must be at most 255 elements. |
| result[#] | object | mandatory | ... |
| result[#].name | string | mandatory | Name of the interface |
| result[#].major | integer | mandatory | Major part of version number |
| result[#].minor | integer | mandatory | Minor part of version number |
| result[#].patch | integer | mandatory | Patch part of version version number |
{
"jsonrpc": "2.0",
"id": 42,
"method": "Spark.1.versions"
}{
"jsonrpc": "2.0",
"id": 42,
"result": [
{
"name": "JMyInterface",
"major": 1,
"minor": 0,
"patch": 0
}
]
}exists method
Checks if a JSON-RPC method or property exists.
This method will return True for the following methods/properties: url, visibility, fps, versions, exists, register, unregister, delete.
| Name | Type | M/O | Description |
|---|---|---|---|
| params | object | mandatory | ... |
| params.method | string | mandatory | Name of the method or property to look up |
| Name | Type | M/O | Description |
|---|---|---|---|
| result | boolean | mandatory | Denotes if the method exists or not |
{
"jsonrpc": "2.0",
"id": 42,
"method": "Spark.1.exists",
"params": {
"method": "url"
}
}{
"jsonrpc": "2.0",
"id": 42,
"result": false
}register method
Registers for an asynchronous JSON-RPC notification.
This method supports the following event names: urlchange, visibilitychange, pageclosure.
| Name | Type | M/O | Description |
|---|---|---|---|
| params | object | mandatory | ... |
| params.event | string | mandatory | Name of the notification to register for |
| params.id | string | mandatory | Client identifier |
| Name | Type | M/O | Description |
|---|---|---|---|
| result | null | mandatory | Always null |
| Message | Description |
|---|---|
ERROR_FAILED_REGISTERED |
Failed to register for the notification (e.g. already registered) |
{
"jsonrpc": "2.0",
"id": 42,
"method": "Spark.1.register",
"params": {
"event": "urlchange",
"id": "myapp"
}
}{
"jsonrpc": "2.0",
"id": 42,
"result": null
}unregister method
Unregisters from an asynchronous JSON-RPC notification.
This method supports the following event names: urlchange, visibilitychange, pageclosure.
| Name | Type | M/O | Description |
|---|---|---|---|
| params | object | mandatory | ... |
| params.event | string | mandatory | Name of the notification to register for |
| params.id | string | mandatory | Client identifier |
| Name | Type | M/O | Description |
|---|---|---|---|
| result | null | mandatory | Always null |
| Message | Description |
|---|---|
ERROR_FAILED_UNREGISTERED |
Failed to unregister from the notification (e.g. not yet registered) |
{
"jsonrpc": "2.0",
"id": 42,
"method": "Spark.1.unregister",
"params": {
"event": "urlchange",
"id": "myapp"
}
}{
"jsonrpc": "2.0",
"id": 42,
"result": null
}delete method
Removes contents of a directory from the persistent storage.
Use this method to recursively delete contents of a directory
| Name | Type | M/O | Description |
|---|---|---|---|
| params | object | mandatory | ... |
| params.path | string | mandatory | Path to directory (within the persistent storage) to delete contents of |
| Name | Type | M/O | Description |
|---|---|---|---|
| result | null | mandatory | Always null (default: None) |
| Message | Description |
|---|---|
ERROR_UNKNOWN_KEY |
The given path was incorrect |
{
"jsonrpc": "2.0",
"id": 42,
"method": "Spark.1.delete",
"params": {
"path": ".cache/wpe/disk-cache"
}
}{
"jsonrpc": "2.0",
"id": 42,
"result": null
}The following properties are provided by the Spark plugin:
Browser interface properties:
| Property | R/W | Description |
|---|---|---|
| url | read/write | URL loaded in the browser |
| visibility | read/write | Current browser visibility |
| fps | read-only | Current number of frames per second the browser is rendering |
url property
Provides access to the URL loaded in the browser.
Also see: urlchange
| Name | Type | M/O | Description |
|---|---|---|---|
| (property) | string | mandatory | URL loaded in the browser |
| Name | Type | M/O | Description |
|---|---|---|---|
| (property) | string | mandatory | URL loaded in the browser |
| Message | Description |
|---|---|
ERROR_INCORRECT_URL |
Incorrect URL given |
{
"jsonrpc": "2.0",
"id": 42,
"method": "Spark.1.url"
}{
"jsonrpc": "2.0",
"id": 42,
"result": "https://www.google.com"
}{
"jsonrpc": "2.0",
"id": 42,
"method": "Spark.1.url",
"params": "https://www.google.com"
}{
"jsonrpc": "2.0",
"id": 42,
"result": "null"
}visibility property
Provides access to the current browser visibility.
Also see: visibilitychange
| Name | Type | M/O | Description |
|---|---|---|---|
| (property) | string | mandatory | Current browser visibility (must be one of the following: hidden, visible) |
| Name | Type | M/O | Description |
|---|---|---|---|
| (property) | string | mandatory | Current browser visibility (must be one of the following: hidden, visible) |
| Message | Description |
|---|---|
ERROR_UNAVAILABLE |
Returned when the operation is unavailable |
{
"jsonrpc": "2.0",
"id": 42,
"method": "Spark.1.visibility"
}{
"jsonrpc": "2.0",
"id": 42,
"result": "hidden"
}{
"jsonrpc": "2.0",
"id": 42,
"method": "Spark.1.visibility",
"params": "hidden"
}{
"jsonrpc": "2.0",
"id": 42,
"result": "null"
}fps property
Provides access to the current number of frames per second the browser is rendering.
This property is read-only.
| Name | Type | M/O | Description |
|---|---|---|---|
| (property) | integer | mandatory | Current number of frames per second the browser is rendering |
{
"jsonrpc": "2.0",
"id": 42,
"method": "Spark.1.fps"
}{
"jsonrpc": "2.0",
"id": 42,
"result": 30
}Notifications are autonomous events triggered by the internals of the implementation and broadcasted via JSON-RPC to all registered observers. Refer to [Thunder] for information on how to register for a notification.
The following events are provided by the Spark plugin:
Browser interface events:
| Notification | Description |
|---|---|
| urlchange | Signals a URL change in the browser |
| visibilitychange | Signals a visibility change of the browser |
| pageclosure | Notifies that the web page requests to close its window |
urlchange notification
Signals a URL change in the browser.
| Name | Type | M/O | Description |
|---|---|---|---|
| params | object | mandatory | ... |
| params.url | string | mandatory | The URL that has been loaded or requested |
| params.loaded | boolean | mandatory | Determines if the URL has just been loaded (true) or if URL change has been requested (false) (default: True) |
{
"jsonrpc": "2.0",
"id": 42,
"method": "Spark.1.register",
"params": {
"event": "urlchange",
"id": "myid"
}
}{
"jsonrpc": "2.0",
"method": "myid.urlchange",
"params": {
"url": "https://www.google.com",
"loaded": false
}
}The client ID parameter is passed within the notification designator, i.e.
<client-id>.urlchange.
visibilitychange notification
Signals a visibility change of the browser.
| Name | Type | M/O | Description |
|---|---|---|---|
| params | object | mandatory | ... |
| params.hidden | boolean | mandatory | Determines if the browser has been hidden (true) or made visible (false) |
{
"jsonrpc": "2.0",
"id": 42,
"method": "Spark.1.register",
"params": {
"event": "visibilitychange",
"id": "myid"
}
}{
"jsonrpc": "2.0",
"method": "myid.visibilitychange",
"params": {
"hidden": false
}
}The client ID parameter is passed within the notification designator, i.e.
<client-id>.visibilitychange.
pageclosure notification
Notifies that the web page requests to close its window.
This notification carries no parameters.
{
"jsonrpc": "2.0",
"id": 42,
"method": "Spark.1.register",
"params": {
"event": "pageclosure",
"id": "myid"
}
}{
"jsonrpc": "2.0",
"method": "myid.pageclosure"
}The client ID parameter is passed within the notification designator, i.e.
<client-id>.pageclosure.