@tstdl/base 0.86.0 → 0.87.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.
Files changed (81) hide show
  1. package/application/application.d.ts +3 -3
  2. package/application/application.js +9 -10
  3. package/authentication/client/authentication.service.js +3 -3
  4. package/browser/browser-context-controller.d.ts +2 -2
  5. package/browser/browser-context-controller.js +6 -7
  6. package/browser/browser-controller.js +6 -7
  7. package/cancellation/index.d.ts +1 -0
  8. package/{global-this.js → cancellation/index.js} +4 -23
  9. package/{utils/cancellation-token.d.ts → cancellation/token.d.ts} +31 -37
  10. package/{utils/cancellation-token.js → cancellation/token.js} +100 -55
  11. package/core.d.ts +6 -5
  12. package/core.js +12 -13
  13. package/data-structures/circular-buffer.d.ts +4 -4
  14. package/data-structures/circular-buffer.js +10 -10
  15. package/database/mongo/module.js +8 -8
  16. package/disposable/async-disposer.d.ts +12 -11
  17. package/disposable/async-disposer.js +53 -27
  18. package/disposable/disposable.d.ts +5 -4
  19. package/disposable/disposable.js +9 -5
  20. package/distributed-loop/distributed-loop.d.ts +4 -4
  21. package/distributed-loop/distributed-loop.js +6 -6
  22. package/enumerable/async-enumerable.d.ts +2 -2
  23. package/enumerable/async-enumerable.js +2 -2
  24. package/enumerable/enumerable.d.ts +2 -2
  25. package/enumerable/enumerable.js +2 -2
  26. package/examples/api/streaming.js +3 -3
  27. package/http/client/adapters/undici-http-client.adapter.js +1 -1
  28. package/http/client/http-client-request.d.ts +5 -5
  29. package/http/client/http-client-request.js +9 -9
  30. package/http/server/node/node-http-server.js +2 -2
  31. package/injector/injector.d.ts +5 -2
  32. package/injector/injector.js +59 -23
  33. package/injector/interfaces.d.ts +4 -3
  34. package/injector/provider.d.ts +12 -12
  35. package/injector/resolve.error.d.ts +1 -1
  36. package/injector/types.d.ts +16 -7
  37. package/lock/mongo/lock.js +2 -2
  38. package/lock/web/web-lock.js +2 -2
  39. package/logger/console/logger.js +2 -2
  40. package/message-bus/message-bus-base.d.ts +2 -2
  41. package/message-bus/message-bus-base.js +2 -2
  42. package/migration/migrator.js +2 -2
  43. package/module/module-base.d.ts +3 -3
  44. package/module/module-base.js +2 -2
  45. package/module/module-metric-reporter.d.ts +2 -2
  46. package/module/module-metric-reporter.js +3 -3
  47. package/module/modules/function.module.d.ts +4 -4
  48. package/module/modules/function.module.js +2 -2
  49. package/module/modules/web-server.module.d.ts +2 -2
  50. package/module/modules/web-server.module.js +2 -2
  51. package/package.json +9 -8
  52. package/polyfills.d.ts +159 -0
  53. package/polyfills.js +2 -0
  54. package/process-shutdown.d.ts +4 -2
  55. package/process-shutdown.js +15 -5
  56. package/queue/mongo/mongo-job.repository.js +3 -4
  57. package/queue/mongo/queue.d.ts +5 -5
  58. package/queue/mongo/queue.js +7 -7
  59. package/queue/queue.d.ts +3 -3
  60. package/search-index/elastic/module.js +4 -4
  61. package/signals/to-signal-2.d.ts +6 -4
  62. package/tsconfig.json +1 -1
  63. package/utils/async-iterable-helpers/buffer.js +2 -2
  64. package/utils/async-iterable-helpers/observable-iterable.js +3 -3
  65. package/utils/async-iterable-helpers/take-until.d.ts +2 -2
  66. package/utils/async-iterable-helpers/take-until.js +7 -7
  67. package/utils/backoff.d.ts +7 -7
  68. package/utils/backoff.js +7 -7
  69. package/utils/event-loop.d.ts +2 -2
  70. package/utils/event-loop.js +2 -2
  71. package/utils/feedable-async-iterable.js +3 -3
  72. package/utils/index.d.ts +0 -1
  73. package/utils/index.js +0 -1
  74. package/utils/iterable-helpers/take-until.d.ts +2 -2
  75. package/utils/iterable-helpers/take-until.js +2 -2
  76. package/utils/patch-worker.d.ts +1 -1
  77. package/utils/patch-worker.js +2 -2
  78. package/utils/periodic-reporter.js +2 -2
  79. package/utils/timing.d.ts +3 -3
  80. package/utils/timing.js +5 -5
  81. package/global-this.d.ts +0 -1
@@ -1,4 +1,4 @@
1
- import type { ReadonlyCancellationToken } from '../utils/cancellation-token.js';
1
+ import type { CancellationSignal } from '../cancellation/token.js';
2
2
  import type { Observable } from 'rxjs';
3
3
  import { Collection } from './collection.js';
4
4
  export declare class CircularBuffer<T> extends Collection<T, CircularBuffer<T>> {
@@ -45,11 +45,11 @@ export declare class CircularBuffer<T> extends Collection<T, CircularBuffer<T>>
45
45
  consume(): IterableIterator<T>;
46
46
  /**
47
47
  * yields all items from the buffer, removes them and waits fore more
48
- * @param cancellationToken token to cancel iteration
49
- * @param yieldOutstandingItems whether to yield all outstanding items or exit immdiately when {@link cancellationToken} is set
48
+ * @param cancellationSignal token to cancel iteration
49
+ * @param yieldOutstandingItems whether to yield all outstanding items or exit immdiately when {@link cancellationSignal} is set
50
50
  * @returns
51
51
  */
52
- consumeAsync(cancellationToken?: ReadonlyCancellationToken, yieldOutstandingItems?: boolean): AsyncIterable<T>;
52
+ consumeAsync(cancellationSignal?: CancellationSignal, yieldOutstandingItems?: boolean): AsyncIterable<T>;
53
53
  protected _clear(): void;
54
54
  private increaseBufferSizeIfNeeded;
55
55
  private resize;
@@ -21,7 +21,7 @@ __export(circular_buffer_exports, {
21
21
  CircularBuffer: () => CircularBuffer
22
22
  });
23
23
  module.exports = __toCommonJS(circular_buffer_exports);
24
- var import_cancellation_token = require("../utils/cancellation-token.js");
24
+ var import_token = require("../cancellation/token.js");
25
25
  var import_type_guards = require("../utils/type-guards.js");
26
26
  var import_rxjs = require("rxjs");
27
27
  var import_collection = require("./collection.js");
@@ -133,7 +133,7 @@ class CircularBuffer extends import_collection.Collection {
133
133
  }
134
134
  clone(newMaxBufferSize = this.maxBufferSize) {
135
135
  if ((0, import_type_guards.isDefined)(newMaxBufferSize) && newMaxBufferSize < this.size) {
136
- throw new Error("newSize must be equal or larger to current size");
136
+ throw new Error("newSize must be equal or larger to current size.");
137
137
  }
138
138
  const cloned = new CircularBuffer(newMaxBufferSize);
139
139
  cloned.addMany(this);
@@ -147,7 +147,7 @@ class CircularBuffer extends import_collection.Collection {
147
147
  try {
148
148
  for (let i = 0; i < size; i++) {
149
149
  if (modified) {
150
- throw new Error("buffer was modified while being iterated");
150
+ throw new Error("Buffer was modified while being iterated.");
151
151
  }
152
152
  yield this.backingArray[readIndex];
153
153
  readIndex = (readIndex + 1) % this.bufferSize;
@@ -164,19 +164,19 @@ class CircularBuffer extends import_collection.Collection {
164
164
  }
165
165
  /**
166
166
  * yields all items from the buffer, removes them and waits fore more
167
- * @param cancellationToken token to cancel iteration
168
- * @param yieldOutstandingItems whether to yield all outstanding items or exit immdiately when {@link cancellationToken} is set
167
+ * @param cancellationSignal token to cancel iteration
168
+ * @param yieldOutstandingItems whether to yield all outstanding items or exit immdiately when {@link cancellationSignal} is set
169
169
  * @returns
170
170
  */
171
- async *consumeAsync(cancellationToken = new import_cancellation_token.CancellationToken(), yieldOutstandingItems = true) {
171
+ async *consumeAsync(cancellationSignal = new import_token.CancellationToken(), yieldOutstandingItems = true) {
172
172
  while (true) {
173
173
  if (this.isEmpty) {
174
- await (0, import_rxjs.firstValueFrom)((0, import_rxjs.race)([this.onItems$, cancellationToken]));
174
+ await (0, import_rxjs.firstValueFrom)((0, import_rxjs.race)([this.onItems$, cancellationSignal]));
175
175
  }
176
- while (this.size > 0 && (cancellationToken.isUnset || yieldOutstandingItems)) {
176
+ while (this.size > 0 && (cancellationSignal.isUnset || yieldOutstandingItems)) {
177
177
  yield this.tryRemove();
178
178
  }
179
- if (cancellationToken.isSet) {
179
+ if (cancellationSignal.isSet) {
180
180
  return;
181
181
  }
182
182
  }
@@ -198,7 +198,7 @@ class CircularBuffer extends import_collection.Collection {
198
198
  }
199
199
  resize(size) {
200
200
  if (size < this.size) {
201
- throw new Error("buffer has more items than it would have capacity after resize");
201
+ throw new Error("Buffer has more items than it would have capacity after resize.");
202
202
  }
203
203
  let newBackingArray;
204
204
  if (this.size > 0) {
@@ -45,12 +45,12 @@ import_injector.Injector.registerSingleton(import_classes.MongoClient, {
45
45
  const client = new import_classes.MongoClient(url, options);
46
46
  client.on("fullsetup", () => logger.verbose("connection setup")).on("reconnect", () => logger.warn("reconnected")).on("timeout", () => logger.warn("connection timed out")).on("close", () => logger.verbose("connection closed"));
47
47
  context.addDisposeHandler(async () => client.close());
48
- context.context.logger = logger;
49
- context.context.url = url;
48
+ context.data.logger = logger;
49
+ context.data.url = url;
50
50
  return client;
51
51
  },
52
- async afterResolve(client, _argument, context) {
53
- await (0, import_core.connect)(`mongo at ${context.url}`, async () => client.connect(), context.logger);
52
+ async afterResolve(client, _argument, { cancellationSignal, data: { url, logger } }) {
53
+ await (0, import_core.connect)(`mongo at ${url}`, async () => client.connect(), logger, cancellationSignal);
54
54
  }
55
55
  }, {
56
56
  defaultArgumentProvider: () => mongoModuleConfig.defaultConnection,
@@ -71,17 +71,17 @@ import_injector.Injector.registerSingleton(import_classes.Collection, {
71
71
  useFactory: (config, context) => {
72
72
  (0, import_type_guards.assertDefined)(config, "mongo repository config resolve argument missing");
73
73
  const database = context.resolve(import_classes.Database, config);
74
- context.context.database = database;
74
+ context.data.database = database;
75
75
  return database.collection(config.collection);
76
76
  },
77
- async afterResolve(_, config, context) {
78
- const existingCollections = await context.database.collections();
77
+ async afterResolve(_, config, { data: { database } }) {
78
+ const existingCollections = await database.collections();
79
79
  for (const collection of existingCollections) {
80
80
  if (collection.collectionName == config.collection) {
81
81
  return;
82
82
  }
83
83
  }
84
- await context.database.createCollection(config.collection);
84
+ await database.createCollection(config.collection);
85
85
  }
86
86
  }, {
87
87
  argumentIdentityProvider: JSON.stringify
@@ -1,7 +1,6 @@
1
- import type { ReadonlyCancellationToken } from '../utils/cancellation-token.js';
2
- import { CancellationToken } from '../utils/cancellation-token.js';
1
+ import type { CancellationSignal } from '../cancellation/token.js';
2
+ import { CancellationToken } from '../cancellation/token.js';
3
3
  import type { AsyncDisposable, Disposable } from './disposable.js';
4
- import { disposeAsync } from './disposable.js';
5
4
  declare const deferrerToken: unique symbol;
6
5
  export type AsyncDisposeTaskFunction = () => any;
7
6
  export type AsyncDisposeHandler = AsyncDisposeTaskFunction | Disposable | AsyncDisposable;
@@ -12,16 +11,17 @@ export type Deferrer = {
12
11
  [deferrerToken]: CancellationToken;
13
12
  yield(): void;
14
13
  };
15
- export declare class AsyncDisposer implements AsyncDisposable {
16
- private readonly deferrers;
17
- private readonly tasks;
18
- readonly _disposingToken: CancellationToken;
19
- readonly _disposedToken: CancellationToken;
20
- get disposingToken(): ReadonlyCancellationToken;
21
- get disposedToken(): ReadonlyCancellationToken;
14
+ export declare class AsyncDisposer implements AsyncDisposable, AsyncDisposableStack {
15
+ #private;
16
+ get disposingSignal(): CancellationSignal;
17
+ get disposedSignal(): CancellationSignal;
22
18
  get disposing(): boolean;
23
19
  get disposed(): boolean;
20
+ readonly [Symbol.toStringTag] = "AsyncDisposable";
24
21
  constructor();
22
+ use<T extends globalThis.AsyncDisposable | globalThis.Disposable | null | undefined>(value: T): T;
23
+ adopt<T>(value: T, onDisposeAsync: (value: T) => void | PromiseLike<void>): T;
24
+ move(): AsyncDisposableStack;
25
25
  getDeferrer(): Deferrer;
26
26
  defer<T>(func: () => Promise<T>): Promise<T>;
27
27
  /**
@@ -29,7 +29,8 @@ export declare class AsyncDisposer implements AsyncDisposable {
29
29
  * @param fnOrDisposable
30
30
  */
31
31
  add(fnOrDisposable: AsyncDisposeHandler): void;
32
+ disposeAsync(): Promise<void>;
32
33
  dispose(): Promise<void>;
33
- [disposeAsync](): Promise<void>;
34
+ [Symbol.asyncDispose](): Promise<void>;
34
35
  }
35
36
  export {};
@@ -22,42 +22,64 @@ __export(async_disposer_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(async_disposer_exports);
24
24
  var import_type_guards = require("../utils/type-guards.js");
25
+ var import_token = require("../cancellation/token.js");
25
26
  var import_multi_error = require("../error/multi.error.js");
26
- var import_cancellation_token = require("../utils/cancellation-token.js");
27
27
  var import_disposable = require("./disposable.js");
28
28
  const deferrerToken = Symbol("DeferrerToken");
29
29
  class AsyncDisposer {
30
- deferrers;
31
- tasks;
32
- _disposingToken;
33
- _disposedToken;
34
- get disposingToken() {
35
- return this._disposingToken;
30
+ #disposingToken;
31
+ #disposedToken;
32
+ #deferrers;
33
+ #tasks;
34
+ get disposingSignal() {
35
+ return this.#disposingToken;
36
36
  }
37
- get disposedToken() {
38
- return this._disposedToken;
37
+ get disposedSignal() {
38
+ return this.#disposedToken;
39
39
  }
40
40
  get disposing() {
41
- return this._disposingToken.isSet;
41
+ return this.#disposingToken.isSet;
42
42
  }
43
43
  get disposed() {
44
- return this._disposedToken.isSet;
44
+ return this.#disposedToken.isSet;
45
45
  }
46
+ [Symbol.toStringTag] = "AsyncDisposable";
46
47
  constructor() {
47
- this.deferrers = /* @__PURE__ */ new Set();
48
- this.tasks = [];
49
- this._disposingToken = new import_cancellation_token.CancellationToken();
50
- this._disposedToken = new import_cancellation_token.CancellationToken();
48
+ this.#deferrers = /* @__PURE__ */ new Set();
49
+ this.#tasks = [];
50
+ this.#disposingToken = new import_token.CancellationToken();
51
+ this.#disposedToken = new import_token.CancellationToken();
52
+ }
53
+ use(value) {
54
+ if ((0, import_type_guards.isNullOrUndefined)(value)) {
55
+ return value;
56
+ }
57
+ this.add(value);
58
+ return value;
59
+ }
60
+ adopt(value, onDisposeAsync) {
61
+ this.add(async () => onDisposeAsync(value));
62
+ return value;
63
+ }
64
+ move() {
65
+ const disposer = new AsyncDisposer();
66
+ disposer.#tasks = this.#tasks;
67
+ disposer.#deferrers = this.#deferrers;
68
+ this.#tasks = [];
69
+ this.#deferrers = /* @__PURE__ */ new Set();
70
+ this.#disposingToken.set();
71
+ this.#disposedToken.set();
72
+ return disposer;
51
73
  }
52
74
  getDeferrer() {
53
75
  const deferrer = {
54
- [deferrerToken]: new import_cancellation_token.CancellationToken(),
76
+ [deferrerToken]: new import_token.CancellationToken(),
55
77
  yield: () => {
56
78
  deferrer[deferrerToken].set();
57
- this.deferrers.delete(deferrer);
79
+ this.#deferrers.delete(deferrer);
58
80
  }
59
81
  };
60
- this.deferrers.add(deferrer);
82
+ this.#deferrers.add(deferrer);
61
83
  return deferrer;
62
84
  }
63
85
  async defer(func) {
@@ -75,24 +97,27 @@ class AsyncDisposer {
75
97
  */
76
98
  add(fnOrDisposable) {
77
99
  const fn = (0, import_disposable.isAsyncDisposable)(fnOrDisposable) ? async () => fnOrDisposable[import_disposable.disposeAsync]() : (0, import_disposable.isDisposable)(fnOrDisposable) ? () => fnOrDisposable[import_disposable.dispose]() : fnOrDisposable;
78
- this.tasks.push({ taskFunction: fn });
100
+ this.#tasks.push({ taskFunction: fn });
101
+ }
102
+ async disposeAsync() {
103
+ await this.dispose();
79
104
  }
80
105
  async dispose() {
81
106
  if (this.disposing) {
82
- return this._disposedToken.$set;
107
+ return this.#disposedToken.$set;
83
108
  }
84
- this._disposingToken.set();
109
+ this.#disposingToken.set();
85
110
  const errors = [];
86
- for (const deferrer of this.deferrers) {
111
+ for (const deferrer of this.#deferrers) {
87
112
  try {
88
113
  await deferrer[deferrerToken];
89
114
  } catch (error2) {
90
115
  errors.push(error2);
91
116
  }
92
117
  }
93
- for (let i = this.tasks.length - 1; i >= 0; i--) {
118
+ for (let i = this.#tasks.length - 1; i >= 0; i--) {
94
119
  try {
95
- const task = this.tasks[i];
120
+ const task = this.#tasks[i];
96
121
  await task.taskFunction();
97
122
  } catch (error2) {
98
123
  errors.push(error2);
@@ -100,12 +125,13 @@ class AsyncDisposer {
100
125
  }
101
126
  const error = errors.length == 1 ? errors[0] : errors.length > 1 ? new import_multi_error.MultiError(errors, "dispose errors") : void 0;
102
127
  if ((0, import_type_guards.isDefined)(error)) {
103
- this._disposedToken.error(error);
128
+ this.#disposedToken.error(error);
104
129
  throw error;
105
130
  }
106
- this._disposedToken.set();
131
+ this.#disposedToken.set();
132
+ return void 0;
107
133
  }
108
- async [import_disposable.disposeAsync]() {
134
+ async [Symbol.asyncDispose]() {
109
135
  return this.dispose();
110
136
  }
111
137
  }
@@ -1,10 +1,11 @@
1
- export declare const dispose: unique symbol;
2
- export declare const disposeAsync: unique symbol;
1
+ export declare const dispose: typeof Symbol.dispose;
2
+ export declare const disposeAsync: typeof Symbol.asyncDispose;
3
3
  export interface Disposable {
4
- [dispose](): void;
4
+ [Symbol.dispose](): void;
5
5
  }
6
6
  export interface AsyncDisposable {
7
- [disposeAsync](): Promise<void>;
7
+ [Symbol.asyncDispose](): PromiseLike<void>;
8
8
  }
9
9
  export declare function isDisposable(object: any): object is Disposable;
10
10
  export declare function isAsyncDisposable(object: any): object is AsyncDisposable;
11
+ export declare function isSyncOrAsyncDisposable(object: any): object is Disposable | AsyncDisposable;
@@ -21,15 +21,19 @@ __export(disposable_exports, {
21
21
  dispose: () => dispose,
22
22
  disposeAsync: () => disposeAsync,
23
23
  isAsyncDisposable: () => isAsyncDisposable,
24
- isDisposable: () => isDisposable
24
+ isDisposable: () => isDisposable,
25
+ isSyncOrAsyncDisposable: () => isSyncOrAsyncDisposable
25
26
  });
26
27
  module.exports = __toCommonJS(disposable_exports);
27
28
  var import_type_guards = require("../utils/type-guards.js");
28
- const dispose = Symbol("dispose");
29
- const disposeAsync = Symbol("disposeAsync");
29
+ const dispose = Symbol.dispose;
30
+ const disposeAsync = Symbol.asyncDispose;
30
31
  function isDisposable(object) {
31
- return (0, import_type_guards.isFunction)(object?.[dispose]);
32
+ return (0, import_type_guards.isFunction)(object?.[Symbol.dispose]);
32
33
  }
33
34
  function isAsyncDisposable(object) {
34
- return (0, import_type_guards.isFunction)(object?.[disposeAsync]);
35
+ return (0, import_type_guards.isFunction)(object?.[Symbol.asyncDispose]);
36
+ }
37
+ function isSyncOrAsyncDisposable(object) {
38
+ return (0, import_type_guards.isFunction)(object?.[Symbol.dispose] ?? object?.[Symbol.asyncDispose]);
35
39
  }
@@ -1,7 +1,7 @@
1
+ import type { CancellationSignal } from '../cancellation/index.js';
1
2
  import { resolveArgumentType } from '../injector/index.js';
2
3
  import type { Resolvable } from '../injector/interfaces.js';
3
4
  import { LockProvider } from '../lock/index.js';
4
- import type { ReadonlyCancellationToken } from '../utils/cancellation-token.js';
5
5
  import type { LoopController } from './controller.js';
6
6
  export type LoopFunction = (controller: LoopController) => any | Promise<any>;
7
7
  /** loop key */
@@ -22,11 +22,11 @@ export declare class DistributedLoop implements Resolvable<DistributedLoopArgume
22
22
  constructor(key: string, lockProvider: LockProvider);
23
23
  /**
24
24
  * run the function {@link func} every {@link interval} milliseconds with an accuracy of {@link accuracy}
25
- * until {@link cancellationToken} is set or stop on the {@link LoopController} is called
25
+ * until {@link cancellationSignal} is set or stop on the {@link LoopController} is called
26
26
  * @param interval in millseconds
27
27
  * @param accuracy in millseconds
28
28
  * @param func handler to run
29
- * @param cancellationToken token to cancel loop (same as calling stop on the {@link LoopController})
29
+ * @param cancellationSignal token to cancel loop (same as calling stop on the {@link LoopController})
30
30
  */
31
- run(interval: number, accuracy: number, func: LoopFunction, cancellationToken?: ReadonlyCancellationToken): LoopController;
31
+ run(interval: number, accuracy: number, func: LoopFunction, cancellationSignal?: CancellationSignal): LoopController;
32
32
  }
@@ -21,10 +21,10 @@ __export(distributed_loop_exports, {
21
21
  DistributedLoop: () => DistributedLoop
22
22
  });
23
23
  module.exports = __toCommonJS(distributed_loop_exports);
24
+ var import_cancellation = require("../cancellation/index.js");
24
25
  var import_injector = require("../injector/index.js");
25
26
  var import_lock = require("../lock/index.js");
26
27
  var import_deferred_promise = require("../promise/deferred-promise.js");
27
- var import_cancellation_token = require("../utils/cancellation-token.js");
28
28
  var import_timer = require("../utils/timer.js");
29
29
  var import_timing = require("../utils/timing.js");
30
30
  var __decorate = function(decorators, target, key, desc) {
@@ -64,15 +64,15 @@ let DistributedLoop = class DistributedLoop2 {
64
64
  }
65
65
  /**
66
66
  * run the function {@link func} every {@link interval} milliseconds with an accuracy of {@link accuracy}
67
- * until {@link cancellationToken} is set or stop on the {@link LoopController} is called
67
+ * until {@link cancellationSignal} is set or stop on the {@link LoopController} is called
68
68
  * @param interval in millseconds
69
69
  * @param accuracy in millseconds
70
70
  * @param func handler to run
71
- * @param cancellationToken token to cancel loop (same as calling stop on the {@link LoopController})
71
+ * @param cancellationSignal token to cancel loop (same as calling stop on the {@link LoopController})
72
72
  */
73
- run(interval, accuracy, func, cancellationToken) {
73
+ run(interval, accuracy, func, cancellationSignal) {
74
74
  const $stopped = new import_deferred_promise.DeferredPromise();
75
- const stopToken = cancellationToken?.createChild() ?? new import_cancellation_token.CancellationToken();
75
+ const stopToken = cancellationSignal?.createChild() ?? new import_cancellation.CancellationToken();
76
76
  const stopFunction = async () => {
77
77
  if (!stopToken.isSet) {
78
78
  stopToken.set();
@@ -83,7 +83,7 @@ let DistributedLoop = class DistributedLoop2 {
83
83
  stop: stopFunction,
84
84
  $stopped
85
85
  };
86
- (async () => {
86
+ void (async () => {
87
87
  const lock = this.lockProvider.get(this.key);
88
88
  const timer = new import_timer.Timer();
89
89
  try {
@@ -1,5 +1,5 @@
1
+ import type { CancellationSignal } from '../cancellation/token.js';
1
2
  import type { AnyIterable } from '../utils/any-iterable-iterator.js';
2
- import type { ReadonlyCancellationToken } from '../utils/cancellation-token.js';
3
3
  import type { AsyncComparator } from '../utils/sort.js';
4
4
  import type { Observable } from 'rxjs';
5
5
  import type { AsyncIteratorFunction, AsyncPredicate, AsyncReducer, AsyncRetryPredicate, ParallelizableIteratorFunction, ParallelizablePredicate, ThrottleFunction } from '../utils/async-iterable-helpers/index.js';
@@ -56,7 +56,7 @@ export declare class AsyncEnumerable<T> implements EnumerableMethods, AsyncItera
56
56
  sort(comparator?: AsyncComparator<T>): AsyncEnumerable<T>;
57
57
  sortToArray(comparator?: AsyncComparator<T>): Promise<T[]>;
58
58
  take(count: number): AsyncEnumerable<T>;
59
- takeUntil(cancellationToken: ReadonlyCancellationToken): AsyncEnumerable<T>;
59
+ takeUntil(cancellationSignal: CancellationSignal): AsyncEnumerable<T>;
60
60
  takeWhile(yieldLastOnFalse: boolean, predicate: AsyncPredicate<T>): AsyncEnumerable<T>;
61
61
  throttle(delayOrThrottleFunction: number | ThrottleFunction): AsyncEnumerable<T>;
62
62
  toArray(): Promise<T[]>;
@@ -198,8 +198,8 @@ class AsyncEnumerable {
198
198
  const taken = (0, import_async_iterable_helpers.takeAsync)(this.source, count);
199
199
  return new AsyncEnumerable(taken);
200
200
  }
201
- takeUntil(cancellationToken) {
202
- const taken = (0, import_async_iterable_helpers.takeUntilAsync)(this.source, cancellationToken);
201
+ takeUntil(cancellationSignal) {
202
+ const taken = (0, import_async_iterable_helpers.takeUntilAsync)(this.source, cancellationSignal);
203
203
  return new AsyncEnumerable(taken);
204
204
  }
205
205
  takeWhile(yieldLastOnFalse, predicate) {
@@ -1,5 +1,5 @@
1
+ import type { CancellationSignal } from '../cancellation/token.js';
1
2
  import type { Comparator } from '../utils/sort.js';
2
- import type { ReadonlyCancellationToken } from '../utils/cancellation-token.js';
3
3
  import type { IterableItemMetadata, IteratorFunction, Predicate, Reducer, TypePredicate } from '../utils/iterable-helpers/index.js';
4
4
  import { AsyncEnumerable } from './async-enumerable.js';
5
5
  import type { EnumerableMethods } from './enumerable-methods.js';
@@ -47,7 +47,7 @@ export declare class Enumerable<T> implements EnumerableMethods, Iterable<T> {
47
47
  sort(comparator?: Comparator<T>): Enumerable<T>;
48
48
  sortToArray(comparator?: Comparator<T>): T[];
49
49
  take(count: number): Enumerable<T>;
50
- takeUntil(cancellationToken: ReadonlyCancellationToken): Enumerable<T>;
50
+ takeUntil(cancellationSignal: CancellationSignal): Enumerable<T>;
51
51
  takeWhile(yieldLastOnFalse: boolean, predicate: Predicate<T>): Enumerable<T>;
52
52
  toArray(): T[];
53
53
  toAsync(): AsyncEnumerable<T>;
@@ -169,8 +169,8 @@ class Enumerable {
169
169
  const taken = (0, import_iterable_helpers.take)(this.source, count);
170
170
  return new Enumerable(taken);
171
171
  }
172
- takeUntil(cancellationToken) {
173
- const taken = (0, import_iterable_helpers.takeUntil)(this.source, cancellationToken);
172
+ takeUntil(cancellationSignal) {
173
+ const taken = (0, import_iterable_helpers.takeUntil)(this.source, cancellationSignal);
174
174
  return new Enumerable(taken);
175
175
  }
176
176
  takeWhile(yieldLastOnFalse, predicate) {
@@ -27,7 +27,7 @@ var __decorate = function(decorators, target, key, desc) {
27
27
  return c > 3 && r && Object.defineProperty(target, key, r), r;
28
28
  };
29
29
  (0, import_core.configureTstdl)();
30
- const logger = import_core.rootInjector.resolve(import_core.CORE_LOGGER);
30
+ const logger = (0, import_core.getGlobalInjector)().resolve(import_core.CORE_LOGGER);
31
31
  const streamingApiDefinition = (0, import_api.defineApi)({
32
32
  resource: "streams",
33
33
  endpoints: {
@@ -69,10 +69,10 @@ StreamingApi = __decorate([
69
69
  ], StreamingApi);
70
70
  async function* counter() {
71
71
  let currentNumber = 0;
72
- while (import_application.Application.shutdownToken.isUnset && currentNumber < 10) {
72
+ while (import_application.Application.shutdownSignal.isUnset && currentNumber < 10) {
73
73
  yield `${++currentNumber}`.toString();
74
74
  logger.info(`yield: "${currentNumber}"`);
75
- await (0, import_timing.cancelableTimeout)(1e3, import_application.Application.shutdownToken);
75
+ await (0, import_timing.cancelableTimeout)(1e3, import_application.Application.shutdownSignal);
76
76
  }
77
77
  }
78
78
  const StreamingApiClient = (0, import_client.compileClient)(streamingApiDefinition);
@@ -83,7 +83,7 @@ let UndiciHttpClientAdapter = class UndiciHttpClientAdapter2 extends import_http
83
83
  try {
84
84
  const response = await (0, import_undici.request)(httpClientRequest.url, {
85
85
  method: httpClientRequest.method,
86
- signal: httpClientRequest.abortToken.asAbortSignal(),
86
+ signal: httpClientRequest.abortSignal.asAbortSignal(),
87
87
  headers: httpClientRequest.headers.asNormalizedObject(),
88
88
  body,
89
89
  headersTimeout: httpClientRequest.timeout,
@@ -1,7 +1,7 @@
1
+ import type { CancellationSignal } from '../../cancellation/index.js';
1
2
  import type { Disposable } from '../../disposable/index.js';
2
3
  import { dispose } from '../../disposable/index.js';
3
4
  import type { Record, TypedOmit, UndefinableJson, UndefinableJsonObject } from '../../types.js';
4
- import type { ReadonlyCancellationToken } from '../../utils/cancellation-token.js';
5
5
  import type { HttpFormObject } from '../http-form.js';
6
6
  import { HttpForm } from '../http-form.js';
7
7
  import type { HttpHeadersObject } from '../http-headers.js';
@@ -28,7 +28,7 @@ export type HttpRequestAuthorization = {
28
28
  bearer?: string;
29
29
  token?: string;
30
30
  };
31
- export type HttpClientRequestOptions = Partial<TypedOmit<HttpClientRequest, 'url' | 'method' | 'abortToken' | 'abort' | 'headers' | 'query' | 'body'>> & {
31
+ export type HttpClientRequestOptions = Partial<TypedOmit<HttpClientRequest, 'url' | 'method' | 'abortSignal' | 'abort' | 'headers' | 'query' | 'body'>> & {
32
32
  urlParameter?: HttpUrlParametersObject | HttpUrlParameters;
33
33
  headers?: HttpHeadersObject | HttpHeaders;
34
34
  query?: HttpQueryObject | HttpQuery;
@@ -41,7 +41,7 @@ export type HttpClientRequestOptions = Partial<TypedOmit<HttpClientRequest, 'url
41
41
  buffer?: Uint8Array;
42
42
  stream?: ReadableStream<Uint8Array>;
43
43
  };
44
- abortToken?: ReadonlyCancellationToken;
44
+ abortSignal?: CancellationSignal;
45
45
  };
46
46
  export type HttpRequestCredentials = 'omit' | 'same-origin' | 'include';
47
47
  export type HttpClientRequestObject = HttpClientRequestOptions & {
@@ -49,7 +49,7 @@ export type HttpClientRequestObject = HttpClientRequestOptions & {
49
49
  method?: HttpMethod;
50
50
  };
51
51
  export declare class HttpClientRequest implements Disposable {
52
- private readonly _abortToken;
52
+ #private;
53
53
  url: string;
54
54
  method: HttpMethod;
55
55
  headers: HttpHeaders;
@@ -118,7 +118,7 @@ export declare class HttpClientRequest implements Disposable {
118
118
  /**
119
119
  * can be used to cancel the request. Throws HttpError
120
120
  */
121
- get abortToken(): ReadonlyCancellationToken;
121
+ get abortSignal(): CancellationSignal;
122
122
  constructor(url: string, method?: HttpMethod, options?: HttpClientRequestOptions);
123
123
  constructor(requestObject: HttpClientRequestObject);
124
124
  [dispose](): void;
@@ -21,8 +21,8 @@ __export(http_client_request_exports, {
21
21
  HttpClientRequest: () => HttpClientRequest
22
22
  });
23
23
  module.exports = __toCommonJS(http_client_request_exports);
24
+ var import_cancellation = require("../../cancellation/index.js");
24
25
  var import_disposable = require("../../disposable/index.js");
25
- var import_cancellation_token = require("../../utils/cancellation-token.js");
26
26
  var import_clone = require("../../utils/clone.js");
27
27
  var import_type_guards = require("../../utils/type-guards.js");
28
28
  var import_http_form = require("../http-form.js");
@@ -30,7 +30,7 @@ var import_http_headers = require("../http-headers.js");
30
30
  var import_http_query = require("../http-query.js");
31
31
  var import_http_url_parameters = require("../http-url-parameters.js");
32
32
  class HttpClientRequest {
33
- _abortToken;
33
+ #abortToken;
34
34
  url;
35
35
  method;
36
36
  headers;
@@ -99,8 +99,8 @@ class HttpClientRequest {
99
99
  /**
100
100
  * can be used to cancel the request. Throws HttpError
101
101
  */
102
- get abortToken() {
103
- return this._abortToken.asReadonly();
102
+ get abortSignal() {
103
+ return this.#abortToken.signal;
104
104
  }
105
105
  constructor(urlOrObject, method, options = {}) {
106
106
  if ((0, import_type_guards.isString)(urlOrObject)) {
@@ -126,16 +126,16 @@ class HttpClientRequest {
126
126
  this.timeout = requestOptions.timeout ?? 3e4;
127
127
  this.throwOnNon200 = requestOptions.throwOnNon200 ?? true;
128
128
  this.context = requestOptions.context ?? {};
129
- this._abortToken = requestOptions.abortToken?.createChild() ?? new import_cancellation_token.CancellationToken();
129
+ this.#abortToken = requestOptions.abortSignal?.createChild() ?? new import_cancellation.CancellationToken();
130
130
  }
131
131
  [import_disposable.dispose]() {
132
- this._abortToken.set();
133
- this._abortToken.complete();
132
+ this.#abortToken.set();
133
+ this.#abortToken.complete();
134
134
  }
135
135
  /** abort the request */
136
136
  abort() {
137
- this._abortToken.set();
138
- this._abortToken.complete();
137
+ this.#abortToken.set();
138
+ this.#abortToken.complete();
139
139
  }
140
140
  clone() {
141
141
  const request = new HttpClientRequest(this);
@@ -32,12 +32,12 @@ __export(node_http_server_exports, {
32
32
  });
33
33
  module.exports = __toCommonJS(node_http_server_exports);
34
34
  var Http = __toESM(require("node:http"), 1);
35
+ var import_cancellation = require("../../../cancellation/index.js");
35
36
  var import_disposable = require("../../../disposable/index.js");
36
37
  var import_http_headers = require("../../../http/http-headers.js");
37
38
  var import_http_query = require("../../../http/http-query.js");
38
39
  var import_injector = require("../../../injector/index.js");
39
40
  var import_logger = require("../../../logger/index.js");
40
- var import_cancellation_token = require("../../../utils/cancellation-token.js");
41
41
  var import_encoding = require("../../../utils/encoding.js");
42
42
  var import_feedable_async_iterable = require("../../../utils/feedable-async-iterable.js");
43
43
  var import_readable_stream_adapter = require("../../../utils/stream/readable-stream-adapter.js");
@@ -129,7 +129,7 @@ let NodeHttpServer = class NodeHttpServer2 extends import_http_server.HttpServer
129
129
  }
130
130
  if (connections > 0) {
131
131
  this.logger.info(`Waiting for ${connections} connections to end`);
132
- await (0, import_timing.cancelableTimeout)(250, import_cancellation_token.CancellationToken.from(close$));
132
+ await (0, import_timing.cancelableTimeout)(250, import_cancellation.CancellationToken.from(close$));
133
133
  }
134
134
  }
135
135
  this.untrackConnectedSockets?.();