jsgar 4.4.0 → 4.5.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 +22 -3
  2. package/gar.js +22 -3
  3. package/package.json +1 -1
package/dist/gar.umd.js CHANGED
@@ -73,6 +73,7 @@
73
73
  this.localTopicMap = new Map();
74
74
  this.localKeyMap = new Map();
75
75
  this.recordMap = new Map();
76
+ this._activeOwnership = { msg_ref: 0, ownership_action: 'None', skip_ownership_checks: false, client_key_id: 0 };
76
77
 
77
78
  this.running = false;
78
79
  this.heartbeatIntervalId = null;
@@ -138,6 +139,9 @@
138
139
  this.localTopicMap.clear();
139
140
  this.localKeyMap.clear();
140
141
 
142
+ // Active ownership state
143
+ this._activeOwnership = { msg_ref: 0, ownership_action: 'None', skip_ownership_checks: false, client_key_id: 0 };
144
+
141
145
  // Heartbeat grace period flags
142
146
  this._initialGracePeriod = false;
143
147
  this._initialGraceDeadline = 0;
@@ -1131,13 +1135,30 @@
1131
1135
  );
1132
1136
  }
1133
1137
 
1138
+ /**
1139
+ * Send an ActiveOwnership message if the parameters differ from the last sent values.
1140
+ * @param {Object} [options]
1141
+ * @param {number} [options.msgRef=0] - Message reference for correlating recoverable error responses.
1142
+ * @param {string} [options.ownershipAction='None'] - 'None' (check only), 'Acquire', or 'Release'.
1143
+ * @param {boolean} [options.skipOwnershipChecks=false] - Bypass ownership validation.
1144
+ * @param {number} [options.clientKeyId=0] - The g::Client key ID for ownership. 0 uses the connection key.
1145
+ */
1146
+ updateActiveOwnership({ msgRef = 0, ownershipAction = 'None', skipOwnershipChecks = false, clientKeyId = 0 } = {}) {
1147
+ const newOwnership = { msg_ref: msgRef, ownership_action: ownershipAction, skip_ownership_checks: skipOwnershipChecks, client_key_id: clientKeyId };
1148
+ const cur = this._activeOwnership;
1149
+ if (newOwnership.msg_ref !== cur.msg_ref || newOwnership.ownership_action !== cur.ownership_action || newOwnership.skip_ownership_checks !== cur.skip_ownership_checks || newOwnership.client_key_id !== cur.client_key_id) {
1150
+ this._activeOwnership = newOwnership;
1151
+ this.sendMessage({ message_type: 'ActiveOwnership', value: newOwnership });
1152
+ }
1153
+ }
1154
+
1134
1155
  /**
1135
1156
  * Introduce a new key if not already known and return local key ID.
1136
1157
  * @param {string} name - Key name
1137
1158
  * @param {string|Array<string>|null} [className=null] - Class name(s)
1138
1159
  * @returns {number} Local key ID
1139
1160
  */
1140
- getAndPossiblyIntroduceKeyId(name, className = null, { forceWrite = false, noAcquire = false } = {}) {
1161
+ getAndPossiblyIntroduceKeyId(name, className = null) {
1141
1162
  if (!this.localKeyMap.has(name)) {
1142
1163
  const keyId = this.localKeyCounter++;
1143
1164
  this.localKeyMap.set(name, keyId);
@@ -1149,8 +1170,6 @@
1149
1170
  value.class_list = className;
1150
1171
  }
1151
1172
  }
1152
- if (forceWrite) value.force_write = true;
1153
- if (noAcquire) value.no_acquire = true;
1154
1173
  this.sendMessage({ message_type: 'KeyIntroduction', value });
1155
1174
  }
1156
1175
  return this.localKeyMap.get(name);
package/gar.js CHANGED
@@ -67,6 +67,7 @@ class GARClient {
67
67
  this.localTopicMap = new Map();
68
68
  this.localKeyMap = new Map();
69
69
  this.recordMap = new Map();
70
+ this._activeOwnership = { msg_ref: 0, ownership_action: 'None', skip_ownership_checks: false, client_key_id: 0 };
70
71
 
71
72
  this.running = false;
72
73
  this.heartbeatIntervalId = null;
@@ -132,6 +133,9 @@ class GARClient {
132
133
  this.localTopicMap.clear();
133
134
  this.localKeyMap.clear();
134
135
 
136
+ // Active ownership state
137
+ this._activeOwnership = { msg_ref: 0, ownership_action: 'None', skip_ownership_checks: false, client_key_id: 0 };
138
+
135
139
  // Heartbeat grace period flags
136
140
  this._initialGracePeriod = false;
137
141
  this._initialGraceDeadline = 0;
@@ -1125,13 +1129,30 @@ class GARClient {
1125
1129
  );
1126
1130
  }
1127
1131
 
1132
+ /**
1133
+ * Send an ActiveOwnership message if the parameters differ from the last sent values.
1134
+ * @param {Object} [options]
1135
+ * @param {number} [options.msgRef=0] - Message reference for correlating recoverable error responses.
1136
+ * @param {string} [options.ownershipAction='None'] - 'None' (check only), 'Acquire', or 'Release'.
1137
+ * @param {boolean} [options.skipOwnershipChecks=false] - Bypass ownership validation.
1138
+ * @param {number} [options.clientKeyId=0] - The g::Client key ID for ownership. 0 uses the connection key.
1139
+ */
1140
+ updateActiveOwnership({ msgRef = 0, ownershipAction = 'None', skipOwnershipChecks = false, clientKeyId = 0 } = {}) {
1141
+ const newOwnership = { msg_ref: msgRef, ownership_action: ownershipAction, skip_ownership_checks: skipOwnershipChecks, client_key_id: clientKeyId };
1142
+ const cur = this._activeOwnership;
1143
+ if (newOwnership.msg_ref !== cur.msg_ref || newOwnership.ownership_action !== cur.ownership_action || newOwnership.skip_ownership_checks !== cur.skip_ownership_checks || newOwnership.client_key_id !== cur.client_key_id) {
1144
+ this._activeOwnership = newOwnership;
1145
+ this.sendMessage({ message_type: 'ActiveOwnership', value: newOwnership });
1146
+ }
1147
+ }
1148
+
1128
1149
  /**
1129
1150
  * Introduce a new key if not already known and return local key ID.
1130
1151
  * @param {string} name - Key name
1131
1152
  * @param {string|Array<string>|null} [className=null] - Class name(s)
1132
1153
  * @returns {number} Local key ID
1133
1154
  */
1134
- getAndPossiblyIntroduceKeyId(name, className = null, { forceWrite = false, noAcquire = false } = {}) {
1155
+ getAndPossiblyIntroduceKeyId(name, className = null) {
1135
1156
  if (!this.localKeyMap.has(name)) {
1136
1157
  const keyId = this.localKeyCounter++;
1137
1158
  this.localKeyMap.set(name, keyId);
@@ -1143,8 +1164,6 @@ class GARClient {
1143
1164
  value.class_list = className;
1144
1165
  }
1145
1166
  }
1146
- if (forceWrite) value.force_write = true;
1147
- if (noAcquire) value.no_acquire = true;
1148
1167
  this.sendMessage({ message_type: 'KeyIntroduction', value });
1149
1168
  }
1150
1169
  return this.localKeyMap.get(name);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsgar",
3
- "version": "4.4.0",
3
+ "version": "4.5.0",
4
4
  "description": "A Javascript client for the GAR protocol",
5
5
  "type": "module",
6
6
  "main": "dist/gar.umd.js",