@lppedd/di-wise-neo 0.9.3 → 0.9.4

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/es/index.mjs CHANGED
@@ -23,8 +23,8 @@ function throwExistingUnregisteredError(token, cause) {
23
23
  // @internal
24
24
  function throwParameterResolutionError(ctor, methodKey, dependency, cause) {
25
25
  const location = getLocation(ctor, methodKey);
26
- const token = dependency.tokenRef.getRefToken();
27
- const message = tag(`failed to resolve dependency for ${location}(parameter #${dependency.index}: ${token.name})`);
26
+ const tokenName = getTokenName(dependency.tokenRef.getRefToken());
27
+ const message = tag(`failed to resolve dependency for ${location}(parameter #${dependency.index}: ${tokenName})`);
28
28
  throw new Error(`${message}\n [cause] ${untag(cause.message)}`, {
29
29
  cause
30
30
  });
@@ -373,11 +373,14 @@ class TokenRegistry {
373
373
  set(token, registration) {
374
374
  check(!internals.has(token), `cannot register reserved token ${token.name}`);
375
375
  let registrations = this.myMap.get(token);
376
- if (!registrations) {
376
+ if (registrations) {
377
+ const name = registration.name;
378
+ if (name !== undefined) {
379
+ const existing = registrations.filter((r)=>r.name === name);
380
+ check(existing.length === 0, `token ${getTokenName(token)} with name '${name}' is already registered`);
381
+ }
382
+ } else {
377
383
  this.myMap.set(token, registrations = []);
378
- } else if (registration.name !== undefined) {
379
- const existing = registrations.filter((r)=>r.name === registration.name);
380
- check(existing.length === 0, `a ${token.name} token named '${registration.name}' is already registered`);
381
384
  }
382
385
  registrations.push(registration);
383
386
  }
@@ -592,7 +595,7 @@ function isDisposable(value) {
592
595
  }
593
596
  } else {
594
597
  if (existingProvider) {
595
- check(token !== provider.useExisting, `the useExisting token ${token.name} cannot be the same as the token being registered`);
598
+ check(token !== provider.useExisting, `token ${getTokenName(token)} cannot alias itself via useExisting`);
596
599
  }
597
600
  this.myTokenRegistry.set(token, {
598
601
  name: name,
@@ -743,8 +746,8 @@ function isDisposable(value) {
743
746
  if (resolution.stack.has(provider)) {
744
747
  const dependentRef = resolution.dependents.get(provider);
745
748
  check(dependentRef, ()=>{
746
- const path = resolution.tokenStack.map((t)=>t.name).join(" → ");
747
- return `circular dependency detected while resolving ${path} → ${token.name}`;
749
+ const path = resolution.tokenStack.map(getTokenName).join(" → ");
750
+ return `circular dependency detected while resolving ${path} → ${getTokenName(token)}`;
748
751
  });
749
752
  return dependentRef.current;
750
753
  }