@cadenza.io/core 3.19.2 → 3.19.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/index.d.mts CHANGED
@@ -1504,6 +1504,7 @@ declare class SignalBroker {
1504
1504
  private isStrategyFlushing;
1505
1505
  private readonly defaultStrategyName;
1506
1506
  constructor();
1507
+ logMemoryFootprint(label?: string): void;
1507
1508
  /**
1508
1509
  * Validates the provided signal name string to ensure it adheres to specific formatting rules.
1509
1510
  * Throws an error if any of the validation checks fail.
@@ -1897,7 +1898,7 @@ declare class Cadenza {
1897
1898
  * ```
1898
1899
  */
1899
1900
  static emit(event: string, data?: AnyObject, options?: EmitOptions): void;
1900
- static schedule(taskName: string, context: AnyObject, delayMs: number, exactDateTime?: Date): void;
1901
+ static schedule(signalName: string, context: AnyObject, delayMs: number, exactDateTime?: Date): void;
1901
1902
  static interval(taskName: string, context: AnyObject, intervalMs: number, leading?: boolean, startDateTime?: Date): void;
1902
1903
  static debounce(signalName: string, context: any, delayMs: number): void;
1903
1904
  static get(taskName: string): Task | undefined;
package/dist/index.d.ts CHANGED
@@ -1504,6 +1504,7 @@ declare class SignalBroker {
1504
1504
  private isStrategyFlushing;
1505
1505
  private readonly defaultStrategyName;
1506
1506
  constructor();
1507
+ logMemoryFootprint(label?: string): void;
1507
1508
  /**
1508
1509
  * Validates the provided signal name string to ensure it adheres to specific formatting rules.
1509
1510
  * Throws an error if any of the validation checks fail.
@@ -1897,7 +1898,7 @@ declare class Cadenza {
1897
1898
  * ```
1898
1899
  */
1899
1900
  static emit(event: string, data?: AnyObject, options?: EmitOptions): void;
1900
- static schedule(taskName: string, context: AnyObject, delayMs: number, exactDateTime?: Date): void;
1901
+ static schedule(signalName: string, context: AnyObject, delayMs: number, exactDateTime?: Date): void;
1901
1902
  static interval(taskName: string, context: AnyObject, intervalMs: number, leading?: boolean, startDateTime?: Date): void;
1902
1903
  static debounce(signalName: string, context: any, delayMs: number): void;
1903
1904
  static get(taskName: string): Task | undefined;
package/dist/index.js CHANGED
@@ -1309,6 +1309,36 @@ var SignalBroker = class _SignalBroker {
1309
1309
  setVerbose(value) {
1310
1310
  this.verbose = value;
1311
1311
  }
1312
+ // Dor debugging
1313
+ logMemoryFootprint(label = "current") {
1314
+ console.log(`[${label}] SignalBroker state sizes:`);
1315
+ console.log(` \u2022 signalObservers entries: ${this.signalObservers.size}`);
1316
+ console.log(
1317
+ ` \u2022 emittedSignalsRegistry size: ${this.emittedSignalsRegistry.size}`
1318
+ );
1319
+ let totalSquashContexts = 0;
1320
+ let totalSquashGroups = 0;
1321
+ for (const groups of this.strategyData.values()) {
1322
+ totalSquashGroups += groups.size;
1323
+ for (const data of groups.values()) {
1324
+ totalSquashContexts += data.contexts.length;
1325
+ }
1326
+ }
1327
+ console.log(` \u2022 Active squash groups: ${totalSquashGroups}`);
1328
+ console.log(` \u2022 Total queued squash contexts: ${totalSquashContexts}`);
1329
+ let totalDebouncers = this.debouncedEmitters.size;
1330
+ console.log(` \u2022 Active debouncers: ${totalDebouncers}`);
1331
+ let totalThrottleQueues = 0;
1332
+ for (const q of this.throttleQueues.values()) {
1333
+ totalThrottleQueues += q.length;
1334
+ }
1335
+ console.log(` \u2022 Total items in throttle queues: ${totalThrottleQueues}`);
1336
+ let totalScheduled = 0;
1337
+ for (const bucket of this.scheduledBuckets.values()) {
1338
+ totalScheduled += bucket.length;
1339
+ }
1340
+ console.log(` \u2022 Pending scheduled items: ${totalScheduled}`);
1341
+ }
1312
1342
  /**
1313
1343
  * Validates the provided signal name string to ensure it adheres to specific formatting rules.
1314
1344
  * Throws an error if any of the validation checks fail.
@@ -1504,7 +1534,8 @@ var SignalBroker = class _SignalBroker {
1504
1534
  delay = options.exactDateTime.getTime() - Date.now();
1505
1535
  }
1506
1536
  delay = Math.max(0, delay);
1507
- const bucketKey = Math.ceil(delay / 100) * 100;
1537
+ const dueAt = Date.now() + delay;
1538
+ const bucketKey = Math.ceil(dueAt / 100) * 100;
1508
1539
  let bucket = this.scheduledBuckets.get(bucketKey);
1509
1540
  if (!bucket) {
1510
1541
  bucket = [];
@@ -6004,8 +6035,11 @@ var Cadenza = class {
6004
6035
  static emit(event, data = {}, options = {}) {
6005
6036
  this.signalBroker?.emit(event, data, options);
6006
6037
  }
6007
- static schedule(taskName, context, delayMs, exactDateTime) {
6008
- this.signalBroker?.schedule(taskName, context, { delayMs, exactDateTime });
6038
+ static schedule(signalName, context, delayMs, exactDateTime) {
6039
+ this.signalBroker?.schedule(signalName, context, {
6040
+ delayMs,
6041
+ exactDateTime
6042
+ });
6009
6043
  }
6010
6044
  static interval(taskName, context, intervalMs, leading = false, startDateTime) {
6011
6045
  this.signalBroker?.interval(