@rotorsoft/act 1.14.1 → 1.16.0

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.
@@ -4552,6 +4552,15 @@ var InMemoryStore = class {
4552
4552
  }
4553
4553
  } else {
4554
4554
  let i2 = (query?.after ?? -1) + 1;
4555
+ if (query?.with_snaps && query.stream_exact && query.stream !== void 0 && query.after === void 0) {
4556
+ for (let j = this._events.length - 1; j >= 0; j--) {
4557
+ const e = this._events[j];
4558
+ if (e.stream === query.stream && e.name === SNAP_EVENT) {
4559
+ i2 = j;
4560
+ break;
4561
+ }
4562
+ }
4563
+ }
4555
4564
  while (i2 < this._events.length) {
4556
4565
  const e = this._events[i2++];
4557
4566
  if (query && !this.in_query(query, e)) continue;
@@ -4854,8 +4863,18 @@ var InMemoryStore = class {
4854
4863
  const limit = query?.limit ?? 100;
4855
4864
  const after = query?.after;
4856
4865
  const blocked = query?.blocked;
4866
+ const source_matches = query?.source_matches;
4857
4867
  const stream_re = query?.stream && !query.stream_exact ? new RegExp(query.stream) : void 0;
4858
4868
  const source_re = query?.source && !query.source_exact ? new RegExp(query.source) : void 0;
4869
+ const reverse_cache = /* @__PURE__ */ new Map();
4870
+ const reverse_match = (source) => {
4871
+ let re = reverse_cache.get(source);
4872
+ if (!re) {
4873
+ re = new RegExp(source);
4874
+ reverse_cache.set(source, re);
4875
+ }
4876
+ return source_matches.some((name) => re.test(name));
4877
+ };
4859
4878
  const sorted = [...this._streams.values()].sort(
4860
4879
  (a, b2) => a.stream.localeCompare(b2.stream)
4861
4880
  );
@@ -4871,6 +4890,9 @@ var InMemoryStore = class {
4871
4890
  if (query.source_exact ? s.source !== query.source : !source_re.test(s.source))
4872
4891
  continue;
4873
4892
  }
4893
+ if (source_matches !== void 0) {
4894
+ if (s.source && !reverse_match(s.source)) continue;
4895
+ }
4874
4896
  if (blocked !== void 0 && s.blocked !== blocked) continue;
4875
4897
  if (query?.lane !== void 0 && s.lane !== query.lane) continue;
4876
4898
  callback({
@@ -4913,6 +4935,8 @@ var InMemoryStore = class {
4913
4935
  const want_count = options?.count ?? false;
4914
4936
  const want_names = options?.names ?? false;
4915
4937
  const before = options?.before;
4938
+ const after = options?.after;
4939
+ const limit = options?.limit;
4916
4940
  const array_targets = Array.isArray(input) ? new Set(input) : null;
4917
4941
  const filter = Array.isArray(input) ? null : input;
4918
4942
  const stream_re = filter?.stream && !filter.stream_exact ? new RegExp(filter.stream) : void 0;
@@ -4951,13 +4975,17 @@ var InMemoryStore = class {
4951
4975
  a.names[n] = (a.names[n] ?? 0) + 1;
4952
4976
  }
4953
4977
  }
4978
+ const ordered = [...acc.keys()].sort((x, y2) => x.localeCompare(y2));
4954
4979
  const out = /* @__PURE__ */ new Map();
4955
- for (const [stream, a] of acc) {
4980
+ for (const stream of ordered) {
4981
+ if (after !== void 0 && stream <= after) continue;
4982
+ const a = acc.get(stream);
4956
4983
  const stats = { head: a.head };
4957
4984
  if (want_tail) stats.tail = a.tail;
4958
4985
  if (want_count) stats.count = a.count;
4959
4986
  if (want_names) stats.names = a.names;
4960
4987
  out.set(stream, stats);
4988
+ if (limit !== void 0 && out.size >= limit) break;
4961
4989
  }
4962
4990
  return out;
4963
4991
  }