@capturebridge/sdk 0.14.2 → 0.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.15.0] - 2024-09-25
9
+
10
+ ### Added
11
+
12
+ - Add `Plugin.hasMethod()` method for checking if a plugin has a specific RPC
13
+ method.
14
+ - Add suppport for transcoding captured images to gif.
15
+
8
16
  ## [0.14.0] - 2024-09-17
9
17
 
10
18
  ### Added
package/Common.js CHANGED
@@ -90,6 +90,7 @@ export const DEFAULT_STREAM_OPT = {
90
90
  *
91
91
  * - `jpg`
92
92
  * - `tiff`
93
+ * - `gif`
93
94
  *
94
95
  * If not provided, a plugin or device-specific format will be returned.
95
96
  *
@@ -140,6 +141,14 @@ export const DATAURL_JPEG = 'data:image/jpeg;base64,'
140
141
  */
141
142
  export const DATAURL_PNG = 'data:image/png;base64,'
142
143
 
144
+ /**
145
+ * @summary `data:` prefix for GIF
146
+ * {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs|Data URLs}
147
+ * @constant
148
+ * @type {string}
149
+ */
150
+ export const DATAURL_GIF = 'data:image/gif;base64,'
151
+
143
152
  /**
144
153
  * @summary For a given base64 string, convert it to the appropriate Data URL
145
154
  * @constant
@@ -162,6 +171,11 @@ export const base64ToDataURL = base64 => {
162
171
  return DATAURL_PNG + base64
163
172
  }
164
173
 
174
+ // Check for GIF magic number (47 49 46 38)
175
+ if (byteArray[0] === 0x47 && byteArray[1] === 0x49 && byteArray[2] === 0x46 && byteArray[3] === 0x38) {
176
+ return DATAURL_GIF + base64
177
+ }
178
+
165
179
  throw new Error('Unknown image format provided in Base64 string')
166
180
  }
167
181
 
package/Plugin.js CHANGED
@@ -231,6 +231,20 @@ class Plugin {
231
231
  asyncToCallback(this, this.update, callback, force)
232
232
  }
233
233
 
234
+ /**
235
+ * Check if a plugin has an RPC method
236
+ *
237
+ * @param {string} method - An RPC method
238
+ * @returns {boolean} Return true if plugin has the provided method.
239
+ * @example
240
+ * const canCapture = await plugin.hasMethod('capture')
241
+ * @method
242
+ */
243
+ async hasMethod (method) {
244
+ await this.update()
245
+ return this.methods.includes(method)
246
+ }
247
+
234
248
  async rpc (request) {
235
249
  const options = {
236
250
  method: 'POST',
package/Version.js CHANGED
@@ -4,5 +4,5 @@
4
4
  * @constant
5
5
  * @type {string}
6
6
  */
7
- const VERSION = '0.14.2'
7
+ const VERSION = '0.15.1'
8
8
  export default VERSION
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capturebridge/sdk",
3
- "version": "0.14.2",
3
+ "version": "0.15.1",
4
4
  "description": "Capture Bridge JavaScript SDK for web applications",
5
5
  "type": "module",
6
6
  "types": "types.d.ts",