rticonnextdds-connector 1.3.1 → 1.4.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rticonnextdds-connector",
3
- "version": "1.3.1",
3
+ "version": "1.4.0",
4
4
  "description": "RTI Connector for JavaScript",
5
5
  "main": "rticonnextdds-connector.js",
6
6
  "files": [
@@ -42,5 +42,6 @@
42
42
  "mocha": "^10.2.0",
43
43
  "mocha-junit-reporter": "^2.2.0",
44
44
  "sinon": "^10.0.0"
45
- }
45
+ },
46
+ "rti.build-id": "BUILD_7.6.0.0_20250918T000000Z_RTI_REL"
46
47
  }
@@ -33,26 +33,20 @@ class _ConnectorBinding {
33
33
  if (os.platform() === 'linux') {
34
34
  libDir = 'linux-arm64'
35
35
  libName = 'librtiddsconnector.so'
36
+ } else if (os.platform() === 'darwin') {
37
+ libDir = 'osx-arm64'
38
+ libName = 'librtiddsconnector.dylib'
36
39
  } else {
37
40
  throw new Error('This platform (' + os.platform() + ' ' + os.arch() + ') is not supported')
38
41
  }
39
42
  } else if (os.arch() === 'arm') {
40
- if (os.platform() === 'linux') {
41
- libDir = 'linux-arm'
42
- libName = 'librtiddsconnector.so'
43
- } else {
44
- throw new Error('This platform (' + os.platform() + ' ' + os.arch() + ') is not supported')
45
- }
43
+ throw new Error('This platform (' + os.platform() + ' ' + os.arch() + ') is not supported')
46
44
  } else {
47
45
  // Note that we are intentionally not checking if os.arch() is x64.
48
46
  // This allows somebody with access to 32-bit libraries to replace them
49
47
  // in the corresponding x64 directory and we will try to load them.
50
48
  // This behaviour is not officially supported.
51
49
  switch (os.platform()) {
52
- case 'darwin':
53
- libDir = 'osx-x64'
54
- libName = 'librtiddsconnector.dylib'
55
- break
56
50
  case 'linux':
57
51
  libDir = 'linux-x64'
58
52
  libName = 'librtiddsconnector.so'
@@ -99,6 +93,7 @@ class _ConnectorBinding {
99
93
  this.RTI_Connector_wait_for_acknowledgments = this.api.func('RTI_Connector_wait_for_acknowledgments', 'int', ['RTI_HANDLE', 'int']);
100
94
  this.RTI_Connector_read = this.api.func('RTI_Connector_read', 'int', ['RTI_HANDLE', 'string']);
101
95
  this.RTI_Connector_take = this.api.func('RTI_Connector_take', 'int', ['RTI_HANDLE', 'string']);
96
+ this.RTI_Connector_return_loan = this.api.func('RTI_Connector_return_loan', 'int', ['RTI_HANDLE', 'string']);
102
97
  this.RTI_Connector_wait_for_data = this.api.func('RTI_Connector_wait_for_data', 'int', ['RTI_HANDLE', 'int']);
103
98
  this.RTI_Connector_wait_for_data_on_reader = this.api.func('RTI_Connector_wait_for_data_on_reader', 'int', ['RTI_HANDLE', 'int']);
104
99
  this.RTI_Connector_wait_for_matched_publication = this.api.func('RTI_Connector_wait_for_matched_publication', 'int', ['RTI_HANDLE', 'int', koffi.out(koffi.pointer('int'))]);
@@ -245,6 +240,14 @@ function _isNumber (value) {
245
240
  return typeof value === 'number' && isFinite(value)
246
241
  }
247
242
 
243
+ /**
244
+ * Checks if a value is an object
245
+ * @param {any} value - The value to check the type of
246
+ */
247
+ function _isObject (value) {
248
+ return typeof value === 'object' && value !== null
249
+ }
250
+
248
251
  /**
249
252
  * Function used to get any value from either the samples or infos (depending
250
253
  * on the supplied getter). The type of the fieldName need not be specified.
@@ -1160,31 +1163,58 @@ class Input {
1160
1163
  return JSON.parse(str[0])
1161
1164
  }
1162
1165
 
1166
+ /**
1167
+ * Returns any samples held by this Input
1168
+ *
1169
+ * After calling this method, the samples are no longer accessible from :meth:`Input.samples`.
1170
+ */
1171
+ returnSamples () {
1172
+ _checkRetcode(connectorBinding.RTI_Connector_return_loan(
1173
+ this.connector.native,
1174
+ this.name))
1175
+ }
1176
+
1163
1177
  /**
1164
1178
  * Wait for this Input to receive data.
1165
1179
  *
1166
1180
  * .. note::
1167
1181
  * This operation is asynchronous.
1168
1182
  *
1169
- * @param {number} [timeout] The maximum time to wait, in milliseconds.
1183
+ * .. note::
1184
+ * If no object is provided as the first parameter and for backwards compatibility,
1185
+ * the arguments are interpreted sequentially as defined in the documentation.
1186
+ *
1187
+ * @param {Object} [options] Options for the wait operation.
1188
+ * @param {number} [options.timeout] The maximum time to wait, in milliseconds.
1170
1189
  * By default, infinite.
1190
+ * @param {boolean} [options.returnSamples] Whether to return samples before waiting.
1191
+ * By default ``True``. Set it to ``False`` for backwards compatibility.
1171
1192
  * @throws {TimeoutError} :class:`TimeoutError` will be thrown if the
1172
1193
  * timeout expires before data is received.
1173
1194
  * @returns {Promise} A ``Promise`` which will be resolved once data is
1174
1195
  * available, or rejected if the timeout expires.
1175
1196
  */
1176
- wait (timeout) {
1197
+ wait({ timeout, returnSamples } = {}) {
1177
1198
  return new Promise((resolve, reject) => {
1178
- // timeout is defaulted to -1 (infinite) if not supplied
1179
- if (timeout === undefined) {
1180
- timeout = -1
1181
- } else if (!_isNumber(timeout)) {
1199
+ /* if the first parameter was not an object, parse it */
1200
+ if (!_isObject(arguments[0])) {
1201
+ [ timeout, returnSamples ] = arguments
1202
+ }
1203
+
1204
+ /* Assign defaults */
1205
+ timeout ??= -1
1206
+ returnSamples ??= true
1207
+
1208
+ if (!_isNumber(timeout)) {
1182
1209
  throw new TypeError('timeout must be a number')
1183
1210
  }
1184
1211
  if (this.waitSetBusy) {
1185
1212
  throw new Error('Can not concurrently wait on the same Input')
1186
1213
  } else {
1187
1214
  this.waitSetBusy = true
1215
+ if (returnSamples) {
1216
+ this.returnSamples()
1217
+ }
1188
1218
  connectorBinding.RTI_Connector_wait_for_data_on_reader.async(
1189
1219
  this.native,
1190
1220
  timeout,