@naylence/runtime 0.3.5-test.965 → 0.3.5-test.966
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/browser/index.cjs +2 -175
- package/dist/browser/index.mjs +2 -175
- package/dist/cjs/naylence/fame/connector/broadcast-channel-connector.browser.js +0 -173
- package/dist/cjs/version.js +2 -2
- package/dist/esm/naylence/fame/connector/broadcast-channel-connector.browser.js +0 -173
- package/dist/esm/version.js +2 -2
- package/dist/node/index.cjs +2 -175
- package/dist/node/index.mjs +2 -175
- package/dist/node/node.cjs +2 -175
- package/dist/node/node.mjs +2 -175
- package/dist/types/naylence/fame/connector/broadcast-channel-connector.browser.d.ts +0 -12
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
package/dist/browser/index.cjs
CHANGED
|
@@ -98,12 +98,12 @@ installProcessEnvShim();
|
|
|
98
98
|
// --- END ENV SHIM ---
|
|
99
99
|
|
|
100
100
|
// This file is auto-generated during build - do not edit manually
|
|
101
|
-
// Generated from package.json version: 0.3.5-test.
|
|
101
|
+
// Generated from package.json version: 0.3.5-test.966
|
|
102
102
|
/**
|
|
103
103
|
* The package version, injected at build time.
|
|
104
104
|
* @internal
|
|
105
105
|
*/
|
|
106
|
-
const VERSION = '0.3.5-test.
|
|
106
|
+
const VERSION = '0.3.5-test.966';
|
|
107
107
|
|
|
108
108
|
/**
|
|
109
109
|
* Fame protocol specific error classes with WebSocket close codes and proper inheritance.
|
|
@@ -9970,11 +9970,6 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
9970
9970
|
ensureBroadcastEnvironment();
|
|
9971
9971
|
super(baseConfig);
|
|
9972
9972
|
this.listenerRegistered = false;
|
|
9973
|
-
this.seenAckKeys = new Map();
|
|
9974
|
-
this.seenAckOrder = [];
|
|
9975
|
-
this.ackDedupTtlMs = 30000;
|
|
9976
|
-
this.ackDedupMaxEntries = 4096;
|
|
9977
|
-
this.textDecoder = new TextDecoder();
|
|
9978
9973
|
this.visibilityChangeListenerRegistered = false;
|
|
9979
9974
|
this.channelName =
|
|
9980
9975
|
typeof config.channelName === 'string' && config.channelName.trim().length > 0
|
|
@@ -10066,9 +10061,6 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10066
10061
|
connector_id: this.connectorId,
|
|
10067
10062
|
payload_length: payload.byteLength,
|
|
10068
10063
|
});
|
|
10069
|
-
if (this._shouldSkipDuplicateAck(senderNodeId, payload)) {
|
|
10070
|
-
return;
|
|
10071
|
-
}
|
|
10072
10064
|
try {
|
|
10073
10065
|
if (typeof this.inbox.tryEnqueue === 'function') {
|
|
10074
10066
|
const accepted = this.inbox.tryEnqueue(payload);
|
|
@@ -10172,9 +10164,6 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10172
10164
|
}
|
|
10173
10165
|
async pushToReceive(rawOrEnvelope) {
|
|
10174
10166
|
const item = this._normalizeInboxItem(rawOrEnvelope);
|
|
10175
|
-
if (this._shouldSkipDuplicateAckFromInboxItem(item)) {
|
|
10176
|
-
return;
|
|
10177
|
-
}
|
|
10178
10167
|
try {
|
|
10179
10168
|
if (typeof this.inbox.tryEnqueue === 'function') {
|
|
10180
10169
|
const accepted = this.inbox.tryEnqueue(item);
|
|
@@ -10274,8 +10263,6 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10274
10263
|
const closeReason = typeof reason === 'string' && reason.length > 0 ? reason : 'closed';
|
|
10275
10264
|
const shutdownError = new FameTransportClose(closeReason, closeCode);
|
|
10276
10265
|
this.inbox.drain(shutdownError);
|
|
10277
|
-
this.seenAckKeys.clear();
|
|
10278
|
-
this.seenAckOrder.length = 0;
|
|
10279
10266
|
}
|
|
10280
10267
|
_normalizeInboxItem(rawOrEnvelope) {
|
|
10281
10268
|
if (rawOrEnvelope instanceof Uint8Array) {
|
|
@@ -10352,125 +10339,6 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10352
10339
|
...extra,
|
|
10353
10340
|
});
|
|
10354
10341
|
}
|
|
10355
|
-
_shouldSkipDuplicateAck(senderId, payload) {
|
|
10356
|
-
const dedupKey = this._extractAckDedupKey(payload);
|
|
10357
|
-
if (!dedupKey) {
|
|
10358
|
-
return false;
|
|
10359
|
-
}
|
|
10360
|
-
const normalizedSenderId = typeof senderId === 'string' && senderId.length > 0
|
|
10361
|
-
? senderId
|
|
10362
|
-
: undefined;
|
|
10363
|
-
if (normalizedSenderId && normalizedSenderId !== this.localNodeId) {
|
|
10364
|
-
logger$_.debug('broadcast_channel_duplicate_ack_bypass_non_self', {
|
|
10365
|
-
channel: this.channelName,
|
|
10366
|
-
connector_id: this.connectorId,
|
|
10367
|
-
sender_id: normalizedSenderId,
|
|
10368
|
-
dedup_key: dedupKey,
|
|
10369
|
-
source: 'listener',
|
|
10370
|
-
});
|
|
10371
|
-
return false;
|
|
10372
|
-
}
|
|
10373
|
-
logger$_.debug('broadcast_channel_duplicate_ack_check', {
|
|
10374
|
-
channel: this.channelName,
|
|
10375
|
-
connector_id: this.connectorId,
|
|
10376
|
-
sender_id: normalizedSenderId ?? null,
|
|
10377
|
-
dedup_key: dedupKey,
|
|
10378
|
-
source: 'listener',
|
|
10379
|
-
cache_entries: this.seenAckKeys.size,
|
|
10380
|
-
});
|
|
10381
|
-
return this._checkDuplicateAck(dedupKey, normalizedSenderId);
|
|
10382
|
-
}
|
|
10383
|
-
_shouldSkipDuplicateAckFromInboxItem(item) {
|
|
10384
|
-
if (item instanceof Uint8Array) {
|
|
10385
|
-
return this._shouldSkipDuplicateAck(undefined, item);
|
|
10386
|
-
}
|
|
10387
|
-
const envelope = this._extractEnvelopeFromInboxItem(item);
|
|
10388
|
-
if (!envelope) {
|
|
10389
|
-
return false;
|
|
10390
|
-
}
|
|
10391
|
-
const frame = envelope.frame;
|
|
10392
|
-
if (!frame || frame.type !== 'DeliveryAck') {
|
|
10393
|
-
return false;
|
|
10394
|
-
}
|
|
10395
|
-
const refId = typeof frame.refId === 'string' && frame.refId.length > 0
|
|
10396
|
-
? frame.refId
|
|
10397
|
-
: null;
|
|
10398
|
-
const dedupKey = refId ?? envelope.id ?? null;
|
|
10399
|
-
if (!dedupKey) {
|
|
10400
|
-
return false;
|
|
10401
|
-
}
|
|
10402
|
-
const senderId = this._extractSenderIdFromInboxItem(item);
|
|
10403
|
-
if (senderId && senderId !== this.localNodeId) {
|
|
10404
|
-
logger$_.debug('broadcast_channel_duplicate_ack_bypass_non_self', {
|
|
10405
|
-
channel: this.channelName,
|
|
10406
|
-
connector_id: this.connectorId,
|
|
10407
|
-
sender_id: senderId,
|
|
10408
|
-
dedup_key: dedupKey,
|
|
10409
|
-
source: 'inbox_item',
|
|
10410
|
-
});
|
|
10411
|
-
return false;
|
|
10412
|
-
}
|
|
10413
|
-
logger$_.debug('broadcast_channel_duplicate_ack_check', {
|
|
10414
|
-
channel: this.channelName,
|
|
10415
|
-
connector_id: this.connectorId,
|
|
10416
|
-
sender_id: senderId ?? null,
|
|
10417
|
-
dedup_key: dedupKey,
|
|
10418
|
-
source: 'inbox_item',
|
|
10419
|
-
cache_entries: this.seenAckKeys.size,
|
|
10420
|
-
});
|
|
10421
|
-
return this._checkDuplicateAck(dedupKey, senderId);
|
|
10422
|
-
}
|
|
10423
|
-
_checkDuplicateAck(dedupKey, senderId) {
|
|
10424
|
-
const now = Date.now();
|
|
10425
|
-
const lastSeen = this.seenAckKeys.get(dedupKey);
|
|
10426
|
-
if (lastSeen && now - lastSeen < this.ackDedupTtlMs) {
|
|
10427
|
-
logger$_.debug('broadcast_channel_duplicate_ack_suppressed', {
|
|
10428
|
-
channel: this.channelName,
|
|
10429
|
-
connector_id: this.connectorId,
|
|
10430
|
-
sender_id: senderId ?? null,
|
|
10431
|
-
dedup_key: dedupKey,
|
|
10432
|
-
age_ms: now - lastSeen,
|
|
10433
|
-
ttl_ms: this.ackDedupTtlMs,
|
|
10434
|
-
cache_entries: this.seenAckKeys.size,
|
|
10435
|
-
});
|
|
10436
|
-
return true;
|
|
10437
|
-
}
|
|
10438
|
-
this.seenAckKeys.set(dedupKey, now);
|
|
10439
|
-
this.seenAckOrder.push(dedupKey);
|
|
10440
|
-
logger$_.debug('broadcast_channel_duplicate_ack_recorded', {
|
|
10441
|
-
channel: this.channelName,
|
|
10442
|
-
connector_id: this.connectorId,
|
|
10443
|
-
sender_id: senderId ?? null,
|
|
10444
|
-
dedup_key: dedupKey,
|
|
10445
|
-
cache_entries: this.seenAckKeys.size,
|
|
10446
|
-
});
|
|
10447
|
-
this._trimSeenAcks(now);
|
|
10448
|
-
return false;
|
|
10449
|
-
}
|
|
10450
|
-
_extractEnvelopeFromInboxItem(item) {
|
|
10451
|
-
if (!item || typeof item !== 'object') {
|
|
10452
|
-
return null;
|
|
10453
|
-
}
|
|
10454
|
-
if ('envelope' in item) {
|
|
10455
|
-
return item.envelope;
|
|
10456
|
-
}
|
|
10457
|
-
if ('frame' in item) {
|
|
10458
|
-
return item;
|
|
10459
|
-
}
|
|
10460
|
-
return null;
|
|
10461
|
-
}
|
|
10462
|
-
_extractSenderIdFromInboxItem(item) {
|
|
10463
|
-
if (!item || typeof item !== 'object') {
|
|
10464
|
-
return undefined;
|
|
10465
|
-
}
|
|
10466
|
-
if ('context' in item) {
|
|
10467
|
-
const context = item.context;
|
|
10468
|
-
if (context && typeof context.fromSystemId === 'string') {
|
|
10469
|
-
return context.fromSystemId;
|
|
10470
|
-
}
|
|
10471
|
-
}
|
|
10472
|
-
return undefined;
|
|
10473
|
-
}
|
|
10474
10342
|
/**
|
|
10475
10343
|
* Override start() to check initial visibility state
|
|
10476
10344
|
*/
|
|
@@ -10524,47 +10392,6 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10524
10392
|
target_mode: 'wildcard',
|
|
10525
10393
|
});
|
|
10526
10394
|
}
|
|
10527
|
-
_trimSeenAcks(now) {
|
|
10528
|
-
while (this.seenAckOrder.length > 0) {
|
|
10529
|
-
const candidate = this.seenAckOrder[0];
|
|
10530
|
-
const timestamp = this.seenAckKeys.get(candidate);
|
|
10531
|
-
if (timestamp === undefined) {
|
|
10532
|
-
this.seenAckOrder.shift();
|
|
10533
|
-
continue;
|
|
10534
|
-
}
|
|
10535
|
-
if (this.seenAckKeys.size > this.ackDedupMaxEntries ||
|
|
10536
|
-
now - timestamp > this.ackDedupTtlMs) {
|
|
10537
|
-
this.seenAckKeys.delete(candidate);
|
|
10538
|
-
this.seenAckOrder.shift();
|
|
10539
|
-
continue;
|
|
10540
|
-
}
|
|
10541
|
-
break;
|
|
10542
|
-
}
|
|
10543
|
-
}
|
|
10544
|
-
_extractAckDedupKey(payload) {
|
|
10545
|
-
try {
|
|
10546
|
-
const decoded = this.textDecoder.decode(payload);
|
|
10547
|
-
const parsed = JSON.parse(decoded);
|
|
10548
|
-
const envelopeId = typeof parsed?.id === 'string' ? parsed.id : null;
|
|
10549
|
-
const frameType = parsed?.frame?.type;
|
|
10550
|
-
if (typeof frameType !== 'string' || frameType !== 'DeliveryAck') {
|
|
10551
|
-
return null;
|
|
10552
|
-
}
|
|
10553
|
-
const refId = parsed.frame?.refId;
|
|
10554
|
-
if (typeof refId === 'string' && refId.length > 0) {
|
|
10555
|
-
return refId;
|
|
10556
|
-
}
|
|
10557
|
-
return envelopeId;
|
|
10558
|
-
}
|
|
10559
|
-
catch (error) {
|
|
10560
|
-
logger$_.debug('broadcast_channel_ack_dedup_parse_failed', {
|
|
10561
|
-
channel: this.channelName,
|
|
10562
|
-
connector_id: this.connectorId,
|
|
10563
|
-
error: error instanceof Error ? error.message : String(error),
|
|
10564
|
-
});
|
|
10565
|
-
return null;
|
|
10566
|
-
}
|
|
10567
|
-
}
|
|
10568
10395
|
};
|
|
10569
10396
|
|
|
10570
10397
|
const ERROR_MESSAGE = 'BroadcastChannelConnector is browser-only and requires BroadcastChannel support';
|
package/dist/browser/index.mjs
CHANGED
|
@@ -96,12 +96,12 @@ installProcessEnvShim();
|
|
|
96
96
|
// --- END ENV SHIM ---
|
|
97
97
|
|
|
98
98
|
// This file is auto-generated during build - do not edit manually
|
|
99
|
-
// Generated from package.json version: 0.3.5-test.
|
|
99
|
+
// Generated from package.json version: 0.3.5-test.966
|
|
100
100
|
/**
|
|
101
101
|
* The package version, injected at build time.
|
|
102
102
|
* @internal
|
|
103
103
|
*/
|
|
104
|
-
const VERSION = '0.3.5-test.
|
|
104
|
+
const VERSION = '0.3.5-test.966';
|
|
105
105
|
|
|
106
106
|
/**
|
|
107
107
|
* Fame protocol specific error classes with WebSocket close codes and proper inheritance.
|
|
@@ -9968,11 +9968,6 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
9968
9968
|
ensureBroadcastEnvironment();
|
|
9969
9969
|
super(baseConfig);
|
|
9970
9970
|
this.listenerRegistered = false;
|
|
9971
|
-
this.seenAckKeys = new Map();
|
|
9972
|
-
this.seenAckOrder = [];
|
|
9973
|
-
this.ackDedupTtlMs = 30000;
|
|
9974
|
-
this.ackDedupMaxEntries = 4096;
|
|
9975
|
-
this.textDecoder = new TextDecoder();
|
|
9976
9971
|
this.visibilityChangeListenerRegistered = false;
|
|
9977
9972
|
this.channelName =
|
|
9978
9973
|
typeof config.channelName === 'string' && config.channelName.trim().length > 0
|
|
@@ -10064,9 +10059,6 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10064
10059
|
connector_id: this.connectorId,
|
|
10065
10060
|
payload_length: payload.byteLength,
|
|
10066
10061
|
});
|
|
10067
|
-
if (this._shouldSkipDuplicateAck(senderNodeId, payload)) {
|
|
10068
|
-
return;
|
|
10069
|
-
}
|
|
10070
10062
|
try {
|
|
10071
10063
|
if (typeof this.inbox.tryEnqueue === 'function') {
|
|
10072
10064
|
const accepted = this.inbox.tryEnqueue(payload);
|
|
@@ -10170,9 +10162,6 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10170
10162
|
}
|
|
10171
10163
|
async pushToReceive(rawOrEnvelope) {
|
|
10172
10164
|
const item = this._normalizeInboxItem(rawOrEnvelope);
|
|
10173
|
-
if (this._shouldSkipDuplicateAckFromInboxItem(item)) {
|
|
10174
|
-
return;
|
|
10175
|
-
}
|
|
10176
10165
|
try {
|
|
10177
10166
|
if (typeof this.inbox.tryEnqueue === 'function') {
|
|
10178
10167
|
const accepted = this.inbox.tryEnqueue(item);
|
|
@@ -10272,8 +10261,6 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10272
10261
|
const closeReason = typeof reason === 'string' && reason.length > 0 ? reason : 'closed';
|
|
10273
10262
|
const shutdownError = new FameTransportClose(closeReason, closeCode);
|
|
10274
10263
|
this.inbox.drain(shutdownError);
|
|
10275
|
-
this.seenAckKeys.clear();
|
|
10276
|
-
this.seenAckOrder.length = 0;
|
|
10277
10264
|
}
|
|
10278
10265
|
_normalizeInboxItem(rawOrEnvelope) {
|
|
10279
10266
|
if (rawOrEnvelope instanceof Uint8Array) {
|
|
@@ -10350,125 +10337,6 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10350
10337
|
...extra,
|
|
10351
10338
|
});
|
|
10352
10339
|
}
|
|
10353
|
-
_shouldSkipDuplicateAck(senderId, payload) {
|
|
10354
|
-
const dedupKey = this._extractAckDedupKey(payload);
|
|
10355
|
-
if (!dedupKey) {
|
|
10356
|
-
return false;
|
|
10357
|
-
}
|
|
10358
|
-
const normalizedSenderId = typeof senderId === 'string' && senderId.length > 0
|
|
10359
|
-
? senderId
|
|
10360
|
-
: undefined;
|
|
10361
|
-
if (normalizedSenderId && normalizedSenderId !== this.localNodeId) {
|
|
10362
|
-
logger$_.debug('broadcast_channel_duplicate_ack_bypass_non_self', {
|
|
10363
|
-
channel: this.channelName,
|
|
10364
|
-
connector_id: this.connectorId,
|
|
10365
|
-
sender_id: normalizedSenderId,
|
|
10366
|
-
dedup_key: dedupKey,
|
|
10367
|
-
source: 'listener',
|
|
10368
|
-
});
|
|
10369
|
-
return false;
|
|
10370
|
-
}
|
|
10371
|
-
logger$_.debug('broadcast_channel_duplicate_ack_check', {
|
|
10372
|
-
channel: this.channelName,
|
|
10373
|
-
connector_id: this.connectorId,
|
|
10374
|
-
sender_id: normalizedSenderId ?? null,
|
|
10375
|
-
dedup_key: dedupKey,
|
|
10376
|
-
source: 'listener',
|
|
10377
|
-
cache_entries: this.seenAckKeys.size,
|
|
10378
|
-
});
|
|
10379
|
-
return this._checkDuplicateAck(dedupKey, normalizedSenderId);
|
|
10380
|
-
}
|
|
10381
|
-
_shouldSkipDuplicateAckFromInboxItem(item) {
|
|
10382
|
-
if (item instanceof Uint8Array) {
|
|
10383
|
-
return this._shouldSkipDuplicateAck(undefined, item);
|
|
10384
|
-
}
|
|
10385
|
-
const envelope = this._extractEnvelopeFromInboxItem(item);
|
|
10386
|
-
if (!envelope) {
|
|
10387
|
-
return false;
|
|
10388
|
-
}
|
|
10389
|
-
const frame = envelope.frame;
|
|
10390
|
-
if (!frame || frame.type !== 'DeliveryAck') {
|
|
10391
|
-
return false;
|
|
10392
|
-
}
|
|
10393
|
-
const refId = typeof frame.refId === 'string' && frame.refId.length > 0
|
|
10394
|
-
? frame.refId
|
|
10395
|
-
: null;
|
|
10396
|
-
const dedupKey = refId ?? envelope.id ?? null;
|
|
10397
|
-
if (!dedupKey) {
|
|
10398
|
-
return false;
|
|
10399
|
-
}
|
|
10400
|
-
const senderId = this._extractSenderIdFromInboxItem(item);
|
|
10401
|
-
if (senderId && senderId !== this.localNodeId) {
|
|
10402
|
-
logger$_.debug('broadcast_channel_duplicate_ack_bypass_non_self', {
|
|
10403
|
-
channel: this.channelName,
|
|
10404
|
-
connector_id: this.connectorId,
|
|
10405
|
-
sender_id: senderId,
|
|
10406
|
-
dedup_key: dedupKey,
|
|
10407
|
-
source: 'inbox_item',
|
|
10408
|
-
});
|
|
10409
|
-
return false;
|
|
10410
|
-
}
|
|
10411
|
-
logger$_.debug('broadcast_channel_duplicate_ack_check', {
|
|
10412
|
-
channel: this.channelName,
|
|
10413
|
-
connector_id: this.connectorId,
|
|
10414
|
-
sender_id: senderId ?? null,
|
|
10415
|
-
dedup_key: dedupKey,
|
|
10416
|
-
source: 'inbox_item',
|
|
10417
|
-
cache_entries: this.seenAckKeys.size,
|
|
10418
|
-
});
|
|
10419
|
-
return this._checkDuplicateAck(dedupKey, senderId);
|
|
10420
|
-
}
|
|
10421
|
-
_checkDuplicateAck(dedupKey, senderId) {
|
|
10422
|
-
const now = Date.now();
|
|
10423
|
-
const lastSeen = this.seenAckKeys.get(dedupKey);
|
|
10424
|
-
if (lastSeen && now - lastSeen < this.ackDedupTtlMs) {
|
|
10425
|
-
logger$_.debug('broadcast_channel_duplicate_ack_suppressed', {
|
|
10426
|
-
channel: this.channelName,
|
|
10427
|
-
connector_id: this.connectorId,
|
|
10428
|
-
sender_id: senderId ?? null,
|
|
10429
|
-
dedup_key: dedupKey,
|
|
10430
|
-
age_ms: now - lastSeen,
|
|
10431
|
-
ttl_ms: this.ackDedupTtlMs,
|
|
10432
|
-
cache_entries: this.seenAckKeys.size,
|
|
10433
|
-
});
|
|
10434
|
-
return true;
|
|
10435
|
-
}
|
|
10436
|
-
this.seenAckKeys.set(dedupKey, now);
|
|
10437
|
-
this.seenAckOrder.push(dedupKey);
|
|
10438
|
-
logger$_.debug('broadcast_channel_duplicate_ack_recorded', {
|
|
10439
|
-
channel: this.channelName,
|
|
10440
|
-
connector_id: this.connectorId,
|
|
10441
|
-
sender_id: senderId ?? null,
|
|
10442
|
-
dedup_key: dedupKey,
|
|
10443
|
-
cache_entries: this.seenAckKeys.size,
|
|
10444
|
-
});
|
|
10445
|
-
this._trimSeenAcks(now);
|
|
10446
|
-
return false;
|
|
10447
|
-
}
|
|
10448
|
-
_extractEnvelopeFromInboxItem(item) {
|
|
10449
|
-
if (!item || typeof item !== 'object') {
|
|
10450
|
-
return null;
|
|
10451
|
-
}
|
|
10452
|
-
if ('envelope' in item) {
|
|
10453
|
-
return item.envelope;
|
|
10454
|
-
}
|
|
10455
|
-
if ('frame' in item) {
|
|
10456
|
-
return item;
|
|
10457
|
-
}
|
|
10458
|
-
return null;
|
|
10459
|
-
}
|
|
10460
|
-
_extractSenderIdFromInboxItem(item) {
|
|
10461
|
-
if (!item || typeof item !== 'object') {
|
|
10462
|
-
return undefined;
|
|
10463
|
-
}
|
|
10464
|
-
if ('context' in item) {
|
|
10465
|
-
const context = item.context;
|
|
10466
|
-
if (context && typeof context.fromSystemId === 'string') {
|
|
10467
|
-
return context.fromSystemId;
|
|
10468
|
-
}
|
|
10469
|
-
}
|
|
10470
|
-
return undefined;
|
|
10471
|
-
}
|
|
10472
10340
|
/**
|
|
10473
10341
|
* Override start() to check initial visibility state
|
|
10474
10342
|
*/
|
|
@@ -10522,47 +10390,6 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10522
10390
|
target_mode: 'wildcard',
|
|
10523
10391
|
});
|
|
10524
10392
|
}
|
|
10525
|
-
_trimSeenAcks(now) {
|
|
10526
|
-
while (this.seenAckOrder.length > 0) {
|
|
10527
|
-
const candidate = this.seenAckOrder[0];
|
|
10528
|
-
const timestamp = this.seenAckKeys.get(candidate);
|
|
10529
|
-
if (timestamp === undefined) {
|
|
10530
|
-
this.seenAckOrder.shift();
|
|
10531
|
-
continue;
|
|
10532
|
-
}
|
|
10533
|
-
if (this.seenAckKeys.size > this.ackDedupMaxEntries ||
|
|
10534
|
-
now - timestamp > this.ackDedupTtlMs) {
|
|
10535
|
-
this.seenAckKeys.delete(candidate);
|
|
10536
|
-
this.seenAckOrder.shift();
|
|
10537
|
-
continue;
|
|
10538
|
-
}
|
|
10539
|
-
break;
|
|
10540
|
-
}
|
|
10541
|
-
}
|
|
10542
|
-
_extractAckDedupKey(payload) {
|
|
10543
|
-
try {
|
|
10544
|
-
const decoded = this.textDecoder.decode(payload);
|
|
10545
|
-
const parsed = JSON.parse(decoded);
|
|
10546
|
-
const envelopeId = typeof parsed?.id === 'string' ? parsed.id : null;
|
|
10547
|
-
const frameType = parsed?.frame?.type;
|
|
10548
|
-
if (typeof frameType !== 'string' || frameType !== 'DeliveryAck') {
|
|
10549
|
-
return null;
|
|
10550
|
-
}
|
|
10551
|
-
const refId = parsed.frame?.refId;
|
|
10552
|
-
if (typeof refId === 'string' && refId.length > 0) {
|
|
10553
|
-
return refId;
|
|
10554
|
-
}
|
|
10555
|
-
return envelopeId;
|
|
10556
|
-
}
|
|
10557
|
-
catch (error) {
|
|
10558
|
-
logger$_.debug('broadcast_channel_ack_dedup_parse_failed', {
|
|
10559
|
-
channel: this.channelName,
|
|
10560
|
-
connector_id: this.connectorId,
|
|
10561
|
-
error: error instanceof Error ? error.message : String(error),
|
|
10562
|
-
});
|
|
10563
|
-
return null;
|
|
10564
|
-
}
|
|
10565
|
-
}
|
|
10566
10393
|
};
|
|
10567
10394
|
|
|
10568
10395
|
const ERROR_MESSAGE = 'BroadcastChannelConnector is browser-only and requires BroadcastChannel support';
|
|
@@ -73,11 +73,6 @@ class BroadcastChannelConnector extends base_async_connector_js_1.BaseAsyncConne
|
|
|
73
73
|
ensureBroadcastEnvironment();
|
|
74
74
|
super(baseConfig);
|
|
75
75
|
this.listenerRegistered = false;
|
|
76
|
-
this.seenAckKeys = new Map();
|
|
77
|
-
this.seenAckOrder = [];
|
|
78
|
-
this.ackDedupTtlMs = 30000;
|
|
79
|
-
this.ackDedupMaxEntries = 4096;
|
|
80
|
-
this.textDecoder = new TextDecoder();
|
|
81
76
|
this.visibilityChangeListenerRegistered = false;
|
|
82
77
|
this.channelName =
|
|
83
78
|
typeof config.channelName === 'string' && config.channelName.trim().length > 0
|
|
@@ -169,9 +164,6 @@ class BroadcastChannelConnector extends base_async_connector_js_1.BaseAsyncConne
|
|
|
169
164
|
connector_id: this.connectorId,
|
|
170
165
|
payload_length: payload.byteLength,
|
|
171
166
|
});
|
|
172
|
-
if (this._shouldSkipDuplicateAck(senderNodeId, payload)) {
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
167
|
try {
|
|
176
168
|
if (typeof this.inbox.tryEnqueue === 'function') {
|
|
177
169
|
const accepted = this.inbox.tryEnqueue(payload);
|
|
@@ -275,9 +267,6 @@ class BroadcastChannelConnector extends base_async_connector_js_1.BaseAsyncConne
|
|
|
275
267
|
}
|
|
276
268
|
async pushToReceive(rawOrEnvelope) {
|
|
277
269
|
const item = this._normalizeInboxItem(rawOrEnvelope);
|
|
278
|
-
if (this._shouldSkipDuplicateAckFromInboxItem(item)) {
|
|
279
|
-
return;
|
|
280
|
-
}
|
|
281
270
|
try {
|
|
282
271
|
if (typeof this.inbox.tryEnqueue === 'function') {
|
|
283
272
|
const accepted = this.inbox.tryEnqueue(item);
|
|
@@ -377,8 +366,6 @@ class BroadcastChannelConnector extends base_async_connector_js_1.BaseAsyncConne
|
|
|
377
366
|
const closeReason = typeof reason === 'string' && reason.length > 0 ? reason : 'closed';
|
|
378
367
|
const shutdownError = new errors_js_1.FameTransportClose(closeReason, closeCode);
|
|
379
368
|
this.inbox.drain(shutdownError);
|
|
380
|
-
this.seenAckKeys.clear();
|
|
381
|
-
this.seenAckOrder.length = 0;
|
|
382
369
|
}
|
|
383
370
|
_normalizeInboxItem(rawOrEnvelope) {
|
|
384
371
|
if (rawOrEnvelope instanceof Uint8Array) {
|
|
@@ -455,125 +442,6 @@ class BroadcastChannelConnector extends base_async_connector_js_1.BaseAsyncConne
|
|
|
455
442
|
...extra,
|
|
456
443
|
});
|
|
457
444
|
}
|
|
458
|
-
_shouldSkipDuplicateAck(senderId, payload) {
|
|
459
|
-
const dedupKey = this._extractAckDedupKey(payload);
|
|
460
|
-
if (!dedupKey) {
|
|
461
|
-
return false;
|
|
462
|
-
}
|
|
463
|
-
const normalizedSenderId = typeof senderId === 'string' && senderId.length > 0
|
|
464
|
-
? senderId
|
|
465
|
-
: undefined;
|
|
466
|
-
if (normalizedSenderId && normalizedSenderId !== this.localNodeId) {
|
|
467
|
-
logger.debug('broadcast_channel_duplicate_ack_bypass_non_self', {
|
|
468
|
-
channel: this.channelName,
|
|
469
|
-
connector_id: this.connectorId,
|
|
470
|
-
sender_id: normalizedSenderId,
|
|
471
|
-
dedup_key: dedupKey,
|
|
472
|
-
source: 'listener',
|
|
473
|
-
});
|
|
474
|
-
return false;
|
|
475
|
-
}
|
|
476
|
-
logger.debug('broadcast_channel_duplicate_ack_check', {
|
|
477
|
-
channel: this.channelName,
|
|
478
|
-
connector_id: this.connectorId,
|
|
479
|
-
sender_id: normalizedSenderId ?? null,
|
|
480
|
-
dedup_key: dedupKey,
|
|
481
|
-
source: 'listener',
|
|
482
|
-
cache_entries: this.seenAckKeys.size,
|
|
483
|
-
});
|
|
484
|
-
return this._checkDuplicateAck(dedupKey, normalizedSenderId);
|
|
485
|
-
}
|
|
486
|
-
_shouldSkipDuplicateAckFromInboxItem(item) {
|
|
487
|
-
if (item instanceof Uint8Array) {
|
|
488
|
-
return this._shouldSkipDuplicateAck(undefined, item);
|
|
489
|
-
}
|
|
490
|
-
const envelope = this._extractEnvelopeFromInboxItem(item);
|
|
491
|
-
if (!envelope) {
|
|
492
|
-
return false;
|
|
493
|
-
}
|
|
494
|
-
const frame = envelope.frame;
|
|
495
|
-
if (!frame || frame.type !== 'DeliveryAck') {
|
|
496
|
-
return false;
|
|
497
|
-
}
|
|
498
|
-
const refId = typeof frame.refId === 'string' && frame.refId.length > 0
|
|
499
|
-
? frame.refId
|
|
500
|
-
: null;
|
|
501
|
-
const dedupKey = refId ?? envelope.id ?? null;
|
|
502
|
-
if (!dedupKey) {
|
|
503
|
-
return false;
|
|
504
|
-
}
|
|
505
|
-
const senderId = this._extractSenderIdFromInboxItem(item);
|
|
506
|
-
if (senderId && senderId !== this.localNodeId) {
|
|
507
|
-
logger.debug('broadcast_channel_duplicate_ack_bypass_non_self', {
|
|
508
|
-
channel: this.channelName,
|
|
509
|
-
connector_id: this.connectorId,
|
|
510
|
-
sender_id: senderId,
|
|
511
|
-
dedup_key: dedupKey,
|
|
512
|
-
source: 'inbox_item',
|
|
513
|
-
});
|
|
514
|
-
return false;
|
|
515
|
-
}
|
|
516
|
-
logger.debug('broadcast_channel_duplicate_ack_check', {
|
|
517
|
-
channel: this.channelName,
|
|
518
|
-
connector_id: this.connectorId,
|
|
519
|
-
sender_id: senderId ?? null,
|
|
520
|
-
dedup_key: dedupKey,
|
|
521
|
-
source: 'inbox_item',
|
|
522
|
-
cache_entries: this.seenAckKeys.size,
|
|
523
|
-
});
|
|
524
|
-
return this._checkDuplicateAck(dedupKey, senderId);
|
|
525
|
-
}
|
|
526
|
-
_checkDuplicateAck(dedupKey, senderId) {
|
|
527
|
-
const now = Date.now();
|
|
528
|
-
const lastSeen = this.seenAckKeys.get(dedupKey);
|
|
529
|
-
if (lastSeen && now - lastSeen < this.ackDedupTtlMs) {
|
|
530
|
-
logger.debug('broadcast_channel_duplicate_ack_suppressed', {
|
|
531
|
-
channel: this.channelName,
|
|
532
|
-
connector_id: this.connectorId,
|
|
533
|
-
sender_id: senderId ?? null,
|
|
534
|
-
dedup_key: dedupKey,
|
|
535
|
-
age_ms: now - lastSeen,
|
|
536
|
-
ttl_ms: this.ackDedupTtlMs,
|
|
537
|
-
cache_entries: this.seenAckKeys.size,
|
|
538
|
-
});
|
|
539
|
-
return true;
|
|
540
|
-
}
|
|
541
|
-
this.seenAckKeys.set(dedupKey, now);
|
|
542
|
-
this.seenAckOrder.push(dedupKey);
|
|
543
|
-
logger.debug('broadcast_channel_duplicate_ack_recorded', {
|
|
544
|
-
channel: this.channelName,
|
|
545
|
-
connector_id: this.connectorId,
|
|
546
|
-
sender_id: senderId ?? null,
|
|
547
|
-
dedup_key: dedupKey,
|
|
548
|
-
cache_entries: this.seenAckKeys.size,
|
|
549
|
-
});
|
|
550
|
-
this._trimSeenAcks(now);
|
|
551
|
-
return false;
|
|
552
|
-
}
|
|
553
|
-
_extractEnvelopeFromInboxItem(item) {
|
|
554
|
-
if (!item || typeof item !== 'object') {
|
|
555
|
-
return null;
|
|
556
|
-
}
|
|
557
|
-
if ('envelope' in item) {
|
|
558
|
-
return item.envelope;
|
|
559
|
-
}
|
|
560
|
-
if ('frame' in item) {
|
|
561
|
-
return item;
|
|
562
|
-
}
|
|
563
|
-
return null;
|
|
564
|
-
}
|
|
565
|
-
_extractSenderIdFromInboxItem(item) {
|
|
566
|
-
if (!item || typeof item !== 'object') {
|
|
567
|
-
return undefined;
|
|
568
|
-
}
|
|
569
|
-
if ('context' in item) {
|
|
570
|
-
const context = item.context;
|
|
571
|
-
if (context && typeof context.fromSystemId === 'string') {
|
|
572
|
-
return context.fromSystemId;
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
return undefined;
|
|
576
|
-
}
|
|
577
445
|
/**
|
|
578
446
|
* Override start() to check initial visibility state
|
|
579
447
|
*/
|
|
@@ -627,46 +495,5 @@ class BroadcastChannelConnector extends base_async_connector_js_1.BaseAsyncConne
|
|
|
627
495
|
target_mode: 'wildcard',
|
|
628
496
|
});
|
|
629
497
|
}
|
|
630
|
-
_trimSeenAcks(now) {
|
|
631
|
-
while (this.seenAckOrder.length > 0) {
|
|
632
|
-
const candidate = this.seenAckOrder[0];
|
|
633
|
-
const timestamp = this.seenAckKeys.get(candidate);
|
|
634
|
-
if (timestamp === undefined) {
|
|
635
|
-
this.seenAckOrder.shift();
|
|
636
|
-
continue;
|
|
637
|
-
}
|
|
638
|
-
if (this.seenAckKeys.size > this.ackDedupMaxEntries ||
|
|
639
|
-
now - timestamp > this.ackDedupTtlMs) {
|
|
640
|
-
this.seenAckKeys.delete(candidate);
|
|
641
|
-
this.seenAckOrder.shift();
|
|
642
|
-
continue;
|
|
643
|
-
}
|
|
644
|
-
break;
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
|
-
_extractAckDedupKey(payload) {
|
|
648
|
-
try {
|
|
649
|
-
const decoded = this.textDecoder.decode(payload);
|
|
650
|
-
const parsed = JSON.parse(decoded);
|
|
651
|
-
const envelopeId = typeof parsed?.id === 'string' ? parsed.id : null;
|
|
652
|
-
const frameType = parsed?.frame?.type;
|
|
653
|
-
if (typeof frameType !== 'string' || frameType !== 'DeliveryAck') {
|
|
654
|
-
return null;
|
|
655
|
-
}
|
|
656
|
-
const refId = parsed.frame?.refId;
|
|
657
|
-
if (typeof refId === 'string' && refId.length > 0) {
|
|
658
|
-
return refId;
|
|
659
|
-
}
|
|
660
|
-
return envelopeId;
|
|
661
|
-
}
|
|
662
|
-
catch (error) {
|
|
663
|
-
logger.debug('broadcast_channel_ack_dedup_parse_failed', {
|
|
664
|
-
channel: this.channelName,
|
|
665
|
-
connector_id: this.connectorId,
|
|
666
|
-
error: error instanceof Error ? error.message : String(error),
|
|
667
|
-
});
|
|
668
|
-
return null;
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
498
|
}
|
|
672
499
|
exports.BroadcastChannelConnector = BroadcastChannelConnector;
|
package/dist/cjs/version.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// This file is auto-generated during build - do not edit manually
|
|
3
|
-
// Generated from package.json version: 0.3.5-test.
|
|
3
|
+
// Generated from package.json version: 0.3.5-test.966
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.VERSION = void 0;
|
|
6
6
|
/**
|
|
7
7
|
* The package version, injected at build time.
|
|
8
8
|
* @internal
|
|
9
9
|
*/
|
|
10
|
-
exports.VERSION = '0.3.5-test.
|
|
10
|
+
exports.VERSION = '0.3.5-test.966';
|