@naylence/runtime 0.3.5-test.961 → 0.3.5-test.962

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.
@@ -5562,12 +5562,12 @@ for (const [name, config] of Object.entries(SQLITE_PROFILES)) {
5562
5562
  }
5563
5563
 
5564
5564
  // This file is auto-generated during build - do not edit manually
5565
- // Generated from package.json version: 0.3.5-test.961
5565
+ // Generated from package.json version: 0.3.5-test.962
5566
5566
  /**
5567
5567
  * The package version, injected at build time.
5568
5568
  * @internal
5569
5569
  */
5570
- const VERSION = '0.3.5-test.961';
5570
+ const VERSION = '0.3.5-test.962';
5571
5571
 
5572
5572
  /**
5573
5573
  * Fame errors module - Fame protocol specific error classes
@@ -11598,6 +11598,26 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
11598
11598
  }
11599
11599
  return null;
11600
11600
  }
11601
+ static normalizeNodeId(value) {
11602
+ if (typeof value !== 'string') {
11603
+ return null;
11604
+ }
11605
+ const trimmed = value.trim();
11606
+ return trimmed.length > 0 ? trimmed : null;
11607
+ }
11608
+ static normalizeTargetNodeId(value) {
11609
+ if (typeof value !== 'string') {
11610
+ return undefined;
11611
+ }
11612
+ const trimmed = value.trim();
11613
+ if (trimmed.length === 0) {
11614
+ return undefined;
11615
+ }
11616
+ if (trimmed === '*') {
11617
+ return '*';
11618
+ }
11619
+ return trimmed;
11620
+ }
11601
11621
  constructor(config, baseConfig = {}) {
11602
11622
  ensureBroadcastEnvironment();
11603
11623
  super(baseConfig);
@@ -11620,10 +11640,18 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
11620
11640
  this.inbox = new BoundedAsyncQueue(preferredCapacity);
11621
11641
  this.inboxCapacity = preferredCapacity;
11622
11642
  this.connectorId = BroadcastChannelConnector.generateConnectorId();
11643
+ const normalizedLocalNodeId = BroadcastChannelConnector.normalizeNodeId(config.localNodeId);
11644
+ if (!normalizedLocalNodeId) {
11645
+ throw new Error('BroadcastChannelConnector requires a non-empty localNodeId');
11646
+ }
11647
+ this.localNodeId = normalizedLocalNodeId;
11648
+ this.targetNodeId = BroadcastChannelConnector.normalizeTargetNodeId(config.initialTargetNodeId);
11623
11649
  this.channel = new BroadcastChannel(this.channelName);
11624
11650
  logger$10.debug('broadcast_channel_connector_created', {
11625
11651
  channel: this.channelName,
11626
11652
  connector_id: this.connectorId,
11653
+ local_node_id: this.localNodeId,
11654
+ target_node_id: this.targetNodeId ?? null,
11627
11655
  inbox_capacity: preferredCapacity,
11628
11656
  timestamp: new Date().toISOString(),
11629
11657
  });
@@ -11645,15 +11673,32 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
11645
11673
  ? message.constructor?.name ?? typeof message
11646
11674
  : typeof message,
11647
11675
  has_sender_id: Boolean(message?.senderId),
11676
+ has_sender_node_id: Boolean(message?.senderNodeId),
11648
11677
  });
11649
11678
  if (!message || typeof message !== 'object') {
11650
11679
  return;
11651
11680
  }
11652
11681
  const busMessage = message;
11653
- if (typeof busMessage.senderId !== 'string' || busMessage.senderId.length === 0) {
11682
+ const senderNodeId = BroadcastChannelConnector.normalizeNodeId(busMessage.senderNodeId);
11683
+ if (!senderNodeId) {
11684
+ logger$10.debug('broadcast_channel_message_rejected', {
11685
+ channel: this.channelName,
11686
+ connector_id: this.connectorId,
11687
+ reason: 'missing_sender_node_id',
11688
+ });
11654
11689
  return;
11655
11690
  }
11656
- if (busMessage.senderId === this.connectorId) {
11691
+ if (senderNodeId === this.localNodeId) {
11692
+ logger$10.debug('broadcast_channel_message_rejected', {
11693
+ channel: this.channelName,
11694
+ connector_id: this.connectorId,
11695
+ reason: 'self_echo',
11696
+ sender_node_id: senderNodeId,
11697
+ });
11698
+ return;
11699
+ }
11700
+ const incomingTargetNodeId = BroadcastChannelConnector.normalizeTargetNodeId(busMessage.targetNodeId);
11701
+ if (!this._shouldAcceptMessageFromBus(senderNodeId, incomingTargetNodeId)) {
11657
11702
  return;
11658
11703
  }
11659
11704
  const payload = BroadcastChannelConnector.coercePayload(busMessage.payload);
@@ -11667,11 +11712,13 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
11667
11712
  }
11668
11713
  logger$10.debug('broadcast_channel_message_received', {
11669
11714
  channel: this.channelName,
11670
- sender_id: busMessage.senderId,
11715
+ sender_id: message?.senderId,
11716
+ sender_node_id: senderNodeId,
11717
+ target_node_id: incomingTargetNodeId ?? null,
11671
11718
  connector_id: this.connectorId,
11672
11719
  payload_length: payload.byteLength,
11673
11720
  });
11674
- if (this._shouldSkipDuplicateAck(busMessage.senderId, payload)) {
11721
+ if (this._shouldSkipDuplicateAck(senderNodeId, payload)) {
11675
11722
  return;
11676
11723
  }
11677
11724
  try {
@@ -11815,12 +11862,17 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
11815
11862
  }
11816
11863
  async _transportSendBytes(data) {
11817
11864
  ensureBroadcastEnvironment();
11865
+ const targetNodeId = this.targetNodeId ?? '*';
11818
11866
  logger$10.debug('broadcast_channel_message_sending', {
11819
11867
  channel: this.channelName,
11820
11868
  sender_id: this.connectorId,
11869
+ sender_node_id: this.localNodeId,
11870
+ target_node_id: targetNodeId,
11821
11871
  });
11822
11872
  this.channel.postMessage({
11823
11873
  senderId: this.connectorId,
11874
+ senderNodeId: this.localNodeId,
11875
+ targetNodeId,
11824
11876
  payload: data,
11825
11877
  });
11826
11878
  }
@@ -11883,6 +11935,51 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
11883
11935
  }
11884
11936
  return rawOrEnvelope;
11885
11937
  }
11938
+ _isWildcardTarget() {
11939
+ return this.targetNodeId === '*' || typeof this.targetNodeId === 'undefined';
11940
+ }
11941
+ _shouldAcceptMessageFromBus(senderNodeId, targetNodeId) {
11942
+ if (this._isWildcardTarget()) {
11943
+ if (targetNodeId && targetNodeId !== '*') {
11944
+ logger$10.debug('broadcast_channel_message_rejected', {
11945
+ channel: this.channelName,
11946
+ connector_id: this.connectorId,
11947
+ reason: 'wildcard_target_mismatch',
11948
+ sender_node_id: senderNodeId,
11949
+ target_node_id: targetNodeId,
11950
+ local_node_id: this.localNodeId,
11951
+ });
11952
+ return false;
11953
+ }
11954
+ return true;
11955
+ }
11956
+ const expectedSender = this.targetNodeId;
11957
+ if (expectedSender && expectedSender !== '*' && senderNodeId !== expectedSender) {
11958
+ logger$10.debug('broadcast_channel_message_rejected', {
11959
+ channel: this.channelName,
11960
+ connector_id: this.connectorId,
11961
+ reason: 'unexpected_sender',
11962
+ expected_sender_node_id: expectedSender,
11963
+ sender_node_id: senderNodeId,
11964
+ local_node_id: this.localNodeId,
11965
+ });
11966
+ return false;
11967
+ }
11968
+ if (targetNodeId &&
11969
+ targetNodeId !== '*' &&
11970
+ targetNodeId !== this.localNodeId) {
11971
+ logger$10.debug('broadcast_channel_message_rejected', {
11972
+ channel: this.channelName,
11973
+ connector_id: this.connectorId,
11974
+ reason: 'unexpected_target',
11975
+ sender_node_id: senderNodeId,
11976
+ target_node_id: targetNodeId,
11977
+ local_node_id: this.localNodeId,
11978
+ });
11979
+ return false;
11980
+ }
11981
+ return true;
11982
+ }
11886
11983
  _describeInboxItem(item) {
11887
11984
  if (item instanceof Uint8Array) {
11888
11985
  return 'bytes';
@@ -11913,7 +12010,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
11913
12010
  const normalizedSenderId = typeof senderId === 'string' && senderId.length > 0
11914
12011
  ? senderId
11915
12012
  : undefined;
11916
- if (normalizedSenderId && normalizedSenderId !== this.connectorId) {
12013
+ if (normalizedSenderId && normalizedSenderId !== this.localNodeId) {
11917
12014
  logger$10.debug('broadcast_channel_duplicate_ack_bypass_non_self', {
11918
12015
  channel: this.channelName,
11919
12016
  connector_id: this.connectorId,
@@ -11953,7 +12050,7 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
11953
12050
  return false;
11954
12051
  }
11955
12052
  const senderId = this._extractSenderIdFromInboxItem(item);
11956
- if (senderId && senderId !== this.connectorId) {
12053
+ if (senderId && senderId !== this.localNodeId) {
11957
12054
  logger$10.debug('broadcast_channel_duplicate_ack_bypass_non_self', {
11958
12055
  channel: this.channelName,
11959
12056
  connector_id: this.connectorId,
@@ -12049,6 +12146,34 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
12049
12146
  });
12050
12147
  }
12051
12148
  }
12149
+ setTargetNodeId(nodeId) {
12150
+ const normalized = BroadcastChannelConnector.normalizeNodeId(nodeId);
12151
+ if (!normalized) {
12152
+ throw new Error('BroadcastChannelConnector target node id must be a non-empty string');
12153
+ }
12154
+ if (normalized === '*') {
12155
+ this.setWildcardTarget();
12156
+ return;
12157
+ }
12158
+ this.targetNodeId = normalized;
12159
+ logger$10.debug('broadcast_channel_target_updated', {
12160
+ channel: this.channelName,
12161
+ connector_id: this.connectorId,
12162
+ local_node_id: this.localNodeId,
12163
+ target_node_id: this.targetNodeId,
12164
+ target_mode: 'direct',
12165
+ });
12166
+ }
12167
+ setWildcardTarget() {
12168
+ this.targetNodeId = '*';
12169
+ logger$10.debug('broadcast_channel_target_updated', {
12170
+ channel: this.channelName,
12171
+ connector_id: this.connectorId,
12172
+ local_node_id: this.localNodeId,
12173
+ target_node_id: this.targetNodeId,
12174
+ target_mode: 'wildcard',
12175
+ });
12176
+ }
12052
12177
  _trimSeenAcks(now) {
12053
12178
  while (this.seenAckOrder.length > 0) {
12054
12179
  const candidate = this.seenAckOrder[0];
@@ -30619,8 +30744,13 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
30619
30744
  }
30620
30745
  const normalized = this._normalizeConfig(config);
30621
30746
  const options = (factoryArgs[0] ?? {});
30747
+ const localNodeId = this._normalizeNodeId(options.localNodeId);
30748
+ if (!localNodeId) {
30749
+ throw new Error('BroadcastChannelConnectorFactory requires a localNodeId in create() options');
30750
+ }
30622
30751
  const channelName = normalized.channelName ?? DEFAULT_CHANNEL$2;
30623
30752
  const inboxCapacity = normalized.inboxCapacity ?? DEFAULT_INBOX_CAPACITY$2;
30753
+ const resolvedTarget = this._normalizeTargetNodeId(options.initialTargetNodeId ?? normalized.initialTargetNodeId);
30624
30754
  const baseConfig = {
30625
30755
  drainTimeout: normalized.drainTimeout,
30626
30756
  flowControl: normalized.flowControl,
@@ -30635,6 +30765,8 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
30635
30765
  type: BROADCAST_CHANNEL_CONNECTOR_TYPE$1,
30636
30766
  channelName,
30637
30767
  inboxCapacity,
30768
+ localNodeId,
30769
+ initialTargetNodeId: resolvedTarget,
30638
30770
  };
30639
30771
  const connector = new BroadcastChannelConnector(connectorConfig, baseConfig);
30640
30772
  if (options.authorization) {
@@ -30658,6 +30790,13 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
30658
30790
  normalized.channelName = channel.trim();
30659
30791
  }
30660
30792
  const capacity = candidate.inboxCapacity ?? candidate['inbox_capacity'];
30793
+ const initialTargetNodeId = candidate.initialTargetNodeId ?? candidate['initial_target_node_id'];
30794
+ if (typeof initialTargetNodeId === 'string' && initialTargetNodeId.trim().length > 0) {
30795
+ normalized.initialTargetNodeId = initialTargetNodeId.trim();
30796
+ }
30797
+ else if (initialTargetNodeId === '*') {
30798
+ normalized.initialTargetNodeId = '*';
30799
+ }
30661
30800
  if (typeof capacity === 'number' &&
30662
30801
  Number.isFinite(capacity) &&
30663
30802
  capacity > 0) {
@@ -30701,6 +30840,19 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
30701
30840
  normalized.inboxCapacity ?? DEFAULT_INBOX_CAPACITY$2;
30702
30841
  return normalized;
30703
30842
  }
30843
+ _normalizeNodeId(value) {
30844
+ if (typeof value !== 'string') {
30845
+ return null;
30846
+ }
30847
+ const trimmed = value.trim();
30848
+ return trimmed.length > 0 ? trimmed : null;
30849
+ }
30850
+ _normalizeTargetNodeId(value) {
30851
+ if (value === '*') {
30852
+ return '*';
30853
+ }
30854
+ return this._normalizeNodeId(value) ?? '*';
30855
+ }
30704
30856
  }
30705
30857
 
30706
30858
  var broadcastChannelConnectorFactory = /*#__PURE__*/Object.freeze({
@@ -32858,7 +33010,7 @@ class BroadcastChannelListener extends TransportListener {
32858
33010
  node: routingNode,
32859
33011
  });
32860
33012
  const selection = defaultGrantSelectionPolicy.selectCallbackGrant(selectionContext);
32861
- connectorConfig = this._grantToConnectorConfig(selection.grant);
33013
+ connectorConfig = this._grantToConnectorConfig(selection.grant, systemId);
32862
33014
  }
32863
33015
  catch (error) {
32864
33016
  logger$n.debug('broadcast_channel_listener_grant_selection_failed', {
@@ -32867,13 +33019,20 @@ class BroadcastChannelListener extends TransportListener {
32867
33019
  error: error instanceof Error ? error.message : String(error),
32868
33020
  });
32869
33021
  connectorConfig =
32870
- this._extractBroadcastConnectorConfig(frame) ??
32871
- {
33022
+ this._extractBroadcastConnectorConfig(frame, systemId) ??
33023
+ this._buildConnectorConfigForSystem(systemId, {
32872
33024
  type: BROADCAST_CHANNEL_CONNECTOR_TYPE$1,
32873
33025
  channelName: this._channelName,
32874
33026
  inboxCapacity: this._inboxCapacity,
32875
33027
  passive: true,
32876
- };
33028
+ });
33029
+ }
33030
+ if (!connectorConfig) {
33031
+ logger$n.error('broadcast_channel_listener_missing_connector_config', {
33032
+ sender_id: params.senderId,
33033
+ system_id: systemId,
33034
+ });
33035
+ return null;
32877
33036
  }
32878
33037
  try {
32879
33038
  const connector = await routingNode.createOriginConnector({
@@ -32899,7 +33058,7 @@ class BroadcastChannelListener extends TransportListener {
32899
33058
  return null;
32900
33059
  }
32901
33060
  }
32902
- _extractBroadcastConnectorConfig(frame) {
33061
+ _extractBroadcastConnectorConfig(frame, systemId) {
32903
33062
  const rawGrants = frame.callbackGrants;
32904
33063
  if (!Array.isArray(rawGrants)) {
32905
33064
  return null;
@@ -32910,7 +33069,10 @@ class BroadcastChannelListener extends TransportListener {
32910
33069
  (grant.type === BROADCAST_CHANNEL_CONNECTION_GRANT_TYPE ||
32911
33070
  grant.type === BROADCAST_CHANNEL_CONNECTOR_TYPE$1)) {
32912
33071
  try {
32913
- return this._grantToConnectorConfig(grant);
33072
+ if (grant.type === BROADCAST_CHANNEL_CONNECTOR_TYPE$1) {
33073
+ return this._buildConnectorConfigForSystem(systemId, grant);
33074
+ }
33075
+ return this._buildConnectorConfigForSystem(systemId, broadcastChannelGrantToConnectorConfig(grant));
32914
33076
  }
32915
33077
  catch (error) {
32916
33078
  logger$n.debug('broadcast_channel_listener_grant_normalization_failed', {
@@ -32921,31 +33083,87 @@ class BroadcastChannelListener extends TransportListener {
32921
33083
  }
32922
33084
  return null;
32923
33085
  }
32924
- _grantToConnectorConfig(grant) {
32925
- if (grant.type !== BROADCAST_CHANNEL_CONNECTOR_TYPE$1) {
32926
- if (grant.type === BROADCAST_CHANNEL_CONNECTION_GRANT_TYPE) {
32927
- return broadcastChannelGrantToConnectorConfig(grant);
33086
+ _grantToConnectorConfig(grant, systemId) {
33087
+ if (grant.type === BROADCAST_CHANNEL_CONNECTOR_TYPE$1) {
33088
+ return this._buildConnectorConfigForSystem(systemId, grant);
33089
+ }
33090
+ if (grant.type === BROADCAST_CHANNEL_CONNECTION_GRANT_TYPE) {
33091
+ return this._buildConnectorConfigForSystem(systemId, broadcastChannelGrantToConnectorConfig(grant));
33092
+ }
33093
+ if ('toConnectorConfig' in grant &&
33094
+ typeof grant.toConnectorConfig ===
33095
+ 'function') {
33096
+ const normalized = grant.toConnectorConfig();
33097
+ if (normalized.type !== BROADCAST_CHANNEL_CONNECTOR_TYPE$1) {
33098
+ throw new Error(`Unsupported grant connector type: ${normalized.type}`);
32928
33099
  }
32929
- throw new Error(`Unsupported grant type: ${grant.type}`);
33100
+ return this._buildConnectorConfigForSystem(systemId, normalized);
32930
33101
  }
32931
- const candidate = grant;
32932
- const config = {
33102
+ throw new Error(`Unsupported grant type: ${grant.type}`);
33103
+ }
33104
+ _buildConnectorConfigForSystem(systemId, baseConfig) {
33105
+ const localNodeId = this._requireLocalNodeId();
33106
+ const targetSystemId = this._normalizeNodeId(systemId);
33107
+ if (!targetSystemId) {
33108
+ throw new Error('BroadcastChannelListener requires a valid system id');
33109
+ }
33110
+ const candidate = baseConfig ?? null;
33111
+ const channelCandidate = candidate && 'channelName' in candidate
33112
+ ? candidate.channelName
33113
+ : undefined;
33114
+ const inboxCandidate = candidate && 'inboxCapacity' in candidate
33115
+ ? candidate.inboxCapacity
33116
+ : undefined;
33117
+ const initialWindowCandidate = candidate && 'initialWindow' in candidate
33118
+ ? candidate.initialWindow
33119
+ : undefined;
33120
+ const passiveCandidate = candidate && 'passive' in candidate
33121
+ ? candidate.passive
33122
+ : undefined;
33123
+ const targetCandidate = candidate && 'initialTargetNodeId' in candidate
33124
+ ? candidate.initialTargetNodeId
33125
+ : undefined;
33126
+ const channelName = typeof channelCandidate === 'string' && channelCandidate.trim().length > 0
33127
+ ? channelCandidate.trim()
33128
+ : this._channelName;
33129
+ const inboxCapacity = typeof inboxCandidate === 'number' &&
33130
+ Number.isFinite(inboxCandidate) &&
33131
+ inboxCandidate > 0
33132
+ ? Math.floor(inboxCandidate)
33133
+ : this._inboxCapacity;
33134
+ const initialWindow = typeof initialWindowCandidate === 'number' &&
33135
+ Number.isFinite(initialWindowCandidate) &&
33136
+ initialWindowCandidate > 0
33137
+ ? Math.floor(initialWindowCandidate)
33138
+ : undefined;
33139
+ const initialTargetNodeId = this._normalizeNodeId(targetCandidate) ?? targetSystemId;
33140
+ return {
32933
33141
  type: BROADCAST_CHANNEL_CONNECTOR_TYPE$1,
32934
- channelName: this._channelName,
32935
- inboxCapacity: this._inboxCapacity,
32936
- passive: true,
33142
+ channelName,
33143
+ inboxCapacity,
33144
+ passive: typeof passiveCandidate === 'boolean' ? passiveCandidate : true,
33145
+ initialWindow,
33146
+ localNodeId,
33147
+ initialTargetNodeId,
32937
33148
  };
32938
- const channelCandidate = candidate.channelName ?? candidate['channel_name'];
32939
- if (typeof channelCandidate === 'string' && channelCandidate.trim().length > 0) {
32940
- config.channelName = channelCandidate.trim();
33149
+ }
33150
+ _requireLocalNodeId() {
33151
+ if (!this._routingNode) {
33152
+ throw new Error('BroadcastChannelListener requires routing node context');
32941
33153
  }
32942
- const inboxCandidate = candidate.inboxCapacity ?? candidate['inbox_capacity'];
32943
- if (typeof inboxCandidate === 'number' &&
32944
- Number.isFinite(inboxCandidate) &&
32945
- inboxCandidate > 0) {
32946
- config.inboxCapacity = Math.floor(inboxCandidate);
33154
+ const normalized = this._normalizeNodeId(this._routingNode.sid) ??
33155
+ this._normalizeNodeId(this._routingNode.id);
33156
+ if (!normalized) {
33157
+ throw new Error('BroadcastChannelListener requires routing node with a stable identifier');
32947
33158
  }
32948
- return config;
33159
+ return normalized;
33160
+ }
33161
+ _normalizeNodeId(value) {
33162
+ if (typeof value !== 'string') {
33163
+ return null;
33164
+ }
33165
+ const trimmed = value.trim();
33166
+ return trimmed.length > 0 ? trimmed : null;
32949
33167
  }
32950
33168
  _monitorConnectorLifecycle(senderId, systemId, connector) {
32951
33169
  const maybeClosable = connector;
@@ -7,9 +7,12 @@ export interface BroadcastChannelConnectorFactoryConfig extends ConnectorConfig,
7
7
  type: typeof BROADCAST_CHANNEL_CONNECTOR_TYPE;
8
8
  channelName?: string;
9
9
  inboxCapacity?: number;
10
+ initialTargetNodeId?: string | '*';
10
11
  }
11
12
  export interface CreateBroadcastChannelConnectorOptions {
12
13
  authorization?: AuthorizationContext;
14
+ localNodeId: string;
15
+ initialTargetNodeId?: string | '*';
13
16
  }
14
17
  export declare const FACTORY_META: {
15
18
  readonly base: "ConnectorFactory";
@@ -23,5 +26,7 @@ export declare class BroadcastChannelConnectorFactory extends ConnectorFactory<B
23
26
  grantFromConfig(config: BroadcastChannelConnectorFactoryConfig | Record<string, unknown>): ConnectionGrant;
24
27
  create(config?: BroadcastChannelConnectorFactoryConfig | Record<string, unknown> | null, ...factoryArgs: unknown[]): Promise<BroadcastChannelConnector>;
25
28
  private _normalizeConfig;
29
+ private _normalizeNodeId;
30
+ private _normalizeTargetNodeId;
26
31
  }
27
32
  export default BroadcastChannelConnectorFactory;
@@ -8,6 +8,8 @@ export interface BroadcastChannelConnectorConfig extends ConnectorConfig {
8
8
  inboxCapacity?: number;
9
9
  initialWindow?: number;
10
10
  passive?: boolean;
11
+ localNodeId: string;
12
+ initialTargetNodeId?: string | '*';
11
13
  }
12
14
  type BroadcastChannelInboxItem = Uint8Array | FameEnvelope | FameChannelMessage;
13
15
  export declare class BroadcastChannelConnector extends BaseAsyncConnector {
@@ -16,6 +18,8 @@ export declare class BroadcastChannelConnector extends BaseAsyncConnector {
16
18
  private readonly inboxCapacity;
17
19
  private listenerRegistered;
18
20
  private readonly connectorId;
21
+ private readonly localNodeId;
22
+ private targetNodeId?;
19
23
  private readonly onMsg;
20
24
  private readonly channel;
21
25
  private readonly seenAckKeys;
@@ -27,12 +31,16 @@ export declare class BroadcastChannelConnector extends BaseAsyncConnector {
27
31
  private visibilityChangeHandler?;
28
32
  private static generateConnectorId;
29
33
  private static coercePayload;
34
+ private static normalizeNodeId;
35
+ private static normalizeTargetNodeId;
30
36
  constructor(config: BroadcastChannelConnectorConfig, baseConfig?: BaseAsyncConnectorConfig);
31
37
  pushToReceive(rawOrEnvelope: Uint8Array | FameEnvelope | FameChannelMessage): Promise<void>;
32
38
  protected _transportSendBytes(data: Uint8Array): Promise<void>;
33
39
  protected _transportReceive(): Promise<BroadcastChannelInboxItem>;
34
40
  protected _transportClose(code: number, reason: string): Promise<void>;
35
41
  private _normalizeInboxItem;
42
+ private _isWildcardTarget;
43
+ private _shouldAcceptMessageFromBus;
36
44
  private _describeInboxItem;
37
45
  private logInboxSnapshot;
38
46
  private _shouldSkipDuplicateAck;
@@ -44,6 +52,8 @@ export declare class BroadcastChannelConnector extends BaseAsyncConnector {
44
52
  * Override start() to check initial visibility state
45
53
  */
46
54
  start(inboundHandler: FameEnvelopeHandler): Promise<void>;
55
+ setTargetNodeId(nodeId: string): void;
56
+ setWildcardTarget(): void;
47
57
  private _trimSeenAcks;
48
58
  private _extractAckDedupKey;
49
59
  }
@@ -1,12 +1,7 @@
1
1
  import { BaseAsyncConnector, type BaseAsyncConnectorConfig } from './base-async-connector.js';
2
- import type { ConnectorConfig } from './connector-config.js';
3
2
  import type { FameEnvelope, FameChannelMessage } from '@naylence/core';
3
+ import type { BroadcastChannelConnectorConfig } from './broadcast-channel-connector.browser.js';
4
4
  export declare const BROADCAST_CHANNEL_CONNECTOR_TYPE: "broadcast-channel-connector";
5
- export interface BroadcastChannelConnectorConfig extends ConnectorConfig {
6
- type: typeof BROADCAST_CHANNEL_CONNECTOR_TYPE;
7
- channelName?: string;
8
- inboxCapacity?: number;
9
- }
10
5
  export declare class BroadcastChannelConnector extends BaseAsyncConnector {
11
6
  constructor(config: BroadcastChannelConnectorConfig, baseConfig?: BaseAsyncConnectorConfig);
12
7
  pushToReceive(_rawOrEnvelope: Uint8Array | FameEnvelope | FameChannelMessage): Promise<void>;
@@ -33,6 +33,9 @@ export declare class BroadcastChannelListener extends TransportListener {
33
33
  private _createConnectorForAttach;
34
34
  private _extractBroadcastConnectorConfig;
35
35
  private _grantToConnectorConfig;
36
+ private _buildConnectorConfigForSystem;
37
+ private _requireLocalNodeId;
38
+ private _normalizeNodeId;
36
39
  private _monitorConnectorLifecycle;
37
40
  private _deliverEnvelope;
38
41
  private _buildChannelMessage;
@@ -17,7 +17,7 @@ export type BroadcastChannelConnectionGrantLike = ConnectionGrantLike & {
17
17
  initialWindow?: unknown;
18
18
  initial_window?: unknown;
19
19
  };
20
- export type BroadcastChannelConnectorConfigLike = ConnectorConfig & BroadcastChannelConnectorConfig;
20
+ export type BroadcastChannelConnectorConfigLike = ConnectorConfig & Partial<BroadcastChannelConnectorConfig>;
21
21
  export declare function isBroadcastChannelConnectionGrant(candidate: unknown): candidate is BroadcastChannelConnectionGrant;
22
22
  export declare function normalizeBroadcastChannelConnectionGrant(candidate: BroadcastChannelConnectionGrantLike): BroadcastChannelConnectionGrant;
23
23
  export declare function broadcastChannelGrantToConnectorConfig(grant: BroadcastChannelConnectionGrantLike): BroadcastChannelConnectorConfigLike;
@@ -2,4 +2,4 @@
2
2
  * The package version, injected at build time.
3
3
  * @internal
4
4
  */
5
- export declare const VERSION = "0.3.5-test.961";
5
+ export declare const VERSION = "0.3.5-test.962";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naylence/runtime",
3
- "version": "0.3.5-test.961",
3
+ "version": "0.3.5-test.962",
4
4
  "type": "module",
5
5
  "description": "Naylence Runtime - Complete TypeScript runtime",
6
6
  "author": "Naylence Dev <naylencedev@gmail.com>",