jsgar 4.5.1 → 4.5.2

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