@rotorsoft/act 1.31.16 → 1.31.18

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
@@ -10,6 +10,7 @@ import {
10
10
  TOMBSTONE_EVENT,
11
11
  cache,
12
12
  config,
13
+ current_autoclose_window,
13
14
  current_reacting,
14
15
  dateReviver,
15
16
  default_scope,
@@ -25,7 +26,7 @@ import {
25
26
  sleep,
26
27
  store,
27
28
  validate
28
- } from "./chunk-T2AT4N6B.js";
29
+ } from "./chunk-34WL4DPW.js";
29
30
  import {
30
31
  ActorSchema,
31
32
  CausationEventSchema,
@@ -805,7 +806,7 @@ var DeferSignal = class extends Error {
805
806
 
806
807
  // src/internal/autoclose-reaction.ts
807
808
  var AUTOCLOSE_TARGET_PREFIX = "__autoclose__:";
808
- function synthesize_autoclose_reactions(registry, states, config2) {
809
+ function synthesize_autoclose_reactions(registry, states, read_window) {
809
810
  for (const st of states.values()) {
810
811
  const predicate = st.autoclose;
811
812
  if (!predicate) continue;
@@ -828,10 +829,9 @@ function synthesize_autoclose_reactions(registry, states, config2) {
828
829
  options: { blockOnError: false, maxRetries: 3 },
829
830
  handler: async (event) => {
830
831
  const aggregate = event.stream;
831
- if (!in_autoclose_window(config2.autocloseWindow, /* @__PURE__ */ new Date()))
832
- throw new DeferSignal({
833
- at: next_window_open(config2.autocloseWindow, /* @__PURE__ */ new Date())
834
- });
832
+ const window = read_window();
833
+ if (!in_autoclose_window(window, /* @__PURE__ */ new Date()))
834
+ throw new DeferSignal({ at: next_window_open(window, /* @__PURE__ */ new Date()) });
835
835
  const stats = await store().query_stats([aggregate], {
836
836
  count: true,
837
837
  tail: keep_days !== void 0 ? true : void 0,
@@ -3521,7 +3521,20 @@ var Act = class {
3521
3521
  this._lanes = lanes;
3522
3522
  validate_only_lanes(options, lanes);
3523
3523
  this._ports = options.scoped ?? default_scope();
3524
- this._scoped = make_run_scoped(this._ports);
3524
+ const ports = this._ports;
3525
+ this._scoped = make_run_scoped({
3526
+ // Delegating getters, NOT a spread: `default_scope()` resolves the
3527
+ // process singletons lazily, so copying its properties would freeze
3528
+ // whichever adapters happened to be installed at construction and
3529
+ // ignore a later `store(...)` / `cache(...)`.
3530
+ get store() {
3531
+ return ports.store;
3532
+ },
3533
+ get cache() {
3534
+ return ports.cache;
3535
+ },
3536
+ autoclose_window: resolveAutocloseConfig(options).autocloseWindow
3537
+ });
3525
3538
  this._correlator = options.correlator ?? default_correlator;
3526
3539
  this._es = build_es(this._logger, this._correlator, patch_fn);
3527
3540
  this._cd = build_drain(this._logger);
@@ -5313,7 +5326,7 @@ function act() {
5313
5326
  synthesize_autoclose_reactions(
5314
5327
  registry,
5315
5328
  states,
5316
- resolveAutocloseConfig(options ?? {})
5329
+ current_autoclose_window
5317
5330
  );
5318
5331
  Object.freeze(registry.actions);
5319
5332
  Object.freeze(registry.events);