@tstdl/base 0.90.33 → 0.90.34

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/.eslintrc.json CHANGED
@@ -86,7 +86,6 @@
86
86
  "capitalized-comments": "off",
87
87
  "class-methods-use-this": "off",
88
88
  "complexity": "off",
89
- "consistent-return": ["error", { "treatUndefinedAsUnspecified": true }],
90
89
  "dot-location": ["error", "property"],
91
90
  "eqeqeq": "off",
92
91
  "func-style": ["error", "declaration", { "allowArrowFunctions": true }],
@@ -1 +1 @@
1
- export {};
1
+ import '../../polyfills.js';
@@ -5,6 +5,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
7
  /* eslint-disable max-classes-per-file */
8
+ import '../../polyfills.js';
8
9
  import { compileClient } from '../../api/client/client.js';
9
10
  import { defineApi } from '../../api/index.js';
10
11
  import { apiController, configureApiServer } from '../../api/server/index.js';
@@ -194,17 +194,15 @@ HttpClient = __decorate([
194
194
  export { HttpClient };
195
195
  function getBuildRequestUrlMiddleware(baseUrl) {
196
196
  async function buildUrlParametersMiddleware({ request }, next) {
197
- if (!request.mapParameters) {
198
- return next();
197
+ if (request.mapParameters) {
198
+ mapParameters(request, baseUrl);
199
199
  }
200
- mapParameters(request, baseUrl);
201
200
  return next();
202
201
  }
203
202
  return buildUrlParametersMiddleware;
204
203
  }
205
204
  function getAddRequestHeadersMiddleware(defaultHeaders) {
206
205
  async function addRequestHeadersMiddleware({ request }, next) {
207
- await next();
208
206
  const { body, authorization } = request;
209
207
  for (const [key, value] of defaultHeaders) {
210
208
  request.headers.setIfMissing(key, value);
@@ -238,6 +236,7 @@ function getAddRequestHeadersMiddleware(defaultHeaders) {
238
236
  request.headers.authorization = `Token ${authorization.token}`;
239
237
  }
240
238
  }
239
+ return next();
241
240
  }
242
241
  return addRequestHeadersMiddleware;
243
242
  }
@@ -47,8 +47,10 @@ let NodeHttpServer = class NodeHttpServer extends HttpServer {
47
47
  });
48
48
  }
49
49
  async [disposeAsync]() {
50
- await this.close(3000);
51
- this.requestIterable.end();
50
+ if (this.httpServer.listening) {
51
+ await this.close(3000);
52
+ this.requestIterable.end();
53
+ }
52
54
  }
53
55
  async listen(port) {
54
56
  if (this.httpServer.listening) {
@@ -1,7 +1,7 @@
1
1
  import { CancellationSignal, CancellationToken } from '../cancellation/index.js';
2
2
  import { CircularBuffer } from '../data-structures/circular-buffer.js';
3
3
  import { MultiKeyMap } from '../data-structures/multi-key-map.js';
4
- import { isAsyncDisposable, isDisposable, isSyncOrAsyncDisposable } from '../disposable/disposable.js';
4
+ import { isSyncOrAsyncDisposable } from '../disposable/disposable.js';
5
5
  import { DeferredPromise } from '../promise/deferred-promise.js';
6
6
  import { reflectionRegistry } from '../reflection/registry.js';
7
7
  import { toArray } from '../utils/array/array.js';
@@ -22,6 +22,7 @@ export class Injector {
22
22
  #children = [];
23
23
  #disposeToken = new CancellationToken();
24
24
  #disposableStack = new AsyncDisposableStack();
25
+ #disposableStackRegistrations = new Set();
25
26
  #registrations = new Map();
26
27
  #injectorScopedResolutions = new MultiKeyMap();
27
28
  #addDisposeHandler;
@@ -44,6 +45,7 @@ export class Injector {
44
45
  };
45
46
  this.#disposableStack.defer(() => this.#registrations.clear());
46
47
  this.#disposableStack.defer(() => this.#injectorScopedResolutions.clear());
48
+ this.#disposableStack.defer(() => this.#disposableStackRegistrations.clear());
47
49
  }
48
50
  /**
49
51
  * Globally register a provider for a token
@@ -323,8 +325,9 @@ export class Injector {
323
325
  if (isUndefined(result)) {
324
326
  throw new Error('Unsupported provider.');
325
327
  }
326
- if (isDisposable(result.value) || isAsyncDisposable(result.value)) {
328
+ if (isSyncOrAsyncDisposable(result.value) && !this.#disposableStackRegistrations.has(result.value)) {
327
329
  this.#disposableStack.use(result.value);
330
+ this.#disposableStackRegistrations.add(result.value);
328
331
  }
329
332
  return result.value;
330
333
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.90.33",
3
+ "version": "0.90.34",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"