@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
|
@@ -11,15 +11,14 @@ import IChecksumMessage from './IChecksumMessage';
|
|
|
11
11
|
import IOfflineCache from './IOfflineCache';
|
|
12
12
|
import { HashAlgorithm } from '../../FileSystem/HashAlgorithm';
|
|
13
13
|
/**
|
|
14
|
-
* The `sos.offline` API groups together methods used to download and save arbitrary files, which can be accessed even if the device is offline.
|
|
14
|
+
* 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.
|
|
15
15
|
*
|
|
16
|
-
*
|
|
16
|
+
* > Please refer to difference between `sos.offline.cache` and `sos.fileSystem` APIs in our [documentation](http://localhost:3000/sdk/sos/offline/).
|
|
17
17
|
*
|
|
18
|
+
* :::warning
|
|
18
19
|
* Emulator has certain limitations while handling offline files. [Read more here](https://docs.signageos.io/hc/en-us/articles/4405238997138)
|
|
19
|
-
*
|
|
20
20
|
* :::
|
|
21
21
|
*
|
|
22
|
-
* @tutorial https://developers.signageos.io/docs/applets/api-guides/offline-content#caching-audio-visual-content-or-arbitrary-data-sosofflinecache
|
|
23
22
|
*/
|
|
24
23
|
export default class Cache implements IOfflineCache {
|
|
25
24
|
private messagePrefix;
|
|
@@ -30,101 +29,279 @@ export default class Cache implements IOfflineCache {
|
|
|
30
29
|
/** @internal */
|
|
31
30
|
constructor(messagePrefix: string, postMessage: IPostMessage<ISavedFileMessage & ISavedContentMessage & ILoadedFileMessage & ILoadedContentMessage & IListedFilesMessage & IListedContentsMessage & IChecksumMessage & IValidatedChecksumMessage>);
|
|
32
31
|
/**
|
|
33
|
-
* The `listFiles()` method list all currently cached files.
|
|
32
|
+
* The `listFiles()` method list all currently cached files in internal storage, which was previously saved by `saveFile()` or `loadOrSaveFile()` methods.
|
|
34
33
|
*
|
|
34
|
+
* @returns {Promise<string[]>} A promise that resolves to an array of unique identifiers (uids) of the saved files.
|
|
35
|
+
* @throws Error If any error occurs during listing files.
|
|
36
|
+
* @throws Error If the files cannot be listed.
|
|
35
37
|
* @since 2.0.0
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* await sos.offline.cache.saveFile('example-file.mp4', 'https://example.com/path/to/your/file.mp4');
|
|
41
|
+
* await sos.offline.cache.saveFile('another-file.jpg', 'https://example.com/path/to/your/image.jpg');
|
|
42
|
+
*
|
|
43
|
+
* // Later list the saved files
|
|
44
|
+
* const files = await sos.offline.cache.listFiles();
|
|
45
|
+
* console.log('Saved files:', files); // Output: Saved files: ['example-file.mp4', 'another-file.jpg']
|
|
36
46
|
*/
|
|
37
47
|
listFiles(): Promise<string[]>;
|
|
38
48
|
/**
|
|
39
49
|
* The `loadFile()` method loads cached file, which was previously saved by `saveFile()` or `loadOrSaveFile()` methods.
|
|
40
50
|
*
|
|
41
|
-
* @
|
|
42
|
-
*
|
|
51
|
+
* @param uid Unique identifier of the file to be loaded.
|
|
52
|
+
* @returns {Promise<IFile>} A promise that resolves to the loaded file.
|
|
53
|
+
* @throws Error If the uid is not a valid string.
|
|
54
|
+
* @throws Error If the uid does not exist
|
|
43
55
|
* @since 1.0.3
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* // Save a file
|
|
59
|
+
* await sos.offline.cache.saveFile('example-file.mp4', 'https://example.com/path/to/your/file.mp4');
|
|
60
|
+
* // Later load the file
|
|
61
|
+
* const file = await sos.offline.cache.loadFile('example-file.mp4');
|
|
62
|
+
* console.log('Loaded file:', file); // Output: Loaded file: { uid: 'example-file.mp4', uri: 'file://path/to/your/file.mp4' }
|
|
44
63
|
*/
|
|
45
64
|
loadFile(uid: string): Promise<IFile>;
|
|
46
65
|
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* :::warning
|
|
50
|
-
*
|
|
51
|
-
* `uid` should have the same file extension (e.g.: mp4, svg, jpg) as the original file.
|
|
66
|
+
* Method `saveFile()` is used to save files from remote a destination into the device internal memory.
|
|
52
67
|
*
|
|
68
|
+
* :::info
|
|
69
|
+
* - Local device file path differs from device to device. It can point to `file://` or `http://localhost` etc.
|
|
53
70
|
* :::
|
|
54
71
|
*
|
|
55
|
-
*
|
|
72
|
+
* :::warning
|
|
73
|
+
* - headers has to be a JSON object. If you are passing the value, make sure you use JSON.parse().
|
|
74
|
+
* - `uid` should have the same file extension (e.g.: mp4, svg, jpg) as the original file.
|
|
75
|
+
* :::
|
|
56
76
|
*
|
|
77
|
+
* @param uid Unique identifier of the file to be saved.
|
|
78
|
+
* @param uri URI of the file to be downloaded.
|
|
79
|
+
* @param headers 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.
|
|
80
|
+
* @throws Error If the network request fails.
|
|
81
|
+
* @throws Error If the uid is not a valid string.
|
|
82
|
+
* @throws Error If the uri is not a valid URI.
|
|
83
|
+
* @throws Error File with the same uid is already cached.
|
|
84
|
+
* @throws Error If the headers are not a valid object with string values.
|
|
57
85
|
* @since 1.0.3
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* await sos.offline.cache.saveFile('example-file.mp4', 'https://example.com/path/to/your/file.mp4')
|
|
89
|
+
* .then(() => {
|
|
90
|
+
* console.log('File saved successfully');
|
|
91
|
+
* })
|
|
92
|
+
* .catch((error) => {
|
|
93
|
+
* console.error('Error saving file:', error);
|
|
94
|
+
* });
|
|
58
95
|
*/
|
|
59
96
|
saveFile(uid: string, uri: string, headers?: {
|
|
60
97
|
[key: string]: string;
|
|
61
98
|
}): Promise<void>;
|
|
62
99
|
/**
|
|
63
|
-
*
|
|
100
|
+
* 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.
|
|
101
|
+
*
|
|
102
|
+
* :::info
|
|
103
|
+
* - 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.
|
|
104
|
+
* - Emulator has certain limitations while handling offline files. [Read more here](https://docs.signageos.io/hc/en-us/articles/4405238997138).
|
|
105
|
+
* - Local device file path differs from device to device. It can point to `file://` or `http://localhost` etc.
|
|
106
|
+
* :::
|
|
107
|
+
*
|
|
108
|
+
* :::warning
|
|
109
|
+
* `uid` should have the same file extension (e.g.: mp4, svg, jpg) as the original file
|
|
110
|
+
* :::
|
|
64
111
|
*
|
|
112
|
+
* @param uid Unique identifier of the file to be loaded or saved.
|
|
113
|
+
* @param uri URI of the file to be downloaded if not cached.
|
|
114
|
+
* @param headers 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.
|
|
115
|
+
* @returns {Promise<IFile>} A promise that resolves to the loaded or saved file.
|
|
116
|
+
* @throws Error If the uid is not a valid string.
|
|
117
|
+
* @throws Error If the uri is not a valid URI.
|
|
118
|
+
* @throws Error If the headers are not a valid object with string values.
|
|
119
|
+
* @throws Error If the file cannot be loaded or saved.
|
|
120
|
+
* @throws AppletOfflineCacheError If the headers are not valid.
|
|
65
121
|
* @since 1.0.9
|
|
122
|
+
* @example // {@link https://github.com/signageos/applet-examples/blob/master/examples/content-js-api/offline-files | Example Applet with Offline Files}
|
|
123
|
+
* @example // {@link https://github.com/signageos/applet-examples/tree/master/examples/content-js-api/video-loop-offline | Example Applet with Video Loop Offline}
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* await sos.offline.cache.loadOrSaveFile('example-file.mp4', 'https://example.com/path/to/your/file.mp4')
|
|
127
|
+
* .then((file) => {
|
|
128
|
+
* console.log('File loaded or saved:', file);
|
|
129
|
+
* })
|
|
130
|
+
* .catch((error) => {
|
|
131
|
+
* console.error('Error loading or saving file:', error);
|
|
132
|
+
* });
|
|
66
133
|
*/
|
|
67
134
|
loadOrSaveFile(uid: string, uri: string, headers?: {
|
|
68
135
|
[key: string]: string;
|
|
69
136
|
}): Promise<IFile>;
|
|
70
137
|
/**
|
|
71
|
-
* The `deleteFile()` method removes the file specified by `uid
|
|
138
|
+
* The `deleteFile()` method removes the file specified by `uid` from cache storage.
|
|
72
139
|
*
|
|
140
|
+
* @param uid Unique identifier of the file to be deleted.
|
|
141
|
+
* @returns {Promise<void>} A promise that resolves when the file is deleted.
|
|
142
|
+
* @throws Error If the uid is not a valid string.
|
|
143
|
+
* @throws Error If the uid is not found in the cache.
|
|
73
144
|
* @since 2.0.0
|
|
74
145
|
*
|
|
75
|
-
* @
|
|
146
|
+
* @example
|
|
147
|
+
* // Save a file
|
|
148
|
+
* await sos.offline.cache.saveFile('example-file.mp4', 'https://example.com/path/to/your/file.mp4');
|
|
149
|
+
* // Later delete the file
|
|
150
|
+
* await sos.offline.cache.deleteFile('example-file.mp4');
|
|
76
151
|
*/
|
|
77
152
|
deleteFile(uid: string): Promise<void>;
|
|
78
153
|
/**
|
|
79
154
|
* The `listContent()` method lists all values saved by `saveContent()` method.
|
|
80
155
|
*
|
|
156
|
+
* @returns {Promise<string[]>} A promise that resolves to an array of saved content.
|
|
81
157
|
* @since 2.0.0
|
|
82
|
-
*
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* // Save some content and list all saved contents
|
|
161
|
+
* await sos.offline.cache.saveContent('ApplicationSecret', '123SuperSecretHash');
|
|
162
|
+
* await sos.offline.cache.saveContent('UserToken', 'abc123xyz');
|
|
163
|
+
*
|
|
164
|
+
* // Later list the saved contents
|
|
165
|
+
* const contents = await sos.offline.cache.listContents();
|
|
166
|
+
* console.log('Saved contents:', contents); // Output: Saved contents: ['ApplicationSecret', 'UserToken']
|
|
83
167
|
*/
|
|
84
168
|
listContents(): Promise<string[]>;
|
|
85
169
|
/**
|
|
86
170
|
* The `loadContent()` method gets the value specified by `uid`, which was previously saved by `saveContent()`.
|
|
87
171
|
*
|
|
172
|
+
* @param uid Unique identifier of the content to be loaded.
|
|
173
|
+
* @returns {Promise<string>} A promise that resolves to the loaded content.
|
|
174
|
+
* @throws Error If the uid does not exist.
|
|
175
|
+
* @throws Error If the uid is not a valid string.
|
|
176
|
+
* @throws Error If the content is not a valid string.
|
|
177
|
+
* @throws Error If any other error occurs during loading.
|
|
88
178
|
* @since 1.0.3
|
|
89
|
-
* @tutorial https://developers.signageos.io/docs/
|
|
179
|
+
* @tutorial https://developers.signageos.io/docs/sos-guides/key-value-storage
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* // Previously saved content with uid 'ApplicationSecret'
|
|
183
|
+
* await sos.offline.cache.saveContent('ApplicationSecret', '123SuperSecretHash');
|
|
184
|
+
*
|
|
185
|
+
* // Load the content
|
|
186
|
+
* const content = await sos.offline.cache.loadContent('ApplicationSecret');
|
|
187
|
+
* console.log('Loaded content:', content); // Output: Loaded content: 123SuperSecretHash
|
|
90
188
|
*/
|
|
91
189
|
loadContent(uid: string): Promise<string>;
|
|
92
190
|
/**
|
|
93
|
-
* The `saveContent()` method saves a string value to the cache
|
|
191
|
+
* The `saveContent()` method saves a string value to the cache with specified `uid`.
|
|
94
192
|
*
|
|
193
|
+
* 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.
|
|
194
|
+
*
|
|
195
|
+
* @param uid Unique identifier of the content to be saved.
|
|
196
|
+
* @param content The string content to be saved.
|
|
197
|
+
* @returns {Promise<void>} A promise that resolves when the content is saved.
|
|
198
|
+
* @throws Error If the uid is not a valid string.
|
|
199
|
+
* @throws Error If the content is not a valid string.
|
|
200
|
+
* @throws Error If the uid already exists.
|
|
201
|
+
* @throws Error If any other error occurs during saving.
|
|
95
202
|
* @since 1.0.3
|
|
96
|
-
* @tutorial https://developers.signageos.io/docs/
|
|
203
|
+
* @tutorial https://developers.signageos.io/docs/sos-guides/key-value-storage
|
|
204
|
+
*
|
|
205
|
+
* @example // {@link https://github.com/signageos/applet-examples/tree/master/examples/content-js-api/offline-content | Example of Applet using saveContent()}
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* sos.offline.cache.saveContent('ApplicationSecret', '123SuperSecretHash')
|
|
209
|
+
* .then(() => {
|
|
210
|
+
* //Content was successfully saved, retrieve it.
|
|
211
|
+
* return sos.offline.cache.loadContent('ApplicationSecret');
|
|
212
|
+
* })
|
|
213
|
+
* .then((content) => {
|
|
214
|
+
* console.log('Loaded', content); // print 123SuperSecretHash
|
|
215
|
+
* })
|
|
97
216
|
*/
|
|
98
217
|
saveContent(uid: string, content: string): Promise<void>;
|
|
99
218
|
/**
|
|
100
|
-
* The `deleteContent() method removes the value specified by `uid` key.
|
|
219
|
+
* The `deleteContent()` method removes the value specified by `uid` key from the cache storage.
|
|
101
220
|
*
|
|
221
|
+
* @param uid Unique identifier of the content to be deleted.
|
|
222
|
+
* @returns {Promise<void>} A promise that resolves when the content is deleted.
|
|
223
|
+
* @throws Error If the uid does not exist.
|
|
224
|
+
* @throws Error If the uid is not a valid string.
|
|
225
|
+
* @throws Error If any other error occurs during deletion.
|
|
102
226
|
* @since 2.0.0
|
|
103
|
-
* @tutorial https://developers.signageos.io/docs/
|
|
227
|
+
* @tutorial https://developers.signageos.io/docs/sos-guides/key-value-storage
|
|
228
|
+
*
|
|
229
|
+
* @example
|
|
230
|
+
* //Store
|
|
231
|
+
* sos.offline.cache.saveContent('ApplicationSecret', '123SuperSecretHash')
|
|
232
|
+
* .then(() => {
|
|
233
|
+
* //Content was successfully saved, retrieve it.
|
|
234
|
+
* return sos.offline.cache.loadContent('ApplicationSecret');
|
|
235
|
+
* })
|
|
236
|
+
* .then((content) => {
|
|
237
|
+
* console.log('Loaded', content); // print 123SuperSecretHash
|
|
238
|
+
*
|
|
239
|
+
* // Let's delete the content now
|
|
240
|
+
* return sos.offline.cache.deleteContent('ApplicationSecret')
|
|
241
|
+
* })
|
|
242
|
+
* .then(() => {
|
|
243
|
+
* console.log("Deleted");
|
|
244
|
+
* })
|
|
245
|
+
* .catch((error) => { console.error(error); });
|
|
104
246
|
*/
|
|
105
247
|
deleteContent(uid: string): Promise<void>;
|
|
106
248
|
/**
|
|
107
249
|
* The `validateChecksumFile()` method validates whether the file, specified by `uid`, has the correct checksum.
|
|
108
250
|
*
|
|
109
|
-
* @
|
|
110
|
-
*
|
|
251
|
+
* @param uid Unique file identifier of a previously downloaded file.
|
|
252
|
+
* @param hash The expected checksum of the file.
|
|
253
|
+
* @param hashType The hashing algorithm to use. Supported algorithms are 'md5' and `crc32`.
|
|
254
|
+
* @returns {Promise<boolean>} A promise that resolves to `true` if the checksum is valid, otherwise `false`.
|
|
255
|
+
* @throws Error If the uid does not exist or the hashing algorithm is not supported.
|
|
256
|
+
* @throws Error If the hash is not a valid string.
|
|
257
|
+
* @throws Error If the hashType is not a valid string.
|
|
111
258
|
* @since 2.0.0
|
|
259
|
+
*
|
|
260
|
+
* @example
|
|
261
|
+
* // Validate the checksum of a file
|
|
262
|
+
* const expectedHash = 'd41d8cd98f00b204e9800998ecf8427e'; // Example MD5 hash
|
|
263
|
+
* // Previously saved file with uid 'example-file.mp4'
|
|
264
|
+
* const isValid = await sos.offline.cache.validateChecksumFile('example-file.mp4', expectedHash, 'md5');
|
|
112
265
|
*/
|
|
113
266
|
validateChecksumFile(uid: string, hash: string, hashType: HashAlgorithm): Promise<boolean>;
|
|
114
267
|
/**
|
|
115
268
|
* The `getChecksumFile()` computes a checksum of the file specified by `uid`.
|
|
116
269
|
*
|
|
117
|
-
* @
|
|
118
|
-
*
|
|
270
|
+
* @param uid Unique file identifier of a previously downloaded file.
|
|
271
|
+
* @param hashType The hashing algorithm to use. Supported algorithms are `md5` and `crc32`.
|
|
272
|
+
* @returns {Promise<string>} A promise that resolves to the computed checksum of the file.
|
|
273
|
+
* @throws Error If the uid does not exist.
|
|
274
|
+
* @throws Error If the hashing algorithm is not supported.
|
|
119
275
|
* @since 2.0.0
|
|
276
|
+
*
|
|
277
|
+
* @example // {@link https://github.com/signageos/applet-examples/tree/master/examples/content-js-api/md5-checksum | Example Applet with MD5 Checksum}
|
|
278
|
+
*
|
|
279
|
+
* @example
|
|
280
|
+
* const checksum = await sos.offline.cache.getChecksumFile('example-file.mp4', 'md5');
|
|
281
|
+
* console.log('MD5 Checksum:', checksum); // Output: MD5 Checksum: d41d8cd98f00b204e9800998ecf8427e
|
|
120
282
|
*/
|
|
121
283
|
getChecksumFile(uid: string, hashType: HashAlgorithm): Promise<string>;
|
|
122
284
|
/**
|
|
123
285
|
* The `decompressFile()` decompresses the file specified by `uid` into a new file specified by `destinationUid`.
|
|
124
286
|
*
|
|
125
|
-
* @
|
|
126
|
-
*
|
|
287
|
+
* @param uid Unique file identifier of a previously downloaded ZIP file.
|
|
288
|
+
* @param destinationUid Unique directory identifier (prefix of file) to extract ZIP file.
|
|
289
|
+
* @param method The decompression method to use. Currently, only 'zip' is supported.
|
|
290
|
+
* @returns {Promise<void>} A promise that resolves when the file is decompressed.
|
|
291
|
+
* @throws Error If the uid does not exist.
|
|
292
|
+
* @throws Error If the destinationUid is not a valid string.
|
|
293
|
+
* @throws Error If the method is not supported.
|
|
127
294
|
* @since 2.1.0
|
|
295
|
+
*
|
|
296
|
+
* @example // {@link https://github.com/signageos/applet-examples/blob/master/examples/content-js-api/offline-zip-decompress | Example Applet with Offline ZIP Decompression}
|
|
297
|
+
* @example
|
|
298
|
+
* // Save the ZIP file
|
|
299
|
+
* await sos.offline.cache.saveFile('example-zip-file.zip', 'https://example.com/path/to/your/file.zip');
|
|
300
|
+
*
|
|
301
|
+
* // Decompress the ZIP file into a directory
|
|
302
|
+
* await sos.offline.cache.decompressFile('example-zip-file.zip', 'extracted-files/', 'zip');
|
|
303
|
+
* .then(() => { console.log('ZIP file extracted'); })
|
|
304
|
+
* .catch((error) => { console.error(error); });
|
|
128
305
|
*/
|
|
129
306
|
decompressFile(uid: string, destinationUid: string, method: 'zip'): Promise<void>;
|
|
130
307
|
private getCachedFile;
|