@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
@@ -13,15 +13,23 @@ const CssLoadFileController_1 = __importDefault(require("./LoadFile/CssLoadFileC
13
13
  const JavascriptLoadFileController_1 = __importDefault(require("./LoadFile/JavascriptLoadFileController"));
14
14
  const Types_1 = __importDefault(require("./Types"));
15
15
  /**
16
- * The `sos.offline` API groups together methods for storing and using JS, CSS and font files.
16
+ * Web-based applications often require additional assets to function, but downloading them every time is undesirable. The JS Applet SDK offers a wide range of APIs for storing different kinds of assets.
17
17
  *
18
- * :::warning
18
+ * Generally, there are four types of assets:
19
+ * - CSS & JavaScript files
20
+ * - Fonts
21
+ * - Audio-visual content (image, video, and audio files)
22
+ * - Arbitrary data (e.g., JSON files, plain text, binary data)
19
23
  *
20
- * Emulator has certain limitations while handling offline files. [Read more here](https://docs.signageos.io/hc/en-us/articles/4405238997138)
24
+ * And the SDK also provides two different APIs:
25
+ * - `sos.offline` & `sos.offline.cache`: A file system abstraction for caching files that are removed when the applet configuration is changed or the applet is reloaded. This method is usually preferred if the files can be re-downloaded.
26
+ * - `sos.fileSystem`: Direct access to the file system. All files are stored permanently and are not removed when the applet configuration changes.
21
27
  *
22
- * :::
28
+ * Using the `sos.offline` and `sos.offline.cache` APIs allows you to ship an applet without content, including only basic bootstrapping code, and load the content dynamically. The content will then be available even when the device is offline.
23
29
  *
24
- * @tutorial https://developers.signageos.io/docs/applets/api-guides/offline-content#caching-css--javascript-sosoffline
30
+ * :::warning
31
+ * Emulator has certain limitations while handling offline files. [Read more here](https://docs.signageos.io/hc/en-us/articles/4405238997138)
32
+ * :::
25
33
  */
26
34
  class Offline {
27
35
  messagePrefix;
@@ -61,10 +69,17 @@ class Offline {
61
69
  });
62
70
  }
63
71
  /**
64
- * The `addFiles()` method downloads the specified files and stores them locally. The order in which the files are downloaded and stored is **not** guaranteed.
72
+ * The `addFiles()` method downloads the specified files and stores them locally.
73
+ * The order in which the files are downloaded and stored is **not** guaranteed.
65
74
  *
75
+ * CSS and JavaScript files are specific because they must be loaded with an HTML tag. The `sos.offline` API methods download, save, and append the resource to the web page. When adding a file, choose a unique identifier (`uid`) that should not change for the resource. The file will be overwritten if another file is added with the same `uid`.
76
+ *
77
+ * @param files Array of files to be downloaded and stored locally.
78
+ * @returns {Promise<Awaited<void>>} Resolves when all files are added.
79
+ * @throws {Error} If the `files` parameter is not an array of objects.
66
80
  * @since 1.0.0
67
81
  *
82
+ * @example // {@link https://github.com/signageos/applet-examples/blob/master/examples/content-js-api/offline-resources | Example of Applet that save files and load them in one file}
68
83
  * @example
69
84
  * await sos.offline.addFile([{
70
85
  * uri: 'https://unpkg.com/normalize.css@8.0.1/normalize.css',
@@ -84,9 +99,24 @@ class Offline {
84
99
  return Promise.all(promises);
85
100
  }
86
101
  /**
87
- * The `addFilesSync()` method downloads the specified files and stores them locally. The order in which the files are downloaded and stored **is** guaranteed.
102
+ * Method `addFile()` will allow you to load single resource into applet. If you want to load more resource, use `addFiles()`.
103
+ *
104
+ * The order in which the files are downloaded and stored **is** guaranteed.
88
105
  *
106
+ * @param files Array of files to be downloaded and stored locally.
107
+ * @returns {Promise<void>} Resolves when all files are added and the files are appended to the document when flags are used.
108
+ * @throws {Error} If the `files` parameter is not an array of objects
89
109
  * @since 1.0.0
110
+ *
111
+ * @example
112
+ * const file = { // File that will be loaded into an applet
113
+ * "uri": "https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js",
114
+ * "uid": "jquery-2.2.4.min.js",
115
+ * "type": sos.offline.types.javascript,
116
+ * "flags": [sos.offline.flags.append(document.body)]
117
+ * }
118
+ *
119
+ * await sos.offline.addFile(file); // And finally load file
90
120
  */
91
121
  async addFilesSync(files) {
92
122
  (0, Validate_1.default)({ addFiles: files }).required().array('object');
@@ -97,17 +127,27 @@ class Offline {
97
127
  /**
98
128
  * The `addFile()` method downloads the specified file and stores it locally.
99
129
  *
130
+ * CSS and JavaScript files are specific because they must be loaded with an HTML tag. The `sos.offline` API methods download, save, and append the resource to the web page. When adding a file, choose a unique identifier (`uid`) that should not change for the resource. The file will be overwritten if another file is added with the same `uid`.
131
+ *
132
+ * :::info
133
+ * The file URL must point to a file. If your URI leads to a redirect (e.g. from http to https), the API will not work.
134
+ * :::
135
+ *
136
+ * @param file URI of the file to be downloaded.
137
+ * @param file.uid Unique file identifier is used for later file retrieval, must contain a-z,A-Z,0-9 characters.
138
+ * @param file.type Type of the file, e.g. 'javascript', 'css', etc.
139
+ * @param file.headers HTTP headers to be sent with the request for the file.
140
+ * @param file.flags Additional flags for appending stored files to the DOM or other operations
141
+ * @returns {Promise<void>} Resolves when the file is added and the file is appended to the document when flags are used.
142
+ * @throws {Error} If the `file` parameter is not an object.
143
+ * @throws {Error} If the `file` parameter does not contain a valid parameters.
100
144
  * @since 1.0.0
101
145
  *
102
146
  * @example
103
147
  * await sos.offline.addFile({
104
- * // Source URL
105
148
  * uri: 'https://code.jquery.com/jquery-3.7.1.slim.min.js',
106
- * // Unique identifier of the resource
107
149
  * uid: 'jquery-3.7.1.slim.min.js',
108
- * // Indicate that the downloaded file is a JavaScript file
109
150
  * type: sos.offline.types.javascript,
110
- * // After the file is downloaded, it will be appended to document.body
111
151
  * flags: [sos.offline.flags.append(document.body)],
112
152
  * });
113
153
  */
@@ -130,10 +170,13 @@ class Offline {
130
170
  * @param font.fontStretch Allows you to make text wider or narrower.
131
171
  * @param font.fontStyle Specifies the font style for a text. (Either `normal`, `italic`, `oblique`, `initial` or `inherit`)
132
172
  * @param font.fontWeight Sets how thick or thin characters in text should be displayed
133
- * @param font.unicodeRange Defines the range of unicode characters the font supports, default value is "U+0-10FFFF"
173
+ * @param font.unicodeRange Defines the range of Unicode characters the font supports, default value is "U+0-10FFFF"
134
174
  * @param font.formats Dictionary of supported formats with its files
135
- *
175
+ * @throws {Error} If the `font` parameter is not an object.
176
+ * @returns {Promise<void>} Resolves when the font is added and the style element is appended to the document.
136
177
  * @since 2.0.0
178
+ *
179
+ * @example // {@link https://github.com/signageos/applet-examples/tree/master/examples/content-js-api/fonts | Example of Applet that loads custom font}
137
180
  */
138
181
  async addFont(font) {
139
182
  (0, Validate_1.default)({ addFont: font }).required().object(IAddFont_1.VIAddFont);
@@ -1 +1 @@
1
- {"version":3,"file":"Offline.js","sourceRoot":"","sources":["../../../src/FrontApplet/Offline/Offline.ts"],"names":[],"mappings":";;;;;AAAA,iEAA+E;AAE/E,oEAA4C;AAC5C,0DAAkC;AAElC,wFAAgE;AAGhE,yCAA+D;AAE/D,2CAAoD;AACpD,6FAAqE;AAGrE,2GAAmF;AACnF,oDAAwC;AAMxC;;;;;;;;;;GAUG;AACH,MAAqB,OAAO;IAalB;IACA;IACA;IAdF,MAAM,CAAC,cAAc,GAAW,SAAS,CAAC;IAEjC,KAAK,CAAQ;IACb,KAAK,CAAS;IACd,QAAQ,CAAY;IACpB,KAAK,CAA0B;IACvC,eAAe,CAAkB;IACjC,eAAe,GAAkC,CAAC,8BAAoB,CAAC,CAAC;IACxE,mBAAmB,GAAgC,CAAC,sCAA4B,EAAE,+BAAqB,CAAC,CAAC;IAEjH,gBAAgB;IAChB,YACS,aAAqB,EACrB,MAA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C,KAAK,EAAE,aAAiC,EAAE,EAAE;YAC9H,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,IAAA,mCAAe,EAAC,IAAI,CAAC,GAAG,EAAE,aAAa,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,aAAa,CAAE,CAAC,CAAC;YACrH,aAAa,CAAC,SAAS,CAAC,aAAa,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;QACvD,CAAC,CAAC,CAAC;QACH,MAAM,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;QAEpC,MAAM,YAAY,GAAG,aAAa,CAAC,oBAAoB,EAAE,CAAC;QAC1D,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;IACvC,CAAC;IAEO,KAAK,CAAC,cAAc,CAAC,IAAW,EAAE,IAAW,EAAE,QAAmB;QACzE,MAAM,cAAc,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvD,IAAI,OAAO,cAAc,KAAK,WAAW,EAAE,CAAC;YAC3C,MAAM,IAAI,KAAK,CAAC,6BAA6B,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;QAC5D,CAAC;QACD,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC/B,MAAM,cAAc,CAAC,SAAS,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAC1D,CAAC;IAEO,gBAAgB;QACvB,OAAO,IAAI,CAAC,aAAa,GAAG,GAAG,GAAG,OAAO,CAAC,cAAc,CAAC;IAC1D,CAAC;;AAtLF,0BAuLC"}
@@ -1,3 +1,6 @@
1
+ /**
2
+ * Interface representing options for a record item in the Proof of Play applet.
3
+ */
1
4
  interface IRecordItemOptions {
2
5
  name: string;
3
6
  customId?: string;
@@ -1,6 +1,11 @@
1
1
  import CommandApi from '../Command/Command';
2
2
  import IRecordItemOptions from './IRecordItemOptions';
3
3
  import IProofOfPlay from './IProofOfPlay';
4
+ /**
5
+ * The `sos.proofOfPlay` API provides methods for recording information about played content on the device.
6
+ *
7
+ * Can be useful for tracking the playback of content, which can be used for analytics, reporting, or debugging purposes.
8
+ */
4
9
  export default class ProofOfPlay implements IProofOfPlay {
5
10
  private commandApi;
6
11
  /** @internal */
@@ -9,8 +14,17 @@ export default class ProofOfPlay implements IProofOfPlay {
9
14
  * The `recordItemPlayed()` method dispatches a `sos.command.dispatch()` command. It sends provided information about played content along
10
15
  * with additional metadata about current applet and device to signageOS.
11
16
  *
17
+ * @param options The options for recording the played item.
18
+ * @param options.name The name of the item that was played.
19
+ * @param options.customId An optional custom identifier for the item.
20
+ * @param options.type The type of the item that was played. It can be one of the following: `video`, `image`, `html`, or `custom`.
21
+ * @param options.tags An array of tags associated with the item.
22
+ * @param options.fileName The name of the file that was played.
23
+ * @param options.playbackSuccess A boolean indicating whether the playback was successful.
24
+ * @param options.errorMessage An optional error message if the playback was not successful.
25
+ * @returns {Promise<void>} A promise that resolves when the item has been recorded.
26
+ * @throws {Error} If any of the provided options are invalid.
12
27
  * @since 5.5.1
13
- *
14
28
  */
15
29
  recordItemPlayed(options: IRecordItemOptions): Promise<void>;
16
30
  }
@@ -5,6 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const Validate_1 = __importDefault(require("../Validate/Validate"));
7
7
  const ProofOfPlayType_1 = __importDefault(require("./ProofOfPlayType"));
8
+ /**
9
+ * The `sos.proofOfPlay` API provides methods for recording information about played content on the device.
10
+ *
11
+ * Can be useful for tracking the playback of content, which can be used for analytics, reporting, or debugging purposes.
12
+ */
8
13
  class ProofOfPlay {
9
14
  commandApi;
10
15
  /** @internal */
@@ -15,8 +20,17 @@ class ProofOfPlay {
15
20
  * The `recordItemPlayed()` method dispatches a `sos.command.dispatch()` command. It sends provided information about played content along
16
21
  * with additional metadata about current applet and device to signageOS.
17
22
  *
23
+ * @param options The options for recording the played item.
24
+ * @param options.name The name of the item that was played.
25
+ * @param options.customId An optional custom identifier for the item.
26
+ * @param options.type The type of the item that was played. It can be one of the following: `video`, `image`, `html`, or `custom`.
27
+ * @param options.tags An array of tags associated with the item.
28
+ * @param options.fileName The name of the file that was played.
29
+ * @param options.playbackSuccess A boolean indicating whether the playback was successful.
30
+ * @param options.errorMessage An optional error message if the playback was not successful.
31
+ * @returns {Promise<void>} A promise that resolves when the item has been recorded.
32
+ * @throws {Error} If any of the provided options are invalid.
18
33
  * @since 5.5.1
19
- *
20
34
  */
21
35
  async recordItemPlayed(options) {
22
36
  const { name, customId, type, tags, fileName, playbackSuccess, errorMessage } = options;
@@ -1 +1 @@
1
- {"version":3,"file":"ProofOfPlay.js","sourceRoot":"","sources":["../../../src/FrontApplet/ProofOfPlay/ProofOfPlay.ts"],"names":[],"mappings":";;;;;AAEA,oEAA4C;AAC5C,wEAAgD;AAGhD,MAAqB,WAAW;IAEX;IADpB,gBAAgB;IAChB,YAAoB,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAAG,CAAC;IAE9C;;;;;;OAMG;IACI,KAAK,CAAC,gBAAgB,CAAC,OAA2B;QACxD,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,eAAe,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;QACxF,IAAA,kBAAQ,EAAC,EAAE,IAAI,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,CAAC;QACvC,IAAA,kBAAQ,EAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;QAChC,IAAA,kBAAQ,EAAC,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;QAChE,IAAA,kBAAQ,EAAC,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,Q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AQ,CAAC,CAAC,CAAC;QAChE,IAAA,kBAAQ,EAAC,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QACnC,IAAA,kBAAQ,EAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;QAChC,IAAA,kBAAQ,EAAC,EAAE,eAAe,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;QACxC,IAAA,kBAAQ,EAAC,EAAE,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;QAEpC,MAAM,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;YAC9B,IAAI,EAAE,yBAAe,CAAC,UAAU;YAChC,QAAQ,EAAE,IAAI;YACd,QAAQ;YACR,QAAQ,EAAE,IAAI;YACd,QAAQ,EAAE,IAAI;YACd,QAAQ;YACR,eAAe;YACf,YAAY;SACZ,CAAC,CAAC;IACJ,CAAC;CACD;AAzCD,8BAyCC"}
@@ -2,6 +2,10 @@ import IPostMessage from '../IPostMessage';
2
2
  import { BroadcastedValueMessage, ClosedMessage, StatusMessage } from './syncMessages';
3
3
  import { StatusEvent } from './syncEvents';
4
4
  import ISync from './ISync';
5
+ /**
6
+ * The `SyncEngine` enum defines the available synchronization engines that can be used to synchronize devices.
7
+ * Each engine has its own method of connecting devices and synchronizing data.
8
+ */
5
9
  export declare enum SyncEngine {
6
10
  /** Use external sync server. Device will connect to the server via websocket. */
7
11
  SyncServer = "sync-server",
@@ -13,10 +17,16 @@ export declare enum SyncEngine {
13
17
  */
14
18
  Udp = "udp"
15
19
  }
20
+ /**
21
+ * Options for sync-server synchronization.
22
+ */
16
23
  export interface ConnectSyncServerOptions {
17
24
  engine?: SyncEngine.SyncServer;
18
25
  uri?: string;
19
26
  }
27
+ /**
28
+ * Options for P2P local synchronization.
29
+ */
20
30
  export interface ConnectP2PLocalOptions {
21
31
  engine: SyncEngine.P2PLocal;
22
32
  }
@@ -24,6 +34,7 @@ export interface ConnectP2PLocalOptions {
24
34
  export interface ConnectUdpOptions {
25
35
  engine: SyncEngine.Udp;
26
36
  }
37
+ type SynchronizationEngineOptions = ConnectSyncServerOptions | ConnectP2PLocalOptions | ConnectUdpOptions;
27
38
  /**
28
39
  * The `sos.sync` API groups together methods for synchronization of multiple devices. Devices are synchronized either through an external
29
40
  * server or one of the devices becomes a master device.
@@ -42,19 +53,21 @@ export default class Sync implements ISync {
42
53
  * You can optionally specify a custom sync server URI in case you are running the sync server in a custom location.
43
54
  *
44
55
  * :::info
45
- *
46
- * All devices, that should be synchronized together, must select the same engine. Otherwise they won't be able to communicate with each
56
+ * All devices, that should be synchronized together, must select the same engine. Otherwise, they won't be able to communicate with each
47
57
  * other.
48
- *
49
58
  * :::
50
59
  *
51
- * @param options.engine Synchronization engine to use.
60
+ * @param options.engine {SynchronizationEngineOptions} Synchronization engine to use.
52
61
  * @param options.uri Address of the sync server engine. Only relevant for sync-server. If omitted, the default server will be used.
53
- *
54
- * @throws if unable to connect.
55
- *
62
+ * @returns {Promise<void>} A promise that resolves when the connection is established.
63
+ * @throws Error If unable to connect.
64
+ * @throws Error If the `uri` is not a valid URL when using the sync-server engine.
65
+ * @throws Error If the `engine` is not a valid synchronization engine.
66
+ * @throws Error If any other error occurs during connection.
56
67
  * @since 5.7.0
57
68
  *
69
+ * @example // {@link https://github.com/signageos/applet-examples/tree/master/examples/content-js-api/sync-video | How to use synchronizer in applet}
70
+ * @example // {@link https://github.com/signageos/applet-examples/tree/master/examples/content-js-api/sync-mixed-content | How to synchronize mixed content}
58
71
  * @example
59
72
  * // use default engine
60
73
  * await sos.sync.connect();
@@ -68,7 +81,7 @@ export default class Sync implements ISync {
68
81
  * // use p2p-local engine
69
82
  * await sos.sync.connect({ engine: 'p2p-local' });
70
83
  */
71
- connect(options?: ConnectSyncServerOptions | ConnectP2PLocalOptions | ConnectUdpOptions): Promise<void>;
84
+ connect(options?: SynchronizationEngineOptions): Promise<void>;
72
85
  /**
73
86
  * @internal
74
87
  * @deprecated Use `connect({ engine: 'sync-server' })` instead.
@@ -80,6 +93,8 @@ export default class Sync implements ISync {
80
93
  * The `close()` method disconnects the device from synchronization server and other devices. Recommended to call this method after the
81
94
  * synchronization is not required any longer.
82
95
  *
96
+ * @returns {Promise<void>} A promise that resolves when the connection is closed.
97
+ * @throws Error If unable to close the connection.
83
98
  * @since 1.0.32
84
99
  */
85
100
  close(): Promise<void>;
@@ -92,11 +107,18 @@ export default class Sync implements ISync {
92
107
  * The `joinGroup()` method joins a group of other devices. This method has to be called after `connect()` call. Before any communication
93
108
  * takes place, all participating devices have to be connected and recognize one another. Recommended to call this method early.
94
109
  *
95
- * @param options.groupName By default, all devices will be synced together. To create groups of devices, independent from each other,
96
- * specify a group name.
97
- * @param options.deviceIdentification Identification of a device connected to `groupName` group.
98
- *
110
+ * @param options Options for joining a group.
111
+ * @returns {Promise<void>} A promise that resolves when the device joins the group.
112
+ * @throws Error If the group name is not a string.
113
+ * @throws Error If the device identification is not a string.
114
+ * @throws Error If unable to join the group.
115
+ * @throws Error If any other error occurs during joining the group.
99
116
  * @since 5.7.0
117
+ *
118
+ * @example // {@link https://github.com/signageos/applet-examples/tree/master/examples/content-js-api/sync-video | How to use synchronizer in applet}
119
+ * @example
120
+ * await sos.sync.connect();
121
+ * await sos.sync.joinGroup({ groupName: 'my-group', deviceIdentification: 'my-device-id' });
100
122
  */
101
123
  joinGroup(options: {
102
124
  groupName?: string;
@@ -105,7 +127,15 @@ export default class Sync implements ISync {
105
127
  /**
106
128
  * The `leaveMethod` method leaves a group of devices.
107
129
  *
130
+ * @param groupName The name of the group to leave. Defaults to the default group.
131
+ * @returns {Promise<void>} A promise that resolves when the device leaves the group.
132
+ * @throws Error If the group name is not a string.
133
+ * @throws Error If unable to leave the group.
134
+ * @throws Error If any other error occurs during leaving the group.
108
135
  * @since 5.7.0
136
+ *
137
+ * @example
138
+ * await sos.sync.leaveGroup('my-group');
109
139
  */
110
140
  leaveGroup(groupName?: string): Promise<void>;
111
141
  /**
@@ -124,22 +154,44 @@ export default class Sync implements ISync {
124
154
  * Therefore, when implementing your applet you should rely on the result data and not the data that is passed to the wait method as an
125
155
  * argument.
126
156
  *
157
+ * @param data Optional data to pass to the group.
158
+ * @param groupName The name of the group to wait for. Defaults to the default group.
159
+ * @param timeout Timeout in milliseconds. If not specified, the default timeout is 30 seconds.
160
+ * @returns {Promise<any>} A promise that resolves with the data from the master device when all devices are ready to continue.
161
+ * @throws Error If the group name is not a string.
162
+ * @throws Error If the timeout is not a number.
163
+ * @throws Error If unable to wait for the group.
164
+ * @throws Error If any other error occurs during waiting for the group.
127
165
  * @since 1.0.32
166
+ *
167
+ * @example
168
+ * // wait for all devices in the group to be ready
169
+ * await sos.sync.wait('someData', 'someRandomNameGroup').then((data) => {
170
+ * // this will be called once all devices are ready
171
+ * console.log('All devices are ready with data:', data);
172
+ * });
128
173
  */
129
174
  wait(data?: any, groupName?: string, timeout?: number): Promise<any>;
130
175
  /**
131
176
  * The `cancelWait()` method aborts a wait on all devices in a group. Sometimes it's necessary to cancel a pending wait. One such
132
177
  * situation would be when the group has to make a sudden change in content or another behavior but there's a risk that part of the group
133
- * already called wait() and is waiting for the rest but the rest will never call it at this point. In order to gracefully cleanup any
178
+ * already called wait() and is waiting for the rest but the rest will never call it at this point. In order to gracefully clean up any
134
179
  * pending activity, use this method.
135
180
  *
181
+ * :::warning
136
182
  * Any pending wait will be canceled and the promise will be rejected with an error.
183
+ * :::
137
184
  *
185
+ * @param groupName The name of the group to cancel the wait for. Defaults to the default group.
186
+ * @returns {Promise<void>} A promise that resolves when the wait is canceled.
187
+ * @throws Error If the group name is not a string.
188
+ * @throws Error If unable to cancel the wait.
189
+ * @throws Error If any other error occurs during canceling the wait.
138
190
  * @since 5.12.0
139
191
  *
140
192
  * @example
141
193
  * sos.sync.wait('someData', 'someRandomNameGroup').catch((err) => {
142
- * // this will happend once cancelWait is called
194
+ * // this will happen once cancelWait is called
143
195
  * console.error('wait failed', err);
144
196
  * });
145
197
  *
@@ -155,9 +207,30 @@ export default class Sync implements ISync {
155
207
  /**
156
208
  * The `broadcastValue()` method sends a key-value pair to all other devices in a specified group.
157
209
  *
158
- * @throws if the value can't be sent
159
- *
210
+ * @param groupName {String} The name of the group to broadcast the value to. Defaults to the default group.
211
+ * @param key {String} The key to broadcast the value under.
212
+ * @param value {any} The value to broadcast. It can be any valid type
213
+ * @returns {Promise<void>} A promise that resolves when the value is broadcasted.
214
+ * @throws Error If the group name is not a string.
215
+ * @throws Error If the key is not a string.
216
+ * @throws Error If the value is not a valid type (e.g. object, array, etc.).
217
+ * @throws Error If unable to broadcast the value.
218
+ * @throws Error If the value can't be sent
160
219
  * @since 5.7.0
220
+ *
221
+ * @example
222
+ * // broadcast a value to all devices in the group
223
+ * await sos.sync.broadcastValue({
224
+ * groupName: 'my-group',
225
+ * key: 'my-key',
226
+ * value: 'my-value',
227
+ * });
228
+ *
229
+ * // Received on the other devices:
230
+ * sos.sync.onValue((key, value, groupName) => {
231
+ * console.log(`Received value for key ${key} in group ${groupName}:`, value);
232
+ * });
233
+ *
161
234
  */
162
235
  broadcastValue({ groupName, key, value }: {
163
236
  groupName?: string;
@@ -168,13 +241,16 @@ export default class Sync implements ISync {
168
241
  * Returns true if the device is currently the master of the group.
169
242
  *
170
243
  * @param groupName The group name to check for master status. Defaults to the default group.
171
- *
244
+ * @return {Promise<boolean>} A promise that resolves with true if the device is the master, false otherwise.
172
245
  * @since 6.7.0
173
246
  */
174
247
  isMaster(groupName?: string): Promise<boolean>;
175
248
  /**
176
249
  * The `onValue()` method sets up a listener, which is called whenever the device receives a broadcasted message.
177
250
  *
251
+ * @param listener The listener function to call when a value is broadcasted.
252
+ * @returns {void} Returns when listener is set up.
253
+ * @throws Error If the listener is not a function.
178
254
  * @since 2.0.0
179
255
  */
180
256
  onValue(listener: (key: string, value: any, groupName?: string) => void): void;
@@ -182,14 +258,20 @@ export default class Sync implements ISync {
182
258
  * The `onStatus()` method sets up a listener, which is called periodically or whenever there is a change (i.e. new device
183
259
  * connects/disconnects to/from the group).
184
260
  *
261
+ * @param listener The listener function to call when the status changes.
262
+ * @returns {void} Returns when listener is set up.
263
+ * @throws Error If the listener is not a function.
185
264
  * @since 2.1.0
186
265
  */
187
266
  onStatus(listener: (status: StatusEvent) => void): void;
188
267
  /**
189
- * The `onStatus()` method sets up a listener, which is called whenever the device is disconnected from the sync. If it closed because
268
+ * The `onClosed()` method sets up a listener, which is called whenever the device is disconnected from the sync. If it closed because
190
269
  * `close()` was called, it will emit without any arguments. if it closed because of an error, it will emit with an error object as the
191
270
  * first argument.
192
271
  *
272
+ * @param listener The listener function to call when the sync is closed.
273
+ * @returns {void} Returns when listener is set up.
274
+ * @throws Error If the listener is not a function.
193
275
  * @since 5.12.0
194
276
  */
195
277
  onClosed(listener: (error?: Error) => void): void;
@@ -203,3 +285,4 @@ export default class Sync implements ISync {
203
285
  handleMessageData(data: BroadcastedValueMessage | StatusMessage | ClosedMessage): void;
204
286
  private getMessage;
205
287
  }
288
+ export {};
@@ -7,6 +7,10 @@ exports.SyncEngine = void 0;
7
7
  const events_1 = require("events");
8
8
  const syncMessages_1 = require("./syncMessages");
9
9
  const Validate_1 = __importDefault(require("../Validate/Validate"));
10
+ /**
11
+ * The `SyncEngine` enum defines the available synchronization engines that can be used to synchronize devices.
12
+ * Each engine has its own method of connecting devices and synchronizing data.
13
+ */
10
14
  var SyncEngine;
11
15
  (function (SyncEngine) {
12
16
  /** Use external sync server. Device will connect to the server via websocket. */
@@ -72,6 +76,8 @@ class Sync {
72
76
  * The `close()` method disconnects the device from synchronization server and other devices. Recommended to call this method after the
73
77
  * synchronization is not required any longer.
74
78
  *
79
+ * @returns {Promise<void>} A promise that resolves when the connection is closed.
80
+ * @throws Error If unable to close the connection.
75
81
  * @since 1.0.32
76
82
  */
77
83
  async close() {
@@ -90,11 +96,18 @@ class Sync {
90
96
  * The `joinGroup()` method joins a group of other devices. This method has to be called after `connect()` call. Before any communication
91
97
  * takes place, all participating devices have to be connected and recognize one another. Recommended to call this method early.
92
98
  *
93
- * @param options.groupName By default, all devices will be synced together. To create groups of devices, independent from each other,
94
- * specify a group name.
95
- * @param options.deviceIdentification Identification of a device connected to `groupName` group.
96
- *
99
+ * @param options Options for joining a group.
100
+ * @returns {Promise<void>} A promise that resolves when the device joins the group.
101
+ * @throws Error If the group name is not a string.
102
+ * @throws Error If the device identification is not a string.
103
+ * @throws Error If unable to join the group.
104
+ * @throws Error If any other error occurs during joining the group.
97
105
  * @since 5.7.0
106
+ *
107
+ * @example // {@link https://github.com/signageos/applet-examples/tree/master/examples/content-js-api/sync-video | How to use synchronizer in applet}
108
+ * @example
109
+ * await sos.sync.connect();
110
+ * await sos.sync.joinGroup({ groupName: 'my-group', deviceIdentification: 'my-device-id' });
98
111
  */
99
112
  async joinGroup(options) {
100
113
  const { groupName = Sync.DEFAULT_GROUP_NAME, deviceIdentification } = options;
@@ -109,7 +122,15 @@ class Sync {
109
122
  /**
110
123
  * The `leaveMethod` method leaves a group of devices.
111
124
  *
125
+ * @param groupName The name of the group to leave. Defaults to the default group.
126
+ * @returns {Promise<void>} A promise that resolves when the device leaves the group.
127
+ * @throws Error If the group name is not a string.
128
+ * @throws Error If unable to leave the group.
129
+ * @throws Error If any other error occurs during leaving the group.
112
130
  * @since 5.7.0
131
+ *
132
+ * @example
133
+ * await sos.sync.leaveGroup('my-group');
113
134
  */
114
135
  async leaveGroup(groupName = Sync.DEFAULT_GROUP_NAME) {
115
136
  (0, Validate_1.default)({ groupName }).required().string();
@@ -134,7 +155,22 @@ class Sync {
134
155
  * Therefore, when implementing your applet you should rely on the result data and not the data that is passed to the wait method as an
135
156
  * argument.
136
157
  *
158
+ * @param data Optional data to pass to the group.
159
+ * @param groupName The name of the group to wait for. Defaults to the default group.
160
+ * @param timeout Timeout in milliseconds. If not specified, the default timeout is 30 seconds.
161
+ * @returns {Promise<any>} A promise that resolves with the data from the master device when all devices are ready to continue.
162
+ * @throws Error If the group name is not a string.
163
+ * @throws Error If the timeout is not a number.
164
+ * @throws Error If unable to wait for the group.
165
+ * @throws Error If any other error occurs during waiting for the group.
137
166
  * @since 1.0.32
167
+ *
168
+ * @example
169
+ * // wait for all devices in the group to be ready
170
+ * await sos.sync.wait('someData', 'someRandomNameGroup').then((data) => {
171
+ * // this will be called once all devices are ready
172
+ * console.log('All devices are ready with data:', data);
173
+ * });
138
174
  */
139
175
  async wait(data, groupName = Sync.DEFAULT_GROUP_NAME, timeout) {
140
176
  (0, Validate_1.default)({ groupName }).required().string();
@@ -150,16 +186,23 @@ class Sync {
150
186
  /**
151
187
  * The `cancelWait()` method aborts a wait on all devices in a group. Sometimes it's necessary to cancel a pending wait. One such
152
188
  * situation would be when the group has to make a sudden change in content or another behavior but there's a risk that part of the group
153
- * already called wait() and is waiting for the rest but the rest will never call it at this point. In order to gracefully cleanup any
189
+ * already called wait() and is waiting for the rest but the rest will never call it at this point. In order to gracefully clean up any
154
190
  * pending activity, use this method.
155
191
  *
192
+ * :::warning
156
193
  * Any pending wait will be canceled and the promise will be rejected with an error.
194
+ * :::
157
195
  *
196
+ * @param groupName The name of the group to cancel the wait for. Defaults to the default group.
197
+ * @returns {Promise<void>} A promise that resolves when the wait is canceled.
198
+ * @throws Error If the group name is not a string.
199
+ * @throws Error If unable to cancel the wait.
200
+ * @throws Error If any other error occurs during canceling the wait.
158
201
  * @since 5.12.0
159
202
  *
160
203
  * @example
161
204
  * sos.sync.wait('someData', 'someRandomNameGroup').catch((err) => {
162
- * // this will happend once cancelWait is called
205
+ * // this will happen once cancelWait is called
163
206
  * console.error('wait failed', err);
164
207
  * });
165
208
  *
@@ -183,9 +226,30 @@ class Sync {
183
226
  /**
184
227
  * The `broadcastValue()` method sends a key-value pair to all other devices in a specified group.
185
228
  *
186
- * @throws if the value can't be sent
187
- *
229
+ * @param groupName {String} The name of the group to broadcast the value to. Defaults to the default group.
230
+ * @param key {String} The key to broadcast the value under.
231
+ * @param value {any} The value to broadcast. It can be any valid type
232
+ * @returns {Promise<void>} A promise that resolves when the value is broadcasted.
233
+ * @throws Error If the group name is not a string.
234
+ * @throws Error If the key is not a string.
235
+ * @throws Error If the value is not a valid type (e.g. object, array, etc.).
236
+ * @throws Error If unable to broadcast the value.
237
+ * @throws Error If the value can't be sent
188
238
  * @since 5.7.0
239
+ *
240
+ * @example
241
+ * // broadcast a value to all devices in the group
242
+ * await sos.sync.broadcastValue({
243
+ * groupName: 'my-group',
244
+ * key: 'my-key',
245
+ * value: 'my-value',
246
+ * });
247
+ *
248
+ * // Received on the other devices:
249
+ * sos.sync.onValue((key, value, groupName) => {
250
+ * console.log(`Received value for key ${key} in group ${groupName}:`, value);
251
+ * });
252
+ *
189
253
  */
190
254
  async broadcastValue({ groupName, key, value }) {
191
255
  groupName = groupName ?? Sync.DEFAULT_GROUP_NAME;
@@ -202,7 +266,7 @@ class Sync {
202
266
  * Returns true if the device is currently the master of the group.
203
267
  *
204
268
  * @param groupName The group name to check for master status. Defaults to the default group.
205
- *
269
+ * @return {Promise<boolean>} A promise that resolves with true if the device is the master, false otherwise.
206
270
  * @since 6.7.0
207
271
  */
208
272
  async isMaster(groupName) {
@@ -215,6 +279,9 @@ class Sync {
215
279
  /**
216
280
  * The `onValue()` method sets up a listener, which is called whenever the device receives a broadcasted message.
217
281
  *
282
+ * @param listener The listener function to call when a value is broadcasted.
283
+ * @returns {void} Returns when listener is set up.
284
+ * @throws Error If the listener is not a function.
218
285
  * @since 2.0.0
219
286
  */
220
287
  onValue(listener) {
@@ -227,6 +294,9 @@ class Sync {
227
294
  * The `onStatus()` method sets up a listener, which is called periodically or whenever there is a change (i.e. new device
228
295
  * connects/disconnects to/from the group).
229
296
  *
297
+ * @param listener The listener function to call when the status changes.
298
+ * @returns {void} Returns when listener is set up.
299
+ * @throws Error If the listener is not a function.
230
300
  * @since 2.1.0
231
301
  */
232
302
  onStatus(listener) {
@@ -240,10 +310,13 @@ class Sync {
240
310
  });
241
311
  }
242
312
  /**
243
- * The `onStatus()` method sets up a listener, which is called whenever the device is disconnected from the sync. If it closed because
313
+ * The `onClosed()` method sets up a listener, which is called whenever the device is disconnected from the sync. If it closed because
244
314
  * `close()` was called, it will emit without any arguments. if it closed because of an error, it will emit with an error object as the
245
315
  * first argument.
246
316
  *
317
+ * @param listener The listener function to call when the sync is closed.
318
+ * @returns {void} Returns when listener is set up.
319
+ * @throws Error If the listener is not a function.
247
320
  * @since 5.12.0
248
321
  */
249
322
  onClosed(listener) {
@@ -283,6 +356,7 @@ class Sync {
283
356
  const closedMessage = data;
284
357
  const closedEvent = closedMessage.error ? new Error(closedMessage.error) : undefined;
285
358
  this.eventEmitter.emit(SyncEvent.Closed, closedEvent);
359
+ break;
286
360
  default:
287
361
  }
288
362
  }