assemblerjs 1.1.9 → 1.1.11

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 (69) hide show
  1. package/dist/index11.js +2 -2
  2. package/dist/index11.mjs +2 -2
  3. package/dist/index13.js +2 -2
  4. package/dist/index13.mjs +2 -2
  5. package/dist/index16.js +1 -1
  6. package/dist/index16.mjs +1 -1
  7. package/dist/index17.js +1 -1
  8. package/dist/index17.mjs +1 -1
  9. package/dist/index18.js +1 -1
  10. package/dist/index18.mjs +1 -1
  11. package/dist/index19.js +1 -1
  12. package/dist/index19.mjs +1 -1
  13. package/dist/index2.js +2 -2
  14. package/dist/index2.mjs +2 -2
  15. package/dist/index20.js +1 -1
  16. package/dist/index20.mjs +1 -1
  17. package/dist/index21.js +1 -1
  18. package/dist/index21.mjs +1 -1
  19. package/dist/index22.js +2 -2
  20. package/dist/index22.mjs +2 -2
  21. package/dist/index23.js +2 -2
  22. package/dist/index23.mjs +2 -2
  23. package/dist/index24.js +2 -2
  24. package/dist/index24.mjs +2 -2
  25. package/dist/index25.js +1 -1
  26. package/dist/index25.mjs +1 -1
  27. package/dist/index26.js +1 -1
  28. package/dist/index26.mjs +1 -1
  29. package/dist/index29.js +15 -38
  30. package/dist/index29.mjs +12 -37
  31. package/dist/index3.js +1 -1
  32. package/dist/index3.mjs +1 -1
  33. package/dist/index30.js +100 -130
  34. package/dist/index30.mjs +98 -130
  35. package/dist/index31.js +123 -36
  36. package/dist/index31.mjs +123 -36
  37. package/dist/index32.js +41 -70
  38. package/dist/index32.mjs +41 -70
  39. package/dist/index33.js +75 -37
  40. package/dist/index33.mjs +75 -37
  41. package/dist/index34.js +42 -29
  42. package/dist/index34.mjs +42 -29
  43. package/dist/index35.js +26 -151
  44. package/dist/index35.mjs +26 -151
  45. package/dist/index36.js +161 -16
  46. package/dist/index36.mjs +161 -13
  47. package/dist/index37.js +33 -100
  48. package/dist/index37.mjs +32 -98
  49. package/dist/index38.js +18 -101
  50. package/dist/index38.mjs +18 -101
  51. package/dist/index39.js +101 -24
  52. package/dist/index39.mjs +101 -24
  53. package/dist/index4.js +6 -6
  54. package/dist/index4.mjs +6 -6
  55. package/dist/index40.js +24 -18
  56. package/dist/index40.mjs +24 -18
  57. package/dist/index41.js +49 -29
  58. package/dist/index41.mjs +49 -28
  59. package/dist/index43.js +29 -49
  60. package/dist/index43.mjs +28 -49
  61. package/dist/index44.js +4 -4
  62. package/dist/index44.mjs +4 -4
  63. package/dist/index48.js +1 -1
  64. package/dist/index48.mjs +1 -1
  65. package/dist/index49.js +2 -2
  66. package/dist/index49.mjs +2 -2
  67. package/dist/index50.js +1 -1
  68. package/dist/index50.mjs +1 -1
  69. package/package.json +1 -1
package/dist/index36.js CHANGED
@@ -2,22 +2,167 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const constants = require('./index28.js');
6
-
7
- const defineCustomMetadata = (t, o, n)=>{
8
- Reflect.defineMetadata(`${constants.ReflectPrefix}${t}${constants.ReflectSuffix}`, o, n);
9
- };
10
- const getCustomMetadata = (t, o)=>{
11
- return Reflect.getMetadata(`${constants.ReflectPrefix}${t}${constants.ReflectSuffix}`, o);
12
- };
13
- const getOwnCustomMetadata = (t, o)=>{
14
- return Reflect.getOwnMetadata(`${constants.ReflectPrefix}${t}${constants.ReflectSuffix}`, o);
5
+ function o(o) {
6
+ if (o === undefined) return 'undefined';
7
+ if (o === null) return 'null';
8
+ if (typeof o === 'function') {
9
+ if (o.name) return o.name;
10
+ if (o.constructor?.name && o.constructor.name !== 'Function') {
11
+ return o.constructor.name;
12
+ }
13
+ return 'AnonymousFunction';
14
+ }
15
+ if (typeof o === 'object') {
16
+ if (o.name && typeof o.name === 'string') {
17
+ return o.name;
18
+ }
19
+ const e = o.constructor?.name;
20
+ if (e && e !== 'Object') {
21
+ return e;
22
+ }
23
+ return '[Object]';
24
+ }
25
+ return String(o);
26
+ }
27
+ let NoOpDebugLogger = class NoOpDebugLogger {
28
+ configure(o) {}
29
+ log(o, e, t) {}
30
+ logBuildStart(o) {}
31
+ logBuildEnd(o, e) {}
32
+ logRegistration(o) {}
33
+ logHook(o, e, t) {}
34
+ logPhaseStart(o, e) {}
35
+ logPhaseEnd(o, e, t) {}
36
+ logResolution(o, e, t) {}
37
+ logConstruction(o) {}
15
38
  };
16
- const getParamTypes = (e)=>{
17
- return Reflect.getMetadata(constants.ReflectParamTypes, e) || [];
39
+ let ActiveDebugLogger = class ActiveDebugLogger {
40
+ configure(o) {
41
+ this.options = {
42
+ ...this.options,
43
+ ...o,
44
+ logPhases: {
45
+ ...this.options.logPhases,
46
+ ...o.logPhases || {}
47
+ }
48
+ };
49
+ }
50
+ logBuildStart(o) {
51
+ this.log('info', 'Build started', {
52
+ entry: o.name
53
+ });
54
+ }
55
+ logBuildEnd(o, e) {
56
+ const t = {
57
+ entry: o.name
58
+ };
59
+ if (e !== undefined) t.duration = `${e.toFixed(2)}ms`;
60
+ this.log('info', 'Build completed', t);
61
+ }
62
+ logRegistration(o) {
63
+ if (!this.shouldLog('registration')) return;
64
+ this.log('info', 'Registration', {
65
+ identifier: o.identifier?.name || String(o.identifier),
66
+ isSingleton: o.isSingleton,
67
+ dependencies: o.dependencies.map((o)=>o?.name || String(o)),
68
+ tags: o.tags
69
+ });
70
+ }
71
+ logHook(e, t, n) {
72
+ if (!this.shouldLog('hooks')) return;
73
+ const i = this.options.logTimings ? performance.now() : 0;
74
+ this.log('info', `Hook: ${e}`, {
75
+ target: o(t),
76
+ config: n
77
+ });
78
+ if (this.options.logTimings) {
79
+ return ()=>{
80
+ const o = performance.now() - i;
81
+ this.log('info', `Hook: ${e} completed`, {
82
+ duration: `${o.toFixed(2)}ms`
83
+ });
84
+ };
85
+ }
86
+ }
87
+ logPhaseStart(o, e) {
88
+ this.log('info', `Phase: ${o} started`, e);
89
+ }
90
+ logPhaseEnd(o, e, t) {
91
+ const n = e !== undefined ? {
92
+ duration: `${e.toFixed(2)}ms`
93
+ } : {};
94
+ if (t) {
95
+ Object.assign(n, t);
96
+ }
97
+ this.log('info', `Phase: ${o} ended`, Object.keys(n).length > 0 ? n : undefined);
98
+ }
99
+ logResolution(o, e, t) {
100
+ if (!this.shouldLog('resolution')) return;
101
+ this.log('info', `Resolving: ${o}`, {
102
+ strategy: `${e} strategy`,
103
+ cache: t ? 'hit' : 'miss'
104
+ });
105
+ }
106
+ logConstruction(o) {
107
+ if (!this.shouldLog('construction')) return;
108
+ this.log('info', `Constructing: ${o}`);
109
+ }
110
+ shouldLog(o) {
111
+ return !this.options.logPhases || this.options.logPhases[o] !== false;
112
+ }
113
+ log(o, e, t) {
114
+ if (this.options.logger) {
115
+ this.options.logger(o, e, t);
116
+ } else {
117
+ const n = `[Assembler:${o}]`;
118
+ const i = this.options.useColors !== false ? this.colorize(o, n) : n;
119
+ if (t) {
120
+ console.log(`${i} ${e}`, t);
121
+ } else {
122
+ console.log(`${i} ${e}`);
123
+ }
124
+ }
125
+ }
126
+ colorize(o, e) {
127
+ const t = {
128
+ info: '\x1b[36m',
129
+ warn: '\x1b[33m',
130
+ error: '\x1b[31m',
131
+ reset: '\x1b[0m'
132
+ };
133
+ const n = t[o] || t.info;
134
+ return `${n}${e}${t.reset}`;
135
+ }
136
+ constructor(){
137
+ this.options = {
138
+ enabled: true,
139
+ logPhases: {
140
+ registration: true,
141
+ resolution: true,
142
+ construction: true,
143
+ hooks: true,
144
+ cache: true
145
+ },
146
+ logTimings: false,
147
+ logDependencyTree: true,
148
+ useColors: true
149
+ };
150
+ }
18
151
  };
152
+ class DebugLogger {
153
+ static getInstance() {
154
+ return DebugLogger.instance;
155
+ }
156
+ static enable(o) {
157
+ DebugLogger.instance = new ActiveDebugLogger();
158
+ if (o) {
159
+ DebugLogger.instance.configure(o);
160
+ }
161
+ }
162
+ static disable() {
163
+ DebugLogger.instance = new NoOpDebugLogger();
164
+ }
165
+ }
166
+ DebugLogger.instance = new NoOpDebugLogger();
19
167
 
20
- exports.defineCustomMetadata = defineCustomMetadata;
21
- exports.getCustomMetadata = getCustomMetadata;
22
- exports.getOwnCustomMetadata = getOwnCustomMetadata;
23
- exports.getParamTypes = getParamTypes;
168
+ exports.DebugLogger = DebugLogger;
package/dist/index36.mjs CHANGED
@@ -1,16 +1,164 @@
1
- import { ReflectPrefix, ReflectSuffix, ReflectParamTypes } from './index28.mjs';
2
-
3
- const defineCustomMetadata = (t, o, n)=>{
4
- Reflect.defineMetadata(`${ReflectPrefix}${t}${ReflectSuffix}`, o, n);
5
- };
6
- const getCustomMetadata = (t, o)=>{
7
- return Reflect.getMetadata(`${ReflectPrefix}${t}${ReflectSuffix}`, o);
8
- };
9
- const getOwnCustomMetadata = (t, o)=>{
10
- return Reflect.getOwnMetadata(`${ReflectPrefix}${t}${ReflectSuffix}`, o);
1
+ function o(o) {
2
+ if (o === undefined) return 'undefined';
3
+ if (o === null) return 'null';
4
+ if (typeof o === 'function') {
5
+ if (o.name) return o.name;
6
+ if (o.constructor?.name && o.constructor.name !== 'Function') {
7
+ return o.constructor.name;
8
+ }
9
+ return 'AnonymousFunction';
10
+ }
11
+ if (typeof o === 'object') {
12
+ if (o.name && typeof o.name === 'string') {
13
+ return o.name;
14
+ }
15
+ const e = o.constructor?.name;
16
+ if (e && e !== 'Object') {
17
+ return e;
18
+ }
19
+ return '[Object]';
20
+ }
21
+ return String(o);
22
+ }
23
+ let NoOpDebugLogger = class NoOpDebugLogger {
24
+ configure(o) {}
25
+ log(o, e, t) {}
26
+ logBuildStart(o) {}
27
+ logBuildEnd(o, e) {}
28
+ logRegistration(o) {}
29
+ logHook(o, e, t) {}
30
+ logPhaseStart(o, e) {}
31
+ logPhaseEnd(o, e, t) {}
32
+ logResolution(o, e, t) {}
33
+ logConstruction(o) {}
11
34
  };
12
- const getParamTypes = (e)=>{
13
- return Reflect.getMetadata(ReflectParamTypes, e) || [];
35
+ let ActiveDebugLogger = class ActiveDebugLogger {
36
+ configure(o) {
37
+ this.options = {
38
+ ...this.options,
39
+ ...o,
40
+ logPhases: {
41
+ ...this.options.logPhases,
42
+ ...o.logPhases || {}
43
+ }
44
+ };
45
+ }
46
+ logBuildStart(o) {
47
+ this.log('info', 'Build started', {
48
+ entry: o.name
49
+ });
50
+ }
51
+ logBuildEnd(o, e) {
52
+ const t = {
53
+ entry: o.name
54
+ };
55
+ if (e !== undefined) t.duration = `${e.toFixed(2)}ms`;
56
+ this.log('info', 'Build completed', t);
57
+ }
58
+ logRegistration(o) {
59
+ if (!this.shouldLog('registration')) return;
60
+ this.log('info', 'Registration', {
61
+ identifier: o.identifier?.name || String(o.identifier),
62
+ isSingleton: o.isSingleton,
63
+ dependencies: o.dependencies.map((o)=>o?.name || String(o)),
64
+ tags: o.tags
65
+ });
66
+ }
67
+ logHook(e, t, n) {
68
+ if (!this.shouldLog('hooks')) return;
69
+ const i = this.options.logTimings ? performance.now() : 0;
70
+ this.log('info', `Hook: ${e}`, {
71
+ target: o(t),
72
+ config: n
73
+ });
74
+ if (this.options.logTimings) {
75
+ return ()=>{
76
+ const o = performance.now() - i;
77
+ this.log('info', `Hook: ${e} completed`, {
78
+ duration: `${o.toFixed(2)}ms`
79
+ });
80
+ };
81
+ }
82
+ }
83
+ logPhaseStart(o, e) {
84
+ this.log('info', `Phase: ${o} started`, e);
85
+ }
86
+ logPhaseEnd(o, e, t) {
87
+ const n = e !== undefined ? {
88
+ duration: `${e.toFixed(2)}ms`
89
+ } : {};
90
+ if (t) {
91
+ Object.assign(n, t);
92
+ }
93
+ this.log('info', `Phase: ${o} ended`, Object.keys(n).length > 0 ? n : undefined);
94
+ }
95
+ logResolution(o, e, t) {
96
+ if (!this.shouldLog('resolution')) return;
97
+ this.log('info', `Resolving: ${o}`, {
98
+ strategy: `${e} strategy`,
99
+ cache: t ? 'hit' : 'miss'
100
+ });
101
+ }
102
+ logConstruction(o) {
103
+ if (!this.shouldLog('construction')) return;
104
+ this.log('info', `Constructing: ${o}`);
105
+ }
106
+ shouldLog(o) {
107
+ return !this.options.logPhases || this.options.logPhases[o] !== false;
108
+ }
109
+ log(o, e, t) {
110
+ if (this.options.logger) {
111
+ this.options.logger(o, e, t);
112
+ } else {
113
+ const n = `[Assembler:${o}]`;
114
+ const i = this.options.useColors !== false ? this.colorize(o, n) : n;
115
+ if (t) {
116
+ console.log(`${i} ${e}`, t);
117
+ } else {
118
+ console.log(`${i} ${e}`);
119
+ }
120
+ }
121
+ }
122
+ colorize(o, e) {
123
+ const t = {
124
+ info: '\x1b[36m',
125
+ warn: '\x1b[33m',
126
+ error: '\x1b[31m',
127
+ reset: '\x1b[0m'
128
+ };
129
+ const n = t[o] || t.info;
130
+ return `${n}${e}${t.reset}`;
131
+ }
132
+ constructor(){
133
+ this.options = {
134
+ enabled: true,
135
+ logPhases: {
136
+ registration: true,
137
+ resolution: true,
138
+ construction: true,
139
+ hooks: true,
140
+ cache: true
141
+ },
142
+ logTimings: false,
143
+ logDependencyTree: true,
144
+ useColors: true
145
+ };
146
+ }
14
147
  };
148
+ class DebugLogger {
149
+ static getInstance() {
150
+ return DebugLogger.instance;
151
+ }
152
+ static enable(o) {
153
+ DebugLogger.instance = new ActiveDebugLogger();
154
+ if (o) {
155
+ DebugLogger.instance.configure(o);
156
+ }
157
+ }
158
+ static disable() {
159
+ DebugLogger.instance = new NoOpDebugLogger();
160
+ }
161
+ }
162
+ DebugLogger.instance = new NoOpDebugLogger();
15
163
 
16
- export { defineCustomMetadata, getCustomMetadata, getOwnCustomMetadata, getParamTypes };
164
+ export { DebugLogger };
package/dist/index37.js CHANGED
@@ -2,112 +2,45 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const constants = require('./index28.js');
6
- const reflection = require('./index36.js');
7
- const helpers = require('./index3.js');
5
+ const eventManager = require('./index6.js');
8
6
 
9
- const n = {
10
- singleton: {
11
- test: (r)=>typeof r === 'boolean' || typeof r === 'undefined',
12
- throw: ()=>{
13
- throw new Error(`'singleton' property must be of type 'boolean' or 'undefined'.`);
14
- },
15
- transform: (r)=>{
16
- return typeof r === 'undefined' ? true : r ? true : false;
7
+ const registerEvents = (t, n)=>{
8
+ const o = t.concrete !== undefined && 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);
17
15
  }
18
- },
19
- events: {
20
- test: (r)=>typeof r === 'undefined' || Array.isArray(r) && r.every((r)=>typeof r === 'string'),
21
- throw: ()=>{
22
- throw new Error(`'events' property must be an array of strings or 'undefined'.`);
23
- },
24
- transform: (r)=>r
25
- },
26
- inject: {
27
- test: (r)=>typeof r === 'undefined' || Array.isArray(r) && r.every((r)=>Array.isArray(r) && r.length >= 1 && r.length <= 3),
28
- throw: ()=>{
29
- throw new Error(`'inject' property must be an array of tuples of length 1, 2 or 3.`);
30
- },
31
- transform: (r)=>r
32
- },
33
- use: {
34
- test: (r)=>typeof r === 'undefined' || Array.isArray(r) && r.every((r)=>{
35
- if (!Array.isArray(r) || r.length !== 2) {
36
- return false;
37
- }
38
- const e = r[1];
39
- return typeof e !== 'undefined';
40
- }),
41
- throw: ()=>{
42
- throw new Error(`'use' property must be an array of tuples of length 2 with [identifier, instance | factory].`);
43
- },
44
- transform: (r)=>r
45
- },
46
- engage: {
47
- test: (r)=>typeof r === 'undefined' || Array.isArray(r) && r.every((r)=>Array.isArray(r) && r.length >= 1 && r.length <= 3),
48
- throw: ()=>{
49
- throw new Error(`'engage' property must be an array of tuples of length 1, 2 or 3.`);
50
- },
51
- transform: (r)=>r
52
- },
53
- tags: {
54
- test: (r)=>typeof r === 'undefined' || typeof r === 'string' || Array.isArray(r) && r.every((r)=>typeof r === 'string'),
55
- throw: ()=>{
56
- throw new Error(`'tags' property must be a string or an array of strings.`);
57
- },
58
- transform: (r)=>typeof r === 'string' ? [
59
- r
60
- ] : r
61
- },
62
- metadata: {
63
- test: (r)=>(typeof r === 'object' || typeof r === 'undefined') && !Array.isArray(r),
64
- throw: ()=>{
65
- throw new Error(`'metadata' property must be of type 'object' or 'undefined'.`);
66
- },
67
- transform: (r)=>r
68
- },
69
- global: {
70
- test: (r)=>(typeof r === 'object' || typeof r === 'undefined') && !Array.isArray(r),
71
- throw: ()=>{
72
- throw new Error(`'global' property must be of type 'object' or 'undefined'.`);
73
- },
74
- transform: (r)=>r
75
- }
76
- };
77
- const validateDefinition = (r)=>{
78
- const e = {
79
- ...r
80
- };
81
- for(const r in e){
82
- if (!Object.keys(n).includes(r)) {
83
- throw new Error(`Property '${r}' is not a valid assemblage definition property.`);
16
+ for (const e of t.events){
17
+ n.on(e, (...n)=>{
18
+ t.privateContext.emit(e, ...n);
19
+ });
84
20
  }
85
- }
86
- for(const r in n){
87
- const t = n[r].test;
88
- const o = n[r].throw;
89
- const s = n[r].transform;
90
- if (!t(e[r])) {
91
- o();
21
+ } else {
22
+ for (const e of t.events){
23
+ if (!t.privateContext.events.has(e)) t.privateContext.addChannels(e);
92
24
  }
93
- e[r] = s(e[r]);
94
25
  }
95
- return e;
96
26
  };
97
- const getDefinition = (e)=>{
98
- if (!helpers.isAssemblage(e)) {
99
- throw new Error(`Class '${e.name}' is not an assemblage or transversal.`);
27
+ const unregisterEvents = (t, n)=>{
28
+ const o = t.concrete !== undefined && t.concrete.prototype instanceof eventManager.EventManager;
29
+ if (o) {
30
+ const e = n;
31
+ for (const n of t.events){
32
+ e.off(n);
33
+ }
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
+ }
41
+ }
100
42
  }
101
- return reflection.getOwnCustomMetadata(constants.ReflectValue.AssemblageDefinition, e);
102
- };
103
- const setDefinitionValue = (t, o, n)=>{
104
- const s = getDefinition(n);
105
- s[t] = o;
106
- const a = validateDefinition(s);
107
- reflection.defineCustomMetadata(constants.ReflectValue.AssemblageDefinition, a, n);
108
- return a;
109
43
  };
110
44
 
111
- exports.getDefinition = getDefinition;
112
- exports.setDefinitionValue = setDefinitionValue;
113
- exports.validateDefinition = validateDefinition;
45
+ exports.registerEvents = registerEvents;
46
+ exports.unregisterEvents = unregisterEvents;
package/dist/index37.mjs CHANGED
@@ -1,107 +1,41 @@
1
- import { ReflectValue } from './index28.mjs';
2
- import { getOwnCustomMetadata, defineCustomMetadata } from './index36.mjs';
3
- import { isAssemblage } from './index3.mjs';
1
+ import { EventManager } from './index6.mjs';
4
2
 
5
- const n = {
6
- singleton: {
7
- test: (r)=>typeof r === 'boolean' || typeof r === 'undefined',
8
- throw: ()=>{
9
- throw new Error(`'singleton' property must be of type 'boolean' or 'undefined'.`);
10
- },
11
- transform: (r)=>{
12
- return typeof r === 'undefined' ? true : r ? true : false;
3
+ const registerEvents = (t, n)=>{
4
+ const o = t.concrete !== undefined && 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);
13
11
  }
14
- },
15
- events: {
16
- test: (r)=>typeof r === 'undefined' || Array.isArray(r) && r.every((r)=>typeof r === 'string'),
17
- throw: ()=>{
18
- throw new Error(`'events' property must be an array of strings or 'undefined'.`);
19
- },
20
- transform: (r)=>r
21
- },
22
- inject: {
23
- test: (r)=>typeof r === 'undefined' || Array.isArray(r) && r.every((r)=>Array.isArray(r) && r.length >= 1 && r.length <= 3),
24
- throw: ()=>{
25
- throw new Error(`'inject' property must be an array of tuples of length 1, 2 or 3.`);
26
- },
27
- transform: (r)=>r
28
- },
29
- use: {
30
- test: (r)=>typeof r === 'undefined' || Array.isArray(r) && r.every((r)=>{
31
- if (!Array.isArray(r) || r.length !== 2) {
32
- return false;
33
- }
34
- const e = r[1];
35
- return typeof e !== 'undefined';
36
- }),
37
- throw: ()=>{
38
- throw new Error(`'use' property must be an array of tuples of length 2 with [identifier, instance | factory].`);
39
- },
40
- transform: (r)=>r
41
- },
42
- engage: {
43
- test: (r)=>typeof r === 'undefined' || Array.isArray(r) && r.every((r)=>Array.isArray(r) && r.length >= 1 && r.length <= 3),
44
- throw: ()=>{
45
- throw new Error(`'engage' property must be an array of tuples of length 1, 2 or 3.`);
46
- },
47
- transform: (r)=>r
48
- },
49
- tags: {
50
- test: (r)=>typeof r === 'undefined' || typeof r === 'string' || Array.isArray(r) && r.every((r)=>typeof r === 'string'),
51
- throw: ()=>{
52
- throw new Error(`'tags' property must be a string or an array of strings.`);
53
- },
54
- transform: (r)=>typeof r === 'string' ? [
55
- r
56
- ] : r
57
- },
58
- metadata: {
59
- test: (r)=>(typeof r === 'object' || typeof r === 'undefined') && !Array.isArray(r),
60
- throw: ()=>{
61
- throw new Error(`'metadata' property must be of type 'object' or 'undefined'.`);
62
- },
63
- transform: (r)=>r
64
- },
65
- global: {
66
- test: (r)=>(typeof r === 'object' || typeof r === 'undefined') && !Array.isArray(r),
67
- throw: ()=>{
68
- throw new Error(`'global' property must be of type 'object' or 'undefined'.`);
69
- },
70
- transform: (r)=>r
71
- }
72
- };
73
- const validateDefinition = (r)=>{
74
- const e = {
75
- ...r
76
- };
77
- for(const r in e){
78
- if (!Object.keys(n).includes(r)) {
79
- throw new Error(`Property '${r}' is not a valid assemblage definition property.`);
12
+ for (const e of t.events){
13
+ n.on(e, (...n)=>{
14
+ t.privateContext.emit(e, ...n);
15
+ });
80
16
  }
81
- }
82
- for(const r in n){
83
- const t = n[r].test;
84
- const o = n[r].throw;
85
- const s = n[r].transform;
86
- if (!t(e[r])) {
87
- o();
17
+ } else {
18
+ for (const e of t.events){
19
+ if (!t.privateContext.events.has(e)) t.privateContext.addChannels(e);
88
20
  }
89
- e[r] = s(e[r]);
90
21
  }
91
- return e;
92
22
  };
93
- const getDefinition = (e)=>{
94
- if (!isAssemblage(e)) {
95
- throw new Error(`Class '${e.name}' is not an assemblage or transversal.`);
23
+ const unregisterEvents = (t, n)=>{
24
+ const o = t.concrete !== undefined && t.concrete.prototype instanceof EventManager;
25
+ if (o) {
26
+ const e = n;
27
+ for (const n of t.events){
28
+ e.off(n);
29
+ }
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
+ }
37
+ }
96
38
  }
97
- return getOwnCustomMetadata(ReflectValue.AssemblageDefinition, e);
98
- };
99
- const setDefinitionValue = (t, o, n)=>{
100
- const s = getDefinition(n);
101
- s[t] = o;
102
- const a = validateDefinition(s);
103
- defineCustomMetadata(ReflectValue.AssemblageDefinition, a, n);
104
- return a;
105
39
  };
106
40
 
107
- export { getDefinition, setDefinitionValue, validateDefinition };
41
+ export { registerEvents, unregisterEvents };