assemblerjs 1.1.23 → 1.1.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.
Files changed (80) hide show
  1. package/dist/index.d.ts +122 -0
  2. package/dist/index.js +15 -13
  3. package/dist/index.mjs +14 -13
  4. package/dist/index11.js +3 -3
  5. package/dist/index11.mjs +3 -3
  6. package/dist/index12.js +2 -2
  7. package/dist/index12.mjs +2 -2
  8. package/dist/index13.js +2 -2
  9. package/dist/index13.mjs +2 -2
  10. package/dist/index14.js +144 -3
  11. package/dist/index14.mjs +144 -3
  12. package/dist/index15.js +4 -22
  13. package/dist/index15.mjs +4 -22
  14. package/dist/index16.js +20 -9
  15. package/dist/index16.mjs +20 -9
  16. package/dist/index17.js +9 -87
  17. package/dist/index17.mjs +9 -87
  18. package/dist/index18.js +88 -16
  19. package/dist/index18.mjs +88 -16
  20. package/dist/index19.js +10 -10
  21. package/dist/index19.mjs +10 -10
  22. package/dist/index2.js +3 -3
  23. package/dist/index2.mjs +3 -3
  24. package/dist/index20.js +10 -10
  25. package/dist/index20.mjs +10 -10
  26. package/dist/index21.js +10 -10
  27. package/dist/index21.mjs +10 -10
  28. package/dist/index22.js +11 -26
  29. package/dist/index22.mjs +11 -25
  30. package/dist/index23.js +22 -22
  31. package/dist/index23.mjs +21 -21
  32. package/dist/index24.js +25 -19
  33. package/dist/index24.mjs +24 -19
  34. package/dist/index25.js +23 -25
  35. package/dist/index25.mjs +23 -21
  36. package/dist/index26.js +26 -46
  37. package/dist/index26.mjs +22 -45
  38. package/dist/index27.js +50 -2
  39. package/dist/index27.mjs +47 -2
  40. package/dist/index28.js +2 -19
  41. package/dist/index28.mjs +2 -15
  42. package/dist/index29.js +17 -159
  43. package/dist/index29.mjs +15 -158
  44. package/dist/index3.js +2 -2
  45. package/dist/index3.mjs +2 -2
  46. package/dist/index30.js +34 -44
  47. package/dist/index30.mjs +33 -44
  48. package/dist/index31.js +145 -66
  49. package/dist/index31.mjs +145 -67
  50. package/dist/index32.js +45 -50
  51. package/dist/index32.mjs +45 -50
  52. package/dist/index33.js +76 -28
  53. package/dist/index33.mjs +76 -28
  54. package/dist/index34.js +50 -170
  55. package/dist/index34.mjs +50 -170
  56. package/dist/index35.js +28 -60
  57. package/dist/index35.mjs +28 -60
  58. package/dist/index36.js +174 -16
  59. package/dist/index36.mjs +174 -13
  60. package/dist/index37.js +57 -16
  61. package/dist/index37.mjs +57 -16
  62. package/dist/index38.js +13 -103
  63. package/dist/index38.mjs +10 -101
  64. package/dist/index39.js +18 -101
  65. package/dist/index39.mjs +18 -101
  66. package/dist/index4.js +7 -7
  67. package/dist/index4.mjs +7 -7
  68. package/dist/index40.js +101 -22
  69. package/dist/index40.mjs +99 -22
  70. package/dist/index41.js +24 -36
  71. package/dist/index41.mjs +24 -35
  72. package/dist/index45.js +6 -6
  73. package/dist/index45.mjs +6 -6
  74. package/dist/index49.js +1 -1
  75. package/dist/index49.mjs +1 -1
  76. package/dist/index50.js +2 -2
  77. package/dist/index50.mjs +2 -2
  78. package/dist/index51.js +2 -2
  79. package/dist/index51.mjs +2 -2
  80. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -467,6 +467,14 @@ declare interface Buildable<T> {
467
467
  configuration: Record<string, any>;
468
468
  }
469
469
 
470
+ /**
471
+ * Metadata about a woven instance caller
472
+ */
473
+ declare interface CallerMetadata {
474
+ className: string;
475
+ identifier?: string | symbol;
476
+ }
477
+
470
478
  /**
471
479
  * Injection binds a concrete class to itself as identifier
472
480
  * and provides a configuration object that will be passed to context.
@@ -914,6 +922,10 @@ export declare interface JoinPoint {
914
922
  result?: any;
915
923
  /** The error thrown by the method (if any) */
916
924
  error?: any;
925
+ /** The name of the calling assemblage class (if available) */
926
+ caller?: string;
927
+ /** The identifier of the calling assemblage (if available) */
928
+ callerIdentifier?: string | symbol;
917
929
  }
918
930
 
919
931
  declare interface LifecycleManager {
@@ -1353,6 +1365,116 @@ export declare interface TransversalMetadata {
1353
1365
  instance?: any;
1354
1366
  }
1355
1367
 
1368
+ /**
1369
+ * TransversalWeaver handles the weaving of aspects onto target instances.
1370
+ * It creates Proxy wrappers to intercept method calls and apply advices.
1371
+ */
1372
+ export declare class TransversalWeaver {
1373
+ /**
1374
+ * Registry mapping woven proxy instances to their caller metadata.
1375
+ * Uses WeakMap to allow garbage collection of instances.
1376
+ */
1377
+ private static callerRegistry;
1378
+ /**
1379
+ * Stack context for caller information.
1380
+ * Independent of Transversals - works even without any engaged aspects.
1381
+ * Allows tracking callers from external sources (Vue, Node, etc).
1382
+ */
1383
+ private static callerStack;
1384
+ /**
1385
+ * Register caller metadata for a woven instance.
1386
+ * This allows manual registration if needed beyond automatic weaving.
1387
+ *
1388
+ * @param instance The woven instance
1389
+ * @param className The name of the calling class
1390
+ * @param identifier Optional identifier of the caller
1391
+ */
1392
+ static registerCaller<T extends object>(instance: T, className: string, identifier?: string | symbol): void;
1393
+ /**
1394
+ * Get the caller metadata for a woven instance.
1395
+ *
1396
+ * @param instance The woven instance
1397
+ * @returns The caller metadata or undefined if not found
1398
+ */
1399
+ static getCallerMetadata(instance: object): CallerMetadata | undefined;
1400
+ /**
1401
+ * Execute a function with caller context.
1402
+ * The caller info will be available in Transversal advices if present,
1403
+ * or accessible via getCurrentCaller() at any time.
1404
+ *
1405
+ * Works with or without Transversals engaged.
1406
+ *
1407
+ * @param caller The name of the calling component/class
1408
+ * @param identifier Optional identifier (class reference, symbol, etc)
1409
+ * @param fn The function to execute
1410
+ * @returns The result of the function (may be a Promise)
1411
+ *
1412
+ * @example
1413
+ * ```typescript
1414
+ * // From Vue component
1415
+ * TransversalWeaver.withCaller('MyVueComponent', () => {
1416
+ * await userService.save(data);
1417
+ * });
1418
+ *
1419
+ * // From Node with identifier
1420
+ * TransversalWeaver.withCaller('UserService', UserService, () => {
1421
+ * await dataService.process();
1422
+ * });
1423
+ * ```
1424
+ */
1425
+ static withCaller<T>(caller: string, identifier?: string | symbol | (() => T | Promise<T>), fn?: () => T | Promise<T>): T | Promise<T>;
1426
+ /**
1427
+ * Get the current caller metadata from the context stack.
1428
+ * Returns undefined if no caller context is active.
1429
+ * Works even if no Transversal is engaged.
1430
+ *
1431
+ * @returns The current caller metadata or undefined
1432
+ *
1433
+ * @example
1434
+ * ```typescript
1435
+ * TransversalWeaver.withCaller('MyComponent', () => {
1436
+ * const caller = TransversalWeaver.getCurrentCaller();
1437
+ * console.log(caller?.className); // 'MyComponent'
1438
+ * });
1439
+ * ```
1440
+ */
1441
+ static getCurrentCaller(): CallerMetadata | undefined;
1442
+ /**
1443
+ * Weaves transversals onto an instance.
1444
+ * Returns a Proxy if transversals apply, otherwise returns the original instance.
1445
+ *
1446
+ * @param instance The instance to weave transversals onto
1447
+ * @param concrete The concrete class of the instance
1448
+ * @param context The assembler context
1449
+ * @returns The woven instance (may be a Proxy)
1450
+ */
1451
+ static weave<T>(instance: T, concrete: Concrete<T>, context: AssemblerContext): T;
1452
+ /**
1453
+ * Executes the advice chain (before -> around -> method -> after).
1454
+ * Handles both synchronous and asynchronous execution.
1455
+ *
1456
+ * @param advices The advices to execute
1457
+ * @param originalMethod The original method to call
1458
+ * @param target The target instance
1459
+ * @param args The method arguments
1460
+ * @param joinPoint The join point information
1461
+ * @returns The method result (may be a Promise)
1462
+ */
1463
+ private static executeAdviceChain;
1464
+ /**
1465
+ * Builds the proceed chain for around advices.
1466
+ * Each advice can call proceed() to continue to the next advice or the original method.
1467
+ *
1468
+ * @param aroundAdvices The around advices to chain
1469
+ * @param originalMethod The original method
1470
+ * @param target The target instance
1471
+ * @param args The method arguments
1472
+ * @param joinPoint The join point information
1473
+ * @returns The result of the advice chain
1474
+ */
1475
+ private static buildAroundChain;
1476
+ }
1477
+
1356
1478
  /**
1357
1479
  * Injects an object passed with `string`, `symbol` or abstract class identifier.
1358
1480
  * The identifier can be:
package/dist/index.js CHANGED
@@ -14,19 +14,20 @@ const eventManager_abstract = require('./index10.js');
14
14
  const decorators = require('./index11.js');
15
15
  const affect = require('./index12.js');
16
16
  const transversalManager = require('./index13.js');
17
- const abstract$1 = require('./index14.js');
18
- const _await = require('./index15.js');
19
- const indexFactory = require('./index16.js');
20
- const parameterDecoratorFactory = require('./index17.js');
21
- const context = require('./index18.js');
22
- const configuration = require('./index19.js');
23
- const definition = require('./index20.js');
24
- const dispose = require('./index21.js');
25
- const use = require('./index22.js');
26
- const global = require('./index23.js');
27
- const optional = require('./index24.js');
28
- const helpers$1 = require('./index25.js');
29
- const constructorDecorator = require('./index26.js');
17
+ const transversalWeaver = require('./index14.js');
18
+ const abstract$1 = require('./index15.js');
19
+ const _await = require('./index16.js');
20
+ const indexFactory = require('./index17.js');
21
+ const parameterDecoratorFactory = require('./index18.js');
22
+ const context = require('./index19.js');
23
+ const configuration = require('./index20.js');
24
+ const definition = require('./index21.js');
25
+ const dispose = require('./index22.js');
26
+ const use = require('./index23.js');
27
+ const global = require('./index24.js');
28
+ const optional = require('./index25.js');
29
+ const helpers$1 = require('./index26.js');
30
+ const constructorDecorator = require('./index27.js');
30
31
 
31
32
 
32
33
 
@@ -49,6 +50,7 @@ exports.Transversal = decorators.Transversal;
49
50
  exports.isTransversal = decorators.isTransversal;
50
51
  exports.Affect = affect.Affect;
51
52
  exports.TransversalManager = transversalManager.TransversalManager;
53
+ exports.TransversalWeaver = transversalWeaver.TransversalWeaver;
52
54
  exports.AbstractTransversal = abstract$1.AbstractTransversal;
53
55
  exports.Await = _await.Await;
54
56
  exports.createParamIndexDecorator = indexFactory.createParamIndexDecorator;
package/dist/index.mjs CHANGED
@@ -10,16 +10,17 @@ export { AbstractEventManager } from './index10.mjs';
10
10
  export { After, Around, Before, Transversal, isTransversal } from './index11.mjs';
11
11
  export { Affect } from './index12.mjs';
12
12
  export { TransversalManager } from './index13.mjs';
13
- export { AbstractTransversal } from './index14.mjs';
14
- export { Await } from './index15.mjs';
15
- export { createParamIndexDecorator } from './index16.mjs';
16
- export { ParameterDecoratorFactory } from './index17.mjs';
17
- export { Context } from './index18.mjs';
18
- export { Configuration } from './index19.mjs';
19
- export { Definition } from './index20.mjs';
20
- export { Dispose } from './index21.mjs';
21
- export { Use, decorateUse } from './index22.mjs';
22
- export { Global, decorateGlobal } from './index23.mjs';
23
- export { Optional } from './index24.mjs';
24
- export { getDecoratedParametersIndexes, getParamIndexKey, getParamValueKey, getParameterIndexes, getParameterValues } from './index25.mjs';
25
- export { ConstructorDecorator, createConstructorDecorator } from './index26.mjs';
13
+ export { TransversalWeaver } from './index14.mjs';
14
+ export { AbstractTransversal } from './index15.mjs';
15
+ export { Await } from './index16.mjs';
16
+ export { createParamIndexDecorator } from './index17.mjs';
17
+ export { ParameterDecoratorFactory } from './index18.mjs';
18
+ export { Context } from './index19.mjs';
19
+ export { Configuration } from './index20.mjs';
20
+ export { Definition } from './index21.mjs';
21
+ export { Dispose } from './index22.mjs';
22
+ export { Use, decorateUse } from './index23.mjs';
23
+ export { Global, decorateGlobal } from './index24.mjs';
24
+ export { Optional } from './index25.mjs';
25
+ export { getDecoratedParametersIndexes, getParamIndexKey, getParamValueKey, getParameterIndexes, getParameterValues } from './index26.mjs';
26
+ export { ConstructorDecorator, createConstructorDecorator } from './index27.mjs';
package/dist/index11.js CHANGED
@@ -2,10 +2,10 @@
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');
5
+ const constants = require('./index29.js');
6
+ const reflection = require('./index38.js');
7
7
  const decorator = require('./index2.js');
8
- const schema = require('./index38.js');
8
+ const schema = require('./index40.js');
9
9
 
10
10
  function isTransversal(e) {
11
11
  try {
package/dist/index11.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { ReflectValue } from './index28.mjs';
2
- import { getCustomMetadata, defineCustomMetadata } from './index36.mjs';
1
+ import { ReflectValue } from './index29.mjs';
2
+ import { getCustomMetadata, defineCustomMetadata } from './index38.mjs';
3
3
  import { Assemblage } from './index2.mjs';
4
- import { getDefinition } from './index38.mjs';
4
+ import { getDefinition } from './index40.mjs';
5
5
 
6
6
  function isTransversal(e) {
7
7
  try {
package/dist/index12.js CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- require('./index27.js');
6
- const constants = require('./index28.js');
5
+ require('./index28.js');
6
+ const constants = require('./index29.js');
7
7
 
8
8
  function Affect(t, f) {
9
9
  return function(o, c, n) {
package/dist/index12.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import './index27.mjs';
2
- import { ReflectValue } from './index28.mjs';
1
+ import './index28.mjs';
2
+ import { ReflectValue } from './index29.mjs';
3
3
 
4
4
  function Affect(t, f) {
5
5
  return function(o, c, n) {
package/dist/index13.js CHANGED
@@ -3,9 +3,9 @@
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
5
  const core = require('@assemblerjs/core');
6
- const pointcutMatcher = require('./index40.js');
6
+ const pointcutMatcher = require('./index41.js');
7
7
  const affect = require('./index12.js');
8
- const schema = require('./index38.js');
8
+ const schema = require('./index40.js');
9
9
 
10
10
  class TransversalManager {
11
11
  static getInstance(e) {
package/dist/index13.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { isClass } from '@assemblerjs/core';
2
- import { PointcutMatcher } from './index40.mjs';
2
+ import { PointcutMatcher } from './index41.mjs';
3
3
  import { getAffectedMethods } from './index12.mjs';
4
- import { getDefinition } from './index38.mjs';
4
+ import { getDefinition } from './index40.mjs';
5
5
 
6
6
  class TransversalManager {
7
7
  static getInstance(e) {
package/dist/index14.js CHANGED
@@ -2,8 +2,149 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- class AbstractTransversal {
6
- static onRegister(s, t) {}
5
+ const transversalManager = require('./index13.js');
6
+ const affect = require('./index12.js');
7
+
8
+ class TransversalWeaver {
9
+ static registerCaller(e, t, r) {
10
+ this.callerRegistry.set(e, {
11
+ className: t,
12
+ identifier: r
13
+ });
14
+ }
15
+ static getCallerMetadata(e) {
16
+ return this.callerRegistry.get(e);
17
+ }
18
+ static withCaller(e, t, r) {
19
+ if (typeof t === 'function') {
20
+ r = t;
21
+ t = undefined;
22
+ }
23
+ const n = {
24
+ className: e,
25
+ identifier: t
26
+ };
27
+ this.callerStack.push(n);
28
+ const a = r();
29
+ if (a instanceof Promise) {
30
+ return a.finally(()=>this.callerStack.pop());
31
+ }
32
+ this.callerStack.pop();
33
+ return a;
34
+ }
35
+ static getCurrentCaller() {
36
+ return this.callerStack[this.callerStack.length - 1];
37
+ }
38
+ static weave(r, n, a) {
39
+ const s = transversalManager.TransversalManager.getInstance(a);
40
+ const c = s.getAspectsForTarget(n);
41
+ const o = Object.getPrototypeOf(r);
42
+ const l = Object.getOwnPropertyNames(o).some((e)=>{
43
+ if (e === 'constructor') return false;
44
+ const r = Object.getOwnPropertyDescriptor(o, e);
45
+ if (!r) return false;
46
+ const n = r.value && typeof r.value === 'function';
47
+ const a = r.get && typeof r.get === 'function';
48
+ if (!n && !a) return false;
49
+ const s = affect.getAffectedMethods(o, e);
50
+ return s.length > 0;
51
+ });
52
+ if (c.length === 0 && !l) {
53
+ return r;
54
+ }
55
+ const i = new Proxy(r, {
56
+ get (e, t, r) {
57
+ const n = Reflect.get(e, t, r);
58
+ if (typeof n !== 'function') {
59
+ return n;
60
+ }
61
+ return function(...r) {
62
+ const a = String(t);
63
+ const o = TransversalWeaver.callerRegistry.get(this) ?? TransversalWeaver.getCurrentCaller();
64
+ const l = {
65
+ target: e,
66
+ methodName: a,
67
+ args: r,
68
+ caller: o?.className,
69
+ callerIdentifier: o?.identifier
70
+ };
71
+ const i = s.getAdvicesForJoinPoint(l, c, e, t);
72
+ return TransversalWeaver.executeAdviceChain(i, n, e, r, l);
73
+ };
74
+ }
75
+ });
76
+ TransversalWeaver.callerRegistry.set(i, {
77
+ className: n.name,
78
+ identifier: n.name
79
+ });
80
+ return i;
81
+ }
82
+ static executeAdviceChain(e, t, r, n, a) {
83
+ const s = e.filter((e)=>e.type === 'before');
84
+ const c = e.filter((e)=>e.type === 'around');
85
+ const o = e.filter((e)=>e.type === 'after');
86
+ try {
87
+ for (const e of s){
88
+ const t = {
89
+ ...a,
90
+ config: e.config
91
+ };
92
+ e.method.call(e.transversalInstance, t);
93
+ }
94
+ let e;
95
+ if (c.length > 0) {
96
+ e = this.buildAroundChain(c, t, r, n, a);
97
+ } else {
98
+ e = t.apply(r, n);
99
+ }
100
+ if (e instanceof Promise) {
101
+ return e.then((e)=>{
102
+ for (const t of o){
103
+ const r = {
104
+ ...a,
105
+ result: e
106
+ };
107
+ t.method.call(t.transversalInstance, r);
108
+ }
109
+ return e;
110
+ }).catch((e)=>{
111
+ a.error = e;
112
+ throw e;
113
+ });
114
+ }
115
+ for (const t of o){
116
+ const r = {
117
+ ...a,
118
+ result: e,
119
+ config: t.config
120
+ };
121
+ t.method.call(t.transversalInstance, r);
122
+ }
123
+ return e;
124
+ } catch (e) {
125
+ a.error = e;
126
+ throw e;
127
+ }
128
+ }
129
+ static buildAroundChain(e, t, r, n, a) {
130
+ let s = 0;
131
+ const c = ()=>{
132
+ if (s < e.length) {
133
+ const t = e[s++];
134
+ const r = {
135
+ ...a,
136
+ proceed: c,
137
+ config: t.config
138
+ };
139
+ return t.method.call(t.transversalInstance, r);
140
+ } else {
141
+ return t.apply(r, n);
142
+ }
143
+ };
144
+ return c();
145
+ }
7
146
  }
147
+ TransversalWeaver.callerRegistry = new WeakMap();
148
+ TransversalWeaver.callerStack = [];
8
149
 
9
- exports.AbstractTransversal = AbstractTransversal;
150
+ exports.TransversalWeaver = TransversalWeaver;
package/dist/index14.mjs CHANGED
@@ -1,5 +1,146 @@
1
- class AbstractTransversal {
2
- static onRegister(s, t) {}
1
+ import { TransversalManager } from './index13.mjs';
2
+ import { getAffectedMethods } from './index12.mjs';
3
+
4
+ class TransversalWeaver {
5
+ static registerCaller(e, t, r) {
6
+ this.callerRegistry.set(e, {
7
+ className: t,
8
+ identifier: r
9
+ });
10
+ }
11
+ static getCallerMetadata(e) {
12
+ return this.callerRegistry.get(e);
13
+ }
14
+ static withCaller(e, t, r) {
15
+ if (typeof t === 'function') {
16
+ r = t;
17
+ t = undefined;
18
+ }
19
+ const n = {
20
+ className: e,
21
+ identifier: t
22
+ };
23
+ this.callerStack.push(n);
24
+ const a = r();
25
+ if (a instanceof Promise) {
26
+ return a.finally(()=>this.callerStack.pop());
27
+ }
28
+ this.callerStack.pop();
29
+ return a;
30
+ }
31
+ static getCurrentCaller() {
32
+ return this.callerStack[this.callerStack.length - 1];
33
+ }
34
+ static weave(r, n, a) {
35
+ const s = TransversalManager.getInstance(a);
36
+ const c = s.getAspectsForTarget(n);
37
+ const o = Object.getPrototypeOf(r);
38
+ const l = Object.getOwnPropertyNames(o).some((e)=>{
39
+ if (e === 'constructor') return false;
40
+ const r = Object.getOwnPropertyDescriptor(o, e);
41
+ if (!r) return false;
42
+ const n = r.value && typeof r.value === 'function';
43
+ const a = r.get && typeof r.get === 'function';
44
+ if (!n && !a) return false;
45
+ const s = getAffectedMethods(o, e);
46
+ return s.length > 0;
47
+ });
48
+ if (c.length === 0 && !l) {
49
+ return r;
50
+ }
51
+ const i = new Proxy(r, {
52
+ get (e, t, r) {
53
+ const n = Reflect.get(e, t, r);
54
+ if (typeof n !== 'function') {
55
+ return n;
56
+ }
57
+ return function(...r) {
58
+ const a = String(t);
59
+ const o = TransversalWeaver.callerRegistry.get(this) ?? TransversalWeaver.getCurrentCaller();
60
+ const l = {
61
+ target: e,
62
+ methodName: a,
63
+ args: r,
64
+ caller: o?.className,
65
+ callerIdentifier: o?.identifier
66
+ };
67
+ const i = s.getAdvicesForJoinPoint(l, c, e, t);
68
+ return TransversalWeaver.executeAdviceChain(i, n, e, r, l);
69
+ };
70
+ }
71
+ });
72
+ TransversalWeaver.callerRegistry.set(i, {
73
+ className: n.name,
74
+ identifier: n.name
75
+ });
76
+ return i;
77
+ }
78
+ static executeAdviceChain(e, t, r, n, a) {
79
+ const s = e.filter((e)=>e.type === 'before');
80
+ const c = e.filter((e)=>e.type === 'around');
81
+ const o = e.filter((e)=>e.type === 'after');
82
+ try {
83
+ for (const e of s){
84
+ const t = {
85
+ ...a,
86
+ config: e.config
87
+ };
88
+ e.method.call(e.transversalInstance, t);
89
+ }
90
+ let e;
91
+ if (c.length > 0) {
92
+ e = this.buildAroundChain(c, t, r, n, a);
93
+ } else {
94
+ e = t.apply(r, n);
95
+ }
96
+ if (e instanceof Promise) {
97
+ return e.then((e)=>{
98
+ for (const t of o){
99
+ const r = {
100
+ ...a,
101
+ result: e
102
+ };
103
+ t.method.call(t.transversalInstance, r);
104
+ }
105
+ return e;
106
+ }).catch((e)=>{
107
+ a.error = e;
108
+ throw e;
109
+ });
110
+ }
111
+ for (const t of o){
112
+ const r = {
113
+ ...a,
114
+ result: e,
115
+ config: t.config
116
+ };
117
+ t.method.call(t.transversalInstance, r);
118
+ }
119
+ return e;
120
+ } catch (e) {
121
+ a.error = e;
122
+ throw e;
123
+ }
124
+ }
125
+ static buildAroundChain(e, t, r, n, a) {
126
+ let s = 0;
127
+ const c = ()=>{
128
+ if (s < e.length) {
129
+ const t = e[s++];
130
+ const r = {
131
+ ...a,
132
+ proceed: c,
133
+ config: t.config
134
+ };
135
+ return t.method.call(t.transversalInstance, r);
136
+ } else {
137
+ return t.apply(r, n);
138
+ }
139
+ };
140
+ return c();
141
+ }
3
142
  }
143
+ TransversalWeaver.callerRegistry = new WeakMap();
144
+ TransversalWeaver.callerStack = [];
4
145
 
5
- export { AbstractTransversal };
146
+ export { TransversalWeaver };
package/dist/index15.js CHANGED
@@ -2,26 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const Await = (t, e = 25)=>{
6
- return (n, s, a)=>{
7
- const i = a.value;
8
- a.value = async function() {
9
- return new Promise((n)=>{
10
- if (this[t]) {
11
- i.apply(this);
12
- n();
13
- } else {
14
- const s = setInterval(()=>{
15
- if (this[t]) {
16
- clearInterval(s);
17
- i.apply(this);
18
- n();
19
- }
20
- }, e);
21
- }
22
- });
23
- };
24
- };
25
- };
5
+ class AbstractTransversal {
6
+ static onRegister(s, t) {}
7
+ }
26
8
 
27
- exports.Await = Await;
9
+ exports.AbstractTransversal = AbstractTransversal;
package/dist/index15.mjs CHANGED
@@ -1,23 +1,5 @@
1
- const Await = (t, e = 25)=>{
2
- return (n, s, a)=>{
3
- const i = a.value;
4
- a.value = async function() {
5
- return new Promise((n)=>{
6
- if (this[t]) {
7
- i.apply(this);
8
- n();
9
- } else {
10
- const s = setInterval(()=>{
11
- if (this[t]) {
12
- clearInterval(s);
13
- i.apply(this);
14
- n();
15
- }
16
- }, e);
17
- }
18
- });
19
- };
20
- };
21
- };
1
+ class AbstractTransversal {
2
+ static onRegister(s, t) {}
3
+ }
22
4
 
23
- export { Await };
5
+ export { AbstractTransversal };