assemblerjs 1.0.0 → 1.0.1

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 (50) hide show
  1. package/README.md +21 -48
  2. package/dist/index12.js +1 -1
  3. package/dist/index12.mjs +1 -1
  4. package/dist/index13.js +1 -1
  5. package/dist/index13.mjs +1 -1
  6. package/dist/index18.js +1 -1
  7. package/dist/index18.mjs +1 -1
  8. package/dist/index19.js +1 -1
  9. package/dist/index19.mjs +1 -1
  10. package/dist/index2.js +3 -3
  11. package/dist/index2.mjs +3 -3
  12. package/dist/index20.js +1 -1
  13. package/dist/index20.mjs +1 -1
  14. package/dist/index21.js +1 -1
  15. package/dist/index21.mjs +1 -1
  16. package/dist/index22.js +2 -2
  17. package/dist/index22.mjs +2 -2
  18. package/dist/index23.js +33 -56
  19. package/dist/index23.mjs +32 -56
  20. package/dist/index24.js +15 -32
  21. package/dist/index24.mjs +13 -32
  22. package/dist/index25.js +11 -63
  23. package/dist/index25.mjs +9 -63
  24. package/dist/index26.js +91 -28
  25. package/dist/index26.mjs +89 -28
  26. package/dist/index27.js +62 -30
  27. package/dist/index27.mjs +62 -30
  28. package/dist/index28.js +27 -36
  29. package/dist/index28.mjs +27 -35
  30. package/dist/index29.js +66 -15
  31. package/dist/index29.mjs +66 -13
  32. package/dist/index3.js +2 -2
  33. package/dist/index3.mjs +2 -2
  34. package/dist/index30.js +31 -13
  35. package/dist/index30.mjs +31 -11
  36. package/dist/index31.js +29 -92
  37. package/dist/index31.mjs +29 -90
  38. package/dist/index33.js +49 -29
  39. package/dist/index33.mjs +49 -28
  40. package/dist/index35.js +29 -49
  41. package/dist/index35.mjs +28 -49
  42. package/dist/index36.js +5 -5
  43. package/dist/index36.mjs +5 -5
  44. package/dist/index38.js +1 -1
  45. package/dist/index38.mjs +1 -1
  46. package/dist/index39.js +1 -1
  47. package/dist/index39.mjs +1 -1
  48. package/dist/index4.js +5 -5
  49. package/dist/index4.mjs +5 -5
  50. package/package.json +1 -1
package/README.md CHANGED
@@ -13,7 +13,7 @@ A modern, type-safe, and lightweight [Dependency Injection](https://en.wikipedia
13
13
  ![Event System](https://img.shields.io/badge/event%20emit-432k%20ops%2Fsec-brightgreen.svg?style=flat)
14
14
  ![Decorators](https://img.shields.io/badge/decorators-890k%20ops%2Fsec-brightgreen.svg?style=flat)
15
15
 
16
- [→ Full Benchmarks](../../docs/assemblerjs/performance/benchmarks.md)
16
+ [→ Full Benchmarks](https://github.com/benoitlahoz/assemblerjs/blob/main/docs/assemblerjs/performance/benchmarks.md)
17
17
 
18
18
  ---
19
19
 
@@ -100,69 +100,42 @@ app.start(); // Output: "App started!"
100
100
 
101
101
  Comprehensive documentation is available at:
102
102
 
103
- **[→ Full Documentation](../../docs/assemblerjs/)**
103
+ **[→ Full Documentation](https://github.com/benoitlahoz/assemblerjs/tree/main/docs/assemblerjs)**
104
104
 
105
105
  ### Quick Links
106
106
 
107
107
  #### Getting Started
108
- - [Installation](../../docs/assemblerjs/getting-started/installation.md)
109
- - [Quick Start Guide](../../docs/assemblerjs/getting-started/quick-start.md)
110
- - [TypeScript Setup](../../docs/assemblerjs/getting-started/typescript-setup.md)
108
+ - [Installation](https://github.com/benoitlahoz/assemblerjs/blob/main/docs/assemblerjs/getting-started/installation.md)
109
+ - [Quick Start Guide](https://github.com/benoitlahoz/assemblerjs/blob/main/docs/assemblerjs/getting-started/quick-start.md)
110
+ - [TypeScript Setup](https://github.com/benoitlahoz/assemblerjs/blob/main/docs/assemblerjs/getting-started/typescript-setup.md)
111
111
 
112
112
  #### Core Concepts
113
- - [Assemblage](../../docs/assemblerjs/core-concepts/assemblage.md) - Building blocks
114
- - [Dependency Injection](../../docs/assemblerjs/core-concepts/dependency-injection.md) - DI patterns
115
- - [Abstraction Pattern](../../docs/assemblerjs/core-concepts/abstraction-pattern.md) - Interface-based design
116
- - [Lifecycle Hooks](../../docs/assemblerjs/core-concepts/lifecycle-hooks.md) - Initialization & cleanup
113
+ - [Assemblage](https://github.com/benoitlahoz/assemblerjs/blob/main/docs/assemblerjs/core-concepts/assemblage.md) - Building blocks
114
+ - [Dependency Injection](https://github.com/benoitlahoz/assemblerjs/blob/main/docs/assemblerjs/core-concepts/dependency-injection.md) - DI patterns
115
+ - [Abstraction Pattern](https://github.com/benoitlahoz/assemblerjs/blob/main/docs/assemblerjs/core-concepts/abstraction-pattern.md) - Interface-based design
116
+ - [Lifecycle Hooks](https://github.com/benoitlahoz/assemblerjs/blob/main/docs/assemblerjs/core-concepts/lifecycle-hooks.md) - Initialization & cleanup
117
117
 
118
118
  #### Decorators
119
- - [Parameter Decorators](../../docs/assemblerjs/decorators/parameter-decorators.md) - Built-in decorators
120
- - [Custom Parameter Decorators](../../docs/assemblerjs/decorators/custom-parameter.md) - Create your own
121
- - [Custom Class Decorators](../../docs/assemblerjs/decorators/custom-class.md) - Type-safe class decorators
119
+ - [Parameter Decorators](https://github.com/benoitlahoz/assemblerjs/blob/main/docs/assemblerjs/decorators/parameter-decorators.md) - Built-in decorators
120
+ - [Custom Parameter Decorators](https://github.com/benoitlahoz/assemblerjs/blob/main/docs/assemblerjs/decorators/custom-parameter.md) - Create your own
121
+ - [Custom Class Decorators](https://github.com/benoitlahoz/assemblerjs/blob/main/docs/assemblerjs/decorators/custom-class.md) - Type-safe class decorators
122
122
 
123
123
  #### Features
124
- - [Event System](../../docs/assemblerjs/features/events.md) - Event-driven architecture
125
- - [Tags](../../docs/assemblerjs/features/tags.md) - Group assemblages
126
- - [Singleton vs Transient](../../docs/assemblerjs/features/singleton-transient.md) - Instance lifecycle
124
+ - [Event System](https://github.com/benoitlahoz/assemblerjs/blob/main/docs/assemblerjs/features/events.md) - Event-driven architecture
125
+ - [Tags](https://github.com/benoitlahoz/assemblerjs/blob/main/docs/assemblerjs/features/tags.md) - Group assemblages
126
+ - [Singleton vs Transient](https://github.com/benoitlahoz/assemblerjs/blob/main/docs/assemblerjs/features/singleton-transient.md) - Instance lifecycle
127
127
 
128
128
  #### API Reference
129
- - [Assembler API](../../docs/assemblerjs/api/assembler.md) - Container methods
130
- - [AssemblerContext API](../../docs/assemblerjs/api/context.md) - Context interface
131
- - [Types](../../docs/assemblerjs/api/types.md) - TypeScript types
129
+ - [Assembler API](https://github.com/benoitlahoz/assemblerjs/blob/main/docs/assemblerjs/api/assembler.md) - Container methods
130
+ - [AssemblerContext API](https://github.com/benoitlahoz/assemblerjs/blob/main/docs/assemblerjs/api/context.md) - Context interface
131
+ - [Types](https://github.com/benoitlahoz/assemblerjs/blob/main/docs/assemblerjs/api/types.md) - TypeScript types
132
132
 
133
133
  #### Guides
134
- - [Advanced Examples](../../docs/assemblerjs/guides/advanced-examples.md) - Real-world patterns
135
- - [Tree-Shaking](../../docs/assemblerjs/guides/tree-shaking.md) - Bundle optimization
134
+ - [Advanced Examples](https://github.com/benoitlahoz/assemblerjs/blob/main/docs/assemblerjs/guides/advanced-examples.md) - Real-world patterns
135
+ - [Tree-Shaking](https://github.com/benoitlahoz/assemblerjs/blob/main/docs/assemblerjs/guides/tree-shaking.md) - Bundle optimization
136
136
 
137
137
  #### Performance
138
- - [Benchmarks](../../docs/assemblerjs/performance/benchmarks.md) - Performance metrics & best practices
139
-
140
- ## Requirements
141
-
142
- - **Node.js:** ≥ 18.12.0
143
- - **TypeScript:** ≥ 5.0 (with decorator support)
144
- - **reflect-metadata:** Required for dependency injection
145
-
146
- ## For Contributors
147
-
148
- ### Architecture
149
-
150
- This package is part of the `assemblerjs` monorepo and depends on:
151
-
152
- - **`@assemblerjs/core`** - Internal utilities package
153
-
154
- ### Development
155
-
156
- ```bash
157
- # Install dependencies from workspace root
158
- yarn install
159
-
160
- # Build the package
161
- npx nx build assemblerjs
162
-
163
- # Run tests
164
- npx nx test assemblerjs
165
- ```
138
+ - [Benchmarks](https://github.com/benoitlahoz/assemblerjs/blob/main/docs/assemblerjs/performance/benchmarks.md) - Performance metrics & best practices
166
139
 
167
140
  ## Tree-Shaking & Bundle Optimization
168
141
 
package/dist/index12.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const reflection = require('./index30.js');
5
+ const reflection = require('./index25.js');
6
6
 
7
7
  const t = (t)=>()=>{
8
8
  return (e, c, n)=>{
package/dist/index12.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { getOwnCustomMetadata, defineCustomMetadata } from './index30.mjs';
1
+ import { getOwnCustomMetadata, defineCustomMetadata } from './index25.mjs';
2
2
 
3
3
  const t = (t)=>()=>{
4
4
  return (e, c, n)=>{
package/dist/index13.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const reflection = require('./index30.js');
5
+ const reflection = require('./index25.js');
6
6
 
7
7
  class ParameterDecoratorFactory {
8
8
  static create(e) {
package/dist/index13.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { getOwnCustomMetadata, defineCustomMetadata } from './index30.mjs';
1
+ import { getOwnCustomMetadata, defineCustomMetadata } from './index25.mjs';
2
2
 
3
3
  class ParameterDecoratorFactory {
4
4
  static create(e) {
package/dist/index18.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const reflection = require('./index30.js');
5
+ const reflection = require('./index25.js');
6
6
  const parameterDecoratorFactory = require('./index13.js');
7
7
  const helpers = require('./index21.js');
8
8
  const resolverStore = require('./index32.js');
package/dist/index18.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { getOwnCustomMetadata } from './index30.mjs';
1
+ import { getOwnCustomMetadata } from './index25.mjs';
2
2
  import { ParameterDecoratorFactory } from './index13.mjs';
3
3
  import { getParamValueKey } from './index21.mjs';
4
4
  import { ResolverStore } from './index32.mjs';
package/dist/index19.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const reflection = require('./index30.js');
5
+ const reflection = require('./index25.js');
6
6
  const parameterDecoratorFactory = require('./index13.js');
7
7
  const helpers = require('./index21.js');
8
8
  const resolverStore = require('./index32.js');
package/dist/index19.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { getOwnCustomMetadata } from './index30.mjs';
1
+ import { getOwnCustomMetadata } from './index25.mjs';
2
2
  import { ParameterDecoratorFactory } from './index13.mjs';
3
3
  import { getParamValueKey } from './index21.mjs';
4
4
  import { ResolverStore } from './index32.mjs';
package/dist/index2.js CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const constants = require('./index29.js');
6
- const reflection = require('./index30.js');
7
- const schema = require('./index31.js');
5
+ const constants = require('./index24.js');
6
+ const reflection = require('./index25.js');
7
+ const schema = require('./index26.js');
8
8
 
9
9
  const Assemblage = (e)=>{
10
10
  return (r)=>{
package/dist/index2.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { ReflectFlags, ReflectValue } from './index29.mjs';
2
- import { defineCustomMetadata } from './index30.mjs';
3
- import { validateDefinition } from './index31.mjs';
1
+ import { ReflectFlags, ReflectValue } from './index24.mjs';
2
+ import { defineCustomMetadata } from './index25.mjs';
3
+ import { validateDefinition } from './index26.mjs';
4
4
 
5
5
  const Assemblage = (e)=>{
6
6
  return (r)=>{
package/dist/index20.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const reflection = require('./index30.js');
5
+ const reflection = require('./index25.js');
6
6
  const parameterDecoratorFactory = require('./index13.js');
7
7
  const helpers = require('./index21.js');
8
8
  const resolverStore = require('./index32.js');
package/dist/index20.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { getParamTypes, getOwnCustomMetadata } from './index30.mjs';
1
+ import { getParamTypes, getOwnCustomMetadata } from './index25.mjs';
2
2
  import { ParameterDecoratorFactory } from './index13.mjs';
3
3
  import { getParamValueKey } from './index21.mjs';
4
4
  import { ResolverStore } from './index32.mjs';
package/dist/index21.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const reflection = require('./index30.js');
5
+ const reflection = require('./index25.js');
6
6
  const parameterDecoratorFactory = require('./index13.js');
7
7
 
8
8
  const getParamIndexKey = (e)=>{
package/dist/index21.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { getOwnCustomMetadata } from './index30.mjs';
1
+ import { getOwnCustomMetadata } from './index25.mjs';
2
2
  import { ParameterDecoratorFactory } from './index13.mjs';
3
3
 
4
4
  const getParamIndexKey = (e)=>{
package/dist/index22.js CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const constants = require('./index29.js');
6
- const reflection = require('./index30.js');
5
+ const constants = require('./index24.js');
6
+ const reflection = require('./index25.js');
7
7
  const helpers = require('./index21.js');
8
8
  const parameterDecoratorFactory = require('./index13.js');
9
9
  const decorator = require('./index2.js');
package/dist/index22.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { ReflectParamTypes, ReflectValue } from './index29.mjs';
2
- import { getOwnCustomMetadata, defineCustomMetadata } from './index30.mjs';
1
+ import { ReflectParamTypes, ReflectValue } from './index24.mjs';
2
+ import { getOwnCustomMetadata, defineCustomMetadata } from './index25.mjs';
3
3
  import { getDecoratedParametersIndexes, getParamValueKey, getParamIndexKey } from './index21.mjs';
4
4
  import { ParameterDecoratorFactory } from './index13.mjs';
5
5
  import { decorateAssemblage } from './index2.mjs';
package/dist/index23.js CHANGED
@@ -2,68 +2,45 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const hookManager = require('./index25.js');
6
- const resolutionStrategies = require('./index33.js');
7
- const use = require('./index34.js');
8
- const inject = require('./index35.js');
9
- const injectable = require('./index36.js');
5
+ const eventManager = require('./index6.js');
10
6
 
11
- class InjectableManager {
12
- setContexts(e, t) {
13
- this.privateContext = e;
14
- this.publicContext = t;
15
- }
16
- register(r, n = false) {
17
- const o = n === true ? use.resolveInstanceInjectionTuple(r) : inject.resolveInjectionTuple(r);
18
- if (this.has(o.identifier)) {
19
- throw new Error(`An assemblage is already registered with identifier '${o.identifier.name}'.`);
7
+ const registerEvents = (t, n)=>{
8
+ const o = t.concrete.prototype instanceof eventManager.EventManager;
9
+ if (o) {
10
+ const e = n;
11
+ const o = e.channels;
12
+ for (const n of t.events){
13
+ if (!o.has(n)) e.addChannels(n);
14
+ if (!t.privateContext.events.has(n)) t.privateContext.addChannels(n);
20
15
  }
21
- const a = injectable.Injectable.of(o, this.privateContext, this.publicContext);
22
- this.injectables.set(a.identifier, a);
23
- hookManager.HookManager.callHook(a.concrete, 'onRegister', this.publicContext, a.configuration);
24
- return a;
25
- }
26
- has(e) {
27
- return this.injectables.has(e);
28
- }
29
- require(e, t) {
30
- if (!this.injectables.has(e)) {
31
- throw new Error(`Class with identifier '${e.name}' has not been registered or is a circular dependency.`);
16
+ for (const e of t.events){
17
+ n.on(e, (...n)=>{
18
+ t.privateContext.emit(e, ...n);
19
+ });
32
20
  }
33
- const i = this.injectables.get(e);
34
- if (i.isSingleton) {
35
- return this.singletonStrategy.resolve(i, t);
36
- } else {
37
- return this.transientStrategy.resolve(i, t);
21
+ } else {
22
+ for (const e of t.events){
23
+ if (!t.privateContext.events.has(e)) t.privateContext.addChannels(e);
38
24
  }
39
25
  }
40
- concrete(e) {
41
- const t = this.injectables.get(e);
42
- if (t) return t.concrete;
43
- return;
44
- }
45
- tagged(...e) {
46
- const t = [];
47
- for (const i of e){
48
- for (const [e, s] of this.injectables){
49
- if (s.tags.includes(i)) t.push(s.build());
50
- }
26
+ };
27
+ const unregisterEvents = (t, n)=>{
28
+ const o = t.concrete.prototype instanceof eventManager.EventManager;
29
+ if (o) {
30
+ const e = n;
31
+ for (const n of t.events){
32
+ e.off(n);
51
33
  }
52
- return t;
53
- }
54
- dispose() {
55
- for (const [e, t] of this.injectables){
56
- t.dispose();
34
+ e.removeChannels(...t.events);
35
+ t.privateContext.removeChannels(...t.events);
36
+ } else {
37
+ for (const e of t.events){
38
+ if (t.privateContext.events.has(e)) {
39
+ t.privateContext.removeChannels(e);
40
+ }
57
41
  }
58
42
  }
59
- get size() {
60
- return this.injectables.size;
61
- }
62
- constructor(){
63
- this.injectables = new Map();
64
- this.singletonStrategy = new resolutionStrategies.SingletonStrategy();
65
- this.transientStrategy = new resolutionStrategies.TransientStrategy();
66
- }
67
- }
43
+ };
68
44
 
69
- exports.InjectableManager = InjectableManager;
45
+ exports.registerEvents = registerEvents;
46
+ exports.unregisterEvents = unregisterEvents;
package/dist/index23.mjs CHANGED
@@ -1,65 +1,41 @@
1
- import { HookManager } from './index25.mjs';
2
- import { SingletonStrategy, TransientStrategy } from './index33.mjs';
3
- import { resolveInstanceInjectionTuple } from './index34.mjs';
4
- import { resolveInjectionTuple } from './index35.mjs';
5
- import { Injectable } from './index36.mjs';
1
+ import { EventManager } from './index6.mjs';
6
2
 
7
- class InjectableManager {
8
- setContexts(e, t) {
9
- this.privateContext = e;
10
- this.publicContext = t;
11
- }
12
- register(r, n = false) {
13
- const o = n === true ? resolveInstanceInjectionTuple(r) : resolveInjectionTuple(r);
14
- if (this.has(o.identifier)) {
15
- throw new Error(`An assemblage is already registered with identifier '${o.identifier.name}'.`);
3
+ const registerEvents = (t, n)=>{
4
+ const o = t.concrete.prototype instanceof EventManager;
5
+ if (o) {
6
+ const e = n;
7
+ const o = e.channels;
8
+ for (const n of t.events){
9
+ if (!o.has(n)) e.addChannels(n);
10
+ if (!t.privateContext.events.has(n)) t.privateContext.addChannels(n);
16
11
  }
17
- const a = Injectable.of(o, this.privateContext, this.publicContext);
18
- this.injectables.set(a.identifier, a);
19
- HookManager.callHook(a.concrete, 'onRegister', this.publicContext, a.configuration);
20
- return a;
21
- }
22
- has(e) {
23
- return this.injectables.has(e);
24
- }
25
- require(e, t) {
26
- if (!this.injectables.has(e)) {
27
- throw new Error(`Class with identifier '${e.name}' has not been registered or is a circular dependency.`);
12
+ for (const e of t.events){
13
+ n.on(e, (...n)=>{
14
+ t.privateContext.emit(e, ...n);
15
+ });
28
16
  }
29
- const i = this.injectables.get(e);
30
- if (i.isSingleton) {
31
- return this.singletonStrategy.resolve(i, t);
32
- } else {
33
- return this.transientStrategy.resolve(i, t);
17
+ } else {
18
+ for (const e of t.events){
19
+ if (!t.privateContext.events.has(e)) t.privateContext.addChannels(e);
34
20
  }
35
21
  }
36
- concrete(e) {
37
- const t = this.injectables.get(e);
38
- if (t) return t.concrete;
39
- return;
40
- }
41
- tagged(...e) {
42
- const t = [];
43
- for (const i of e){
44
- for (const [e, s] of this.injectables){
45
- if (s.tags.includes(i)) t.push(s.build());
46
- }
22
+ };
23
+ const unregisterEvents = (t, n)=>{
24
+ const o = t.concrete.prototype instanceof EventManager;
25
+ if (o) {
26
+ const e = n;
27
+ for (const n of t.events){
28
+ e.off(n);
47
29
  }
48
- return t;
49
- }
50
- dispose() {
51
- for (const [e, t] of this.injectables){
52
- t.dispose();
30
+ e.removeChannels(...t.events);
31
+ t.privateContext.removeChannels(...t.events);
32
+ } else {
33
+ for (const e of t.events){
34
+ if (t.privateContext.events.has(e)) {
35
+ t.privateContext.removeChannels(e);
36
+ }
53
37
  }
54
38
  }
55
- get size() {
56
- return this.injectables.size;
57
- }
58
- constructor(){
59
- this.injectables = new Map();
60
- this.singletonStrategy = new SingletonStrategy();
61
- this.transientStrategy = new TransientStrategy();
62
- }
63
- }
39
+ };
64
40
 
65
- export { InjectableManager };
41
+ export { registerEvents, unregisterEvents };
package/dist/index24.js CHANGED
@@ -2,36 +2,19 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- class ObjectManager {
6
- use(e, t) {
7
- if (this.has(e)) {
8
- throw new Error(`A value is already registered with identifier '${String(e)}'.`);
9
- }
10
- this.objects.set(e, t);
11
- return t;
12
- }
13
- has(e) {
14
- return this.objects.has(e);
15
- }
16
- require(e) {
17
- if (!this.objects.has(e)) {
18
- throw new Error(`Injected object with identifier '${String(e)}' has not been registered.`);
19
- }
20
- return this.objects.get(e);
21
- }
22
- addGlobal(e, t) {
23
- if (this.globals.has(e)) {
24
- throw new Error(`Global value with key '${e}' has already been registered.`);
25
- }
26
- this.globals.set(e, t);
27
- }
28
- global(e) {
29
- return this.globals.get(e);
30
- }
31
- constructor(){
32
- this.objects = new Map();
33
- this.globals = new Map();
34
- }
35
- }
5
+ const ReflectParamTypes = 'design:paramtypes';
6
+ const ReflectPrefix = '__';
7
+ const ReflectSuffix = '__';
8
+ exports.ReflectFlags = void 0;
9
+ (function(e) {
10
+ e["IsAssemblage"] = "is_assemblage";
11
+ })(exports.ReflectFlags || (exports.ReflectFlags = {}));
12
+ exports.ReflectValue = void 0;
13
+ (function(e) {
14
+ e["AssemblageDefinition"] = "assemblage:definition.value";
15
+ e["AssemblageContext"] = "assemblage:context.value";
16
+ })(exports.ReflectValue || (exports.ReflectValue = {}));
36
17
 
37
- exports.ObjectManager = ObjectManager;
18
+ exports.ReflectParamTypes = ReflectParamTypes;
19
+ exports.ReflectPrefix = ReflectPrefix;
20
+ exports.ReflectSuffix = ReflectSuffix;
package/dist/index24.mjs CHANGED
@@ -1,33 +1,14 @@
1
- class ObjectManager {
2
- use(e, t) {
3
- if (this.has(e)) {
4
- throw new Error(`A value is already registered with identifier '${String(e)}'.`);
5
- }
6
- this.objects.set(e, t);
7
- return t;
8
- }
9
- has(e) {
10
- return this.objects.has(e);
11
- }
12
- require(e) {
13
- if (!this.objects.has(e)) {
14
- throw new Error(`Injected object with identifier '${String(e)}' has not been registered.`);
15
- }
16
- return this.objects.get(e);
17
- }
18
- addGlobal(e, t) {
19
- if (this.globals.has(e)) {
20
- throw new Error(`Global value with key '${e}' has already been registered.`);
21
- }
22
- this.globals.set(e, t);
23
- }
24
- global(e) {
25
- return this.globals.get(e);
26
- }
27
- constructor(){
28
- this.objects = new Map();
29
- this.globals = new Map();
30
- }
31
- }
1
+ const ReflectParamTypes = 'design:paramtypes';
2
+ const ReflectPrefix = '__';
3
+ const ReflectSuffix = '__';
4
+ var ReflectFlags;
5
+ (function(e) {
6
+ e["IsAssemblage"] = "is_assemblage";
7
+ })(ReflectFlags || (ReflectFlags = {}));
8
+ var ReflectValue;
9
+ (function(e) {
10
+ e["AssemblageDefinition"] = "assemblage:definition.value";
11
+ e["AssemblageContext"] = "assemblage:context.value";
12
+ })(ReflectValue || (ReflectValue = {}));
32
13
 
33
- export { ObjectManager };
14
+ export { ReflectFlags, ReflectParamTypes, ReflectPrefix, ReflectSuffix, ReflectValue };
package/dist/index25.js CHANGED
@@ -2,70 +2,18 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const core = require('@assemblerjs/core');
5
+ const constants = require('./index24.js');
6
6
 
7
- class HookManager {
8
- prepareInitHook(e, t) {
9
- this.initCache.push({
10
- instance: e,
11
- configuration: t
12
- });
13
- return this.initCache;
14
- }
15
- callInitHooks(e) {
16
- for (const t of this.initCache){
17
- HookManager.callHookImmediate(t.instance, 'onInit', e, t.configuration);
18
- }
19
- }
20
- callInitedHooks(e) {
21
- for (const t of [
22
- ...this.initCache
23
- ].reverse()){
24
- HookManager.callHookImmediate(t.instance, 'onInited', e, t.configuration);
25
- }
26
- }
27
- clearCache() {
28
- this.initCache.length = 0;
29
- }
30
- getCache() {
31
- return this.initCache;
32
- }
33
- constructor(){
34
- this.initCache = [];
35
- }
36
- }
37
- HookManager.callHook = (t, i, o, n)=>{
38
- return new Promise((a, c)=>{
39
- const r = t[i];
40
- if (r) {
41
- if (core.isAsync(r)) {
42
- r.bind(t)(o, n).then(()=>{
43
- a();
44
- }).catch((e)=>{
45
- c(e);
46
- });
47
- return;
48
- }
49
- try {
50
- r.bind(t)(o, n);
51
- a();
52
- } catch (e) {
53
- c(e);
54
- }
55
- } else {
56
- a();
57
- }
58
- });
7
+ const defineCustomMetadata = (t, o, n)=>{
8
+ Reflect.defineMetadata(`${constants.ReflectPrefix}${t}${constants.ReflectSuffix}`, o, n);
59
9
  };
60
- HookManager.callHookImmediate = (t, i, o, n)=>{
61
- const a = t[i];
62
- if (a) {
63
- if (core.isAsync(a)) {
64
- a.bind(t)(o, n).catch(()=>{});
65
- return;
66
- }
67
- a.bind(t)(o, n);
68
- }
10
+ const getOwnCustomMetadata = (t, o)=>{
11
+ return Reflect.getOwnMetadata(`${constants.ReflectPrefix}${t}${constants.ReflectSuffix}`, o);
12
+ };
13
+ const getParamTypes = (e)=>{
14
+ return Reflect.getMetadata(constants.ReflectParamTypes, e) || [];
69
15
  };
70
16
 
71
- exports.HookManager = HookManager;
17
+ exports.defineCustomMetadata = defineCustomMetadata;
18
+ exports.getOwnCustomMetadata = getOwnCustomMetadata;
19
+ exports.getParamTypes = getParamTypes;