@tstdl/base 0.93.24 → 0.93.25

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.
@@ -38,7 +38,6 @@ export declare class Injector implements AsyncDisposable {
38
38
  #private;
39
39
  readonly id: number;
40
40
  readonly name: string;
41
- readonly nameWithId: string;
42
41
  get disposed(): boolean;
43
42
  constructor(name: string, parent?: Injector | null);
44
43
  /**
@@ -31,13 +31,11 @@ export class Injector {
31
31
  #addDisposeHandler;
32
32
  id = _id++;
33
33
  name;
34
- nameWithId;
35
34
  get disposed() {
36
35
  return this.#disposableStack.disposed;
37
36
  }
38
37
  constructor(name, parent = null) {
39
38
  this.name = name;
40
- this.nameWithId = `${name}#${this.id}`;
41
39
  this.#parent = parent;
42
40
  this.register(Injector, { useValue: this });
43
41
  this.register(CancellationSignal, { useValue: this.#disposeToken.signal });
@@ -322,22 +320,18 @@ export class Injector {
322
320
  if (isUndefined(token)) {
323
321
  throw new ResolveError('Token is undefined. This might be due to a circular dependency. Consider using an alias or forwardRef.', chain);
324
322
  }
325
- const ownValues = [];
326
- const parentValues = [];
327
- const registration = this.tryGetRegistration(token, options);
323
+ const registration = this.tryGetRegistration(token);
328
324
  if (isDefined(registration)) {
329
325
  const registrations = isArray(registration) ? registration : [registration];
330
- const resolved = registrations.map((reg) => this._resolveRegistration(reg, argument, options, context, chain));
331
- ownValues.push(...resolved);
326
+ return registrations.map((reg) => this._resolveRegistration(reg, argument, options, context, chain));
332
327
  }
333
328
  if ((options.onlySelf != true) && isNotNull(this.#parent)) {
334
- parentValues.push(...this.#parent._resolveAll(token, argument, options, context, chain));
329
+ return this.#parent._resolveAll(token, argument, { ...options, skipSelf: false }, context, chain);
335
330
  }
336
- const allValues = [...ownValues, ...parentValues];
337
- if ((allValues.length == 0) && (options.optional != true)) {
338
- throw new ResolveError(`No provider for ${getTokenName(token)} registered.`, chain);
331
+ if (options.optional == true) {
332
+ return [];
339
333
  }
340
- return allValues;
334
+ throw new ResolveError(`No provider for ${getTokenName(token)} registered.`, chain);
341
335
  }
342
336
  _resolveRegistration(registration, argument, options, context, chain) {
343
337
  checkOverflow(chain, context);
@@ -362,7 +356,7 @@ export class Injector {
362
356
  }
363
357
  // A new scope is only needed if we are instantiating a class, running a factory, or if the registration explicitly defines scoped providers.
364
358
  const needsNewScope = isClassProvider(provider) || isFactoryProvider(provider) || (providers.length > 0);
365
- const injector = needsNewScope ? this.fork(`[${getTokenName(token)}]ResolutionInjector`) : this;
359
+ const injector = needsNewScope ? this.fork(`[${getTokenName(token)}]Injector`) : this;
366
360
  for (const nestedProvider of providers) {
367
361
  injector.registerSingleton(nestedProvider.provide, nestedProvider, { multi: nestedProvider.multi });
368
362
  }
@@ -1,6 +1,5 @@
1
1
  import { reflectionRegistry } from '../reflection/index.js';
2
2
  import { assertDefinedPass, isDefined } from '../utils/type-guards.js';
3
- import { start } from 'repl';
4
3
  import { getTokenName } from './token.js';
5
4
  export class ResolveChain {
6
5
  nodes;
@@ -42,13 +41,13 @@ export class ResolveChain {
42
41
  if (chain.length < this.length) {
43
42
  chainString += '\n [...]';
44
43
  }
45
- const longestInjectorName = Math.max(...chain.nodes.map((node) => (node.type == 'ellipsis') ? 0 : node.injector.nameWithId.length));
44
+ const longestInjectorName = Math.max(...chain.nodes.map((node) => (node.type == 'ellipsis') ? 0 : `${node.injector.name}#${node.injector.id}`.length));
46
45
  for (const node of chain.nodes) {
47
46
  if (node.type == 'ellipsis') {
48
47
  chainString += `\n ${'[...]'.padStart(longestInjectorName)}`;
49
48
  continue;
50
49
  }
51
- const paddedInjectorName = node.injector.name.padStart(longestInjectorName);
50
+ const paddedInjectorName = `${node.injector.name}#${node.injector.id}`.padStart(longestInjectorName);
52
51
  const tokenName = getTokenName(node.token);
53
52
  const forwardRefPrefix = node.forwardRef ? 'ForwardRef::' : '';
54
53
  switch (node.type) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.93.24",
3
+ "version": "0.93.25",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"