@jibb-open/jssdk 3.5.5 → 3.5.8

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/README.md CHANGED
@@ -1,3 +1,4 @@
1
1
  # jibb-jssdk
2
+ For SDK Documentation please visit: http://inkerz.github.io/jibb-jssdk
2
3
 
3
- please see code examples under Namespaces > Examples
4
+ also, please see code examples under Namespaces > Examples
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jibb-open/jssdk",
3
- "version": "3.5.5",
3
+ "version": "3.5.8",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "LOG_LEVEL=error mocha --timeout 10000 ",
@@ -9,10 +9,7 @@
9
9
  "watch": "watch 'npm run build' src",
10
10
  "docs": "jsdoc -r ./src/ ./README.md"
11
11
  },
12
- "repository": {
13
- "type": "git",
14
- "url": "git+https://github.com/Inkerz/jibb-jssdk.git"
15
- },
12
+ "repository": "https://github.com/Inkerz/jibb-jssdk",
16
13
  "author": "",
17
14
  "license": "ISC",
18
15
  "bugs": {
@@ -47,7 +47,7 @@ export async function getRecording(recordingId) {
47
47
  *
48
48
  * @async
49
49
  * @param {*} pagination
50
- * @returns
50
+ * @returns {}
51
51
  */
52
52
  export async function getRecordingList(pagination) {
53
53
  let headers = {
@@ -26,7 +26,7 @@ export async function getOrganizationList() {
26
26
  /**
27
27
  *
28
28
  * @param {number} orgId
29
- * @returns
29
+ * @returns {object}
30
30
  */
31
31
  export async function getOrganization(orgId) {
32
32
  if (orgId === "") {
@@ -1,5 +1,9 @@
1
1
  <!DOCTYPE html>
2
- <html>
2
+ <html lang="en">
3
+
4
+ <head>
5
+ <title>Example</title>
6
+ </head>
3
7
  <body>
4
8
 
5
9
  <h1>The script testing start session</h1>
@@ -115,20 +115,14 @@ var $root = ($protobuf.roots["default"] || ($protobuf.roots["default"] = new $pr
115
115
  go_package: "github.com/Inkerz/jibbapis/sdk/go/ipsa"
116
116
  },
117
117
  nested: {
118
- ResponseCode: {
118
+ StatusCode: {
119
119
  values: {
120
120
  SUCCESS: 0,
121
- IGNORED: 1,
122
- UNKNOWN_SESSION_TYPE: 2,
123
121
  INVALID_INPUT: 3,
124
- SESSION_TIMEOUT: 4,
125
- SESSION_CLOSING: 5,
126
122
  SESSION_BUSY: 6,
127
- CONTENT_CHANGED: 111,
128
123
  SURFACE_DETECTED: 110,
129
124
  SURFACE_NOT_DETECTED: 100,
130
125
  SURFACE_NOT_STABILIZED: 101,
131
- SURFACE_NOT_FOCUSED: 102,
132
126
  SURFACE_CHANGED: 103,
133
127
  SURFACE_TOO_LEFT: 104,
134
128
  SURFACE_TOO_RIGHT: 105,
@@ -438,29 +432,45 @@ var $root = ($protobuf.roots["default"] || ($protobuf.roots["default"] = new $pr
438
432
  }
439
433
  }
440
434
  },
441
- Response: {
435
+ Status: {
442
436
  fields: {
443
- id: {
444
- type: "int32",
437
+ corners: {
438
+ rule: "repeated",
439
+ type: "float",
445
440
  id: 1
446
441
  },
447
- response: {
442
+ codes: {
448
443
  rule: "repeated",
449
- type: "ResponseCode",
444
+ type: "StatusCode",
450
445
  id: 2
451
446
  },
452
- corners: {
453
- rule: "repeated",
454
- type: "sint32",
447
+ processingTime: {
448
+ type: "int32",
449
+ id: 3
450
+ },
451
+ upsampling: {
452
+ type: "float",
455
453
  id: 4
456
454
  },
455
+ paperDetectionConfidence: {
456
+ type: "int32",
457
+ id: 5
458
+ }
459
+ }
460
+ },
461
+ Response: {
462
+ fields: {
463
+ id: {
464
+ type: "int32",
465
+ id: 1
466
+ },
457
467
  image: {
458
468
  type: "bytes",
459
469
  id: 5
460
470
  },
461
- processingTime: {
462
- type: "uint32",
463
- id: 7
471
+ status: {
472
+ type: "Status",
473
+ id: 8
464
474
  }
465
475
  }
466
476
  }
@@ -850,22 +860,6 @@ var $root = ($protobuf.roots["default"] || ($protobuf.roots["default"] = new $pr
850
860
  }
851
861
  }
852
862
  },
853
- GetUserSettingsResponse: {
854
- fields: {
855
- content: {
856
- type: "google.protobuf.Struct",
857
- id: 1
858
- }
859
- }
860
- },
861
- SetUserSettingsRequest: {
862
- fields: {
863
- content: {
864
- type: "google.protobuf.Struct",
865
- id: 1
866
- }
867
- }
868
- },
869
863
  GetOrganizationIdRequest: {
870
864
  fields: {
871
865
  organizationName: {
@@ -1351,69 +1345,6 @@ var $root = ($protobuf.roots["default"] || ($protobuf.roots["default"] = new $pr
1351
1345
  }
1352
1346
  }
1353
1347
  },
1354
- Struct: {
1355
- fields: {
1356
- fields: {
1357
- keyType: "string",
1358
- type: "Value",
1359
- id: 1
1360
- }
1361
- }
1362
- },
1363
- Value: {
1364
- oneofs: {
1365
- kind: {
1366
- oneof: [
1367
- "nullValue",
1368
- "numberValue",
1369
- "stringValue",
1370
- "boolValue",
1371
- "structValue",
1372
- "listValue"
1373
- ]
1374
- }
1375
- },
1376
- fields: {
1377
- nullValue: {
1378
- type: "NullValue",
1379
- id: 1
1380
- },
1381
- numberValue: {
1382
- type: "double",
1383
- id: 2
1384
- },
1385
- stringValue: {
1386
- type: "string",
1387
- id: 3
1388
- },
1389
- boolValue: {
1390
- type: "bool",
1391
- id: 4
1392
- },
1393
- structValue: {
1394
- type: "Struct",
1395
- id: 5
1396
- },
1397
- listValue: {
1398
- type: "ListValue",
1399
- id: 6
1400
- }
1401
- }
1402
- },
1403
- NullValue: {
1404
- values: {
1405
- NULL_VALUE: 0
1406
- }
1407
- },
1408
- ListValue: {
1409
- fields: {
1410
- values: {
1411
- rule: "repeated",
1412
- type: "Value",
1413
- id: 1
1414
- }
1415
- }
1416
- },
1417
1348
  Empty: {
1418
1349
  fields: {}
1419
1350
  }
package/src/ws/ipsa.js CHANGED
@@ -56,9 +56,7 @@ class IPSAClass extends RetryConnection {
56
56
  this.appConfigRequest = null
57
57
  this.configRequest = null
58
58
  this.runtimeConfigRequest = null
59
- this.requestTimes = new Array(8)
60
- this.responseTimes = new Array(8)
61
- this.responseTimes.fill(1000)
59
+ this.stats = new Map();
62
60
  this.requestId = 0
63
61
  }
64
62
 
@@ -124,11 +122,13 @@ class IPSAClass extends RetryConnection {
124
122
  if (!this.isConnected() || !this.isStarted())
125
123
  return
126
124
 
127
- let wait = Math.max(500, this.getAverageResponseTime())
128
- logger.debug("Next IPSA request: ", wait)
129
- setTimeout(loopFunction, wait)
130
-
131
- this.#writeInputImage().catch(err => logger.error(err))
125
+ if (this.socket.bufferedAmount > 0) {
126
+ logger.warn("ipsa: low internet speed connection")
127
+ setTimeout(loopFunction, 100)
128
+ } else {
129
+ setTimeout(loopFunction, 500)
130
+ this.#writeInputImage().catch(err => logger.error(err))
131
+ }
132
132
  }
133
133
 
134
134
  loopFunction()
@@ -145,8 +145,19 @@ class IPSAClass extends RetryConnection {
145
145
  }
146
146
 
147
147
  getAverageResponseTime() {
148
- let sum = this.responseTimes.reduce((a, b) => {return a + b})
149
- return sum / this.responseTimes.length
148
+ let avg = NaN
149
+
150
+ try {
151
+ let items = Array.from(this.stats.values())
152
+ .map(e => (e.responseTime - e.requestTime))
153
+ .filter(e => !isNaN(e));
154
+
155
+ let sum = items.reduce((a, b) => (a + b));
156
+ avg = sum / items.length;
157
+ } catch (err) {
158
+ }
159
+
160
+ return avg;
150
161
  }
151
162
 
152
163
  async #handleMessage(msg) {
@@ -181,9 +192,11 @@ class IPSAClass extends RetryConnection {
181
192
  }
182
193
 
183
194
  #onResponse(response) {
184
- if (response.id > 100) {
195
+ if (response.id >= 100) {
185
196
  let id = response.id - 100
186
- this.responseTimes[id] = performance.now() - this.requestTimes[id]
197
+ let s = this.stats.get(id) || {}
198
+ s.responseTime = performance.now()
199
+ this.stats.set(id, s)
187
200
  }
188
201
 
189
202
  if (this.onResponse) {
@@ -193,13 +206,8 @@ class IPSAClass extends RetryConnection {
193
206
 
194
207
  async #writeInputImage() {
195
208
  let img = await this.onInputImage()
196
- this.requestId = (this.requestId + 1) % this.requestTimes.length
197
- this.requestTimes[this.requestId] = performance.now()
198
-
199
- if (this.socket.bufferedAmount > 2 * img.length) {
200
- logger.warn("ipsa: low internet speed connection")
201
- return
202
- }
209
+ this.requestId = (this.requestId + 1) % 8
210
+ this.stats.set(this.requestId, {requestTime: performance.now()})
203
211
 
204
212
  let request = ipsa.Request.create({
205
213
  id: this.requestId + 100,