@aom-js/core 0.0.3 → 0.1.0

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 (90) hide show
  1. package/dist/cjs/defines/callstack.d.ts +40 -0
  2. package/dist/cjs/defines/callstack.d.ts.map +1 -0
  3. package/dist/cjs/defines/callstack.js +99 -0
  4. package/dist/cjs/defines/callstack.js.map +1 -0
  5. package/dist/cjs/defines/classes.d.ts +1 -1
  6. package/dist/cjs/defines/classes.d.ts.map +1 -1
  7. package/dist/cjs/defines/classes.js.map +1 -1
  8. package/dist/cjs/defines/core.d.ts +14 -73
  9. package/dist/cjs/defines/core.d.ts.map +1 -1
  10. package/dist/cjs/defines/core.js +30 -143
  11. package/dist/cjs/defines/core.js.map +1 -1
  12. package/dist/cjs/defines/functions.d.ts +1 -2
  13. package/dist/cjs/defines/functions.d.ts.map +1 -1
  14. package/dist/cjs/defines/functions.js +0 -4
  15. package/dist/cjs/defines/functions.js.map +1 -1
  16. package/dist/cjs/defines/index.d.ts +4 -4
  17. package/dist/cjs/defines/index.js +4 -4
  18. package/dist/cjs/defines/internals.d.ts +14 -0
  19. package/dist/cjs/defines/internals.d.ts.map +1 -0
  20. package/dist/cjs/defines/internals.js +3 -0
  21. package/dist/cjs/defines/internals.js.map +1 -0
  22. package/dist/cjs/defines/node.d.ts +27 -0
  23. package/dist/cjs/defines/node.d.ts.map +1 -0
  24. package/dist/cjs/defines/node.js +82 -0
  25. package/dist/cjs/defines/node.js.map +1 -0
  26. package/dist/cjs/defines/types.d.ts +9 -4
  27. package/dist/cjs/defines/types.d.ts.map +1 -1
  28. package/dist/cjs/defines/types.js +14 -8
  29. package/dist/cjs/defines/types.js.map +1 -1
  30. package/dist/cjs/index.d.ts +1 -1
  31. package/dist/cjs/index.js +1 -1
  32. package/dist/cjs/package.json +1 -0
  33. package/dist/mjs/defines/callstack.d.ts +40 -0
  34. package/dist/mjs/defines/callstack.d.ts.map +1 -0
  35. package/dist/mjs/defines/callstack.js +94 -0
  36. package/dist/mjs/defines/callstack.js.map +1 -0
  37. package/dist/mjs/defines/classes.d.ts +9 -0
  38. package/dist/mjs/defines/classes.d.ts.map +1 -0
  39. package/dist/mjs/defines/classes.js.map +1 -1
  40. package/dist/mjs/defines/core.d.ts +18 -0
  41. package/dist/mjs/defines/core.d.ts.map +1 -0
  42. package/dist/mjs/defines/core.js +28 -141
  43. package/dist/mjs/defines/core.js.map +1 -1
  44. package/dist/mjs/defines/functions.d.ts +3 -0
  45. package/dist/mjs/defines/functions.d.ts.map +1 -0
  46. package/dist/mjs/defines/functions.js +0 -3
  47. package/dist/mjs/defines/functions.js.map +1 -1
  48. package/dist/mjs/defines/index.d.ts +5 -0
  49. package/dist/mjs/defines/index.d.ts.map +1 -0
  50. package/dist/mjs/defines/index.js +4 -4
  51. package/dist/mjs/defines/internals.d.ts +14 -0
  52. package/dist/mjs/defines/internals.d.ts.map +1 -0
  53. package/dist/mjs/defines/internals.js +2 -0
  54. package/dist/mjs/defines/internals.js.map +1 -0
  55. package/dist/mjs/defines/node.d.ts +27 -0
  56. package/dist/mjs/defines/node.d.ts.map +1 -0
  57. package/dist/mjs/defines/node.js +78 -0
  58. package/dist/mjs/defines/node.js.map +1 -0
  59. package/dist/mjs/defines/types.d.ts +17 -0
  60. package/dist/mjs/defines/types.d.ts.map +1 -0
  61. package/dist/mjs/defines/types.js +13 -7
  62. package/dist/mjs/defines/types.js.map +1 -1
  63. package/dist/mjs/index.d.ts +2 -0
  64. package/dist/mjs/index.d.ts.map +1 -0
  65. package/dist/mjs/index.js +1 -1
  66. package/dist/types/defines/callstack.d.ts +39 -0
  67. package/dist/types/defines/classes.d.ts +1 -1
  68. package/dist/types/defines/core.d.ts +14 -73
  69. package/dist/types/defines/functions.d.ts +1 -2
  70. package/dist/types/defines/index.d.ts +4 -4
  71. package/dist/types/defines/internals.d.ts +13 -0
  72. package/dist/types/defines/node.d.ts +26 -0
  73. package/dist/types/defines/types.d.ts +9 -4
  74. package/dist/types/index.d.ts +1 -1
  75. package/package.json +13 -8
  76. package/readme.md +310 -2
  77. package/dist/cjs/constants/errors.d.ts +0 -3
  78. package/dist/cjs/constants/errors.d.ts.map +0 -1
  79. package/dist/cjs/constants/errors.js +0 -6
  80. package/dist/cjs/constants/errors.js.map +0 -1
  81. package/dist/cjs/constants/index.d.ts +0 -2
  82. package/dist/cjs/constants/index.d.ts.map +0 -1
  83. package/dist/cjs/constants/index.js +0 -18
  84. package/dist/cjs/constants/index.js.map +0 -1
  85. package/dist/mjs/constants/errors.js +0 -3
  86. package/dist/mjs/constants/errors.js.map +0 -1
  87. package/dist/mjs/constants/index.js +0 -2
  88. package/dist/mjs/constants/index.js.map +0 -1
  89. package/dist/types/constants/errors.d.ts +0 -2
  90. package/dist/types/constants/index.d.ts +0 -1
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=internals.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internals.js","sourceRoot":"","sources":["../../../src/defines/internals.ts"],"names":[],"mappings":""}
@@ -0,0 +1,27 @@
1
+ import { ClassConstructor, ClassType, Property, InstanceTarget } from "./types.js";
2
+ import type { AomCore } from "./core.js";
3
+ import { AomCallstack } from "./callstack.js";
4
+ import type { AomClass, OriginDescriptor } from "./internals.js";
5
+ type NodeOriginDescriptor<T extends AomCore> = {
6
+ _: AomNode<T>;
7
+ self: T;
8
+ } & OriginDescriptor;
9
+ export declare class AomNode<T extends AomCore> {
10
+ private readonly __nominal?;
11
+ base: AomClass<T>;
12
+ target: ClassConstructor;
13
+ property?: Property;
14
+ root: T;
15
+ self: T;
16
+ originInstance: InstanceTarget;
17
+ origins: NodeOriginDescriptor<T>[];
18
+ private inherited;
19
+ properties: Map<Property, T>;
20
+ statics: Map<Property, T>;
21
+ callstack: AomCallstack<T>;
22
+ constructor(self: T, base: AomClass<any>, target: ClassConstructor, property?: Property, origin?: OriginDescriptor);
23
+ apply(): void;
24
+ inherit(parent: ClassType): T;
25
+ }
26
+ export {};
27
+ //# sourceMappingURL=node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../src/defines/node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAChF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG9D,KAAK,oBAAoB,CAAC,CAAC,SAAS,OAAO,IAAI;IAAE,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IAAC,IAAI,EAAE,CAAC,CAAA;CAAE,GAAG,gBAAgB,CAAC;AAY7F,qBAAa,OAAO,CAAC,CAAC,SAAS,OAAO;IACpC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAI;IAG/B,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;IAGlB,MAAM,EAAE,gBAAgB,CAAC;IAGzB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAIpB,IAAI,EAAE,CAAC,CAAC;IAGR,IAAI,EAAE,CAAC,CAAC;IAGR,cAAc,EAAE,cAAc,CAAC;IAS/B,OAAO,EAAE,oBAAoB,CAAC,CAAC,CAAC,EAAE,CAAC;IAInC,OAAO,CAAC,SAAS,CAAqB;IAGtC,UAAU,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;IAG7B,OAAO,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;IAI1B,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;IAE3B,YACE,IAAI,EAAE,CAAC,EACP,IAAI,EAAE,QAAQ,CAAC,GAAG,CAAC,EACnB,MAAM,EAAE,gBAAgB,EACxB,QAAQ,CAAC,EAAE,QAAQ,EACnB,MAAM,CAAC,EAAE,gBAAgB,EA0B1B;IAyBD,KAAK,SAmBJ;IA2CD,OAAO,CAAC,MAAM,EAAE,SAAS,KA+ExB;CACF"}
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AomNode = void 0;
4
+ const callstack_1 = require("./callstack.js");
5
+ class AomNode {
6
+ constructor(self, base, target, property, origin) {
7
+ this.self = self;
8
+ this.base = base;
9
+ this.target = target;
10
+ this.property = property;
11
+ this.properties = new Map();
12
+ this.statics = new Map();
13
+ this.origins = [];
14
+ this.inherited = new WeakSet();
15
+ this.callstack = new callstack_1.AomCallstack(this);
16
+ if (property) {
17
+ this.root = this.base.instance(target);
18
+ if (origin) {
19
+ this.originInstance = origin.target;
20
+ if (!origin.descriptor?.enumerable) {
21
+ this.root._.origins.push({ _: this, self, ...origin });
22
+ }
23
+ }
24
+ }
25
+ else {
26
+ this.root = this.self;
27
+ }
28
+ }
29
+ apply() {
30
+ this.properties.forEach(($) => {
31
+ $._.callstack.apply();
32
+ });
33
+ this.statics.forEach(($) => {
34
+ $._.callstack.apply();
35
+ });
36
+ this.origins.forEach(({ _ }) => {
37
+ _.callstack.apply();
38
+ });
39
+ this.callstack.apply();
40
+ }
41
+ inherit(parent) {
42
+ const $parent = this.base.instance(parent);
43
+ if (this.inherited.has(parent)) {
44
+ return $parent;
45
+ }
46
+ this.inherited.add(parent);
47
+ $parent._.callstack.transferTo(this.self);
48
+ const transferDescritorWithDecorators = (target, property, source, descriptor) => {
49
+ if (descriptor && descriptor.value) {
50
+ const curriedDescriptor = function (...args) {
51
+ return Reflect.apply(descriptor.value, this, args);
52
+ };
53
+ Reflect.defineProperty(target, property, {
54
+ ...descriptor,
55
+ value: curriedDescriptor,
56
+ });
57
+ }
58
+ const $childInstance = this.base.instance(target, property);
59
+ source._.callstack.transferTo($childInstance);
60
+ };
61
+ $parent._.origins.forEach((origin) => {
62
+ const $origin = origin.descriptor ? this.base.instance(origin.descriptor.value) : origin.self;
63
+ const isClassOrigin = origin.target === $origin._.target;
64
+ const property = $origin._.property;
65
+ if (isClassOrigin &&
66
+ !Object.hasOwn(this.target, property) &&
67
+ !this.root._.statics.get(property)) {
68
+ transferDescritorWithDecorators(this.target, property, $origin, origin.descriptor);
69
+ }
70
+ else if (!isClassOrigin &&
71
+ !Object.hasOwn(this.target.prototype, property) &&
72
+ !this.root._.properties.get(property)) {
73
+ transferDescritorWithDecorators(this.target.prototype, property, $origin, origin.descriptor);
74
+ }
75
+ else {
76
+ }
77
+ });
78
+ return $parent;
79
+ }
80
+ }
81
+ exports.AomNode = AomNode;
82
+ //# sourceMappingURL=node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.js","sourceRoot":"","sources":["../../../src/defines/node.ts"],"names":[],"mappings":";;;AAEA,2CAA2C;AAgB3C;IA6CE,YACE,IAAO,EACP,IAAmB,EACnB,MAAwB,EACxB,QAAmB,EACnB,MAAyB;QAEzB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAEzB,IAAI,CAAC,UAAU,GAAG,IAAI,GAAG,EAAE,CAAC;QAC5B,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,EAAE,CAAC;QAEzB,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAClB,IAAI,CAAC,SAAS,GAAG,IAAI,OAAO,EAAE,CAAC;QAC/B,IAAI,CAAC,SAAS,GAAG,IAAI,wBAAY,CAAC,IAAI,CAAC,CAAC;QAGxC,IAAI,QAAQ,EAAE,CAAC;YACb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;YACvC,I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AAG,CAAC,QAAQ,CAAC,EAClC,CAAC;gBACD,+BAA+B,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC;YACrF,CAAC;iBAAM,IACL,CAAC,aAAa;gBACd,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,QAAQ,CAAC;gBAC/C,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,EACrC,CAAC;gBAED,+BAA+B,CAC7B,IAAI,CAAC,MAAM,CAAC,SAAS,EACrB,QAAQ,EACR,OAAO,EACP,MAAM,CAAC,UAAU,CAClB,CAAC;YACJ,CAAC;iBAAM,CAAC;YAKR,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,OAAO,CAAC;IACjB,CAAC;CACF"}
@@ -1,12 +1,17 @@
1
1
  export declare type ClassConstructor<T extends any = {}> = new (...args: any[]) => T;
2
- export declare type Constructor = ClassConstructor | Function;
2
+ export declare type ClassType = ClassConstructor | Function;
3
3
  export declare type Property = string | symbol;
4
- export declare type InstanceTarget = Constructor | object;
5
- export declare type CombinedDecorator = <T>(target: Constructor, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<T>) => void;
6
- export declare enum DecoratorsQueueStore {
4
+ export declare type InstanceTarget = ClassType | InstanceType<ClassConstructor>;
5
+ export declare type CombinedDecorator = <T>(target: ClassType, propertyKey?: Property, descriptor?: TypedPropertyDescriptor<T>) => void;
6
+ export declare enum ExecutionPhase {
7
7
  INSTANT = "instant",
8
8
  FIRST = "first",
9
9
  LAST = "last",
10
10
  DELAY = "delay"
11
11
  }
12
+ export declare enum InheritPlacement {
13
+ APPEND = "append",
14
+ PREPEND = "prepend",
15
+ SKIP = "skip"
16
+ }
12
17
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/defines/types.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,MAAM,gBAAgB,CAAC,CAAC,SAAS,GAAG,GAAG,EAAE,IAAI,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;AACrF,MAAM,CAAC,OAAO,MAAM,WAAW,GAAG,gBAAgB,GAAG,QAAQ,CAAC;AAC9D,MAAM,CAAC,OAAO,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;AAE/C,MAAM,CAAC,OAAO,MAAM,cAAc,GAAG,WAAW,GAAG,MAAM,CAAC;AAG1D,MAAM,CAAC,OAAO,MAAM,iBAAiB,GAAG,CAAC,CAAC,EACxC,MAAM,EAAE,WAAW,EACnB,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,EAC7B,UAAU,CAAC,EAAE,uBAAuB,CAAC,CAAC,CAAC,KACpC,IAAI,CAAC;AAEV,oBAAY,oBAAoB;IAC9B,OAAO,YAAY;IACnB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,KAAK,UAAU;CAEhB"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/defines/types.ts"],"names":[],"mappings":"AAaA,MAAM,CAAC,OAAO,MAAM,gBAAgB,CAAC,CAAC,SAAS,GAAG,GAAG,EAAE,IAAI,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;AAGrF,MAAM,CAAC,OAAO,MAAM,SAAS,GAAG,gBAAgB,GAAG,QAAQ,CAAC;AAG5D,MAAM,CAAC,OAAO,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;AAO/C,MAAM,CAAC,OAAO,MAAM,cAAc,GAAG,SAAS,GAAG,YAAY,CAAC,gBAAgB,CAAC,CAAC;AAmBhF,MAAM,CAAC,OAAO,MAAM,iBAAiB,GAAG,CAAC,CAAC,EACxC,MAAM,EAAE,SAAS,EACjB,WAAW,CAAC,EAAE,QAAQ,EACtB,UAAU,CAAC,EAAE,uBAAuB,CAAC,CAAC,CAAC,KACpC,IAAI,CAAC;AAoCV,oBAAY,cAAc;IACxB,OAAO,YAAY;IACnB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,KAAK,UAAU;CAEhB;AA2BD,oBAAY,gBAAgB;IAE1B,MAAM,WAAW;IAQjB,OAAO,YAAY;IAEnB,IAAI,SAAS;CACd"}
@@ -1,11 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DecoratorsQueueStore = void 0;
4
- var DecoratorsQueueStore;
5
- (function (DecoratorsQueueStore) {
6
- DecoratorsQueueStore["INSTANT"] = "instant";
7
- DecoratorsQueueStore["FIRST"] = "first";
8
- DecoratorsQueueStore["LAST"] = "last";
9
- DecoratorsQueueStore["DELAY"] = "delay";
10
- })(DecoratorsQueueStore || (exports.DecoratorsQueueStore = DecoratorsQueueStore = {}));
3
+ exports.InheritPlacement = exports.ExecutionPhase = void 0;
4
+ var ExecutionPhase;
5
+ (function (ExecutionPhase) {
6
+ ExecutionPhase["INSTANT"] = "instant";
7
+ ExecutionPhase["FIRST"] = "first";
8
+ ExecutionPhase["LAST"] = "last";
9
+ ExecutionPhase["DELAY"] = "delay";
10
+ })(ExecutionPhase || (exports.ExecutionPhase = ExecutionPhase = {}));
11
+ var InheritPlacement;
12
+ (function (InheritPlacement) {
13
+ InheritPlacement["APPEND"] = "append";
14
+ InheritPlacement["PREPEND"] = "prepend";
15
+ InheritPlacement["SKIP"] = "skip";
16
+ })(InheritPlacement || (exports.InheritPlacement = InheritPlacement = {}));
11
17
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/defines/types.ts"],"names":[],"mappings":";;;AAaA,IAAY,oBAMX;AAND,WAAY,oBAAoB;IAC9B,2CAAmB,CAAA;IACnB,uCAAe,CAAA;IACf,qCAAa,CAAA;IACb,uCAAe,CAAA;AAEjB,CAAC,EANW,oBAAoB,oCAApB,oBAAoB,QAM/B"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/defines/types.ts"],"names":[],"mappings":";;;AAqFA,IAAY,cAMX;AAND,WAAY,cAAc;IACxB,qCAAmB,CAAA;IACnB,iCAAe,CAAA;IACf,+BAAa,CAAA;IACb,iCAAe,CAAA;AAEjB,CAAC,EANW,cAAc,aAAd,cAAc,GAAd,cAAc,QAMzB;AA2BD,IAAY,gBAaX;AAbD,WAAY,gBAAgB;IAE1B,qCAAiB,CAAA;IAQjB,uCAAmB,CAAA;IAEnB,iCAAa,CAAA;AACf,CAAC,EAbW,gBAAgB,aAAhB,gBAAgB,GAAhB,gBAAgB,QAa3B"}
@@ -1,2 +1,2 @@
1
- export * from "./defines";
1
+ export * from "./defines/index.js";
2
2
  //# sourceMappingURL=index.d.ts.map
package/dist/cjs/index.js CHANGED
@@ -14,5 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./defines"), exports);
17
+ __exportStar(require("./defines/index.js"), exports);
18
18
  //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -0,0 +1,40 @@
1
+ import { ExecutionPhase, InheritPlacement } from "./types.js";
2
+ import type { AomCore } from "./core.js";
3
+ import type { AomNode } from "./node.js";
4
+ import type { AomHandler, AomCombinedHandler, AomMethodHandler, AomPropertyHandler, AomParameterHandler } from "./internals.js";
5
+ type LazyCallHandler<T extends AomCore> = AomHandler<T> | AomCombinedHandler<T> | AomMethodHandler<T> | AomPropertyHandler<T> | AomParameterHandler<T>;
6
+ type LazyCall<T extends AomCore> = [
7
+ LazyCallHandler<T>,
8
+ args: [T, ...any],
9
+ inherit?: InheritPlacement,
10
+ parameter?: boolean
11
+ ];
12
+ export declare class AomCallstackQueue<T extends AomCore> {
13
+ private readonly __nominal?;
14
+ private queue;
15
+ private fired;
16
+ private callstack;
17
+ private type;
18
+ private async;
19
+ private deferred;
20
+ constructor(callstack: AomCallstack<T>, type: ExecutionPhase);
21
+ prependBatch(values: Array<LazyCall<any>>): void;
22
+ add<U extends T>(value: LazyCall<U>): any;
23
+ exec(): void;
24
+ run<U extends T>([handler, args]: LazyCall<U>): any;
25
+ hasParameters(): boolean;
26
+ transferTo<U extends T>(target: U, skipParameters?: boolean): void;
27
+ }
28
+ export declare class AomCallstack<T extends AomCore> {
29
+ private readonly __nominal?;
30
+ _: AomNode<T>;
31
+ stores: {
32
+ [key in ExecutionPhase]: AomCallstackQueue<T>;
33
+ };
34
+ constructor(_: AomNode<T>);
35
+ add<U extends T>(value: LazyCall<U>, storeFlag: ExecutionPhase): void;
36
+ apply(): void;
37
+ transferTo<U extends T>(target: U): void;
38
+ }
39
+ export {};
40
+ //# sourceMappingURL=callstack.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"callstack.d.ts","sourceRoot":"","sources":["../../../src/defines/callstack.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EACV,UAAU,EACV,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,aAAa,CAAC;AAIrB,KAAK,eAAe,CAAC,CAAC,SAAS,OAAO,IAClC,UAAU,CAAC,CAAC,CAAC,GACb,kBAAkB,CAAC,CAAC,CAAC,GACrB,gBAAgB,CAAC,CAAC,CAAC,GACnB,kBAAkB,CAAC,CAAC,CAAC,GACrB,mBAAmB,CAAC,CAAC,CAAC,CAAC;AAkB3B,KAAK,QAAQ,CAAC,CAAC,SAAS,OAAO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,GAAG,CAAC,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,cAAc,QAE7D;IASD,KAAK,SAIJ;IAUD,UAAU,CAAC,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC,QAYhC;CACF"}
@@ -0,0 +1,94 @@
1
+ import { ExecutionPhase, InheritPlacement } from "./types.js";
2
+ export class AomCallstackQueue {
3
+ constructor(callstack, type) {
4
+ this.callstack = callstack;
5
+ this.queue = [];
6
+ this.fired = [];
7
+ this.type = type;
8
+ this.async = [ExecutionPhase.DELAY].includes(type);
9
+ this.deferred = [ExecutionPhase.LAST, ExecutionPhase.DELAY].includes(type);
10
+ }
11
+ prependBatch(values) {
12
+ this.queue.unshift(...values);
13
+ }
14
+ add(value) {
15
+ const { type } = this;
16
+ if (this.deferred) {
17
+ this.queue.push(value);
18
+ }
19
+ else if ([ExecutionPhase.FIRST].includes(type)) {
20
+ this.fired.push(value);
21
+ return this.run(value);
22
+ }
23
+ else if (type === ExecutionPhase.INSTANT) {
24
+ return this.run(value);
25
+ }
26
+ }
27
+ exec() {
28
+ let value;
29
+ while ((value = this.queue.shift())) {
30
+ this.run(value);
31
+ this.fired.push(value);
32
+ }
33
+ }
34
+ run([handler, args]) {
35
+ if (this.async) {
36
+ setTimeout(() => {
37
+ Reflect.apply(handler, null, args);
38
+ });
39
+ }
40
+ else {
41
+ return Reflect.apply(handler, null, args);
42
+ }
43
+ }
44
+ hasParameters() {
45
+ return [...this.fired, ...this.queue].some(([, , , parameter]) => parameter);
46
+ }
47
+ transferTo(target, skipParameters = false) {
48
+ const { type } = this;
49
+ const replaceContext = (value) => {
50
+ const [handler, args, inherit, parameter] = value;
51
+ const newArgs = [target, ...args.slice(1)];
52
+ target._.callstack.add([handler, newArgs, inherit, parameter], type);
53
+ };
54
+ const prepend = [];
55
+ [...this.fired, ...this.queue].forEach((value) => {
56
+ const [handler, args, inherit, parameter] = value;
57
+ if (inherit === InheritPlacement.SKIP || (parameter && skipParameters))
58
+ return;
59
+ if (inherit === InheritPlacement.PREPEND && this.deferred) {
60
+ prepend.push([handler, [target, ...args.slice(1)], inherit, parameter]);
61
+ }
62
+ else {
63
+ replaceContext(value);
64
+ }
65
+ });
66
+ if (prepend.length) {
67
+ target._.callstack.stores[type].prependBatch(prepend);
68
+ }
69
+ }
70
+ }
71
+ export class AomCallstack {
72
+ constructor(_) {
73
+ this._ = _;
74
+ this.stores = {};
75
+ Object.values(ExecutionPhase).forEach((type) => {
76
+ this.stores[type] = new AomCallstackQueue(this, type);
77
+ });
78
+ }
79
+ add(value, storeFlag) {
80
+ this.stores[storeFlag].add(value);
81
+ }
82
+ apply() {
83
+ Object.values(ExecutionPhase).forEach((type) => {
84
+ this.stores[type].exec();
85
+ });
86
+ }
87
+ transferTo(target) {
88
+ const skipParameters = Object.values(target._.callstack.stores).some((store) => store.hasParameters());
89
+ Object.values(ExecutionPhase).forEach((type) => {
90
+ this.stores[type].transferTo(target, skipParameters);
91
+ });
92
+ }
93
+ }
94
+ //# sourceMappingURL=callstack.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"callstack.js","sourceRoot":"","sources":["../../../src/defines/callstack.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAkD3D,MAAM,OAAO,iBAAiB;IAe5B,YAAY,SAA0B,EAAE,IAAoB;QAC1D,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAE3B,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAEhB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACnD,IAAI,CAAC,QAAQ,GAAG,CAAC,cAAc,CAAC,IAAI,EAAE,cAAc,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EAAE,CACtB,CAAC;QACF,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YAC7C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;QACvD,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,9 @@
1
+ import { ClassConstructor } from "./types.js";
2
+ export declare class ClassInstanceMap {
3
+ private map;
4
+ set<T extends object>(key: ClassConstructor<T>, value: T): this;
5
+ get<T extends object>(key: ClassConstructor<T>): T | undefined;
6
+ has<T extends object>(key: ClassConstructor<T>): boolean;
7
+ delete<T extends object>(key: ClassConstructor<T>): boolean;
8
+ }
9
+ //# sourceMappingURL=classes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"classes.d.ts","sourceRoot":"","sources":["../../../src/defines/classes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAa,MAAM,SAAS,CAAC;AAyBtD,qBAAa,gBAAgB;IAE3B,OAAO,CAAC,GAAG,CAAoC;IAK/C,GAAG,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAG9D;IAKD,GAAG,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS,CAI7D;IAID,GAAG,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,OAAO,CAEvD;IAID,MAAM,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,OAAO,CAE1D;CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"classes.js","sourceRoot":"","sources":["../../../src/defines/classes.ts"],"names":[],"mappings":"AAGA,MAA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CombinedDecorator, Property, ExecutionPhase, InheritPlacement, InstanceTarget } from "./types.js";
2
+ import { AomNode } from "./node.js";
3
+ import type { AomClass, OriginDescriptor, AomHandler, AomCombinedHandler, AomMethodHandler, AomPropertyHandler, AomParameterHandler } from "./internals.js";
4
+ export declare class AomCore {
5
+ _: AomNode<this>;
6
+ constructor(base: AomClass<any>, target: ClassConstructor, property?: Property, origin?: OriginDescriptor);
7
+ private static instancesMap;
8
+ private static instanceKey;
9
+ static checkExists<T extends AomCore, E extends InstanceTarget>(this: AomClass<T>, target: E, property?: Property): T | undefined;
10
+ static instance<T extends AomCore, E extends InstanceTarget>(this: AomClass<T>, target: E, property?: Property): T;
11
+ static resolveFor<T extends AomCore>(this: AomClass<T>, $: T, context: ClassConstructor): T;
12
+ static classDecorator<T extends AomCore>(this: AomClass<T>, handler: AomHandler<T>, storeFlag?: ExecutionPhase, inherit?: InheritPlacement): ClassDecorator;
13
+ static combinedDecorator<T extends AomCore>(this: AomClass<T>, handler: AomCombinedHandler<T>, storeFlag?: ExecutionPhase, inherit?: InheritPlacement): CombinedDecorator;
14
+ static methodDecorator<T extends AomCore>(this: AomClass<T>, handler: AomMethodHandler<T>, storeFlag?: ExecutionPhase, inherit?: InheritPlacement): MethodDecorator;
15
+ static propertyDecorator<T extends AomCore>(this: AomClass<T>, handler: AomPropertyHandler<T>, storeFlag?: ExecutionPhase, inherit?: InheritPlacement): PropertyDecorator;
16
+ static parameterDecorator<T extends AomCore>(this: AomClass<T>, handler: AomParameterHandler<T>, storeFlag?: ExecutionPhase, inherit?: InheritPlacement): ParameterDecorator;
17
+ }
18
+ //# sourceMappingURL=core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../src/defines/core.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EAEjB,QAAQ,EACR,cAAc,EACd,gBAAgB,EAChB,cAAc,EACf,MAAM,SAAS,CAAC;AAEjB,O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Ac,CAQhB;IAkCD,MAAM,CAAC,iBAAiB,CAAC,CAAC,SAAS,OAAO,EACxC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,EACjB,OAAO,EAAE,kBAAkB,CAAC,CAAC,CAAC,EAC9B,SAAS,GAAE,cAAqC,EAChD,OAAO,CAAC,EAAE,gBAAgB,GACzB,iBAAiB,CASnB;IAoCD,MAAM,CAAC,eAAe,CAAC,CAAC,SAAS,OAAO,EACtC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,EACjB,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAC5B,SAAS,GAAE,cAAqC,EAChD,OAAO,CAAC,EAAE,gBAAgB,GACzB,eAAe,CAQjB;IA+BD,MAAM,CAAC,iBAAiB,CAAC,CAAC,SAAS,OAAO,EACxC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,EACjB,OAAO,EAAE,kBAAkB,CAAC,CAAC,CAAC,EAC9B,SAAS,GAAE,cAAqC,EAChD,OAAO,CAAC,EAAE,gBAAgB,GACzB,iBAAiB,CAQnB;IAsCD,MAAM,CAAC,kBAAkB,CAAC,CAAC,SAAS,OAAO,EACzC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,EACjB,OAAO,EAAE,mBAAmB,CAAC,CAAC,CAAC,EAC/B,SAAS,GAAE,cAAqC,EAChD,OAAO,CAAC,EAAE,gBAAgB,GACzB,kBAAkB,CAgBpB;CACF"}
@@ -1,130 +1,6 @@
1
- import { DecoratorsQueueStore, } from "./types";
2
- import { isClass } from "./functions";
3
- class AomCallstackQueue {
4
- constructor(callstack, type, indexed) {
5
- this.callstack = callstack;
6
- this.queue = [];
7
- this.fired = [];
8
- this.type = type;
9
- this.indexed = indexed;
10
- this.async = [DecoratorsQueueStore.DELAY].includes(type);
11
- }
12
- add(value, index) {
13
- const { type } = this;
14
- if ([DecoratorsQueueStore.LAST, DecoratorsQueueStore.DELAY].includes(type)) {
15
- index >= 0 ? (this.queue[index] = value) : this.queue.push(value);
16
- }
17
- else if ([DecoratorsQueueStore.FIRST].includes(type)) {
18
- index >= 0 ? (this.fired[index] = value) : this.fired.push(value);
19
- return this.run(value);
20
- }
21
- else if (type === DecoratorsQueueStore.INSTANT) {
22
- return this.run(value);
23
- }
24
- }
25
- exec() {
26
- while (this.queue.length) {
27
- const value = this.queue.shift();
28
- this.run(value);
29
- this.fired.push(value);
30
- }
31
- }
32
- run([handler, args]) {
33
- if (this.async) {
34
- setTimeout(() => {
35
- Reflect.apply(handler, null, args);
36
- });
37
- }
38
- else {
39
- return Reflect.apply(handler, null, args);
40
- }
41
- }
42
- transferTo(target) {
43
- const { type, indexed } = this;
44
- const replaceContext = (value, index) => {
45
- const [handler, args] = value;
46
- args[0] = target;
47
- return target._.callstack.add([handler, args], type, index);
48
- };
49
- if (indexed) {
50
- const targetIndexedStore = target._.callstack.indexes[type];
51
- const targetExistsIndexed = targetIndexedStore.queue.length || targetIndexedStore.fired.length;
52
- if (!targetExistsIndexed) {
53
- this.fired.forEach((value, index) => replaceContext(value, index));
54
- this.queue.forEach((value, index) => replaceContext(value, index));
55
- }
56
- }
57
- else {
58
- this.fired.forEach((value) => replaceContext(value));
59
- this.queue.forEach((value) => replaceContext(value));
60
- }
61
- }
62
- }
63
- class AomCallstack {
64
- constructor(_) {
65
- this._ = _;
66
- this.stores = {};
67
- this.indexes = {};
68
- Object.values(DecoratorsQueueStore).forEach((type) => {
69
- this.stores[type] = new AomCallstackQueue(this, type);
70
- this.indexes[type] = new AomCallstackQueue(this, type, true);
71
- });
72
- }
73
- add(value, storeFlag, index) {
74
- if (index >= 0) {
75
- this.indexes[storeFlag].add(value, index);
76
- }
77
- else {
78
- this.stores[storeFlag].add(value);
79
- }
80
- }
81
- apply() {
82
- Object.values(DecoratorsQueueStore).forEach((type) => {
83
- this.stores[type].exec();
84
- this.indexes[type].exec();
85
- });
86
- }
87
- transferTo(target) {
88
- Object.values(DecoratorsQueueStore).forEach((type) => {
89
- this.stores[type].transferTo(target);
90
- this.indexes[type].transferTo(target);
91
- });
92
- }
93
- }
94
- class AomNode {
95
- constructor(self, base, target, property, origin) {
96
- this.self = self;
97
- this.base = base;
98
- this.target = target;
99
- this.property = property;
100
- this.properties = new Map();
101
- this.statics = new Map();
102
- this.origins = [];
103
- this.callstack = new AomCallstack(this);
104
- if (property) {
105
- this.root = this.base.instance(target);
106
- this.originInstance = origin.target;
107
- if (origin && !origin.descriptor?.enumerable) {
108
- this.root._.origins.push({ _: this, self, ...origin });
109
- }
110
- }
111
- else {
112
- this.root = this.self;
113
- }
114
- }
115
- apply() {
116
- this.properties.forEach(($) => {
117
- $._.callstack.apply();
118
- });
119
- this.statics.forEach(($) => {
120
- $._.callstack.apply();
121
- });
122
- this.origins.forEach(({ _ }) => {
123
- _.callstack.apply();
124
- });
125
- this.callstack.apply();
126
- }
127
- }
1
+ import { ExecutionPhase, } from "./types.js";
2
+ import { isClass } from "./functions.js";
3
+ import { AomNode } from "./node.js";
128
4
  export class AomCore {
129
5
  constructor(base, target, property, origin) {
130
6
  this._ = new AomNode(this, base, target, property, origin);
@@ -155,8 +31,11 @@ export class AomCore {
155
31
  else {
156
32
  propertiesMap = constructorInstance._.properties;
157
33
  }
158
- instanceKey = propertiesMap.get(property);
159
- if (!instanceKey) {
34
+ const existing = propertiesMap.get(property);
35
+ if (existing) {
36
+ instanceKey = existing;
37
+ }
38
+ else {
160
39
  const originDescriptor = { target, property, descriptor };
161
40
  instanceKey = new this(this, constructor, property, originDescriptor);
162
41
  map.set(instanceKey, instanceKey);
@@ -179,8 +58,9 @@ export class AomCore {
179
58
  const instanceKey = this.instanceKey(target, property);
180
59
  const constructor = (target instanceof Function ? target : target.constructor);
181
60
  let instance = map.get(instanceKey);
182
- const descriptor = Reflect.getOwnPropertyDescriptor(target, property);
183
- const originDescriptor = { target, property, descriptor };
61
+ const originDescriptor = property === undefined
62
+ ? undefined
63
+ : { target, property, descriptor: Reflect.getOwnPropertyDescriptor(target, property) };
184
64
  if (!instance) {
185
65
  instance = new this(this, constructor, property, originDescriptor);
186
66
  map.set(instanceKey, instance);
@@ -190,39 +70,46 @@ export class AomCore {
190
70
  }
191
71
  return instance;
192
72
  }
193
- static classDecorator(handler, storeFlag = DecoratorsQueueStore.FIRST) {
73
+ static resolveFor($, context) {
74
+ const { target, property } = $._;
75
+ if (property && context.prototype instanceof target && Object.hasOwn(context, property)) {
76
+ return this.instance(context, property);
77
+ }
78
+ return $;
79
+ }
80
+ static classDecorator(handler, storeFlag = ExecutionPhase.FIRST, inherit) {
194
81
  const self = this;
195
82
  return function (target) {
196
83
  const targetInstance = self.instance(target);
197
- return targetInstance._.callstack.add([handler, [targetInstance]], storeFlag);
84
+ targetInstance._.callstack.add([handler, [targetInstance], inherit], storeFlag);
198
85
  };
199
86
  }
200
- static combinedDecorator(handler, storeFlag = DecoratorsQueueStore.FIRST) {
87
+ static combinedDecorator(handler, storeFlag = ExecutionPhase.FIRST, inherit) {
201
88
  const self = this;
202
89
  return function (target, property, descriptor) {
203
90
  const targetInstance = self.instance(target, property);
204
- return targetInstance._.callstack.add([handler, [targetInstance, descriptor]], storeFlag);
91
+ targetInstance._.callstack.add([handler, [targetInstance, descriptor], inherit], storeFlag);
205
92
  };
206
93
  }
207
- static methodDecorator(handler, storeFlag = DecoratorsQueueStore.FIRST) {
94
+ static methodDecorator(handler, storeFlag = ExecutionPhase.FIRST, inherit) {
208
95
  const self = this;
209
96
  return function (target, property, descriptor) {
210
97
  const targetInstance = self.instance(target, property);
211
- return targetInstance._.callstack.add([handler, [targetInstance, descriptor]], storeFlag);
98
+ targetInstance._.callstack.add([handler, [targetInstance, descriptor], inherit], storeFlag);
212
99
  };
213
100
  }
214
- static propertyDecorator(handler, storeFlag = DecoratorsQueueStore.FIRST) {
101
+ static propertyDecorator(handler, storeFlag = ExecutionPhase.FIRST, inherit) {
215
102
  const self = this;
216
103
  return function (target, property) {
217
104
  const targetInstance = self.instance(target, property);
218
- return targetInstance._.callstack.add([handler, [targetInstance]], storeFlag);
105
+ targetInstance._.callstack.add([handler, [targetInstance], inherit], storeFlag);
219
106
  };
220
107
  }
221
- static parameterDecorator(handler, storeFlag = DecoratorsQueueStore.FIRST) {
108
+ static parameterDecorator(handler, storeFlag = ExecutionPhase.FIRST, inherit) {
222
109
  const self = this;
223
110
  return function (target, property, parameterIndex) {
224
111
  const targetInstance = self.instance(target, property);
225
- return targetInstance._.callstack.add([handler, [targetInstance, parameterIndex]], storeFlag, parameterIndex);
112
+ targetInstance._.callstack.add([handler, [targetInstance, parameterIndex], inherit, true], storeFlag);
226
113
  };
227
114
  }
228
115
  }