jsgar 4.3.1 → 4.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.
Files changed (3) hide show
  1. package/dist/gar.umd.js +9 -17
  2. package/gar.js +9 -17
  3. package/package.json +1 -1
package/dist/gar.umd.js CHANGED
@@ -35,13 +35,13 @@
35
35
  * Initialize the GAR client.
36
36
  * @param {string} wsEndpoint - WebSocket endpoint (e.g., "ws://localhost:8765")
37
37
  * @param {string} user - Client username for identification
38
- * @param {number} [heartbeatTimeoutInterval=4000] - Heartbeat interval in milliseconds
38
+ * @param {number} [heartbeatTimeoutInterval=60000] - Heartbeat interval in milliseconds
39
39
  * @param {boolean} [allowSelfSignedCertificate=false] - Allow self-signed certificates
40
40
  * @param {string} [logLevel='INFO'] - Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL)
41
41
  * @param {boolean} [uniqueKeyAndRecordUpdates=false] - Only one update per key/record
42
42
  * @param {string} [token=null] - Token for authenticated connections (appended as ?token= query param)
43
43
  */
44
- constructor(wsEndpoint, user, working_namespace = null, heartbeatTimeoutInterval = 4000, allowSelfSignedCertificate = false, logLevel = 'INFO', uniqueKeyAndRecordUpdates = false, token = null) {
44
+ constructor(wsEndpoint, user, working_namespace = null, heartbeatTimeoutInterval = 60000, allowSelfSignedCertificate = false, logLevel = 'INFO', uniqueKeyAndRecordUpdates = false, token = null) {
45
45
  this.wsEndpoint = token ? `${wsEndpoint}${wsEndpoint.includes('?') ? '&' : '?'}token=${token}` : wsEndpoint;
46
46
  this.websocket = null;
47
47
  this.messageQueue = [];
@@ -1137,29 +1137,21 @@
1137
1137
  * @param {string|Array<string>|null} [className=null] - Class name(s)
1138
1138
  * @returns {number} Local key ID
1139
1139
  */
1140
- getAndPossiblyIntroduceKeyId(name, className = null) {
1140
+ getAndPossiblyIntroduceKeyId(name, className = null, { forceWrite = false, noAcquire = false } = {}) {
1141
1141
  if (!this.localKeyMap.has(name)) {
1142
1142
  const keyId = this.localKeyCounter++;
1143
1143
  this.localKeyMap.set(name, keyId);
1144
- let classList = null;
1144
+ const value = { key_id: keyId, name };
1145
1145
  if (className) {
1146
1146
  if (typeof className === 'string') {
1147
- classList = className.split(/\s+/).filter(Boolean);
1147
+ value.class_list = className.split(/\s+/).filter(Boolean);
1148
1148
  } else if (Array.isArray(className)) {
1149
- classList = className;
1149
+ value.class_list = className;
1150
1150
  }
1151
1151
  }
1152
- const msg = {
1153
- message_type: 'KeyIntroduction',
1154
- value: {
1155
- key_id: keyId,
1156
- name
1157
- }
1158
- };
1159
- if (classList) {
1160
- msg.value.class_list = classList;
1161
- }
1162
- this.sendMessage(msg);
1152
+ if (forceWrite) value.force_write = true;
1153
+ if (noAcquire) value.no_acquire = true;
1154
+ this.sendMessage({ message_type: 'KeyIntroduction', value });
1163
1155
  }
1164
1156
  return this.localKeyMap.get(name);
1165
1157
  }
package/gar.js CHANGED
@@ -29,13 +29,13 @@ class GARClient {
29
29
  * Initialize the GAR client.
30
30
  * @param {string} wsEndpoint - WebSocket endpoint (e.g., "ws://localhost:8765")
31
31
  * @param {string} user - Client username for identification
32
- * @param {number} [heartbeatTimeoutInterval=4000] - Heartbeat interval in milliseconds
32
+ * @param {number} [heartbeatTimeoutInterval=60000] - Heartbeat interval in milliseconds
33
33
  * @param {boolean} [allowSelfSignedCertificate=false] - Allow self-signed certificates
34
34
  * @param {string} [logLevel='INFO'] - Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL)
35
35
  * @param {boolean} [uniqueKeyAndRecordUpdates=false] - Only one update per key/record
36
36
  * @param {string} [token=null] - Token for authenticated connections (appended as ?token= query param)
37
37
  */
38
- constructor(wsEndpoint, user, working_namespace = null, heartbeatTimeoutInterval = 4000, allowSelfSignedCertificate = false, logLevel = 'INFO', uniqueKeyAndRecordUpdates = false, token = null) {
38
+ constructor(wsEndpoint, user, working_namespace = null, heartbeatTimeoutInterval = 60000, allowSelfSignedCertificate = false, logLevel = 'INFO', uniqueKeyAndRecordUpdates = false, token = null) {
39
39
  this.wsEndpoint = token ? `${wsEndpoint}${wsEndpoint.includes('?') ? '&' : '?'}token=${token}` : wsEndpoint;
40
40
  this.websocket = null;
41
41
  this.messageQueue = [];
@@ -1131,29 +1131,21 @@ class GARClient {
1131
1131
  * @param {string|Array<string>|null} [className=null] - Class name(s)
1132
1132
  * @returns {number} Local key ID
1133
1133
  */
1134
- getAndPossiblyIntroduceKeyId(name, className = null) {
1134
+ getAndPossiblyIntroduceKeyId(name, className = null, { forceWrite = false, noAcquire = false } = {}) {
1135
1135
  if (!this.localKeyMap.has(name)) {
1136
1136
  const keyId = this.localKeyCounter++;
1137
1137
  this.localKeyMap.set(name, keyId);
1138
- let classList = null;
1138
+ const value = { key_id: keyId, name };
1139
1139
  if (className) {
1140
1140
  if (typeof className === 'string') {
1141
- classList = className.split(/\s+/).filter(Boolean);
1141
+ value.class_list = className.split(/\s+/).filter(Boolean);
1142
1142
  } else if (Array.isArray(className)) {
1143
- classList = className;
1143
+ value.class_list = className;
1144
1144
  }
1145
1145
  }
1146
- const msg = {
1147
- message_type: 'KeyIntroduction',
1148
- value: {
1149
- key_id: keyId,
1150
- name
1151
- }
1152
- };
1153
- if (classList) {
1154
- msg.value.class_list = classList;
1155
- }
1156
- this.sendMessage(msg);
1146
+ if (forceWrite) value.force_write = true;
1147
+ if (noAcquire) value.no_acquire = true;
1148
+ this.sendMessage({ message_type: 'KeyIntroduction', value });
1157
1149
  }
1158
1150
  return this.localKeyMap.get(name);
1159
1151
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsgar",
3
- "version": "4.3.1",
3
+ "version": "4.4.0",
4
4
  "description": "A Javascript client for the GAR protocol",
5
5
  "type": "module",
6
6
  "main": "dist/gar.umd.js",