@signageos/front-applet 8.1.2 → 8.1.4

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.
Files changed (110) hide show
  1. package/dist/bundle.js +1 -1
  2. package/dist/bundle.js.map +1 -1
  3. package/docs/sos/browser.md +66 -14
  4. package/docs/sos/command.md +52 -6
  5. package/docs/sos/debug.md +21 -2
  6. package/docs/sos/deviceInfo.md +31 -0
  7. package/docs/sos/display.md +34 -3
  8. package/docs/sos/fileSystem.md +1135 -59
  9. package/docs/sos/hardware/barcodeScanner.md +58 -15
  10. package/docs/sos/hardware/index.md +72 -15
  11. package/docs/sos/hardware/led.md +32 -3
  12. package/docs/sos/index.md +3 -3
  13. package/docs/sos/input.md +42 -1
  14. package/docs/sos/monitors.md +8 -0
  15. package/docs/sos/native/mdc.md +69 -23
  16. package/docs/sos/offline/cache.md +376 -30
  17. package/docs/sos/offline/index.md +127 -24
  18. package/docs/sos/osd.md +8 -1
  19. package/docs/sos/proofOfPlay.md +28 -0
  20. package/docs/sos/stream.md +78 -78
  21. package/docs/sos/sync.md +228 -21
  22. package/docs/sos/video.md +73 -73
  23. package/docs/sos_management/app.md +11 -11
  24. package/docs/sos_management/audio.md +3 -3
  25. package/docs/sos_management/firmware.md +11 -11
  26. package/docs/sos_management/index.md +9 -9
  27. package/docs/sos_management/network.md +10 -10
  28. package/docs/sos_management/package.md +6 -6
  29. package/docs/sos_management/power.md +27 -27
  30. package/docs/sos_management/screen.md +17 -17
  31. package/docs/sos_management/security.md +3 -3
  32. package/docs/sos_management/time.md +8 -8
  33. package/docs/sos_management/wifi.md +12 -12
  34. package/es6/FrontApplet/Browser/Browser.d.ts +25 -9
  35. package/es6/FrontApplet/Browser/Browser.js +25 -9
  36. package/es6/FrontApplet/Browser/Browser.js.map +1 -1
  37. package/es6/FrontApplet/Browser/IOpenLinkOptions.d.ts +7 -0
  38. package/es6/FrontApplet/Browser/IOpenLinkOptions.js.map +1 -1
  39. package/es6/FrontApplet/Browser/events.d.ts +6 -0
  40. package/es6/FrontApplet/Browser/events.js.map +1 -1
  41. package/es6/FrontApplet/Command/Command.d.ts +15 -6
  42. package/es6/FrontApplet/Command/Command.js +15 -6
  43. package/es6/FrontApplet/Command/Command.js.map +1 -1
  44. package/es6/FrontApplet/Command/ICommand.d.ts +7 -0
  45. package/es6/FrontApplet/Command/ICommandEvent.d.ts +6 -0
  46. package/es6/FrontApplet/Debug/Debug.d.ts +11 -3
  47. package/es6/FrontApplet/Debug/Debug.js +11 -3
  48. package/es6/FrontApplet/Debug/Debug.js.map +1 -1
  49. package/es6/FrontApplet/DeviceInfo/DeviceInfo.d.ts +19 -0
  50. package/es6/FrontApplet/DeviceInfo/DeviceInfo.js +20 -2
  51. package/es6/FrontApplet/DeviceInfo/DeviceInfo.js.map +1 -1
  52. package/es6/FrontApplet/Display/Display.d.ts +22 -14
  53. package/es6/FrontApplet/Display/Display.js +22 -14
  54. package/es6/FrontApplet/Display/Display.js.map +1 -1
  55. package/es6/FrontApplet/Display/IDisplay.d.ts +4 -0
  56. package/es6/FrontApplet/FileSystem/FileSystem.d.ts +429 -41
  57. package/es6/FrontApplet/FileSystem/FileSystem.js +427 -39
  58. package/es6/FrontApplet/FileSystem/FileSystem.js.map +1 -1
  59. package/es6/FrontApplet/FileSystem/HashAlgorithm.d.ts +4 -1
  60. package/es6/FrontApplet/FileSystem/types.d.ts +46 -0
  61. package/es6/FrontApplet/FileSystem/types.js.map +1 -1
  62. package/es6/FrontApplet/Hardware/BarcodeScanner/BarcodeScanner.d.ts +36 -8
  63. package/es6/FrontApplet/Hardware/BarcodeScanner/BarcodeScanner.js +34 -2
  64. package/es6/FrontApplet/Hardware/BarcodeScanner/BarcodeScanner.js.map +1 -1
  65. package/es6/FrontApplet/Hardware/BarcodeScanner/IBarcodeScanner.d.ts +5 -0
  66. package/es6/FrontApplet/Hardware/Hardware.d.ts +34 -5
  67. package/es6/FrontApplet/Hardware/Hardware.js +33 -5
  68. package/es6/FrontApplet/Hardware/Hardware.js.map +1 -1
  69. package/es6/FrontApplet/Hardware/ISerialPort.d.ts +17 -1
  70. package/es6/FrontApplet/Hardware/ISerialPortDataMessage.d.ts +3 -0
  71. package/es6/FrontApplet/Hardware/ISerialPortOptions.d.ts +6 -0
  72. package/es6/FrontApplet/Hardware/ISerialPortOptions.js +3 -0
  73. package/es6/FrontApplet/Hardware/ISerialPortOptions.js.map +1 -1
  74. package/es6/FrontApplet/Hardware/Led/Led.d.ts +19 -3
  75. package/es6/FrontApplet/Hardware/Led/Led.js +19 -3
  76. package/es6/FrontApplet/Hardware/Led/Led.js.map +1 -1
  77. package/es6/FrontApplet/Input/IKeyUpEvent.d.ts +9 -0
  78. package/es6/FrontApplet/Input/IKeyUpEvent.js +6 -0
  79. package/es6/FrontApplet/Input/IKeyUpEvent.js.map +1 -1
  80. package/es6/FrontApplet/Input/Input.d.ts +17 -1
  81. package/es6/FrontApplet/Input/Input.js +17 -1
  82. package/es6/FrontApplet/Input/Input.js.map +1 -1
  83. package/es6/FrontApplet/Monitors/Monitors.d.ts +5 -0
  84. package/es6/FrontApplet/Monitors/Monitors.js +5 -0
  85. package/es6/FrontApplet/Monitors/Monitors.js.map +1 -1
  86. package/es6/FrontApplet/NativeCommands/MDC/INativeMdcCommands.d.ts +1 -0
  87. package/es6/FrontApplet/NativeCommands/MDC/Mdc.d.ts +32 -11
  88. package/es6/FrontApplet/NativeCommands/MDC/Mdc.js +14 -11
  89. package/es6/FrontApplet/NativeCommands/MDC/Mdc.js.map +1 -1
  90. package/es6/FrontApplet/OSD/OSD.d.ts +5 -1
  91. package/es6/FrontApplet/OSD/OSD.js +5 -1
  92. package/es6/FrontApplet/OSD/OSD.js.map +1 -1
  93. package/es6/FrontApplet/Offline/Cache/Cache.d.ts +205 -28
  94. package/es6/FrontApplet/Offline/Cache/Cache.js +205 -28
  95. package/es6/FrontApplet/Offline/Cache/Cache.js.map +1 -1
  96. package/es6/FrontApplet/Offline/IAddFont.js.map +1 -1
  97. package/es6/FrontApplet/Offline/IFileType.js.map +1 -1
  98. package/es6/FrontApplet/Offline/ISaveFile.d.ts +3 -0
  99. package/es6/FrontApplet/Offline/ISaveFile.js.map +1 -1
  100. package/es6/FrontApplet/Offline/Offline.d.ts +58 -15
  101. package/es6/FrontApplet/Offline/Offline.js +56 -13
  102. package/es6/FrontApplet/Offline/Offline.js.map +1 -1
  103. package/es6/FrontApplet/ProofOfPlay/IRecordItemOptions.d.ts +3 -0
  104. package/es6/FrontApplet/ProofOfPlay/ProofOfPlay.d.ts +15 -1
  105. package/es6/FrontApplet/ProofOfPlay/ProofOfPlay.js +15 -1
  106. package/es6/FrontApplet/ProofOfPlay/ProofOfPlay.js.map +1 -1
  107. package/es6/FrontApplet/Sync/Sync.d.ts +101 -18
  108. package/es6/FrontApplet/Sync/Sync.js +84 -10
  109. package/es6/FrontApplet/Sync/Sync.js.map +1 -1
  110. package/package.json +1 -1
@@ -4,16 +4,12 @@ sidebar_position: 0
4
4
 
5
5
  # cache
6
6
 
7
- <Admonition type="info" icon="" title="">
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
- The `sos.offline` API groups together methods used to download and save arbitrary files, which can be accessed even if the device is offline.
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
- If the uid does not exist.
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/applets/api-guides/key-value-storage)
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
- If the uid does not exist.
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
 
@@ -67,46 +155,108 @@ The `getChecksumFile()` computes a checksum of the file specified by `uid`.
67
155
  ```ts expandable
68
156
  getChecksumFile(uid: string, hashType: HashAlgorithm): Promise<string>;
69
157
  // show-more
70
- type HashAlgorithm = 'md5' | 'sha1' | 'sha256' | 'sha384' | 'sha512' | 'crc32' | AnyString;
158
+ /**
159
+ * Represents the supported hash algorithms by Core Apps.
160
+ */
161
+ type HashAlgorithm = 'md5' | 'crc32' | AnyString;
71
162
 
72
163
  type AnyString = string & {};
73
164
 
74
165
  ```
75
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
+
76
178
  #### Possible errors
77
179
 
78
- If the uid does not exist or the hashing algorithm is not supported.
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
+ :::
79
196
 
80
197
  <Separator />
81
198
 
82
199
  ### listContents()
83
200
 
84
- <Admonition type="info" icon="" title="">
85
- Learn more about using this API [here](https://developers.signageos.io/docs/applets/api-guides/key-value-storage)
86
- </Admonition>
87
-
88
201
  The `listContent()` method lists all values saved by `saveContent()` method.
89
202
 
90
203
  ```ts expandable
91
204
  listContents(): Promise<string[]>;
92
205
  ```
93
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
+
94
223
  <Separator />
95
224
 
96
225
  ### listFiles()
97
226
 
98
- 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.
99
228
 
100
229
  ```ts expandable
101
230
  listFiles(): Promise<string[]>;
102
231
  ```
103
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
+
104
254
  <Separator />
105
255
 
106
256
  ### loadContent()
107
257
 
108
258
  <Admonition type="info" icon="" title="">
109
- Learn more about using this API [here](https://developers.signageos.io/docs/applets/api-guides/key-value-storage)
259
+ Learn more about using this API [here](https://developers.signageos.io/docs/sos-guides/key-value-storage)
110
260
  </Admonition>
111
261
 
112
262
  The `loadContent()` method gets the value specified by `uid`, which was previously saved by `saveContent()`.
@@ -115,6 +265,35 @@ The `loadContent()` method gets the value specified by `uid`, which was previous
115
265
  loadContent(uid: string): Promise<string>;
116
266
  ```
117
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
+
118
297
  <Separator />
119
298
 
120
299
  ### loadFile()
@@ -130,15 +309,47 @@ interface IFile {
130
309
 
131
310
  ```
132
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
+
133
322
  #### Possible errors
134
323
 
135
- If the uid does not exists
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
+ ```
136
337
 
137
338
  <Separator />
138
339
 
139
340
  ### loadOrSaveFile()
140
341
 
141
- The loadOrSaveFile() method loads the file from the cache, or downloads it if it's not already cached.
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
+ :::
142
353
 
143
354
  ```ts expandable
144
355
  loadOrSaveFile(uid: string, uri: string, headers?: {
@@ -151,30 +362,113 @@ interface IFile {
151
362
 
152
363
  ```
153
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
+
154
405
  <Separator />
155
406
 
156
407
  ### saveContent()
157
408
 
158
409
  <Admonition type="info" icon="" title="">
159
- Learn more about using this API [here](https://developers.signageos.io/docs/applets/api-guides/key-value-storage)
410
+ Learn more about using this API [here](https://developers.signageos.io/docs/sos-guides/key-value-storage)
160
411
  </Admonition>
161
412
 
162
- 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.
163
416
 
164
417
  ```ts expandable
165
418
  saveContent(uid: string, content: string): Promise<void>;
166
419
  ```
167
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
+
168
459
  <Separator />
169
460
 
170
461
  ### saveFile()
171
462
 
172
- The `saveFile()` method downloads file from `uri` and saves it to the offline cache.
463
+ Method `saveFile()` is used to save files from remote a destination into the device internal memory.
173
464
 
174
- :::warning
175
-
176
- `uid` should have the same file extension (e.g.: mp4, svg, jpg) as the original file.
465
+ :::info
466
+ - Local device file path differs from device to device. It can point to `file://` or `http://localhost` etc.
467
+ :::
177
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.
178
472
  :::
179
473
 
180
474
  ```ts expandable
@@ -183,9 +477,34 @@ saveFile(uid: string, uri: string, headers?: {
183
477
  }): Promise<void>;
184
478
  ```
185
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
+
186
488
  #### Possible errors
187
489
 
188
- If the network request fails or a file with the same uid is already cached
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
+ ```
189
508
 
190
509
  <Separator />
191
510
 
@@ -196,12 +515,39 @@ The `validateChecksumFile()` method validates whether the file, specified by `ui
196
515
  ```ts expandable
197
516
  validateChecksumFile(uid: string, hash: string, hashType: HashAlgorithm): Promise<boolean>;
198
517
  // show-more
199
- type HashAlgorithm = 'md5' | 'sha1' | 'sha256' | 'sha384' | 'sha512' | 'crc32' | AnyString;
518
+ /**
519
+ * Represents the supported hash algorithms by Core Apps.
520
+ */
521
+ type HashAlgorithm = 'md5' | 'crc32' | AnyString;
200
522
 
201
523
  type AnyString = string & {};
202
524
 
203
525
  ```
204
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
+
205
539
  #### Possible errors
206
540
 
207
- If the uid does not exist or the hashing algorithm is not supported.
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
+ ```