@signageos/front-applet 5.0.0-beta.9 → 5.1.0
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 +50 -11
- package/dist/bundle.js +2 -2
- package/dist/bundle.js.map +1 -1
- package/docs/js-api/js-api-introduction.md +32 -22
- package/docs/js-api/js-applet-basics.md +6 -1
- package/docs/js-api/js-applet-resources.md +2 -2
- package/docs/js-api/js-browser.md +13 -7
- package/docs/js-api/js-file-system.md +89 -7
- package/docs/js-api/js-input.md +1 -1
- package/docs/js-api/js-loading-fonts.md +1 -1
- package/docs/js-api/js-monitoring-commands.md +1 -1
- package/docs/js-api/js-offline-cache-media-files.md +22 -10
- package/docs/js-api/js-offline-cache-simple-data.md +2 -2
- package/docs/js-api/js-sensors.md +1 -1
- package/docs/js-api/js-sync-playback.md +1 -1
- package/docs/js-api/js-video-inputs-internal-ports.md +1 -1
- package/docs/js-api/js-video-stream.md +2 -2
- package/docs/js-api/js-video.md +1 -1
- package/docs/management-api/10-js-management-application.md +3 -3
- package/docs/management-api/11-js-management-network.md +36 -1
- package/docs/management-api/13-js-management-wifi.md +4 -0
- package/docs/management-api/2-js-management-firmware.md +17 -3
- package/docs/management-api/5-js-management-screen.md +2 -2
- package/docs/management-api/6-js-management-time.md +18 -2
- package/docs/management-api/9-js-management-debug.md +2 -2
- 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/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.js +17 -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 +1 -0
- package/es6/FrontApplet/Management/INetworkInfo.js.map +1 -1
- package/es6/FrontApplet/Management/Network.d.ts +1 -0
- package/es6/FrontApplet/Management/Network.js +9 -0
- 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 +5 -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,25 +9,19 @@ 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://docs.signageos.io/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 |
|
|
@@ -38,21 +32,25 @@ Content-playback API is an API for managing content on screen.
|
|
|
38
32
|
| [Browser](/api/js/content/js-browser) | Opening managed web-browser on Android devices inc. whitelisting, blacklisting and other features |
|
|
39
33
|
| [Command](/api/js/content/js-command) | Sending business or technical logs through signageOS in secured offline-ready way |
|
|
40
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 |
|
|
41
36
|
| [Hardware](/api/js/content/js-hardware) | Hardware-specific APIs like LED lights on Philips 10BDL |
|
|
42
|
-
| [Serial](/api/js/content/js-hardware-serial) | Control external devices via serial |
|
|
43
37
|
| [Inputs](/api/js/content/js-input) | Controller inputs like IR remote unified under one API |
|
|
44
|
-
| [
|
|
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 |
|
|
45
41
|
| [Synchronized playback](/api/js/content/js-sync-playback) | API for creating synced playback and videowalls |
|
|
46
|
-
| [Timings](/api/js/content/js-timing) | Managing Timing/Applet switching from JS |
|
|
47
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 |
|
|
48
43
|
| [Video Playback](/api/js/content/js-video) | Playing accelerated gapless videos via native video player |
|
|
49
44
|
| [Video Streams](/api/js/content/js-video-stream) | Playing video streams (RTSP, HLS, UDP) via native video player |
|
|
50
|
-
| [Sensors](/api/js/content/js-sensors) | Using sensors and IoT devices in your application |
|
|
51
|
-
| [Monitors](/api/js/content/js-monitors) | Information about monitors |
|
|
52
45
|
:::
|
|
53
46
|
|
|
54
|
-
## Device
|
|
55
|
-
|
|
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
|
+
:::
|
|
56
54
|
|
|
57
55
|
::: table-responsive
|
|
58
56
|
| Domain | Description |
|
|
@@ -71,3 +69,15 @@ Device management API is for managing, updating firmware, and other settings on
|
|
|
71
69
|
| [Security](/api/js/management/12-js-management-security) | Control system security (PIN code) |
|
|
72
70
|
| [Wi-Fi](/api/js/management/13-js-management-wifi) | Manage Wi-Fi |
|
|
73
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
|
|
@@ -188,7 +192,8 @@ console.log(sos.config.imgUrl);
|
|
|
188
192
|
```
|
|
189
193
|
<div class="row d-flex align-content-stretch force-padding-20">
|
|
190
194
|
<div class="col-12 d-flex">
|
|
191
|
-
<a class="wide-box wide-box--white d-flex align-content-stretch widebox-kb-color" target="_blank"
|
|
195
|
+
<a class="wide-box wide-box--white d-flex align-content-stretch widebox-kb-color" target="_blank"
|
|
196
|
+
href="https://docs.signageos.io/hc/en-us/articles/4405238989458">
|
|
192
197
|
<div>
|
|
193
198
|
<div class="wide-box__image d-flex align-items-center">
|
|
194
199
|
<i class="fas fa-hand-point-right svg-black"></i>
|
|
@@ -42,7 +42,7 @@ Every method above, accept single object or array of objects depending by type.
|
|
|
42
42
|
|
|
43
43
|
::: alert alert--info
|
|
44
44
|
* The file URL must point to a file. If your URI leads to a 303 redirect (e.g. from http to http**s**), the API will not work.
|
|
45
|
-
* There are some limitations for [Emulator](
|
|
45
|
+
* There are some limitations for [Emulator](https://docs.signageos.io/hc/en-us/articles/4405238997138).
|
|
46
46
|
:::
|
|
47
47
|
|
|
48
48
|
## addFile()
|
|
@@ -128,7 +128,7 @@ sos.offline.addFilesSync(files).then(() => {
|
|
|
128
128
|
```
|
|
129
129
|
|
|
130
130
|
## Usage with Typescript
|
|
131
|
-
You can also use all these methods with [signageOS TypeScript](/
|
|
131
|
+
You can also use all these methods with [signageOS TypeScript](https://docs.signageos.io/hc/en-us/articles/4405069154962#signageos-typescript).
|
|
132
132
|
|
|
133
133
|
```typescript
|
|
134
134
|
interface ISaveFile {
|
|
@@ -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">
|
|
@@ -90,7 +93,7 @@ sos.browser.open('https://www.signageos.io', {
|
|
|
90
93
|
</div>
|
|
91
94
|
|
|
92
95
|
### Browser themes usage with Typescript
|
|
93
|
-
You can also use all these methods with [signageOS TypeScript](/
|
|
96
|
+
You can also use all these methods with [signageOS TypeScript](https://docs.signageos.io/hc/en-us/articles/4405069154962#signageos-typescript).
|
|
94
97
|
|
|
95
98
|
::: alert alert--info
|
|
96
99
|
Browser themes are only available on Android devices.
|
|
@@ -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;
|
|
@@ -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,13 +405,14 @@ 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
|
|
362
412
|
* FAIL: When file path is directory
|
|
363
413
|
|
|
364
414
|
::: alert alert--info
|
|
365
|
-
Does not work on Samsung Tizen display - [read more here](
|
|
415
|
+
Does not work on Samsung Tizen display - [read more here](https://docs.signageos.io/hc/en-us/articles/4416327809810)
|
|
366
416
|
:::
|
|
367
417
|
|
|
368
418
|
### Parameters
|
|
@@ -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
|
|
@@ -436,6 +491,7 @@ Creates a directory in a path.
|
|
|
436
491
|
| `filePath` | FilePath | <div class="red">Yes</div> | Object contains storageUnit object returned by `listStorageUnits()` and `filePath` if the file or directory |
|
|
437
492
|
|
|
438
493
|
### Javascript Example
|
|
494
|
+
|
|
439
495
|
```javascript
|
|
440
496
|
// Create directory 'test-dir' in a root directory
|
|
441
497
|
await sos.fileSystem.createDirectory({ storageUnit: internalStorageUnit, filePath: 'test-dir' });
|
|
@@ -458,6 +514,7 @@ await Promise.all(myDirs.map(async (dirname) => {
|
|
|
458
514
|
```
|
|
459
515
|
|
|
460
516
|
## isDirectory()
|
|
517
|
+
|
|
461
518
|
Returns true if existing path is directory.
|
|
462
519
|
|
|
463
520
|
* OK: Returns true if existing path is directory
|
|
@@ -471,11 +528,13 @@ Returns true if existing path is directory.
|
|
|
471
528
|
| `filePath` | FilePath | <div class="red">Yes</div> | Object contains storageUnit object returned by `listStorageUnits()` and `filePath` if the file or directory |
|
|
472
529
|
|
|
473
530
|
### Javascript Example
|
|
531
|
+
|
|
474
532
|
```javascript
|
|
475
533
|
await sos.fileSystem.isDirectory({ storageUnit: internalStorageUnit, filePath: 'test-dir' });
|
|
476
534
|
```
|
|
477
535
|
|
|
478
536
|
## copyFile()
|
|
537
|
+
|
|
479
538
|
Copy file OR directory to a new location.
|
|
480
539
|
|
|
481
540
|
### Parameters
|
|
@@ -486,6 +545,7 @@ Copy file OR directory to a new location.
|
|
|
486
545
|
| `destinationFilePath` | FilePath | <div class="red">Yes</div> | Object contains storageUnit object returned by `listStorageUnits()` and `filePath` if the file or directory |
|
|
487
546
|
|
|
488
547
|
### Javascript Example
|
|
548
|
+
|
|
489
549
|
```javascript
|
|
490
550
|
await sos.fileSystem.copyFile(
|
|
491
551
|
{ storageUnit: internalStorageUnit, filePath: 'test-dir/log.1.txt' },
|
|
@@ -494,16 +554,13 @@ await sos.fileSystem.copyFile(
|
|
|
494
554
|
```
|
|
495
555
|
|
|
496
556
|
## writeFile()
|
|
557
|
+
|
|
497
558
|
Write into file directly:
|
|
559
|
+
|
|
498
560
|
- string support only
|
|
499
561
|
- override only
|
|
500
562
|
- no append
|
|
501
563
|
|
|
502
|
-
::: alert alert--warning
|
|
503
|
-
**LG webOS limitation**:
|
|
504
|
-
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.
|
|
505
|
-
:::
|
|
506
|
-
|
|
507
564
|
### Parameters
|
|
508
565
|
|
|
509
566
|
| Param | Type | Required | Description |
|
|
@@ -513,6 +570,7 @@ It's possible to handle only files up to **~10KB** on webOS devices. At the mome
|
|
|
513
570
|
|
|
514
571
|
|
|
515
572
|
### Javascript Example
|
|
573
|
+
|
|
516
574
|
```javascript
|
|
517
575
|
await sos.fileSystem.writeFile(
|
|
518
576
|
{ storageUnit: internalStorageUnit, filePath: 'test-dir/log.txt' },
|
|
@@ -520,6 +578,30 @@ await sos.fileSystem.writeFile(
|
|
|
520
578
|
);
|
|
521
579
|
```
|
|
522
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
|
+
|
|
523
605
|
## readFile()
|
|
524
606
|
Read a text file.
|
|
525
607
|
|
package/docs/js-api/js-input.md
CHANGED
|
@@ -53,7 +53,7 @@ await sos.input.onKeyUp((keyUpEvent) => {
|
|
|
53
53
|
| ARROW_DOWN | 14 | | |
|
|
54
54
|
|
|
55
55
|
## Usage with Typescript
|
|
56
|
-
You can also use all these methods with [signageOS TypeScript](/
|
|
56
|
+
You can also use all these methods with [signageOS TypeScript](https://docs.signageos.io/hc/en-us/articles/4405069154962#signageos-typescript).
|
|
57
57
|
|
|
58
58
|
```typescript
|
|
59
59
|
interface IKeyUpEvent {
|
|
@@ -102,7 +102,7 @@ await sos.offline.addFont({
|
|
|
102
102
|
</div>
|
|
103
103
|
|
|
104
104
|
## Usage with Typescript
|
|
105
|
-
You can also use all these methods with [signageOS TypeScript](/
|
|
105
|
+
You can also use all these methods with [signageOS TypeScript](https://docs.signageos.io/hc/en-us/articles/4405069154962#signageos-typescript).
|
|
106
106
|
|
|
107
107
|
```typescript
|
|
108
108
|
addFont(
|
|
@@ -69,7 +69,7 @@ export interface ConsoleLogged {
|
|
|
69
69
|
}
|
|
70
70
|
```
|
|
71
71
|
|
|
72
|
-
To trigger some monitoring commands to be dispatched from a device. This REST API can be used to send monitoring [commands to the device](https://docs.signageos.io/api/device-monitoring-api/#Send_Device_Applet_Command_to_device). Following commands can be used:
|
|
72
|
+
To trigger some monitoring commands to be dispatched from a device. This REST API can be used to send monitoring [commands to the device](https://sdk.docs.signageos.io/api/device-monitoring-api/#Send_Device_Applet_Command_to_device). Following commands can be used:
|
|
73
73
|
|
|
74
74
|
### Typescript
|
|
75
75
|
```typescript
|
|
@@ -30,7 +30,7 @@ File API allows files (video files, media files etc.) to be stored for offline u
|
|
|
30
30
|
:::
|
|
31
31
|
|
|
32
32
|
::: alert alert--warning
|
|
33
|
-
Emulator has certain limitations while handling offline files. [Read more here](/
|
|
33
|
+
Emulator has certain limitations while handling offline files. [Read more here](https://docs.signageos.io/hc/en-us/articles/4405238997138)
|
|
34
34
|
:::
|
|
35
35
|
|
|
36
36
|
## listFiles()
|
|
@@ -66,10 +66,14 @@ Method `saveFile()` is used to save files from remote a destination into the dev
|
|
|
66
66
|
`headers` has to be a JSON object. If you are passing the value, make sure you use `JSON.parse()`.
|
|
67
67
|
:::
|
|
68
68
|
|
|
69
|
+
::: alert alert--warning
|
|
70
|
+
`uid` should have the same file extension (e.g.: mp4, svg, jpg) as the original file.
|
|
71
|
+
:::
|
|
72
|
+
|
|
69
73
|
### Javascript example
|
|
70
74
|
```javascript
|
|
71
75
|
// Example saving files into internal memory, unique id could be salted md5 hash, uri directs to our CDN
|
|
72
|
-
await sos.offline.cache.saveFile('9d66725ba2105f1833731ade5b7f334e', 'https://cdn.my-cms.com/files/video.mp4', { "Authorization": "Basic Zm9vOmJhcg==" })
|
|
76
|
+
await sos.offline.cache.saveFile('9d66725ba2105f1833731ade5b7f334e.mp4', 'https://cdn.my-cms.com/files/video.mp4', { "Authorization": "Basic Zm9vOmJhcg==" })
|
|
73
77
|
.then(() => { console.log('Saved'); })
|
|
74
78
|
.catch((error) => { console.error(error); });
|
|
75
79
|
```
|
|
@@ -87,15 +91,19 @@ Method `loadFile()` is used for individual file retrieval from internal memory.
|
|
|
87
91
|
| --------- | ------------ | :---------: | --------------- |
|
|
88
92
|
| `uid` | string | <div class="red">Yes</div> | Unique file identifier is used for later file retrieval, must contain a-z,A-Z,0-9 and . characters |
|
|
89
93
|
|
|
94
|
+
::: alert alert--warning
|
|
95
|
+
`uid` should have the same file extension (e.g.: mp4, svg, jpg) as the original file.
|
|
96
|
+
:::
|
|
97
|
+
|
|
90
98
|
### Javascript Example
|
|
91
99
|
```javascript
|
|
92
|
-
await sos.offline.cache.loadFile('9d66725ba2105f1833731ade5b7f334e')
|
|
100
|
+
await sos.offline.cache.loadFile('9d66725ba2105f1833731ade5b7f334e.mp4')
|
|
93
101
|
.then((file) => { console.log('Loaded', file); })
|
|
94
102
|
.catch((error) => { console.error(error); });
|
|
95
103
|
|
|
96
104
|
// Logs into console
|
|
97
105
|
{
|
|
98
|
-
filePath: '/real/device/path/to/file/9d66725ba2105f1833731ade5b7f334e',
|
|
106
|
+
filePath: '/real/device/path/to/file/9d66725ba2105f1833731ade5b7f334e.mp4',
|
|
99
107
|
}
|
|
100
108
|
```
|
|
101
109
|
|
|
@@ -113,7 +121,7 @@ To get file from internal memory & save it when not yet exists we prepared `load
|
|
|
113
121
|
|
|
114
122
|
::: alert alert--info
|
|
115
123
|
* The file URI has to return the file. If your URI leads to a 303 redirect (e.g. from http to http**s**), the API will not work.
|
|
116
|
-
* Emulator has certain limitations while handling offline files. [Read more here](
|
|
124
|
+
* Emulator has certain limitations while handling offline files. [Read more here](https://docs.signageos.io/hc/en-us/articles/4405238997138)
|
|
117
125
|
:::
|
|
118
126
|
|
|
119
127
|
### Parameters
|
|
@@ -124,15 +132,19 @@ To get file from internal memory & save it when not yet exists we prepared `load
|
|
|
124
132
|
| `uri` | string | <div class="red">Yes</div> | URL address where to get the file |
|
|
125
133
|
| `headers` | object | <div class="yellow">No</div> | Key, value pairs of HTTP headers to send along with the request. Used when the target file is protected by a password or if any other specific headers are needed to access it. |
|
|
126
134
|
|
|
135
|
+
::: alert alert--warning
|
|
136
|
+
`uid` should have the same file extension (e.g.: mp4, svg, jpg) as the original file.
|
|
137
|
+
:::
|
|
138
|
+
|
|
127
139
|
### Javascript Example
|
|
128
140
|
```javascript
|
|
129
|
-
await sos.offline.cache.loadOrSaveFile('9d66725ba2105f1833731ade5b7f334e', 'https://cdn.my-cms.com/files/video.mp4', { "Authorization": "Basic Zm9vOmJhcg==" })
|
|
141
|
+
await sos.offline.cache.loadOrSaveFile('9d66725ba2105f1833731ade5b7f334e.mp4', 'https://cdn.my-cms.com/files/video.mp4', { "Authorization": "Basic Zm9vOmJhcg==" })
|
|
130
142
|
.then((file) => { console.log('Loaded or Saved', file); })
|
|
131
143
|
.catch((error) => { console.error(error); });
|
|
132
144
|
|
|
133
145
|
// Logs into console
|
|
134
146
|
{
|
|
135
|
-
filePath: '/real/device/path/to/file/9d66725ba2105f1833731ade5b7f334e',
|
|
147
|
+
filePath: '/real/device/path/to/file/9d66725ba2105f1833731ade5b7f334e.mp4',
|
|
136
148
|
}
|
|
137
149
|
```
|
|
138
150
|
|
|
@@ -187,7 +199,7 @@ Method `deleteFile()` is used for deleting previously saved file from internal m
|
|
|
187
199
|
|
|
188
200
|
### Javascript example
|
|
189
201
|
```javascript
|
|
190
|
-
await sos.offline.cache.deleteFile('9d66725ba2105f1833731ade5b7f334e')
|
|
202
|
+
await sos.offline.cache.deleteFile('9d66725ba2105f1833731ade5b7f334e.mp4')
|
|
191
203
|
.then(() => { console.log('Deleted'); })
|
|
192
204
|
.catch((error) => { console.error(error); });
|
|
193
205
|
```
|
|
@@ -203,7 +215,7 @@ Method `getChecksumFile()` is used for getting the checksum of file from interna
|
|
|
203
215
|
|
|
204
216
|
### Javascript example
|
|
205
217
|
```javascript
|
|
206
|
-
await sos.offline.cache.getChecksumFile('9d66725ba2105f1833731ade5b7f334e', 'md5')
|
|
218
|
+
await sos.offline.cache.getChecksumFile('9d66725ba2105f1833731ade5b7f334e.mp4', 'md5')
|
|
207
219
|
.then((checksum) => { console.log('MD5 checksum is ' + checksum); })
|
|
208
220
|
.catch((error) => { console.error(error); });
|
|
209
221
|
```
|
|
@@ -282,7 +294,7 @@ await sos.offline.cache.decompressFile(zipUid, destinationDirectoryUid, 'zip')
|
|
|
282
294
|
|
|
283
295
|
* [Managing files](https://github.com/signageos/applet-examples/blob/master/examples/content-js-api/file-system)
|
|
284
296
|
* [Sample applet from Box](https://github.com/signageos/applet-examples/blob/master/index.html)
|
|
285
|
-
* All other examples are available in Knowledge Base under [Applet Examples](/
|
|
297
|
+
* All other examples are available in Knowledge Base under [Applet Examples](https://github.com/signageos/applet-examples/)
|
|
286
298
|
|
|
287
299
|
## Errors
|
|
288
300
|
Although we are doing our best, following errors may occur when working with the offline cache.
|
|
@@ -28,7 +28,7 @@ We do not recommend using a different storage type then Offline Cache or full fe
|
|
|
28
28
|
:::
|
|
29
29
|
|
|
30
30
|
::: alert alert--warning
|
|
31
|
-
Emulator has certain limitations while handling offline files. [Read more here](/
|
|
31
|
+
Emulator has certain limitations while handling offline files. [Read more here](https://docs.signageos.io/hc/en-us/articles/4405238997138)
|
|
32
32
|
:::
|
|
33
33
|
|
|
34
34
|
## loadContent()
|
|
@@ -108,7 +108,7 @@ sos.offline.cache.saveContent('ApplicationSecret', '123SuperSecretHash')
|
|
|
108
108
|
```
|
|
109
109
|
|
|
110
110
|
## Usage with Typescript
|
|
111
|
-
You can also use all these methods with [signageOS TypeScript](/
|
|
111
|
+
You can also use all these methods with [signageOS TypeScript](https://docs.signageos.io/hc/en-us/articles/4405069154962#signageos-typescript).
|
|
112
112
|
|
|
113
113
|
```typescript
|
|
114
114
|
loadContent(uid: string): Promise<string>;
|