assemblerjs 1.1.6 → 1.1.7

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/index31.js CHANGED
@@ -5,18 +5,44 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
5
5
  const hookManager = require('./index33.js');
6
6
  const resolutionStrategies = require('./index43.js');
7
7
  const debugLogger = require('./index36.js');
8
+ const core = require('@assemblerjs/core');
8
9
  const use = require('./index42.js');
9
10
  const inject = require('./index41.js');
10
11
  const injectable = require('./index44.js');
11
12
 
13
+ function c(e) {
14
+ if (e?.name) return e.name;
15
+ if (typeof e === 'string') return e;
16
+ if (typeof e === 'symbol') return e.toString();
17
+ if (typeof e === 'number') return String(e);
18
+ if (typeof e === 'boolean') return String(e);
19
+ if (typeof e === 'object' && e !== null) {
20
+ try {
21
+ const t = JSON.stringify(e);
22
+ if (t.length > 100) {
23
+ return t.substring(0, 100) + '...';
24
+ }
25
+ return t;
26
+ } catch {
27
+ return `[${e.constructor?.name || 'Object'}]`;
28
+ }
29
+ }
30
+ return String(e);
31
+ }
32
+ function l(e) {
33
+ if (core.isClass(e)) return 'class';
34
+ if (typeof e === 'string') return 'string';
35
+ if (typeof e === 'symbol') return 'symbol';
36
+ return 'unknown';
37
+ }
12
38
  class InjectableManager {
13
39
  setContexts(e, t) {
14
40
  this.privateContext = e;
15
41
  this.publicContext = t;
16
42
  }
17
- register(n, s = false) {
43
+ register(i, s = false) {
18
44
  const a = debugLogger.DebugLogger.getInstance();
19
- const c = s === true ? use.resolveInstanceInjectionTuple(n) : inject.resolveInjectionTuple(n);
45
+ const c = s === true ? use.resolveInstanceInjectionTuple(i) : inject.resolveInjectionTuple(i);
20
46
  if (this.has(c.identifier)) {
21
47
  const e = `An assemblage is already registered with identifier '${c.identifier.name}'.`;
22
48
  a.log('error', 'Duplicate registration', {
@@ -36,28 +62,31 @@ class InjectableManager {
36
62
  has(e) {
37
63
  return this.injectables.has(e);
38
64
  }
39
- require(e, t, i) {
65
+ require(e, t, r) {
40
66
  if (!this.injectables.has(e)) {
41
67
  const t = this.resolvingStack.has(e);
42
- const r = t ? 'Circular dependency detected' : 'Dependency not registered';
43
- const n = t ? `Circular dependency detected: '${e.name}' is already being resolved.` : `Class with identifier '${e.name}' has not been registered.`;
44
- debugLogger.DebugLogger.getInstance().log('error', r, {
45
- identifier: e.name,
46
- caller: i ? i?.name || String(i) : 'unknown',
47
- error: n
68
+ const n = t ? 'Circular dependency detected' : 'Dependency not registered';
69
+ const i = c(e);
70
+ const s = l(e);
71
+ const a = t ? `Circular dependency detected: '${i}' is already being resolved.` : `Dependency '${i}' has not been registered (Class/Service not found in current assemblies).`;
72
+ debugLogger.DebugLogger.getInstance().log('error', n, {
73
+ identifier: i,
74
+ caller: r ? c(r) : 'unknown',
75
+ type: s,
76
+ error: a
48
77
  });
49
- throw new Error(n);
78
+ throw new Error(a);
50
79
  }
51
- const r = this.injectables.get(e);
52
- this.resolvingStack.add(r.identifier);
80
+ const n = this.injectables.get(e);
81
+ this.resolvingStack.add(n.identifier);
53
82
  try {
54
- if (r.isSingleton) {
55
- return this.singletonStrategy.resolve(r, t);
83
+ if (n.isSingleton) {
84
+ return this.singletonStrategy.resolve(n, t);
56
85
  } else {
57
- return this.transientStrategy.resolve(r, t);
86
+ return this.transientStrategy.resolve(n, t);
58
87
  }
59
88
  } finally{
60
- this.resolvingStack.delete(r.identifier);
89
+ this.resolvingStack.delete(n.identifier);
61
90
  }
62
91
  }
63
92
  concrete(e) {
@@ -67,9 +96,9 @@ class InjectableManager {
67
96
  }
68
97
  tagged(...e) {
69
98
  const t = [];
70
- for (const i of e){
71
- for (const [e, r] of this.injectables){
72
- if (r.tags.includes(i)) t.push(r.build());
99
+ for (const r of e){
100
+ for (const [e, n] of this.injectables){
101
+ if (n.tags.includes(r)) t.push(n.build());
73
102
  }
74
103
  }
75
104
  return t;
package/dist/index31.mjs CHANGED
@@ -1,18 +1,44 @@
1
1
  import { HookManager } from './index33.mjs';
2
2
  import { SingletonStrategy, TransientStrategy } from './index43.mjs';
3
3
  import { DebugLogger } from './index36.mjs';
4
+ import { isClass } from '@assemblerjs/core';
4
5
  import { resolveInstanceInjectionTuple } from './index42.mjs';
5
6
  import { resolveInjectionTuple } from './index41.mjs';
6
7
  import { Injectable } from './index44.mjs';
7
8
 
9
+ function c(e) {
10
+ if (e?.name) return e.name;
11
+ if (typeof e === 'string') return e;
12
+ if (typeof e === 'symbol') return e.toString();
13
+ if (typeof e === 'number') return String(e);
14
+ if (typeof e === 'boolean') return String(e);
15
+ if (typeof e === 'object' && e !== null) {
16
+ try {
17
+ const t = JSON.stringify(e);
18
+ if (t.length > 100) {
19
+ return t.substring(0, 100) + '...';
20
+ }
21
+ return t;
22
+ } catch {
23
+ return `[${e.constructor?.name || 'Object'}]`;
24
+ }
25
+ }
26
+ return String(e);
27
+ }
28
+ function l(e) {
29
+ if (isClass(e)) return 'class';
30
+ if (typeof e === 'string') return 'string';
31
+ if (typeof e === 'symbol') return 'symbol';
32
+ return 'unknown';
33
+ }
8
34
  class InjectableManager {
9
35
  setContexts(e, t) {
10
36
  this.privateContext = e;
11
37
  this.publicContext = t;
12
38
  }
13
- register(n, s = false) {
39
+ register(i, s = false) {
14
40
  const a = DebugLogger.getInstance();
15
- const c = s === true ? resolveInstanceInjectionTuple(n) : resolveInjectionTuple(n);
41
+ const c = s === true ? resolveInstanceInjectionTuple(i) : resolveInjectionTuple(i);
16
42
  if (this.has(c.identifier)) {
17
43
  const e = `An assemblage is already registered with identifier '${c.identifier.name}'.`;
18
44
  a.log('error', 'Duplicate registration', {
@@ -32,28 +58,31 @@ class InjectableManager {
32
58
  has(e) {
33
59
  return this.injectables.has(e);
34
60
  }
35
- require(e, t, i) {
61
+ require(e, t, r) {
36
62
  if (!this.injectables.has(e)) {
37
63
  const t = this.resolvingStack.has(e);
38
- const r = t ? 'Circular dependency detected' : 'Dependency not registered';
39
- const n = t ? `Circular dependency detected: '${e.name}' is already being resolved.` : `Class with identifier '${e.name}' has not been registered.`;
40
- DebugLogger.getInstance().log('error', r, {
41
- identifier: e.name,
42
- caller: i ? i?.name || String(i) : 'unknown',
43
- error: n
64
+ const n = t ? 'Circular dependency detected' : 'Dependency not registered';
65
+ const i = c(e);
66
+ const s = l(e);
67
+ const a = t ? `Circular dependency detected: '${i}' is already being resolved.` : `Dependency '${i}' has not been registered (Class/Service not found in current assemblies).`;
68
+ DebugLogger.getInstance().log('error', n, {
69
+ identifier: i,
70
+ caller: r ? c(r) : 'unknown',
71
+ type: s,
72
+ error: a
44
73
  });
45
- throw new Error(n);
74
+ throw new Error(a);
46
75
  }
47
- const r = this.injectables.get(e);
48
- this.resolvingStack.add(r.identifier);
76
+ const n = this.injectables.get(e);
77
+ this.resolvingStack.add(n.identifier);
49
78
  try {
50
- if (r.isSingleton) {
51
- return this.singletonStrategy.resolve(r, t);
79
+ if (n.isSingleton) {
80
+ return this.singletonStrategy.resolve(n, t);
52
81
  } else {
53
- return this.transientStrategy.resolve(r, t);
82
+ return this.transientStrategy.resolve(n, t);
54
83
  }
55
84
  } finally{
56
- this.resolvingStack.delete(r.identifier);
85
+ this.resolvingStack.delete(n.identifier);
57
86
  }
58
87
  }
59
88
  concrete(e) {
@@ -63,9 +92,9 @@ class InjectableManager {
63
92
  }
64
93
  tagged(...e) {
65
94
  const t = [];
66
- for (const i of e){
67
- for (const [e, r] of this.injectables){
68
- if (r.tags.includes(i)) t.push(r.build());
95
+ for (const r of e){
96
+ for (const [e, n] of this.injectables){
97
+ if (n.tags.includes(r)) t.push(n.build());
69
98
  }
70
99
  }
71
100
  return t;
package/dist/index32.js CHANGED
@@ -4,32 +4,39 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
5
  const debugLogger = require('./index36.js');
6
6
 
7
+ function t(e) {
8
+ return typeof e === 'symbol' ? 'symbol' : 'string';
9
+ }
7
10
  class ObjectManager {
8
- use(t, r) {
9
- if (this.has(t)) {
10
- const r = `A value is already registered with identifier '${String(t)}'.`;
11
- debugLogger.DebugLogger.getInstance().log('error', 'Duplicate object registration', {
12
- identifier: String(t),
13
- error: r
11
+ use(r, o) {
12
+ if (this.has(r)) {
13
+ const o = typeof r === 'symbol' ? r.toString() : String(r);
14
+ const s = `Object/value '${o}' is already registered (cannot register twice).`;
15
+ debugLogger.DebugLogger.getInstance().log('error', 'Duplicate object/value registration', {
16
+ identifier: o,
17
+ type: t(r),
18
+ error: s
14
19
  });
15
- throw new Error(r);
20
+ throw new Error(s);
16
21
  }
17
- this.objects.set(t, r);
18
- return r;
22
+ this.objects.set(r, o);
23
+ return o;
19
24
  }
20
25
  has(e) {
21
26
  return this.objects.has(e);
22
27
  }
23
- require(t) {
24
- if (!this.objects.has(t)) {
25
- const r = `Injected object with identifier '${String(t)}' has not been registered.`;
26
- debugLogger.DebugLogger.getInstance().log('error', 'Object not found', {
27
- identifier: String(t),
28
- error: r
28
+ require(r) {
29
+ if (!this.objects.has(r)) {
30
+ const o = typeof r === 'symbol' ? r.toString() : String(r);
31
+ const s = `Object/value '${o}' has not been registered in the object store.`;
32
+ debugLogger.DebugLogger.getInstance().log('error', 'Object/value not found', {
33
+ identifier: o,
34
+ type: t(r),
35
+ error: s
29
36
  });
30
- throw new Error(r);
37
+ throw new Error(s);
31
38
  }
32
- return this.objects.get(t);
39
+ return this.objects.get(r);
33
40
  }
34
41
  addGlobal(e, t) {
35
42
  if (this.globals.has(e)) {
package/dist/index32.mjs CHANGED
@@ -1,31 +1,38 @@
1
1
  import { DebugLogger } from './index36.mjs';
2
2
 
3
+ function t(e) {
4
+ return typeof e === 'symbol' ? 'symbol' : 'string';
5
+ }
3
6
  class ObjectManager {
4
- use(t, r) {
5
- if (this.has(t)) {
6
- const r = `A value is already registered with identifier '${String(t)}'.`;
7
- DebugLogger.getInstance().log('error', 'Duplicate object registration', {
8
- identifier: String(t),
9
- error: r
7
+ use(r, o) {
8
+ if (this.has(r)) {
9
+ const o = typeof r === 'symbol' ? r.toString() : String(r);
10
+ const s = `Object/value '${o}' is already registered (cannot register twice).`;
11
+ DebugLogger.getInstance().log('error', 'Duplicate object/value registration', {
12
+ identifier: o,
13
+ type: t(r),
14
+ error: s
10
15
  });
11
- throw new Error(r);
16
+ throw new Error(s);
12
17
  }
13
- this.objects.set(t, r);
14
- return r;
18
+ this.objects.set(r, o);
19
+ return o;
15
20
  }
16
21
  has(e) {
17
22
  return this.objects.has(e);
18
23
  }
19
- require(t) {
20
- if (!this.objects.has(t)) {
21
- const r = `Injected object with identifier '${String(t)}' has not been registered.`;
22
- DebugLogger.getInstance().log('error', 'Object not found', {
23
- identifier: String(t),
24
- error: r
24
+ require(r) {
25
+ if (!this.objects.has(r)) {
26
+ const o = typeof r === 'symbol' ? r.toString() : String(r);
27
+ const s = `Object/value '${o}' has not been registered in the object store.`;
28
+ DebugLogger.getInstance().log('error', 'Object/value not found', {
29
+ identifier: o,
30
+ type: t(r),
31
+ error: s
25
32
  });
26
- throw new Error(r);
33
+ throw new Error(s);
27
34
  }
28
- return this.objects.get(t);
35
+ return this.objects.get(r);
29
36
  }
30
37
  addGlobal(e, t) {
31
38
  if (this.globals.has(e)) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "assemblerjs",
3
3
  "description": "A general purpose Dependency Injection library for node and browser.",
4
- "version": "1.1.6",
4
+ "version": "1.1.7",
5
5
  "author": "Benoît LAHOZ <info@benoitlahoz.io>",
6
6
  "bugs": "https://github.com/benoitlahoz/assemblerjs/issues",
7
7
  "homepage": "https://github.com/benoitlahoz/assemblerjs#README",