@signageos/front-applet 8.1.3 → 8.2.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/dist/bundle.js +1 -1
- package/dist/bundle.js.map +1 -1
- package/docs/sos/browser.md +17 -17
- package/docs/sos/command.md +6 -6
- package/docs/sos/debug.md +7 -3
- package/docs/sos/deviceInfo.md +6 -2
- package/docs/sos/display.md +3 -3
- package/docs/sos/fileSystem.md +67 -67
- package/docs/sos/hardware/barcodeScanner.md +58 -15
- package/docs/sos/hardware/index.md +72 -15
- package/docs/sos/hardware/led.md +32 -3
- package/docs/sos/index.md +3 -3
- package/docs/sos/input.md +7 -7
- package/docs/sos/monitors.md +8 -0
- package/docs/sos/native/mdc.md +9 -9
- package/docs/sos/offline/cache.md +368 -28
- package/docs/sos/offline/index.md +127 -24
- package/docs/sos/osd.md +8 -1
- package/docs/sos/proofOfPlay.md +28 -0
- package/docs/sos/stream.md +78 -78
- package/docs/sos/sync.md +228 -21
- package/docs/sos/video.md +73 -73
- package/docs/sos_management/app.md +11 -11
- package/docs/sos_management/audio.md +3 -3
- package/docs/sos_management/firmware.md +11 -11
- package/docs/sos_management/index.md +10 -10
- package/docs/sos_management/network.md +10 -10
- package/docs/sos_management/package.md +28 -7
- package/docs/sos_management/power.md +27 -27
- package/docs/sos_management/screen.md +17 -17
- package/docs/sos_management/security.md +3 -3
- package/docs/sos_management/time.md +8 -8
- package/docs/sos_management/wifi.md +12 -12
- package/es6/FrontApplet/Debug/Debug.d.ts +1 -1
- package/es6/FrontApplet/Debug/Debug.js +1 -1
- package/es6/FrontApplet/DeviceInfo/DeviceInfo.d.ts +6 -2
- package/es6/FrontApplet/DeviceInfo/DeviceInfo.js +6 -2
- package/es6/FrontApplet/DeviceInfo/DeviceInfo.js.map +1 -1
- package/es6/FrontApplet/Display/Display.d.ts +1 -1
- package/es6/FrontApplet/Display/Display.js +1 -1
- package/es6/FrontApplet/Hardware/BarcodeScanner/BarcodeScanner.d.ts +36 -8
- package/es6/FrontApplet/Hardware/BarcodeScanner/BarcodeScanner.js +34 -2
- package/es6/FrontApplet/Hardware/BarcodeScanner/BarcodeScanner.js.map +1 -1
- package/es6/FrontApplet/Hardware/BarcodeScanner/IBarcodeScanner.d.ts +5 -0
- package/es6/FrontApplet/Hardware/Hardware.d.ts +34 -5
- package/es6/FrontApplet/Hardware/Hardware.js +33 -5
- package/es6/FrontApplet/Hardware/Hardware.js.map +1 -1
- package/es6/FrontApplet/Hardware/ISerialPort.d.ts +17 -1
- package/es6/FrontApplet/Hardware/ISerialPortDataMessage.d.ts +3 -0
- package/es6/FrontApplet/Hardware/ISerialPortOptions.d.ts +6 -0
- package/es6/FrontApplet/Hardware/ISerialPortOptions.js +3 -0
- package/es6/FrontApplet/Hardware/ISerialPortOptions.js.map +1 -1
- package/es6/FrontApplet/Hardware/Led/Led.d.ts +19 -3
- package/es6/FrontApplet/Hardware/Led/Led.js +19 -3
- package/es6/FrontApplet/Hardware/Led/Led.js.map +1 -1
- package/es6/FrontApplet/Management/IManagement.d.ts +1 -1
- package/es6/FrontApplet/Management/Package/IPackage.d.ts +1 -0
- package/es6/FrontApplet/Management/Package/Package.d.ts +10 -1
- package/es6/FrontApplet/Management/Package/Package.js +17 -1
- package/es6/FrontApplet/Management/Package/Package.js.map +1 -1
- package/es6/FrontApplet/Monitors/Monitors.d.ts +5 -0
- package/es6/FrontApplet/Monitors/Monitors.js +5 -0
- package/es6/FrontApplet/Monitors/Monitors.js.map +1 -1
- package/es6/FrontApplet/NativeCommands/MDC/INativeMdcCommands.d.ts +1 -0
- package/es6/FrontApplet/OSD/OSD.d.ts +5 -1
- package/es6/FrontApplet/OSD/OSD.js +5 -1
- package/es6/FrontApplet/OSD/OSD.js.map +1 -1
- package/es6/FrontApplet/Offline/Cache/Cache.d.ts +205 -28
- package/es6/FrontApplet/Offline/Cache/Cache.js +205 -28
- package/es6/FrontApplet/Offline/Cache/Cache.js.map +1 -1
- package/es6/FrontApplet/Offline/IAddFont.js.map +1 -1
- package/es6/FrontApplet/Offline/IFileType.js.map +1 -1
- package/es6/FrontApplet/Offline/ISaveFile.d.ts +3 -0
- package/es6/FrontApplet/Offline/ISaveFile.js.map +1 -1
- package/es6/FrontApplet/Offline/Offline.d.ts +58 -15
- package/es6/FrontApplet/Offline/Offline.js +56 -13
- package/es6/FrontApplet/Offline/Offline.js.map +1 -1
- package/es6/FrontApplet/ProofOfPlay/IRecordItemOptions.d.ts +3 -0
- package/es6/FrontApplet/ProofOfPlay/ProofOfPlay.d.ts +15 -1
- package/es6/FrontApplet/ProofOfPlay/ProofOfPlay.js +15 -1
- package/es6/FrontApplet/ProofOfPlay/ProofOfPlay.js.map +1 -1
- package/es6/FrontApplet/Sync/Sync.d.ts +101 -18
- package/es6/FrontApplet/Sync/Sync.js +84 -10
- package/es6/FrontApplet/Sync/Sync.js.map +1 -1
- package/package.json +1 -1
package/docs/sos/hardware/led.md
CHANGED
|
@@ -4,19 +4,48 @@ sidebar_position: 0
|
|
|
4
4
|
|
|
5
5
|
# led
|
|
6
6
|
|
|
7
|
-
The `sos.hardware.led` API groups together methods for controlling LEDs of the device.
|
|
8
|
-
|
|
7
|
+
The `sos.hardware.led` API groups together methods for controlling LEDs of the device.
|
|
8
|
+
|
|
9
|
+
:::warning
|
|
10
|
+
This is currently only supported by Phillips devices.
|
|
11
|
+
:::
|
|
9
12
|
|
|
10
13
|
## Methods
|
|
11
14
|
|
|
12
15
|
### setColor()
|
|
13
16
|
|
|
14
|
-
The `setColor()` methods sets the LED color
|
|
17
|
+
The `setColor()` methods sets the LED color.
|
|
15
18
|
|
|
16
19
|
```ts expandable
|
|
17
20
|
setColor(color: string | null): Promise<void>;
|
|
18
21
|
```
|
|
19
22
|
|
|
23
|
+
#### Params
|
|
24
|
+
|
|
25
|
+
| Name | Type | Required | Description |
|
|
26
|
+
|---------|------------------|------------------|-------------------------------------------------------------------------------------------------------------------|
|
|
27
|
+
| `color` | `string \| null` | <div>Yes</div> | The color to set the LED to, in hexadecimal format (e.g. `#FF0000` for red). If `null`, it will turn off the LED. |
|
|
28
|
+
|
|
29
|
+
#### Return value
|
|
30
|
+
|
|
31
|
+
Returns a promise that resolves when the color is successfully set.
|
|
32
|
+
|
|
33
|
+
#### Possible errors
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
- If the color is not a valid hexadecimal string or is not a string at all.
|
|
37
|
+
- If the LED cannot be controlled by the device.
|
|
38
|
+
- If any other error occurs while setting the color.
|
|
39
|
+
|
|
40
|
+
#### Example
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
// Set the LED color to red
|
|
44
|
+
await sos.hardware.led.setColor('#FF0000');
|
|
45
|
+
// Turn off the LED
|
|
46
|
+
await sos.hardware.led.setColor(null);
|
|
47
|
+
```
|
|
48
|
+
|
|
20
49
|
## API Example
|
|
21
50
|
|
|
22
51
|
```ts
|
package/docs/sos/index.md
CHANGED
|
@@ -69,9 +69,9 @@ onReady(listener?: () => void): Promise<void>;
|
|
|
69
69
|
|
|
70
70
|
#### Params
|
|
71
71
|
|
|
72
|
-
| Name
|
|
73
|
-
|
|
74
|
-
| `listener`
|
|
72
|
+
| Name | Type | Required | Description |
|
|
73
|
+
|------------|--------------|-----------------|--------------------------------------------------------------|
|
|
74
|
+
| `listener` | `() => void` | <div>No</div> | Optional listener which is called when the sos API is ready. |
|
|
75
75
|
|
|
76
76
|
#### Return value
|
|
77
77
|
|
package/docs/sos/input.md
CHANGED
|
@@ -72,9 +72,9 @@ enum KeyUpEventMap {
|
|
|
72
72
|
|
|
73
73
|
#### Params
|
|
74
74
|
|
|
75
|
-
| Name | Type | Description |
|
|
76
|
-
|
|
77
|
-
| `listener` | `(event: IKeyUpEvent) => void` | The listener function that will be called on every key up event. |
|
|
75
|
+
| Name | Type | Required | Description |
|
|
76
|
+
|------------|--------------------------------|------------------|------------------------------------------------------------------|
|
|
77
|
+
| `listener` | `(event: IKeyUpEvent) => void` | <div>Yes</div> | The listener function that will be called on every key up event. |
|
|
78
78
|
|
|
79
79
|
#### Return value
|
|
80
80
|
|
|
@@ -98,10 +98,10 @@ removeEventListener(event: 'keyup', listener: (...args: any[]) => void): void;
|
|
|
98
98
|
|
|
99
99
|
#### Params
|
|
100
100
|
|
|
101
|
-
| Name | Type | Description |
|
|
102
|
-
|
|
103
|
-
| `event` | `"keyup"` | The name of the event to remove the listener for. Currently, only `keyup` is supported. |
|
|
104
|
-
| `listener` | `(...args: any[]) => void` | The listener function to remove. |
|
|
101
|
+
| Name | Type | Required | Description |
|
|
102
|
+
|------------|----------------------------|------------------|-----------------------------------------------------------------------------------------|
|
|
103
|
+
| `event` | `"keyup"` | <div>Yes</div> | The name of the event to remove the listener for. Currently, only `keyup` is supported. |
|
|
104
|
+
| `listener` | `(...args: any[]) => void` | <div>Yes</div> | The listener function to remove. |
|
|
105
105
|
|
|
106
106
|
#### Return value
|
|
107
107
|
|
package/docs/sos/monitors.md
CHANGED
|
@@ -6,6 +6,10 @@ sidebar_position: 0
|
|
|
6
6
|
|
|
7
7
|
The `sos.monitors` API groups together methods for providing information about monitors connected to the device.
|
|
8
8
|
|
|
9
|
+
:::note
|
|
10
|
+
This API is available only on Linux devices.
|
|
11
|
+
:::
|
|
12
|
+
|
|
9
13
|
## Methods
|
|
10
14
|
|
|
11
15
|
### getList()
|
|
@@ -24,6 +28,10 @@ interface IConnectedMonitor {
|
|
|
24
28
|
|
|
25
29
|
```
|
|
26
30
|
|
|
31
|
+
#### Return value
|
|
32
|
+
|
|
33
|
+
A promise that resolves to an array of connected monitors.
|
|
34
|
+
|
|
27
35
|
## API Example
|
|
28
36
|
|
|
29
37
|
```ts
|
package/docs/sos/native/mdc.md
CHANGED
|
@@ -197,11 +197,11 @@ enum CodesMDC {
|
|
|
197
197
|
|
|
198
198
|
#### Params
|
|
199
199
|
|
|
200
|
-
| Name
|
|
201
|
-
|
|
202
|
-
| `ipAddress`
|
|
203
|
-
| `command`
|
|
204
|
-
| `data`
|
|
200
|
+
| Name | Type | Required | Description |
|
|
201
|
+
|-------------|------------|------------------|------------------------------------------------------|
|
|
202
|
+
| `ipAddress` | `string` | <div>Yes</div> | The IP address of the device to send the command to. |
|
|
203
|
+
| `command` | `CodesMDC` | <div>Yes</div> | The MDC command to send |
|
|
204
|
+
| `data` | `number[]` | <div>No</div> | The optional data to send with the command. |
|
|
205
205
|
|
|
206
206
|
#### Return value
|
|
207
207
|
|
|
@@ -260,10 +260,10 @@ interface IMDCResponse {
|
|
|
260
260
|
|
|
261
261
|
#### Params
|
|
262
262
|
|
|
263
|
-
| Name | Type | Description |
|
|
264
|
-
|
|
265
|
-
| `ipAddress` | `string` | The IP address of the device to send the command to. |
|
|
266
|
-
| `data` | `number[] \| []` | The data as array of numbers to send with the command. It can be also empty array. |
|
|
263
|
+
| Name | Type | Required | Description |
|
|
264
|
+
|-------------|------------------|------------------|------------------------------------------------------------------------------------|
|
|
265
|
+
| `ipAddress` | `string` | <div>Yes</div> | The IP address of the device to send the command to. |
|
|
266
|
+
| `data` | `number[] \| []` | <div>Yes</div> | The data as array of numbers to send with the command. It can be also empty array. |
|
|
267
267
|
|
|
268
268
|
#### Return value
|
|
269
269
|
|
|
@@ -4,16 +4,12 @@ sidebar_position: 0
|
|
|
4
4
|
|
|
5
5
|
# cache
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
Learn more about using this API [here](https://developers.signageos.io/docs/applets/api-guides/offline-content#caching-audio-visual-content-or-arbitrary-data-sosofflinecache)
|
|
9
|
-
</Admonition>
|
|
7
|
+
The `sos.offline.cache` API groups together methods used to download and save arbitrary files, which can be accessed even if the device is offline.
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
> Please refer to difference between `sos.offline.cache` and `sos.fileSystem` APIs in our [documentation](http://localhost:3000/sdk/sos/offline/).
|
|
12
10
|
|
|
13
11
|
:::warning
|
|
14
|
-
|
|
15
12
|
Emulator has certain limitations while handling offline files. [Read more here](https://docs.signageos.io/hc/en-us/articles/4405238997138)
|
|
16
|
-
|
|
17
13
|
:::
|
|
18
14
|
|
|
19
15
|
## Methods
|
|
@@ -26,37 +22,129 @@ The `decompressFile()` decompresses the file specified by `uid` into a new file
|
|
|
26
22
|
decompressFile(uid: string, destinationUid: string, method: 'zip'): Promise<void>;
|
|
27
23
|
```
|
|
28
24
|
|
|
25
|
+
#### Params
|
|
26
|
+
|
|
27
|
+
| Name | Type | Required | Description |
|
|
28
|
+
|------------------|----------|------------------|----------------------------------------------------------------------|
|
|
29
|
+
| `uid` | `string` | <div>Yes</div> | Unique file identifier of a previously downloaded ZIP file. |
|
|
30
|
+
| `destinationUid` | `string` | <div>Yes</div> | Unique directory identifier (prefix of file) to extract ZIP file. |
|
|
31
|
+
| `method` | `"zip"` | <div>Yes</div> | The decompression method to use. Currently, only 'zip' is supported. |
|
|
32
|
+
|
|
33
|
+
#### Return value
|
|
34
|
+
|
|
35
|
+
A promise that resolves when the file is decompressed.
|
|
36
|
+
|
|
29
37
|
#### Possible errors
|
|
30
38
|
|
|
31
|
-
|
|
39
|
+
|
|
40
|
+
- Error If the uid does not exist.
|
|
41
|
+
- Error If the destinationUid is not a valid string.
|
|
42
|
+
- Error If the method is not supported.
|
|
43
|
+
|
|
44
|
+
#### Example
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
// Save the ZIP file
|
|
48
|
+
await sos.offline.cache.saveFile('example-zip-file.zip', 'https://example.com/path/to/your/file.zip');
|
|
49
|
+
|
|
50
|
+
// Decompress the ZIP file into a directory
|
|
51
|
+
await sos.offline.cache.decompressFile('example-zip-file.zip', 'extracted-files/', 'zip');
|
|
52
|
+
.then(() => { console.log('ZIP file extracted'); })
|
|
53
|
+
.catch((error) => { console.error(error); });
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
:::note[GitHub Example]
|
|
57
|
+
|
|
58
|
+
- [ Example Applet with Offline ZIP Decompression](https://github.com/signageos/applet-examples/blob/master/examples/content-js-api/offline-zip-decompress)
|
|
59
|
+
|
|
60
|
+
:::
|
|
32
61
|
|
|
33
62
|
<Separator />
|
|
34
63
|
|
|
35
64
|
### deleteContent()
|
|
36
65
|
|
|
37
66
|
<Admonition type="info" icon="" title="">
|
|
38
|
-
Learn more about using this API [here](https://developers.signageos.io/docs/
|
|
67
|
+
Learn more about using this API [here](https://developers.signageos.io/docs/sos-guides/key-value-storage)
|
|
39
68
|
</Admonition>
|
|
40
69
|
|
|
41
|
-
The `deleteContent() method removes the value specified by `uid` key.
|
|
70
|
+
The `deleteContent()` method removes the value specified by `uid` key from the cache storage.
|
|
42
71
|
|
|
43
72
|
```ts expandable
|
|
44
73
|
deleteContent(uid: string): Promise<void>;
|
|
45
74
|
```
|
|
46
75
|
|
|
76
|
+
#### Params
|
|
77
|
+
|
|
78
|
+
| Name | Type | Required | Description |
|
|
79
|
+
|-------|----------|------------------|-------------------------------------------------|
|
|
80
|
+
| `uid` | `string` | <div>Yes</div> | Unique identifier of the content to be deleted. |
|
|
81
|
+
|
|
82
|
+
#### Return value
|
|
83
|
+
|
|
84
|
+
A promise that resolves when the content is deleted.
|
|
85
|
+
|
|
86
|
+
#### Possible errors
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
- Error If the uid does not exist.
|
|
90
|
+
- Error If the uid is not a valid string.
|
|
91
|
+
- Error If any other error occurs during deletion.
|
|
92
|
+
|
|
93
|
+
#### Example
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
//Store
|
|
97
|
+
sos.offline.cache.saveContent('ApplicationSecret', '123SuperSecretHash')
|
|
98
|
+
.then(() => {
|
|
99
|
+
//Content was successfully saved, retrieve it.
|
|
100
|
+
return sos.offline.cache.loadContent('ApplicationSecret');
|
|
101
|
+
})
|
|
102
|
+
.then((content) => {
|
|
103
|
+
console.log('Loaded', content); // print 123SuperSecretHash
|
|
104
|
+
|
|
105
|
+
// Let's delete the content now
|
|
106
|
+
return sos.offline.cache.deleteContent('ApplicationSecret')
|
|
107
|
+
})
|
|
108
|
+
.then(() => {
|
|
109
|
+
console.log("Deleted");
|
|
110
|
+
})
|
|
111
|
+
.catch((error) => { console.error(error); });
|
|
112
|
+
```
|
|
113
|
+
|
|
47
114
|
<Separator />
|
|
48
115
|
|
|
49
116
|
### deleteFile()
|
|
50
117
|
|
|
51
|
-
The `deleteFile()` method removes the file specified by `uid
|
|
118
|
+
The `deleteFile()` method removes the file specified by `uid` from cache storage.
|
|
52
119
|
|
|
53
120
|
```ts expandable
|
|
54
121
|
deleteFile(uid: string): Promise<void>;
|
|
55
122
|
```
|
|
56
123
|
|
|
124
|
+
#### Params
|
|
125
|
+
|
|
126
|
+
| Name | Type | Required | Description |
|
|
127
|
+
|-------|----------|------------------|----------------------------------------------|
|
|
128
|
+
| `uid` | `string` | <div>Yes</div> | Unique identifier of the file to be deleted. |
|
|
129
|
+
|
|
130
|
+
#### Return value
|
|
131
|
+
|
|
132
|
+
A promise that resolves when the file is deleted.
|
|
133
|
+
|
|
57
134
|
#### Possible errors
|
|
58
135
|
|
|
59
|
-
|
|
136
|
+
|
|
137
|
+
- Error If the uid is not a valid string.
|
|
138
|
+
- Error If the uid is not found in the cache.
|
|
139
|
+
|
|
140
|
+
#### Example
|
|
141
|
+
|
|
142
|
+
```ts
|
|
143
|
+
// Save a file
|
|
144
|
+
await sos.offline.cache.saveFile('example-file.mp4', 'https://example.com/path/to/your/file.mp4');
|
|
145
|
+
// Later delete the file
|
|
146
|
+
await sos.offline.cache.deleteFile('example-file.mp4');
|
|
147
|
+
```
|
|
60
148
|
|
|
61
149
|
<Separator />
|
|
62
150
|
|
|
@@ -76,40 +164,99 @@ type AnyString = string & {};
|
|
|
76
164
|
|
|
77
165
|
```
|
|
78
166
|
|
|
167
|
+
#### Params
|
|
168
|
+
|
|
169
|
+
| Name | Type | Required | Description |
|
|
170
|
+
|------------|-----------------|------------------|---------------------------------------------------------------------------|
|
|
171
|
+
| `uid` | `string` | <div>Yes</div> | Unique file identifier of a previously downloaded file. |
|
|
172
|
+
| `hashType` | `HashAlgorithm` | <div>Yes</div> | The hashing algorithm to use. Supported algorithms are `md5` and `crc32`. |
|
|
173
|
+
|
|
174
|
+
#### Return value
|
|
175
|
+
|
|
176
|
+
A promise that resolves to the computed checksum of the file.
|
|
177
|
+
|
|
79
178
|
#### Possible errors
|
|
80
179
|
|
|
81
|
-
|
|
180
|
+
|
|
181
|
+
- Error If the uid does not exist.
|
|
182
|
+
- Error If the hashing algorithm is not supported.
|
|
183
|
+
|
|
184
|
+
#### Example
|
|
185
|
+
|
|
186
|
+
```ts
|
|
187
|
+
const checksum = await sos.offline.cache.getChecksumFile('example-file.mp4', 'md5');
|
|
188
|
+
console.log('MD5 Checksum:', checksum); // Output: MD5 Checksum: d41d8cd98f00b204e9800998ecf8427e
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
:::note[GitHub Example]
|
|
192
|
+
|
|
193
|
+
- [ Example Applet with MD5 Checksum](https://github.com/signageos/applet-examples/tree/master/examples/content-js-api/md5-checksum)
|
|
194
|
+
|
|
195
|
+
:::
|
|
82
196
|
|
|
83
197
|
<Separator />
|
|
84
198
|
|
|
85
199
|
### listContents()
|
|
86
200
|
|
|
87
|
-
<Admonition type="info" icon="" title="">
|
|
88
|
-
Learn more about using this API [here](https://developers.signageos.io/docs/applets/api-guides/key-value-storage)
|
|
89
|
-
</Admonition>
|
|
90
|
-
|
|
91
201
|
The `listContent()` method lists all values saved by `saveContent()` method.
|
|
92
202
|
|
|
93
203
|
```ts expandable
|
|
94
204
|
listContents(): Promise<string[]>;
|
|
95
205
|
```
|
|
96
206
|
|
|
207
|
+
#### Return value
|
|
208
|
+
|
|
209
|
+
A promise that resolves to an array of saved content.
|
|
210
|
+
|
|
211
|
+
#### Example
|
|
212
|
+
|
|
213
|
+
```ts
|
|
214
|
+
// Save some content and list all saved contents
|
|
215
|
+
await sos.offline.cache.saveContent('ApplicationSecret', '123SuperSecretHash');
|
|
216
|
+
await sos.offline.cache.saveContent('UserToken', 'abc123xyz');
|
|
217
|
+
|
|
218
|
+
// Later list the saved contents
|
|
219
|
+
const contents = await sos.offline.cache.listContents();
|
|
220
|
+
console.log('Saved contents:', contents); // Output: Saved contents: ['ApplicationSecret', 'UserToken']
|
|
221
|
+
```
|
|
222
|
+
|
|
97
223
|
<Separator />
|
|
98
224
|
|
|
99
225
|
### listFiles()
|
|
100
226
|
|
|
101
|
-
The `listFiles()` method list all currently cached files.
|
|
227
|
+
The `listFiles()` method list all currently cached files in internal storage, which was previously saved by `saveFile()` or `loadOrSaveFile()` methods.
|
|
102
228
|
|
|
103
229
|
```ts expandable
|
|
104
230
|
listFiles(): Promise<string[]>;
|
|
105
231
|
```
|
|
106
232
|
|
|
233
|
+
#### Return value
|
|
234
|
+
|
|
235
|
+
A promise that resolves to an array of unique identifiers (uids) of the saved files.
|
|
236
|
+
|
|
237
|
+
#### Possible errors
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
- Error If any error occurs during listing files.
|
|
241
|
+
- Error If the files cannot be listed.
|
|
242
|
+
|
|
243
|
+
#### Example
|
|
244
|
+
|
|
245
|
+
```ts
|
|
246
|
+
await sos.offline.cache.saveFile('example-file.mp4', 'https://example.com/path/to/your/file.mp4');
|
|
247
|
+
await sos.offline.cache.saveFile('another-file.jpg', 'https://example.com/path/to/your/image.jpg');
|
|
248
|
+
|
|
249
|
+
// Later list the saved files
|
|
250
|
+
const files = await sos.offline.cache.listFiles();
|
|
251
|
+
console.log('Saved files:', files); // Output: Saved files: ['example-file.mp4', 'another-file.jpg']
|
|
252
|
+
```
|
|
253
|
+
|
|
107
254
|
<Separator />
|
|
108
255
|
|
|
109
256
|
### loadContent()
|
|
110
257
|
|
|
111
258
|
<Admonition type="info" icon="" title="">
|
|
112
|
-
Learn more about using this API [here](https://developers.signageos.io/docs/
|
|
259
|
+
Learn more about using this API [here](https://developers.signageos.io/docs/sos-guides/key-value-storage)
|
|
113
260
|
</Admonition>
|
|
114
261
|
|
|
115
262
|
The `loadContent()` method gets the value specified by `uid`, which was previously saved by `saveContent()`.
|
|
@@ -118,6 +265,35 @@ The `loadContent()` method gets the value specified by `uid`, which was previous
|
|
|
118
265
|
loadContent(uid: string): Promise<string>;
|
|
119
266
|
```
|
|
120
267
|
|
|
268
|
+
#### Params
|
|
269
|
+
|
|
270
|
+
| Name | Type | Required | Description |
|
|
271
|
+
|-------|----------|------------------|------------------------------------------------|
|
|
272
|
+
| `uid` | `string` | <div>Yes</div> | Unique identifier of the content to be loaded. |
|
|
273
|
+
|
|
274
|
+
#### Return value
|
|
275
|
+
|
|
276
|
+
A promise that resolves to the loaded content.
|
|
277
|
+
|
|
278
|
+
#### Possible errors
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
- Error If the uid does not exist.
|
|
282
|
+
- Error If the uid is not a valid string.
|
|
283
|
+
- Error If the content is not a valid string.
|
|
284
|
+
- Error If any other error occurs during loading.
|
|
285
|
+
|
|
286
|
+
#### Example
|
|
287
|
+
|
|
288
|
+
```ts
|
|
289
|
+
// Previously saved content with uid 'ApplicationSecret'
|
|
290
|
+
await sos.offline.cache.saveContent('ApplicationSecret', '123SuperSecretHash');
|
|
291
|
+
|
|
292
|
+
// Load the content
|
|
293
|
+
const content = await sos.offline.cache.loadContent('ApplicationSecret');
|
|
294
|
+
console.log('Loaded content:', content); // Output: Loaded content: 123SuperSecretHash
|
|
295
|
+
```
|
|
296
|
+
|
|
121
297
|
<Separator />
|
|
122
298
|
|
|
123
299
|
### loadFile()
|
|
@@ -133,15 +309,47 @@ interface IFile {
|
|
|
133
309
|
|
|
134
310
|
```
|
|
135
311
|
|
|
312
|
+
#### Params
|
|
313
|
+
|
|
314
|
+
| Name | Type | Required | Description |
|
|
315
|
+
|-------|----------|------------------|---------------------------------------------|
|
|
316
|
+
| `uid` | `string` | <div>Yes</div> | Unique identifier of the file to be loaded. |
|
|
317
|
+
|
|
318
|
+
#### Return value
|
|
319
|
+
|
|
320
|
+
A promise that resolves to the loaded file.
|
|
321
|
+
|
|
136
322
|
#### Possible errors
|
|
137
323
|
|
|
138
|
-
|
|
324
|
+
|
|
325
|
+
- Error If the uid is not a valid string.
|
|
326
|
+
- Error If the uid does not exist
|
|
327
|
+
|
|
328
|
+
#### Example
|
|
329
|
+
|
|
330
|
+
```ts
|
|
331
|
+
// Save a file
|
|
332
|
+
await sos.offline.cache.saveFile('example-file.mp4', 'https://example.com/path/to/your/file.mp4');
|
|
333
|
+
// Later load the file
|
|
334
|
+
const file = await sos.offline.cache.loadFile('example-file.mp4');
|
|
335
|
+
console.log('Loaded file:', file); // Output: Loaded file: { uid: 'example-file.mp4', uri: 'file://path/to/your/file.mp4' }
|
|
336
|
+
```
|
|
139
337
|
|
|
140
338
|
<Separator />
|
|
141
339
|
|
|
142
340
|
### loadOrSaveFile()
|
|
143
341
|
|
|
144
|
-
|
|
342
|
+
Method `loadOrSaveFile()` is used for individual file retrieval & save in case when file is not saved in local storage yet. To get file from internal memory & save it when not yet exists we prepared `loadOrSaveFile()` method.
|
|
343
|
+
|
|
344
|
+
:::info
|
|
345
|
+
- The file URI has to return the file. If your URI leads to a 303 redirect (e.g. from http to https), the API will not work.
|
|
346
|
+
- Emulator has certain limitations while handling offline files. [Read more here](https://docs.signageos.io/hc/en-us/articles/4405238997138).
|
|
347
|
+
- Local device file path differs from device to device. It can point to `file://` or `http://localhost` etc.
|
|
348
|
+
:::
|
|
349
|
+
|
|
350
|
+
:::warning
|
|
351
|
+
`uid` should have the same file extension (e.g.: mp4, svg, jpg) as the original file
|
|
352
|
+
:::
|
|
145
353
|
|
|
146
354
|
```ts expandable
|
|
147
355
|
loadOrSaveFile(uid: string, uri: string, headers?: {
|
|
@@ -154,30 +362,113 @@ interface IFile {
|
|
|
154
362
|
|
|
155
363
|
```
|
|
156
364
|
|
|
365
|
+
#### Params
|
|
366
|
+
|
|
367
|
+
| Name | Type | Required | Description |
|
|
368
|
+
|-----------|------------------------------|------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
369
|
+
| `uid` | `string` | <div>Yes</div> | Unique identifier of the file to be loaded or saved. |
|
|
370
|
+
| `uri` | `string` | <div>Yes</div> | URI of the file to be downloaded if not cached. |
|
|
371
|
+
| `headers` | `{ [key: string]: string; }` | <div>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. |
|
|
372
|
+
|
|
373
|
+
#### Return value
|
|
374
|
+
|
|
375
|
+
A promise that resolves to the loaded or saved file.
|
|
376
|
+
|
|
377
|
+
#### Possible errors
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
- Error If the uid is not a valid string.
|
|
381
|
+
- Error If the uri is not a valid URI.
|
|
382
|
+
- Error If the headers are not a valid object with string values.
|
|
383
|
+
- Error If the file cannot be loaded or saved.
|
|
384
|
+
- AppletOfflineCacheError If the headers are not valid.
|
|
385
|
+
|
|
386
|
+
#### Example
|
|
387
|
+
|
|
388
|
+
```ts
|
|
389
|
+
await sos.offline.cache.loadOrSaveFile('example-file.mp4', 'https://example.com/path/to/your/file.mp4')
|
|
390
|
+
.then((file) => {
|
|
391
|
+
console.log('File loaded or saved:', file);
|
|
392
|
+
})
|
|
393
|
+
.catch((error) => {
|
|
394
|
+
console.error('Error loading or saving file:', error);
|
|
395
|
+
});
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
:::note[GitHub Example]
|
|
399
|
+
|
|
400
|
+
- [ Example Applet with Offline Files](https://github.com/signageos/applet-examples/blob/master/examples/content-js-api/offline-files)
|
|
401
|
+
- [ Example Applet with Video Loop Offline](https://github.com/signageos/applet-examples/tree/master/examples/content-js-api/video-loop-offline)
|
|
402
|
+
|
|
403
|
+
:::
|
|
404
|
+
|
|
157
405
|
<Separator />
|
|
158
406
|
|
|
159
407
|
### saveContent()
|
|
160
408
|
|
|
161
409
|
<Admonition type="info" icon="" title="">
|
|
162
|
-
Learn more about using this API [here](https://developers.signageos.io/docs/
|
|
410
|
+
Learn more about using this API [here](https://developers.signageos.io/docs/sos-guides/key-value-storage)
|
|
163
411
|
</Admonition>
|
|
164
412
|
|
|
165
|
-
The `saveContent()` method saves a string value to the cache
|
|
413
|
+
The `saveContent()` method saves a string value to the cache with specified `uid`.
|
|
414
|
+
|
|
415
|
+
Use when you need to save some data into local memory. This API provides you with approach similar to the HTML5's Local Storage, but implemented internally via native device API and completely device-agnostic.
|
|
166
416
|
|
|
167
417
|
```ts expandable
|
|
168
418
|
saveContent(uid: string, content: string): Promise<void>;
|
|
169
419
|
```
|
|
170
420
|
|
|
421
|
+
#### Params
|
|
422
|
+
|
|
423
|
+
| Name | Type | Required | Description |
|
|
424
|
+
|-----------|----------|------------------|-----------------------------------------------|
|
|
425
|
+
| `uid` | `string` | <div>Yes</div> | Unique identifier of the content to be saved. |
|
|
426
|
+
| `content` | `string` | <div>Yes</div> | The string content to be saved. |
|
|
427
|
+
|
|
428
|
+
#### Return value
|
|
429
|
+
|
|
430
|
+
A promise that resolves when the content is saved.
|
|
431
|
+
|
|
432
|
+
#### Possible errors
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
- Error If the uid is not a valid string.
|
|
436
|
+
- Error If the content is not a valid string.
|
|
437
|
+
- Error If the uid already exists.
|
|
438
|
+
- Error If any other error occurs during saving.
|
|
439
|
+
|
|
440
|
+
#### Example
|
|
441
|
+
|
|
442
|
+
```ts
|
|
443
|
+
sos.offline.cache.saveContent('ApplicationSecret', '123SuperSecretHash')
|
|
444
|
+
.then(() => {
|
|
445
|
+
//Content was successfully saved, retrieve it.
|
|
446
|
+
return sos.offline.cache.loadContent('ApplicationSecret');
|
|
447
|
+
})
|
|
448
|
+
.then((content) => {
|
|
449
|
+
console.log('Loaded', content); // print 123SuperSecretHash
|
|
450
|
+
})
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
:::note[GitHub Example]
|
|
454
|
+
|
|
455
|
+
- [ Example of Applet using saveContent()](https://github.com/signageos/applet-examples/tree/master/examples/content-js-api/offline-content)
|
|
456
|
+
|
|
457
|
+
:::
|
|
458
|
+
|
|
171
459
|
<Separator />
|
|
172
460
|
|
|
173
461
|
### saveFile()
|
|
174
462
|
|
|
175
|
-
|
|
463
|
+
Method `saveFile()` is used to save files from remote a destination into the device internal memory.
|
|
176
464
|
|
|
177
|
-
:::
|
|
178
|
-
|
|
179
|
-
|
|
465
|
+
:::info
|
|
466
|
+
- Local device file path differs from device to device. It can point to `file://` or `http://localhost` etc.
|
|
467
|
+
:::
|
|
180
468
|
|
|
469
|
+
:::warning
|
|
470
|
+
- headers has to be a JSON object. If you are passing the value, make sure you use JSON.parse().
|
|
471
|
+
- `uid` should have the same file extension (e.g.: mp4, svg, jpg) as the original file.
|
|
181
472
|
:::
|
|
182
473
|
|
|
183
474
|
```ts expandable
|
|
@@ -186,9 +477,34 @@ saveFile(uid: string, uri: string, headers?: {
|
|
|
186
477
|
}): Promise<void>;
|
|
187
478
|
```
|
|
188
479
|
|
|
480
|
+
#### Params
|
|
481
|
+
|
|
482
|
+
| Name | Type | Required | Description |
|
|
483
|
+
|-----------|------------------------------|------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
484
|
+
| `uid` | `string` | <div>Yes</div> | Unique identifier of the file to be saved. |
|
|
485
|
+
| `uri` | `string` | <div>Yes</div> | URI of the file to be downloaded. |
|
|
486
|
+
| `headers` | `{ [key: string]: string; }` | <div>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. |
|
|
487
|
+
|
|
189
488
|
#### Possible errors
|
|
190
489
|
|
|
191
|
-
|
|
490
|
+
|
|
491
|
+
- Error If the network request fails.
|
|
492
|
+
- Error If the uid is not a valid string.
|
|
493
|
+
- Error If the uri is not a valid URI.
|
|
494
|
+
- Error File with the same uid is already cached.
|
|
495
|
+
- Error If the headers are not a valid object with string values.
|
|
496
|
+
|
|
497
|
+
#### Example
|
|
498
|
+
|
|
499
|
+
```ts
|
|
500
|
+
await sos.offline.cache.saveFile('example-file.mp4', 'https://example.com/path/to/your/file.mp4')
|
|
501
|
+
.then(() => {
|
|
502
|
+
console.log('File saved successfully');
|
|
503
|
+
})
|
|
504
|
+
.catch((error) => {
|
|
505
|
+
console.error('Error saving file:', error);
|
|
506
|
+
});
|
|
507
|
+
```
|
|
192
508
|
|
|
193
509
|
<Separator />
|
|
194
510
|
|
|
@@ -208,6 +524,30 @@ type AnyString = string & {};
|
|
|
208
524
|
|
|
209
525
|
```
|
|
210
526
|
|
|
527
|
+
#### Params
|
|
528
|
+
|
|
529
|
+
| Name | Type | Required | Description |
|
|
530
|
+
|------------|-----------------|------------------|---------------------------------------------------------------------------|
|
|
531
|
+
| `uid` | `string` | <div>Yes</div> | Unique file identifier of a previously downloaded file. |
|
|
532
|
+
| `hash` | `string` | <div>Yes</div> | The expected checksum of the file. |
|
|
533
|
+
| `hashType` | `HashAlgorithm` | <div>Yes</div> | The hashing algorithm to use. Supported algorithms are 'md5' and `crc32`. |
|
|
534
|
+
|
|
535
|
+
#### Return value
|
|
536
|
+
|
|
537
|
+
A promise that resolves to `true` if the checksum is valid, otherwise `false`.
|
|
538
|
+
|
|
211
539
|
#### Possible errors
|
|
212
540
|
|
|
213
|
-
|
|
541
|
+
|
|
542
|
+
- Error If the uid does not exist or the hashing algorithm is not supported.
|
|
543
|
+
- Error If the hash is not a valid string.
|
|
544
|
+
- Error If the hashType is not a valid string.
|
|
545
|
+
|
|
546
|
+
#### Example
|
|
547
|
+
|
|
548
|
+
```ts
|
|
549
|
+
// Validate the checksum of a file
|
|
550
|
+
const expectedHash = 'd41d8cd98f00b204e9800998ecf8427e'; // Example MD5 hash
|
|
551
|
+
// Previously saved file with uid 'example-file.mp4'
|
|
552
|
+
const isValid = await sos.offline.cache.validateChecksumFile('example-file.mp4', expectedHash, 'md5');
|
|
553
|
+
```
|