jsgar 4.5.1 → 4.5.3
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/dist/gar.umd.js +23 -3
- package/gar.js +23 -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, require_existing: 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, require_existing: 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,31 @@
|
|
|
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 {boolean} [options.requireExisting=false] - Only write to existing keys; do not create new keys.
|
|
1149
|
+
* @param {number} [options.clientKeyId=0] - The g::Client key ID for ownership. 0 uses the connection key.
|
|
1150
|
+
*/
|
|
1151
|
+
updateActiveOwnership({ msgRef = 0, ownershipAction = 'None', skipOwnershipChecks = false, requireExisting = false, clientKeyId = 0 } = {}) {
|
|
1152
|
+
const newOwnership = { msg_ref: msgRef, ownership_action: ownershipAction, skip_ownership_checks: skipOwnershipChecks, require_existing: requireExisting, client_key_id: clientKeyId };
|
|
1153
|
+
const cur = this._activeOwnership;
|
|
1154
|
+
if (newOwnership.msg_ref !== cur.msg_ref || newOwnership.ownership_action !== cur.ownership_action || newOwnership.skip_ownership_checks !== cur.skip_ownership_checks || newOwnership.require_existing !== cur.require_existing || newOwnership.client_key_id !== cur.client_key_id) {
|
|
1155
|
+
this._activeOwnership = newOwnership;
|
|
1156
|
+
this.sendMessage({ message_type: 'ActiveOwnership', value: newOwnership });
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1138
1160
|
/**
|
|
1139
1161
|
* Introduce a new key if not already known and return local key ID.
|
|
1140
1162
|
* @param {string} name - Key name
|
|
1141
1163
|
* @param {string|Array<string>|null} [className=null] - Class name(s)
|
|
1142
1164
|
* @returns {number} Local key ID
|
|
1143
1165
|
*/
|
|
1144
|
-
getAndPossiblyIntroduceKeyId(name, className = null
|
|
1166
|
+
getAndPossiblyIntroduceKeyId(name, className = null) {
|
|
1145
1167
|
const existingId = this.localKeyMap.get(name);
|
|
1146
1168
|
if (existingId !== undefined && this.invalidatedKeyIds.has(existingId)) {
|
|
1147
1169
|
this.invalidatedKeyIds.delete(existingId);
|
|
@@ -1158,8 +1180,6 @@
|
|
|
1158
1180
|
value.class_list = className;
|
|
1159
1181
|
}
|
|
1160
1182
|
}
|
|
1161
|
-
if (forceWrite) value.force_write = true;
|
|
1162
|
-
if (noAcquire) value.no_acquire = true;
|
|
1163
1183
|
this.sendMessage({ message_type: 'KeyIntroduction', value });
|
|
1164
1184
|
}
|
|
1165
1185
|
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, require_existing: 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, require_existing: 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,31 @@ 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 {boolean} [options.requireExisting=false] - Only write to existing keys; do not create new keys.
|
|
1143
|
+
* @param {number} [options.clientKeyId=0] - The g::Client key ID for ownership. 0 uses the connection key.
|
|
1144
|
+
*/
|
|
1145
|
+
updateActiveOwnership({ msgRef = 0, ownershipAction = 'None', skipOwnershipChecks = false, requireExisting = false, clientKeyId = 0 } = {}) {
|
|
1146
|
+
const newOwnership = { msg_ref: msgRef, ownership_action: ownershipAction, skip_ownership_checks: skipOwnershipChecks, require_existing: requireExisting, client_key_id: clientKeyId };
|
|
1147
|
+
const cur = this._activeOwnership;
|
|
1148
|
+
if (newOwnership.msg_ref !== cur.msg_ref || newOwnership.ownership_action !== cur.ownership_action || newOwnership.skip_ownership_checks !== cur.skip_ownership_checks || newOwnership.require_existing !== cur.require_existing || newOwnership.client_key_id !== cur.client_key_id) {
|
|
1149
|
+
this._activeOwnership = newOwnership;
|
|
1150
|
+
this.sendMessage({ message_type: 'ActiveOwnership', value: newOwnership });
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1132
1154
|
/**
|
|
1133
1155
|
* Introduce a new key if not already known and return local key ID.
|
|
1134
1156
|
* @param {string} name - Key name
|
|
1135
1157
|
* @param {string|Array<string>|null} [className=null] - Class name(s)
|
|
1136
1158
|
* @returns {number} Local key ID
|
|
1137
1159
|
*/
|
|
1138
|
-
getAndPossiblyIntroduceKeyId(name, className = null
|
|
1160
|
+
getAndPossiblyIntroduceKeyId(name, className = null) {
|
|
1139
1161
|
const existingId = this.localKeyMap.get(name);
|
|
1140
1162
|
if (existingId !== undefined && this.invalidatedKeyIds.has(existingId)) {
|
|
1141
1163
|
this.invalidatedKeyIds.delete(existingId);
|
|
@@ -1152,8 +1174,6 @@ class GARClient {
|
|
|
1152
1174
|
value.class_list = className;
|
|
1153
1175
|
}
|
|
1154
1176
|
}
|
|
1155
|
-
if (forceWrite) value.force_write = true;
|
|
1156
|
-
if (noAcquire) value.no_acquire = true;
|
|
1157
1177
|
this.sendMessage({ message_type: 'KeyIntroduction', value });
|
|
1158
1178
|
}
|
|
1159
1179
|
return this.localKeyMap.get(name);
|