@signageos/front-applet 5.0.0-beta.8 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +71 -1
- package/dist/bundle.js +2 -2
- package/dist/bundle.js.map +1 -1
- package/docs/js-api/js-api-introduction.md +37 -22
- package/docs/js-api/js-applet-basics.md +4 -0
- package/docs/js-api/js-browser.md +12 -6
- package/docs/js-api/js-command.md +33 -12
- package/docs/js-api/js-display.md +48 -0
- package/docs/js-api/js-file-system.md +106 -7
- package/docs/js-api/js-hardware-serial.md +2 -2
- package/docs/js-api/js-input.md +27 -2
- package/docs/js-api/js-offline-cache-media-files.md +19 -7
- package/docs/js-api/js-video-stream.md +3 -3
- package/docs/management-api/10-js-management-application.md +18 -1
- package/docs/management-api/11-js-management-network.md +122 -3
- package/docs/management-api/13-js-management-wifi.md +4 -0
- package/docs/management-api/2-js-management-firmware.md +4 -0
- package/docs/management-api/5-js-management-screen.md +8 -4
- package/docs/management-api/6-js-management-time.md +17 -1
- package/es6/FrontApplet/Browser/Browser.d.ts +16 -6
- package/es6/FrontApplet/Browser/Browser.js +39 -12
- package/es6/FrontApplet/Browser/Browser.js.map +1 -1
- package/es6/FrontApplet/Browser/IOpenLinkOptions.d.ts +8 -0
- package/es6/FrontApplet/Browser/IOpenLinkOptions.js +4 -0
- package/es6/FrontApplet/Browser/IOpenLinkOptions.js.map +1 -1
- package/es6/FrontApplet/Browser/events.d.ts +15 -0
- package/es6/FrontApplet/Browser/events.js +14 -0
- package/es6/FrontApplet/Browser/events.js.map +1 -0
- package/es6/FrontApplet/Browser/messages.d.ts +5 -0
- package/es6/FrontApplet/Browser/messages.js +3 -0
- package/es6/FrontApplet/Browser/messages.js.map +1 -0
- package/es6/FrontApplet/Debug/Debug.d.ts +22 -0
- package/es6/FrontApplet/Debug/Debug.js +35 -0
- package/es6/FrontApplet/Debug/Debug.js.map +1 -0
- package/es6/FrontApplet/Exchange/Exchange.d.ts +7 -0
- package/es6/FrontApplet/Exchange/Exchange.js +28 -0
- package/es6/FrontApplet/Exchange/Exchange.js.map +1 -0
- package/es6/FrontApplet/FileSystem/FileSystem.d.ts +1 -0
- package/es6/FrontApplet/FileSystem/FileSystem.js +10 -0
- package/es6/FrontApplet/FileSystem/FileSystem.js.map +1 -1
- package/es6/FrontApplet/FrontApplet.d.ts +4 -2
- package/es6/FrontApplet/FrontApplet.js +20 -7
- package/es6/FrontApplet/FrontApplet.js.map +1 -1
- package/es6/FrontApplet/Hardware/BarcodeScanner/BarcodeScanner.d.ts +30 -0
- package/es6/FrontApplet/Hardware/BarcodeScanner/BarcodeScanner.js +92 -0
- package/es6/FrontApplet/Hardware/BarcodeScanner/BarcodeScanner.js.map +1 -0
- package/es6/FrontApplet/Hardware/BarcodeScanner/IBarcodeScannerDataMessage.d.ts +5 -0
- package/es6/FrontApplet/Hardware/BarcodeScanner/IBarcodeScannerDataMessage.js +3 -0
- package/es6/FrontApplet/Hardware/BarcodeScanner/IBarcodeScannerDataMessage.js.map +1 -0
- package/es6/FrontApplet/Hardware/Hardware.d.ts +4 -1
- package/es6/FrontApplet/Hardware/Hardware.js +3 -0
- package/es6/FrontApplet/Hardware/Hardware.js.map +1 -1
- package/es6/FrontApplet/Management/INetworkInfo.d.ts +26 -2
- package/es6/FrontApplet/Management/INetworkInfo.js +7 -1
- package/es6/FrontApplet/Management/INetworkInfo.js.map +1 -1
- package/es6/FrontApplet/Management/Network.d.ts +18 -2
- package/es6/FrontApplet/Management/Network.js +51 -9
- package/es6/FrontApplet/Management/Network.js.map +1 -1
- package/es6/FrontApplet/Management/Time.d.ts +18 -0
- package/es6/FrontApplet/Management/Time.js +16 -4
- package/es6/FrontApplet/Management/Time.js.map +1 -1
- package/es6/FrontApplet/Management/Wifi.d.ts +13 -1
- package/es6/FrontApplet/Management/Wifi.js +12 -1
- package/es6/FrontApplet/Management/Wifi.js.map +1 -1
- package/es6/FrontApplet/Management/helpers/SecurityHelper.js +1 -1
- package/es6/FrontApplet/Validate/Validate.js +1 -1
- package/es6/FrontApplet/Validate/Validate.js.map +1 -1
- package/es6/Monitoring/Montoring.js +1 -1
- package/es6/Monitoring/Montoring.js.map +1 -1
- package/package.json +6 -33
- package/docs/js-api/js-timing.md +0 -54
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
title:
|
|
2
|
+
title: JS SDK Home
|
|
3
3
|
author: Josef Kral
|
|
4
4
|
date: 4.2.2018
|
|
5
5
|
type: rest-api
|
|
@@ -9,49 +9,48 @@ tags:
|
|
|
9
9
|
- api
|
|
10
10
|
description: "[Content JS API] General introduction to signageOS JS API"
|
|
11
11
|
---
|
|
12
|
-
# Applet
|
|
12
|
+
# Javascript SDK for Applet development
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
You can use the same functions across all devices with the same result. Applet JS API is available automatically within your Applet out-of-the-box.
|
|
16
|
-
|
|
17
|
-
Applet JS API supports content-playback features and device management features.
|
|
18
|
-
|
|
19
|
-
### About signageOS APIs
|
|
20
|
-
|
|
21
|
-
In signageOS there are 2 main groups of APIs:
|
|
22
|
-
- `Client-side` - JS API available for both **signageOS Open** and signageOS Platform plans
|
|
23
|
-
- `Server-side` - REST API available in **signageOS Platform plan only**
|
|
14
|
+
Javascript SDK gives you access to device's native features and functionalities. You can use the same functions across all devices with the same result.
|
|
24
15
|
|
|
25
16
|
::: alert alert--tip
|
|
26
|
-
All APIs are standardized and available across all [supported devices](/
|
|
17
|
+
All APIs are standardized and available across all [supported devices](https://signageos.zendesk.com/hc/en-us/sections/4405700629266-Supported-Devices).
|
|
27
18
|
:::
|
|
28
19
|
|
|
29
|
-
## Content-
|
|
30
|
-
|
|
20
|
+
## Content-related JS APIs
|
|
21
|
+
|
|
22
|
+
Content-related APIs help you with content part of your application /Applet/.
|
|
23
|
+
|
|
24
|
+
Universal APIs for File system, access to accelerated video playback, sensor management and more provide you with robust tool set for creating extensive experiences.
|
|
31
25
|
|
|
32
26
|
::: table-responsive
|
|
33
27
|
| Domain | Description |
|
|
34
28
|
| ------ | ----------- |
|
|
35
29
|
| **[Basic information](/api/js/content/js-applet-basics)** | General information required to use the signageOS JS API |
|
|
36
30
|
| [Applet Resources](/api/js/content/js-applet-resources) | Pre-load necessary files required by your HTML5 player/Applet |
|
|
31
|
+
| [Display](/api/js/content/js-display) | Query features supported by the display |
|
|
37
32
|
| [Browser](/api/js/content/js-browser) | Opening managed web-browser on Android devices inc. whitelisting, blacklisting and other features |
|
|
38
33
|
| [Command](/api/js/content/js-command) | Sending business or technical logs through signageOS in secured offline-ready way |
|
|
39
34
|
| [File system](/api/js/content/js-file-system) | Full-featured file system API including ZIP and folder management |
|
|
35
|
+
| [Fonts](/api/js/content/js-loading-fonts) | Make it easy to load additional fonts into SoC devices |
|
|
40
36
|
| [Hardware](/api/js/content/js-hardware) | Hardware-specific APIs like LED lights on Philips 10BDL |
|
|
41
|
-
| [Serial](/api/js/content/js-hardware-serial) | Control external devices via serial |
|
|
42
37
|
| [Inputs](/api/js/content/js-input) | Controller inputs like IR remote unified under one API |
|
|
43
|
-
| [
|
|
38
|
+
| [Monitors](/api/js/content/js-monitors) | Information about monitors |
|
|
39
|
+
| [Sensors](/api/js/content/js-sensors) | Using sensors and IoT devices in your application |
|
|
40
|
+
| [Serial](/api/js/content/js-hardware-serial) | Control external devices via serial |
|
|
44
41
|
| [Synchronized playback](/api/js/content/js-sync-playback) | API for creating synced playback and videowalls |
|
|
45
|
-
| [Timings](/api/js/content/js-timing) | Managing Timing/Applet switching from JS |
|
|
46
42
|
| [Video Inputs aka PiP](/api/js/content/js-video-inputs-internal-ports) | Show HDMI/DP/VGA as a part of your content via PiP feature |
|
|
47
43
|
| [Video Playback](/api/js/content/js-video) | Playing accelerated gapless videos via native video player |
|
|
48
44
|
| [Video Streams](/api/js/content/js-video-stream) | Playing video streams (RTSP, HLS, UDP) via native video player |
|
|
49
|
-
| [Sensors](/api/js/content/js-sensors) | Using sensors and IoT devices in your application |
|
|
50
|
-
| [Monitors](/api/js/content/js-monitors) | Information about monitors |
|
|
51
45
|
:::
|
|
52
46
|
|
|
53
|
-
## Device
|
|
54
|
-
|
|
47
|
+
## Device control JS APIs
|
|
48
|
+
|
|
49
|
+
Device control features exposed via Javascript APIs.
|
|
50
|
+
|
|
51
|
+
::: alert alert--tip
|
|
52
|
+
For **Device Management** we strongly recommend using REST APIs. [See the REST API documentation here](https://api.docs.signageos.io).
|
|
53
|
+
:::
|
|
55
54
|
|
|
56
55
|
::: table-responsive
|
|
57
56
|
| Domain | Description |
|
|
@@ -63,6 +62,22 @@ Device management API is for managing, updating firmware, and other settings on
|
|
|
63
62
|
| [Screen](/api/js/management/5-js-management-screen) | Manage brightness, orientation and resolution, display on/off |
|
|
64
63
|
| [Time](/api/js/management/6-js-management-time) | Set time, timezone and get current settings |
|
|
65
64
|
| [Volume](/api/js/management/7-js-management-volume) | Control system volume level |
|
|
65
|
+
| [Package](/api/js/management/8-js-management-package) | Install and manage packages |
|
|
66
|
+
| [Debug](/api/js/management/9-js-management-debug) | Enable/disable debug mode |
|
|
67
|
+
| [Application](/api/js/management/10-js-management-application) | Get application version and upgrade application from remote location |
|
|
68
|
+
| [Network](/api/js/management/11-js-management-network) | Manage network settings |
|
|
66
69
|
| [Security](/api/js/management/12-js-management-security) | Control system security (PIN code) |
|
|
67
70
|
| [Wi-Fi](/api/js/management/13-js-management-wifi) | Manage Wi-Fi |
|
|
68
71
|
:::
|
|
72
|
+
|
|
73
|
+
# Node.JS SDK
|
|
74
|
+
|
|
75
|
+
Library which allows you to fully manage signageOS applets, devices, management & monitoring using Node.JS and REST API.
|
|
76
|
+
|
|
77
|
+
See full [documentation on GitHub](https://github.com/signageos/sdk)
|
|
78
|
+
|
|
79
|
+
# REST API
|
|
80
|
+
|
|
81
|
+
Large collection of REST API endpoints for device management and monitoring.
|
|
82
|
+
|
|
83
|
+
See full [documentation on Postman](https://api.docs.signageos.io)
|
|
@@ -16,12 +16,16 @@ description: "[Content JS API] This thread contains basic methods of every Apple
|
|
|
16
16
|
This thread contains basic methods of every Applet used to load necessary configuration or device identifications and how to create Applet.
|
|
17
17
|
|
|
18
18
|
## All methods and properties
|
|
19
|
+
|
|
19
20
|
::: table-responsive
|
|
20
21
|
| Methods/Property | Description | Supported since |
|
|
21
22
|
| ----------------- | ----------- | :---------------: |
|
|
22
23
|
| `onReady()` | This method will wait until sOS object library and all dependencies are ready to be used. | 1.0.0 |
|
|
23
24
|
| `restore()` | Clear all previously played videos, streams, clear display view. | 1.0.0 |
|
|
24
25
|
| `appletVersion` | Returns current Applet version | JS API `4.5.0`, Front-display `7.8.0`|
|
|
26
|
+
| `config` object | Returns object with key-values set via Timing or as a bundled config| JS API `1.5.0`, Front-display `6.8.0`|
|
|
27
|
+
| `config` object | Returns object with key-values set via Timing or as a bundled config| `1.0.0`|
|
|
28
|
+
| `capabilities` | Enum of device-specific capabilities and features | `1.0.0`|
|
|
25
29
|
:::
|
|
26
30
|
|
|
27
31
|
## Starting Applet
|
|
@@ -21,7 +21,6 @@ Default URL can be opened and even the whitelisting/blacklisting of certain doma
|
|
|
21
21
|
::: table-responsive
|
|
22
22
|
| Methods | Description | Supported since |
|
|
23
23
|
| ----------------- | ----------- | ----- | :---------------: |
|
|
24
|
-
| `openLink()` | **Deprecated:** Use `open()` instead. | 1.0.19 |
|
|
25
24
|
| `open()` | Open page in integrated browser | 4.0.0 |
|
|
26
25
|
| `close()` | Open page in integrated browser | 4.4.0 |
|
|
27
26
|
:::
|
|
@@ -33,9 +32,9 @@ Default URL can be opened and even the whitelisting/blacklisting of certain doma
|
|
|
33
32
|
- Android devices with Android 5+ (Philips, Benq, Sharp, generic Android device)
|
|
34
33
|
|
|
35
34
|
**With some limitation you can use this API also on**
|
|
36
|
-
- Samsung Tizen (SSSP 4 and above); where the website is just in fullscreen without
|
|
37
|
-
- LG webOS (webOS 3.0 and above); where the website is just in fullscreen without
|
|
38
|
-
- Raspberry Pi and NEC Compute Module;
|
|
35
|
+
- Samsung Tizen (SSSP 4 and above); where the website is just in fullscreen without an address bar or theme options (headless mode)
|
|
36
|
+
- LG webOS (webOS 3.0 and above); where the website is just in fullscreen without an address bar or theme options (headless mode)
|
|
37
|
+
- Raspberry Pi and NEC Compute Module; where the website is just in fullscreen without an address bar or theme options (headless mode)
|
|
39
38
|
:::
|
|
40
39
|
|
|
41
40
|
### Javascript
|
|
@@ -56,6 +55,9 @@ Method `open()` also supports properties for browser. You can set height, width
|
|
|
56
55
|
| `coordinates` | Object | Size of browser screen (only Raspberry Pi) |
|
|
57
56
|
| `idleTimeout` | Number | Timeout in milliseconds for loading page |
|
|
58
57
|
| `theme` | Object | Setting custom theme for Android |
|
|
58
|
+
| `headlessMode` | Boolean | Headless mode hides the entire address bar (default) |
|
|
59
|
+
| `canUserClose` | Boolean | Whether the user can manually close the browser. Default:<br>**Headless:** `false`<br>**With UI:** `true` |
|
|
60
|
+
| `clearData` | Boolean | Clear cache after the browser closes. Default:<br>**Headless:** `false`<br>**With UI:** `true` |
|
|
59
61
|
:::
|
|
60
62
|
|
|
61
63
|
|
|
@@ -64,13 +66,14 @@ sos.browser.open('https://www.signageos.io', {
|
|
|
64
66
|
aclDomains: ['google.com', 'yahoo.com'],
|
|
65
67
|
aclMode: 'blacklist', // or 'whitelist'
|
|
66
68
|
readOnlyAddressBar: true,
|
|
67
|
-
coordinates: { // Supported only on Raspberry Pi
|
|
69
|
+
coordinates: { // Supported only on Raspberry Pi and Android
|
|
68
70
|
x: 0,
|
|
69
71
|
y: 0,
|
|
70
72
|
height: 500,
|
|
71
73
|
width: 500,
|
|
72
74
|
},
|
|
73
75
|
// theme: { ... } // supported only on Android
|
|
76
|
+
headlessMode: false, // supported only on Android
|
|
74
77
|
```
|
|
75
78
|
|
|
76
79
|
<div class="row d-flex align-content-stretch force-padding-20">
|
|
@@ -141,7 +144,10 @@ interface IOpenLinkOptions {
|
|
|
141
144
|
width: number;
|
|
142
145
|
height: number;
|
|
143
146
|
};
|
|
144
|
-
theme?: ITheme;
|
|
147
|
+
theme?: ITheme;
|
|
148
|
+
headlessMode?: boolean;
|
|
149
|
+
clearData?: boolean;
|
|
150
|
+
canUserClose?: boolean;
|
|
145
151
|
}
|
|
146
152
|
|
|
147
153
|
open(uri: string, options?: IOpenLinkOptions): void;
|
|
@@ -13,15 +13,22 @@ description: "[Content JS API] In some cases, you might be interested in a compl
|
|
|
13
13
|
|
|
14
14
|
# Command
|
|
15
15
|
|
|
16
|
-
## Command dispatching
|
|
17
16
|
In some cases, you might be interested in a complete log of what the device was doing during its operation. All of your business or technical logs can be stored in our storage for later usage. You can identify which events happened or even trigger self-repairing logic.
|
|
18
17
|
|
|
19
|
-
All commands will be available in [Applet Command REST API](https://api.docs.signageos.io/#
|
|
18
|
+
All commands will be available in [Applet Command REST API](https://api.docs.signageos.io/#8e7a8814-e612-1fad-0152-72f37591c7f2) and can be downloaded [historically as CSV export](https://api.docs.signageos.io/#5dceec58-ac4f-7a0c-f5ef-0854f9376e6d).
|
|
20
19
|
|
|
20
|
+
## All methods
|
|
21
21
|
::: table-responsive
|
|
22
22
|
| Methods | Description | Supported since |
|
|
23
|
-
| ----------------- | ----------- | ----- |
|
|
24
|
-
| `dispatch()` | Dispatch method for
|
|
23
|
+
| ----------------- | ----------- | ----- |
|
|
24
|
+
| `dispatch()` | Dispatch method for sending logs and data from device | 1.0.3 |
|
|
25
|
+
| `onCommand()` | Event listener for incoming commands from server | 1.0.3 |
|
|
26
|
+
|
|
27
|
+
:::
|
|
28
|
+
|
|
29
|
+
## dispatch()
|
|
30
|
+
|
|
31
|
+
Dispatch() is used for sending your custom logs or data from device to signageOS.
|
|
25
32
|
|
|
26
33
|
### Parameters
|
|
27
34
|
::: table-responsive
|
|
@@ -99,27 +106,41 @@ dispatch(command: ICommand): void;
|
|
|
99
106
|
|
|
100
107
|
<div class="row d-flex align-content-stretch force-padding-20">
|
|
101
108
|
<div class="col-12 d-flex">
|
|
102
|
-
<a class="wide-box wide-box--white d-flex align-content-stretch widebox-kb-color" href="
|
|
109
|
+
<a class="wide-box wide-box--white d-flex align-content-stretch widebox-kb-color" href="https://api.docs.signageos.io/#8e7a8814-e612-1fad-0152-72f37591c7f2">
|
|
103
110
|
<div>
|
|
104
111
|
<div class="wide-box__image d-flex align-items-center">
|
|
105
112
|
<i class="fas fa-server svg-black"></i>
|
|
106
113
|
</div>
|
|
107
114
|
<div>
|
|
108
|
-
<h3 class="wide-box__title wide-box__title__small pl-85">Rest API:
|
|
109
|
-
<div class="wide-box__description">Receiving
|
|
115
|
+
<h3 class="wide-box__title wide-box__title__small pl-85">Rest API: Get Commands</h3>
|
|
116
|
+
<div class="wide-box__description">Receiving your data dispatched from devices</div>
|
|
110
117
|
</div>
|
|
111
118
|
</div>
|
|
112
119
|
</a>
|
|
113
120
|
</div>
|
|
114
121
|
</div>
|
|
115
122
|
|
|
116
|
-
|
|
123
|
+
<div class="row d-flex align-content-stretch force-padding-20">
|
|
124
|
+
<div class="col-12 d-flex">
|
|
125
|
+
<a class="wide-box wide-box--white d-flex align-content-stretch widebox-kb-color" href="https://api.docs.signageos.io/#5dceec58-ac4f-7a0c-f5ef-0854f9376e6d">
|
|
126
|
+
<div>
|
|
127
|
+
<div class="wide-box__image d-flex align-items-center">
|
|
128
|
+
<i class="fas fa-server svg-black"></i>
|
|
129
|
+
</div>
|
|
130
|
+
<div>
|
|
131
|
+
<h3 class="wide-box__title wide-box__title__small pl-85">Rest API: Monitoring/Device Reports</h3>
|
|
132
|
+
<div class="wide-box__description">Receiving historical data</div>
|
|
133
|
+
</div>
|
|
134
|
+
</div>
|
|
135
|
+
</a>
|
|
136
|
+
</div>
|
|
137
|
+
</div>
|
|
138
|
+
|
|
139
|
+
## onCommand()
|
|
117
140
|
Used for sending custom messages to online connected devices.
|
|
118
|
-
This can be done through the REST API by [POST new applet command](https://docs.signageos.io
|
|
141
|
+
This can be done through the REST API by [POST new applet command](https://api.docs.signageos.io/#511e18f3-b61b-a049-6395-8541132adc44).
|
|
119
142
|
The command will be dispatched to the device & the applet can set up the logic by subscribing `onCommand` method.
|
|
120
143
|
|
|
121
|
-
Dispatched commands will are available in Device Monitoring REST API.
|
|
122
|
-
|
|
123
144
|
**Parameters:**
|
|
124
145
|
::: table-responsive
|
|
125
146
|
| Param | Type | Required | Description |
|
|
@@ -161,7 +182,7 @@ onCommand(listener: (command: ICommand) => void): void;
|
|
|
161
182
|
|
|
162
183
|
<div class="row d-flex align-content-stretch force-padding-20">
|
|
163
184
|
<div class="col-12 d-flex">
|
|
164
|
-
<a class="wide-box wide-box--white d-flex align-content-stretch widebox-kb-color" href="
|
|
185
|
+
<a class="wide-box wide-box--white d-flex align-content-stretch widebox-kb-color" href="https://api.docs.signageos.io/#511e18f3-b61b-a049-6395-8541132adc44">
|
|
165
186
|
<div>
|
|
166
187
|
<div class="wide-box__image d-flex align-items-center">
|
|
167
188
|
<i class="fas fa-server svg-black"></i>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Display
|
|
3
|
+
author: Michal Artazov
|
|
4
|
+
date: 12.4.2021
|
|
5
|
+
type: js-api
|
|
6
|
+
tags:
|
|
7
|
+
- applet
|
|
8
|
+
- applet_api
|
|
9
|
+
- api
|
|
10
|
+
- display
|
|
11
|
+
- js_api
|
|
12
|
+
description: "[Content JS API] Display API allows you to query the display to find out, which features it supports."
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
# Display
|
|
16
|
+
|
|
17
|
+
Display API allows you to query the display to find out, which features it supports.
|
|
18
|
+
That way your applet can handle cases, when a certain feature isn't supported by a particular display.
|
|
19
|
+
|
|
20
|
+
## All methods
|
|
21
|
+
|
|
22
|
+
::: table-responsive
|
|
23
|
+
| Method | Description | Supported since |
|
|
24
|
+
| ------------------ | ---------------------- | :-------------: |
|
|
25
|
+
| `supports()` | Query, whether a certain feature is supported by the display | 3.1.0 |
|
|
26
|
+
:::
|
|
27
|
+
|
|
28
|
+
## supports()
|
|
29
|
+
|
|
30
|
+
Query the display to find out, whether a certain feature is supported.
|
|
31
|
+
To let you know, when you should call this method, we will warn you throughout the content JS API documentation
|
|
32
|
+
with a warning message like this one:
|
|
33
|
+
|
|
34
|
+
::: alert alert--warning
|
|
35
|
+
* Before using this API, ensure that the display supports serial via `sos.display.supports("SERIAL")`.
|
|
36
|
+
* More info [**HERE**](/api/js/content/js-display#supports).
|
|
37
|
+
:::
|
|
38
|
+
|
|
39
|
+
::: table-responsive
|
|
40
|
+
| Param | Type | Required | Description |
|
|
41
|
+
| ------------ | ------ | :------------------------: | --------------- |
|
|
42
|
+
| `capability` | string | <div class="red">Yes</div> | Capability name |
|
|
43
|
+
:::
|
|
44
|
+
|
|
45
|
+
### Javascript example
|
|
46
|
+
```javascript
|
|
47
|
+
const serialPort = await sos.display.supports("SERIAL");
|
|
48
|
+
```
|
|
@@ -69,10 +69,12 @@ File System directory structure is **PERSISTENT** and is **NOT** automatically d
|
|
|
69
69
|
| `isDirectory()` | Returns true if existing path is directory | 2.1.0 |
|
|
70
70
|
| `copyFile()` | Copy file or directory to a new location | 3.3.0 |
|
|
71
71
|
| `writeFile()` | Write string to a file | 3.2.0 |
|
|
72
|
+
| `appendFile()` | Write string to a file | 4.13.0 |
|
|
72
73
|
| `readFile()` | Read a text file | 3.3.0 |
|
|
73
74
|
:::
|
|
74
75
|
|
|
75
76
|
## listStorageUnits()
|
|
77
|
+
|
|
76
78
|
Return list of storage units /internal, external/ from the device. Capacity values are in bytes.
|
|
77
79
|
|
|
78
80
|
::: alert alert--info
|
|
@@ -85,6 +87,7 @@ This is a mandatory method that is required for all the other File System APIs.
|
|
|
85
87
|
|
|
86
88
|
|
|
87
89
|
### Javascript Example
|
|
90
|
+
|
|
88
91
|
```javascript
|
|
89
92
|
// Storage units are equivalent to disk volumes (C:, D: etc on Windows; /mnt/disc1, /mnt/disc2 on Unix)
|
|
90
93
|
const storageUnits = await sos.fileSystem.listStorageUnits();
|
|
@@ -94,6 +97,7 @@ const internalStorageUnit = storageUnits.find((storageUnit) => !storageUnit.remo
|
|
|
94
97
|
|
|
95
98
|
console.log(storageUnits);
|
|
96
99
|
```
|
|
100
|
+
|
|
97
101
|
### Returns
|
|
98
102
|
|
|
99
103
|
```json
|
|
@@ -115,14 +119,15 @@ console.log(storageUnits);
|
|
|
115
119
|
]
|
|
116
120
|
```
|
|
117
121
|
|
|
118
|
-
|
|
119
122
|
## listFiles()
|
|
123
|
+
|
|
120
124
|
List files and folders located in the internal/external storage.
|
|
121
125
|
* SUCCESS: Return list of files of existing directory
|
|
122
126
|
* FAIL: When listing not existing directory
|
|
123
127
|
* FAIL: When listing existing file (not a directory)
|
|
124
128
|
|
|
125
129
|
### Javascript Example
|
|
130
|
+
|
|
126
131
|
```javascript
|
|
127
132
|
// Storage units are equivalent to disk volumes (C:, D: etc on Windows; /mnt/disc1, /mnt/disc2 on Unix)
|
|
128
133
|
const storageUnits = await sos.fileSystem.listStorageUnits();
|
|
@@ -203,16 +208,19 @@ console.log(testDirDirectoryFilePaths);
|
|
|
203
208
|
```
|
|
204
209
|
|
|
205
210
|
## getFile()
|
|
211
|
+
|
|
206
212
|
Return a file from an internal storage
|
|
207
213
|
* OK: Returns local uri of existing file
|
|
208
214
|
* OK: Returns NULL of not existing file
|
|
209
215
|
|
|
210
216
|
### Parameters
|
|
217
|
+
|
|
211
218
|
| Param | Type | Required | Description |
|
|
212
219
|
| -------------- | ------ | :-------: | ----- |
|
|
213
220
|
| `filePath` | FilePath | <div class="red">Yes</div> | Object contains storageUnit object returned by `listStorageUnits()` and `filePath` if the file or directory |
|
|
214
221
|
|
|
215
222
|
### Javascript Example
|
|
223
|
+
|
|
216
224
|
```javascript
|
|
217
225
|
// always pass storageUnit to tell the JS API where to look
|
|
218
226
|
// get properties of file (at least localUri) or null when not exist
|
|
@@ -243,6 +251,7 @@ Return statement is a dynamic object! It has to be always generated and retrieve
|
|
|
243
251
|
```
|
|
244
252
|
|
|
245
253
|
## exists()
|
|
254
|
+
|
|
246
255
|
* OK: Returns true of existing directory or file
|
|
247
256
|
* OK: Returns false of not existing directory nor file
|
|
248
257
|
|
|
@@ -253,6 +262,7 @@ Return statement is a dynamic object! It has to be always generated and retrieve
|
|
|
253
262
|
| `filePath` | FilePath | <div class="red">Yes</div> | Object contains storageUnit object returned by `listStorageUnits()` and `filePath` if the file or directory |
|
|
254
263
|
|
|
255
264
|
### Javascript Example
|
|
265
|
+
|
|
256
266
|
```javascript
|
|
257
267
|
// always pass storageUnit to tell the JS API where to look
|
|
258
268
|
// check if there is such a file
|
|
@@ -262,9 +272,11 @@ console.log(fileExists);
|
|
|
262
272
|
```
|
|
263
273
|
|
|
264
274
|
### Returns
|
|
275
|
+
|
|
265
276
|
Boolean value
|
|
266
277
|
|
|
267
278
|
## downloadFile()
|
|
279
|
+
|
|
268
280
|
Download file to path within existing directory or **overrides existing file** in a path when successfully downloaded
|
|
269
281
|
|
|
270
282
|
* OK: Download file to path within existing directory
|
|
@@ -285,6 +297,7 @@ Download file to path within existing directory or **overrides existing file** i
|
|
|
285
297
|
:::
|
|
286
298
|
|
|
287
299
|
### Javascript Example
|
|
300
|
+
|
|
288
301
|
```javascript
|
|
289
302
|
// You can download file to specific existing directory
|
|
290
303
|
await sos.fileSystem.downloadFile(
|
|
@@ -294,7 +307,39 @@ await sos.fileSystem.downloadFile(
|
|
|
294
307
|
);
|
|
295
308
|
```
|
|
296
309
|
|
|
310
|
+
#### Encoding
|
|
311
|
+
|
|
312
|
+
All downloads respect a standard of `Encoding` with optional compression of files. See [Mozilla standard Accept Encoding](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Encoding) and [Content Encoding](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding).
|
|
313
|
+
|
|
314
|
+
Download file method is always sending optional following headers:
|
|
315
|
+
```
|
|
316
|
+
Accept-Encoding: gzip
|
|
317
|
+
Accept-Encoding: compress
|
|
318
|
+
Accept-Encoding: deflate
|
|
319
|
+
Accept-Encoding: br
|
|
320
|
+
Accept-Encoding: identity
|
|
321
|
+
Accept-Encoding: *
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
If the server understands the `Encoding` standard, it compresses files using `gzip` algorithm before the files are sent to the client. If so, the response will contain the following headers:
|
|
325
|
+
```
|
|
326
|
+
Content-Encoding: gzip
|
|
327
|
+
Content-Encoding: compress
|
|
328
|
+
Content-Encoding: deflate
|
|
329
|
+
Content-Encoding: br
|
|
330
|
+
```
|
|
331
|
+
So the data communication is compressed under the hood. The client will automatically decompress data before it's saved to a specified location path. So from JS API point of view, there is no requirement to decompress data by itself.
|
|
332
|
+
|
|
333
|
+
The standard is supported on all following platforms:
|
|
334
|
+
|
|
335
|
+
- WebOS 3+
|
|
336
|
+
- Tizen 2.4+
|
|
337
|
+
- Brightsign
|
|
338
|
+
- Raspberry Pi
|
|
339
|
+
- Windows
|
|
340
|
+
|
|
297
341
|
## deleteFile()
|
|
342
|
+
|
|
298
343
|
Delete a file or directory from the path.
|
|
299
344
|
|
|
300
345
|
* OK: (not recursive) Deletes an existing file or existing empty directory
|
|
@@ -310,6 +355,7 @@ Delete a file or directory from the path.
|
|
|
310
355
|
| `recursive`| boolean | <div class="yellow">No</div> | `TRUE` for recursive delete of all content from a directory |
|
|
311
356
|
|
|
312
357
|
### Javascript Example
|
|
358
|
+
|
|
313
359
|
```javascript
|
|
314
360
|
// Delete directory and all files inside
|
|
315
361
|
//// First check, if there is such a directory
|
|
@@ -327,7 +373,9 @@ if (await sos.fileSystem.exists({ storageUnit: internalStorageUnit, filePath: 't
|
|
|
327
373
|
```
|
|
328
374
|
|
|
329
375
|
## moveFile()
|
|
376
|
+
|
|
330
377
|
Move file OR directory to destination path or Move directory to destination path.
|
|
378
|
+
|
|
331
379
|
* OK: Move file to destination path
|
|
332
380
|
* OK: Move directory to destination path
|
|
333
381
|
* FAIL: When destination path exists (is file or directory)
|
|
@@ -341,6 +389,7 @@ Move file OR directory to destination path or Move directory to destination path
|
|
|
341
389
|
| `filePath` | FilePath | <div class="red">Yes</div> | Object contains storageUnit object returned by `listStorageUnits()` and `filePath` if the file or directory |
|
|
342
390
|
|
|
343
391
|
### Javascript Example
|
|
392
|
+
|
|
344
393
|
```javascript
|
|
345
394
|
// Move file to a different directory
|
|
346
395
|
//// First check, if there is such a file and directory
|
|
@@ -356,6 +405,7 @@ if (await sos.fileSystem.exists({ storageUnit: internalStorageUnit, filePath: 't
|
|
|
356
405
|
```
|
|
357
406
|
|
|
358
407
|
## getFileChecksum()
|
|
408
|
+
|
|
359
409
|
Returns checksum of existing file in a path.
|
|
360
410
|
* OK: Returns checksum of existing file in path
|
|
361
411
|
* FAIL: When file path doesn't exist
|
|
@@ -373,17 +423,20 @@ Does not work on Samsung Tizen display - [read more here](knowledge-base/md5-tiz
|
|
|
373
423
|
| `hashFunction` | string | <div class="red">Yes</div> | Available function is `md5` |
|
|
374
424
|
|
|
375
425
|
### Javascript Example
|
|
426
|
+
|
|
376
427
|
```javascript
|
|
377
428
|
const md5Checksum = await sos.fileSystem.getFileChecksum({ storageUnit: internalStorageUnit, filePath: 'test-dir/log.1.txt.backup' }, 'md5');
|
|
378
429
|
console.log(md5Checksum);
|
|
379
430
|
```
|
|
380
431
|
|
|
381
432
|
### Returns
|
|
433
|
+
|
|
382
434
|
```json
|
|
383
435
|
"b3c6930b9306b8e35a978d342cf5a01e" // string
|
|
384
436
|
```
|
|
385
437
|
|
|
386
438
|
## extractFile()
|
|
439
|
+
|
|
387
440
|
Extract ZIPed all files (recursively) to destination path and override existing files or merge existing directories.
|
|
388
441
|
|
|
389
442
|
* OK: Extract ZIPed all files (recursively) to destination path
|
|
@@ -405,6 +458,7 @@ The directory/folder you are extracting your ZIP file into has to be created BEF
|
|
|
405
458
|
| `archiveMethod` | string | <div class="red">Yes</div> | Available method is `zip` |
|
|
406
459
|
|
|
407
460
|
### Javascript Example
|
|
461
|
+
|
|
408
462
|
```javascript
|
|
409
463
|
// Create directory 'test-dir' in a root directory
|
|
410
464
|
await sos.fileSystem.createDirectory({ storageUnit: internalStorageUnit, filePath: 'test-dir' });
|
|
@@ -418,6 +472,7 @@ await sos.fileSystem.extractFile(
|
|
|
418
472
|
```
|
|
419
473
|
|
|
420
474
|
## createDirectory()
|
|
475
|
+
|
|
421
476
|
Creates a directory in a path.
|
|
422
477
|
|
|
423
478
|
* OK: Creates directory in path
|
|
@@ -425,7 +480,8 @@ Creates a directory in a path.
|
|
|
425
480
|
* FAIL: When creating directory in not existing containing (parent) directory
|
|
426
481
|
|
|
427
482
|
::: alert alert--warning
|
|
428
|
-
Never start OR end the `filePath` with a slash - `/`. It will cause error *50512*
|
|
483
|
+
- Never start OR end the `filePath` with a slash - `/`. It will cause error *50512*
|
|
484
|
+
- It is a good practice to check if directory exists - `isDirectory()` prior creating it
|
|
429
485
|
:::
|
|
430
486
|
|
|
431
487
|
### Parameters
|
|
@@ -435,12 +491,30 @@ Never start OR end the `filePath` with a slash - `/`. It will cause error *50512
|
|
|
435
491
|
| `filePath` | FilePath | <div class="red">Yes</div> | Object contains storageUnit object returned by `listStorageUnits()` and `filePath` if the file or directory |
|
|
436
492
|
|
|
437
493
|
### Javascript Example
|
|
494
|
+
|
|
438
495
|
```javascript
|
|
439
496
|
// Create directory 'test-dir' in a root directory
|
|
440
497
|
await sos.fileSystem.createDirectory({ storageUnit: internalStorageUnit, filePath: 'test-dir' });
|
|
441
498
|
```
|
|
442
499
|
|
|
500
|
+
```javascript
|
|
501
|
+
// Create multiple directories
|
|
502
|
+
const myDirs = [
|
|
503
|
+
'dir1',
|
|
504
|
+
'dir2',
|
|
505
|
+
'dir1/dir3',
|
|
506
|
+
];
|
|
507
|
+
await Promise.all(myDirs.map(async (dirname) => {
|
|
508
|
+
const fp = { storageUnit: internalStorageUnit, filePath: `uploads/${dirname}` };
|
|
509
|
+
if (!await sos.fileSystem.exists(fp)) {
|
|
510
|
+
await sos.fileSystem.createDirectory(fp);
|
|
511
|
+
}
|
|
512
|
+
});
|
|
513
|
+
// All dirs created
|
|
514
|
+
```
|
|
515
|
+
|
|
443
516
|
## isDirectory()
|
|
517
|
+
|
|
444
518
|
Returns true if existing path is directory.
|
|
445
519
|
|
|
446
520
|
* OK: Returns true if existing path is directory
|
|
@@ -454,11 +528,13 @@ Returns true if existing path is directory.
|
|
|
454
528
|
| `filePath` | FilePath | <div class="red">Yes</div> | Object contains storageUnit object returned by `listStorageUnits()` and `filePath` if the file or directory |
|
|
455
529
|
|
|
456
530
|
### Javascript Example
|
|
531
|
+
|
|
457
532
|
```javascript
|
|
458
533
|
await sos.fileSystem.isDirectory({ storageUnit: internalStorageUnit, filePath: 'test-dir' });
|
|
459
534
|
```
|
|
460
535
|
|
|
461
536
|
## copyFile()
|
|
537
|
+
|
|
462
538
|
Copy file OR directory to a new location.
|
|
463
539
|
|
|
464
540
|
### Parameters
|
|
@@ -469,6 +545,7 @@ Copy file OR directory to a new location.
|
|
|
469
545
|
| `destinationFilePath` | FilePath | <div class="red">Yes</div> | Object contains storageUnit object returned by `listStorageUnits()` and `filePath` if the file or directory |
|
|
470
546
|
|
|
471
547
|
### Javascript Example
|
|
548
|
+
|
|
472
549
|
```javascript
|
|
473
550
|
await sos.fileSystem.copyFile(
|
|
474
551
|
{ storageUnit: internalStorageUnit, filePath: 'test-dir/log.1.txt' },
|
|
@@ -477,16 +554,13 @@ await sos.fileSystem.copyFile(
|
|
|
477
554
|
```
|
|
478
555
|
|
|
479
556
|
## writeFile()
|
|
557
|
+
|
|
480
558
|
Write into file directly:
|
|
559
|
+
|
|
481
560
|
- string support only
|
|
482
561
|
- override only
|
|
483
562
|
- no append
|
|
484
563
|
|
|
485
|
-
::: alert alert--warning
|
|
486
|
-
**LG webOS limitation**:
|
|
487
|
-
It's possible to handle only files up to **~10KB** on webOS devices. At the moment we are working on the solution regarding the file/s 'manipulation' on LG devices.
|
|
488
|
-
:::
|
|
489
|
-
|
|
490
564
|
### Parameters
|
|
491
565
|
|
|
492
566
|
| Param | Type | Required | Description |
|
|
@@ -496,6 +570,7 @@ It's possible to handle only files up to **~10KB** on webOS devices. At the mome
|
|
|
496
570
|
|
|
497
571
|
|
|
498
572
|
### Javascript Example
|
|
573
|
+
|
|
499
574
|
```javascript
|
|
500
575
|
await sos.fileSystem.writeFile(
|
|
501
576
|
{ storageUnit: internalStorageUnit, filePath: 'test-dir/log.txt' },
|
|
@@ -503,6 +578,30 @@ await sos.fileSystem.writeFile(
|
|
|
503
578
|
);
|
|
504
579
|
```
|
|
505
580
|
|
|
581
|
+
## appendFile()
|
|
582
|
+
|
|
583
|
+
Append content into file directly:
|
|
584
|
+
|
|
585
|
+
- string support only
|
|
586
|
+
- append only
|
|
587
|
+
|
|
588
|
+
### Parameters
|
|
589
|
+
|
|
590
|
+
| Param | Type | Required | Description |
|
|
591
|
+
| ------ | -------- | :------: | ---- |
|
|
592
|
+
| `filePath` | FilePath | <div class="red">Yes</div> | Object contains storageUnit object returned by `listStorageUnits()` and `filePath` if the file or directory |
|
|
593
|
+
| `content` | String | <div class="red">Yes</div> | Parsed content as string |
|
|
594
|
+
|
|
595
|
+
|
|
596
|
+
### Javascript Example
|
|
597
|
+
|
|
598
|
+
```javascript
|
|
599
|
+
await sos.fileSystem.appendFile(
|
|
600
|
+
{ storageUnit: internalStorageUnit, filePath: 'test-dir/log.txt' },
|
|
601
|
+
'My awesome log line\n',
|
|
602
|
+
);
|
|
603
|
+
```
|
|
604
|
+
|
|
506
605
|
## readFile()
|
|
507
606
|
Read a text file.
|
|
508
607
|
|
|
@@ -20,8 +20,8 @@ This can be leveraged to integrate a wide variety of hardware into your digital
|
|
|
20
20
|
Such hardware could be, for example, printers, payment terminals or sensors.
|
|
21
21
|
|
|
22
22
|
::: alert alert--warning
|
|
23
|
-
* Before using this API, ensure that the
|
|
24
|
-
* More info
|
|
23
|
+
* Before using this API, ensure that the display supports serial via `sos.display.supports("SERIAL")`.
|
|
24
|
+
* More info [**HERE**](/api/js/content/js-display#supports).
|
|
25
25
|
:::
|
|
26
26
|
|
|
27
27
|
## All methods
|