cry-synced-db-client 0.1.99 → 0.1.100

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/index.js CHANGED
@@ -7211,7 +7211,7 @@ var Ebus2ProxyServerUpdateNotifier = class {
7211
7211
  this.reconnectAttempt = 0;
7212
7212
  this.forcedOffline = false;
7213
7213
  this.subscribedChannels = /* @__PURE__ */ new Set();
7214
- var _a, _b, _c, _d;
7214
+ var _a, _b, _c, _d, _e;
7215
7215
  this.wsUrl = config.wsUrl;
7216
7216
  this.dbName = config.dbName;
7217
7217
  this.collections = config.collections;
@@ -7225,6 +7225,8 @@ var Ebus2ProxyServerUpdateNotifier = class {
7225
7225
  if (config.onWsDisconnect) this.onWsDisconnectCallbacks.push(config.onWsDisconnect);
7226
7226
  if (config.onWsReconnect) this.onWsReconnectCallbacks.push(config.onWsReconnect);
7227
7227
  this.onWsNotification = config.onWsNotification;
7228
+ this.subscribeServices = (_e = config.subscribeServices) != null ? _e : false;
7229
+ this.onServicesChange = config.onServicesChange;
7228
7230
  }
7229
7231
  subscribe(callback) {
7230
7232
  this.callbacks.add(callback);
@@ -7358,6 +7360,9 @@ var Ebus2ProxyServerUpdateNotifier = class {
7358
7360
  this.reconnectAttempt = 0;
7359
7361
  this.currentReconnectDelay = this.reconnectDelayMs;
7360
7362
  this.sendSubscribe(`db/${this.dbName}`);
7363
+ if (this.subscribeServices) {
7364
+ this.sendSubscribe("ebus/services");
7365
+ }
7361
7366
  this.startPingInterval();
7362
7367
  for (const callback of this.onWsConnectCallbacks) {
7363
7368
  try {
@@ -7417,6 +7422,14 @@ var Ebus2ProxyServerUpdateNotifier = class {
7417
7422
  }
7418
7423
  }
7419
7424
  handleChannelMessage(message) {
7425
+ if (message.channel === "ebus/services" && this.onServicesChange) {
7426
+ try {
7427
+ this.onServicesChange(message.data);
7428
+ } catch (err) {
7429
+ console.error("onServicesChange callback failed:", err);
7430
+ }
7431
+ return;
7432
+ }
7420
7433
  const prefix = `db/${this.dbName}/`;
7421
7434
  if (!message.channel.startsWith(prefix)) {
7422
7435
  return;
@@ -25,6 +25,15 @@ export interface Ebus2ProxyServerUpdateNotifierConfig {
25
25
  onWsReconnect?: (attempt: number) => void;
26
26
  /** Called when a notification is received */
27
27
  onWsNotification?: (payload: PublishDataPayload) => void;
28
+ /** Subscribe to ebus/services channel for worker presence */
29
+ subscribeServices?: boolean;
30
+ /** Called when ebus/services data changes (worker presence) */
31
+ onServicesChange?: (services: EbusService[]) => void;
32
+ }
33
+ export interface EbusService {
34
+ name: string;
35
+ workers: number;
36
+ requests: number;
28
37
  }
29
38
  export declare class Ebus2ProxyServerUpdateNotifier implements I_ServerUpdateNotifier {
30
39
  private wsUrl;
@@ -39,6 +48,8 @@ export declare class Ebus2ProxyServerUpdateNotifier implements I_ServerUpdateNot
39
48
  private onWsDisconnectCallbacks;
40
49
  private onWsReconnectCallbacks;
41
50
  private onWsNotification?;
51
+ private subscribeServices;
52
+ private onServicesChange?;
42
53
  private ws;
43
54
  private callbacks;
44
55
  private connected;
@@ -6,6 +6,6 @@ export { DexieDb } from "./db/DexieDb";
6
6
  export { RestProxy } from "./db/RestProxy";
7
7
  export type { RestProxyConfig } from "./db/RestProxy";
8
8
  export { Ebus2ProxyServerUpdateNotifier } from "./db/Ebus2ProxyServerUpdateNotifier";
9
- export type { Ebus2ProxyServerUpdateNotifierConfig } from "./db/Ebus2ProxyServerUpdateNotifier";
9
+ export type { Ebus2ProxyServerUpdateNotifierConfig, EbusService } from "./db/Ebus2ProxyServerUpdateNotifier";
10
10
  export { resolveConflict } from "./utils/conflictResolution";
11
11
  export { filterByQuery, matchesQuery, sortItems, applySkipLimit, projectItem, applyQueryOpts } from "./utils/localQuery";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cry-synced-db-client",
3
- "version": "0.1.99",
3
+ "version": "0.1.100",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",