lombok-typescript 0.6.0 → 0.8.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.
- package/README.md +24 -6
- package/dist/cli/index.cjs +157 -5
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.js +157 -5
- package/dist/cli/index.js.map +1 -1
- package/dist/codegen/index.cjs +157 -5
- package/dist/codegen/index.cjs.map +1 -1
- package/dist/codegen/index.js +157 -5
- package/dist/codegen/index.js.map +1 -1
- package/dist/legacy/index.cjs +241 -0
- package/dist/legacy/index.cjs.map +1 -1
- package/dist/legacy/index.d.cts +24 -3
- package/dist/legacy/index.d.ts +24 -3
- package/dist/legacy/index.js +232 -1
- package/dist/legacy/index.js.map +1 -1
- package/dist/stage3/index.cjs +257 -1
- package/dist/stage3/index.cjs.map +1 -1
- package/dist/stage3/index.d.cts +24 -3
- package/dist/stage3/index.d.ts +24 -3
- package/dist/stage3/index.js +248 -2
- package/dist/stage3/index.js.map +1 -1
- package/dist/{chain-of-responsibility-CQ7votcC.d.cts → visitor-B5ByGIWE.d.cts} +26 -1
- package/dist/{chain-of-responsibility-Dwsaoe4x.d.ts → visitor-BqARKwCX.d.ts} +26 -1
- package/package.json +5 -5
package/dist/stage3/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as Backend, M as MetadataStore } from '../backend-CkLBcDd8.cjs';
|
|
2
|
-
import {
|
|
3
|
-
export {
|
|
2
|
+
import { d as AnyClass, A as AccessorsOptions, F as FieldDefaultsOptions, a as FlyweightOptions, H as HandlerOptions, b as HookOptions, L as LogOptions, M as MemoizeOptions, P as ProxyHooks, S as StateOptions, T as TemplateMethodOptions, c as TransitionOptions, V as VisitorOptions } from '../visitor-B5ByGIWE.cjs';
|
|
3
|
+
export { e as CommandHistory, i as StrategyRegistry, j as createFromFactory, o as getFactoryRegistry, p as getStrategyFromRegistry, q as getStrategyRegistry, r as getVisitableRegistry, s as listStrategies, t as registerFactory, u as registerStrategy } from '../visitor-B5ByGIWE.cjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Backend for the Stage 3 ECMAScript decorator standard (TS 5.0+).
|
|
@@ -121,6 +121,27 @@ declare function Handler(options: HandlerOptions): (value: (this: unknown, ...ar
|
|
|
121
121
|
declare const Iterable: <T extends AnyClass>(value: T, context: ClassDecoratorContext) => T | void;
|
|
122
122
|
/** Marks the collection field iterated by `@Iterable`. */
|
|
123
123
|
declare const IterateOver: <This, Value>(_value: undefined, context: ClassFieldDecoratorContext<This, Value>) => void | ((this: This, initialValue: Value) => Value);
|
|
124
|
+
/** Shared instance pool keyed by constructor arguments. */
|
|
125
|
+
declare function Flyweight(options: FlyweightOptions): <T extends AnyClass>(value: T, context: ClassDecoratorContext) => T | void;
|
|
126
|
+
/** Tree composite API — add, remove, traverse children. */
|
|
127
|
+
declare const Composite: <T extends AnyClass>(value: T, context: ClassDecoratorContext) => T | void;
|
|
128
|
+
/** Runtime method interception via Proxy. */
|
|
129
|
+
declare function Proxy(hooks?: ProxyHooks): <T extends AnyClass>(value: T, context: ClassDecoratorContext) => T | void;
|
|
130
|
+
/**
|
|
131
|
+
* GoF Decorator — wraps an inner instance as `protected inner`.
|
|
132
|
+
* @see GoF Decorator Pattern (ADR-15)
|
|
133
|
+
*/
|
|
134
|
+
declare function Wraps(InnerClass: AnyClass): <T extends AnyClass>(value: T, context: ClassDecoratorContext) => T | void;
|
|
135
|
+
/** Codegen template method with ordered `@Hook` steps. */
|
|
136
|
+
declare function TemplateMethod(options: TemplateMethodOptions): <T extends AnyClass>(value: T, context: ClassDecoratorContext) => T | void;
|
|
137
|
+
/** Marks a method as a template hook step. */
|
|
138
|
+
declare function Hook(options?: Partial<HookOptions>): (value: (this: unknown, ...args: unknown[]) => unknown, context: ClassMethodDecoratorContext<unknown, (this: unknown, ...args: unknown[]) => unknown>) => void | ((this: unknown, ...args: unknown[]) => unknown);
|
|
139
|
+
/** Helper scaffold — codegen emits abstract product factory methods. */
|
|
140
|
+
declare function AbstractFactory(products: string[]): <T extends AnyClass>(value: T, context: ClassDecoratorContext) => T | void;
|
|
141
|
+
/** Double-dispatch visitor — calls `visit{ClassName}` on the visitor. */
|
|
142
|
+
declare function Visitor(options: VisitorOptions): <T extends AnyClass>(value: T, context: ClassDecoratorContext) => T | void;
|
|
143
|
+
/** Registers a node type for visitor dispatch. */
|
|
144
|
+
declare const Visitable: <T extends AnyClass>(value: T, context: ClassDecoratorContext) => T | void;
|
|
124
145
|
|
|
125
146
|
/**
|
|
126
147
|
* Stage 3 decorator backend, for the modern ECMAScript decorator standard
|
|
@@ -143,4 +164,4 @@ declare const IterateOver: <This, Value>(_value: undefined, context: ClassFieldD
|
|
|
143
164
|
/** Read the Stage 3 `Symbol.metadata` object from a class, if present. */
|
|
144
165
|
declare function getClassMetadata(cls: new (...args: any[]) => any): object | undefined;
|
|
145
166
|
|
|
146
|
-
export { Accessors, Builder, ChainOfResponsibility, Command, Data, Delegate, Equals, EqualsExclude, Factory, FieldDefaults, Getter, Handler, Iterable, IterateOver, Log, Memento, Memoize, NonNull, Observable, Observer, Prototype, Setter, Singleton, Stage3Backend, type Stage3ClassLogic, type Stage3FieldLogic, type Stage3GetterLogic, type Stage3MethodLogic, type Stage3SetterLogic, State, Strategy, ToString, Transition, UtilityClass, Value, With, defineClassDecorator, defineFieldDecorator, defineGetterDecorator, defineMethodDecorator, defineSetterDecorator, getClassMetadata, stage3Backend };
|
|
167
|
+
export { AbstractFactory, Accessors, Builder, ChainOfResponsibility, Command, Composite, Data, Delegate, Equals, EqualsExclude, Factory, FieldDefaults, Flyweight, Getter, Handler, Hook, Iterable, IterateOver, Log, Memento, Memoize, NonNull, Observable, Observer, Prototype, Proxy, Setter, Singleton, Stage3Backend, type Stage3ClassLogic, type Stage3FieldLogic, type Stage3GetterLogic, type Stage3MethodLogic, type Stage3SetterLogic, State, Strategy, TemplateMethod, ToString, Transition, UtilityClass, Value, Visitable, Visitor, With, Wraps, defineClassDecorator, defineFieldDecorator, defineGetterDecorator, defineMethodDecorator, defineSetterDecorator, getClassMetadata, stage3Backend };
|
package/dist/stage3/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as Backend, M as MetadataStore } from '../backend-CkLBcDd8.js';
|
|
2
|
-
import {
|
|
3
|
-
export {
|
|
2
|
+
import { d as AnyClass, A as AccessorsOptions, F as FieldDefaultsOptions, a as FlyweightOptions, H as HandlerOptions, b as HookOptions, L as LogOptions, M as MemoizeOptions, P as ProxyHooks, S as StateOptions, T as TemplateMethodOptions, c as TransitionOptions, V as VisitorOptions } from '../visitor-BqARKwCX.js';
|
|
3
|
+
export { e as CommandHistory, i as StrategyRegistry, j as createFromFactory, o as getFactoryRegistry, p as getStrategyFromRegistry, q as getStrategyRegistry, r as getVisitableRegistry, s as listStrategies, t as registerFactory, u as registerStrategy } from '../visitor-BqARKwCX.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Backend for the Stage 3 ECMAScript decorator standard (TS 5.0+).
|
|
@@ -121,6 +121,27 @@ declare function Handler(options: HandlerOptions): (value: (this: unknown, ...ar
|
|
|
121
121
|
declare const Iterable: <T extends AnyClass>(value: T, context: ClassDecoratorContext) => T | void;
|
|
122
122
|
/** Marks the collection field iterated by `@Iterable`. */
|
|
123
123
|
declare const IterateOver: <This, Value>(_value: undefined, context: ClassFieldDecoratorContext<This, Value>) => void | ((this: This, initialValue: Value) => Value);
|
|
124
|
+
/** Shared instance pool keyed by constructor arguments. */
|
|
125
|
+
declare function Flyweight(options: FlyweightOptions): <T extends AnyClass>(value: T, context: ClassDecoratorContext) => T | void;
|
|
126
|
+
/** Tree composite API — add, remove, traverse children. */
|
|
127
|
+
declare const Composite: <T extends AnyClass>(value: T, context: ClassDecoratorContext) => T | void;
|
|
128
|
+
/** Runtime method interception via Proxy. */
|
|
129
|
+
declare function Proxy(hooks?: ProxyHooks): <T extends AnyClass>(value: T, context: ClassDecoratorContext) => T | void;
|
|
130
|
+
/**
|
|
131
|
+
* GoF Decorator — wraps an inner instance as `protected inner`.
|
|
132
|
+
* @see GoF Decorator Pattern (ADR-15)
|
|
133
|
+
*/
|
|
134
|
+
declare function Wraps(InnerClass: AnyClass): <T extends AnyClass>(value: T, context: ClassDecoratorContext) => T | void;
|
|
135
|
+
/** Codegen template method with ordered `@Hook` steps. */
|
|
136
|
+
declare function TemplateMethod(options: TemplateMethodOptions): <T extends AnyClass>(value: T, context: ClassDecoratorContext) => T | void;
|
|
137
|
+
/** Marks a method as a template hook step. */
|
|
138
|
+
declare function Hook(options?: Partial<HookOptions>): (value: (this: unknown, ...args: unknown[]) => unknown, context: ClassMethodDecoratorContext<unknown, (this: unknown, ...args: unknown[]) => unknown>) => void | ((this: unknown, ...args: unknown[]) => unknown);
|
|
139
|
+
/** Helper scaffold — codegen emits abstract product factory methods. */
|
|
140
|
+
declare function AbstractFactory(products: string[]): <T extends AnyClass>(value: T, context: ClassDecoratorContext) => T | void;
|
|
141
|
+
/** Double-dispatch visitor — calls `visit{ClassName}` on the visitor. */
|
|
142
|
+
declare function Visitor(options: VisitorOptions): <T extends AnyClass>(value: T, context: ClassDecoratorContext) => T | void;
|
|
143
|
+
/** Registers a node type for visitor dispatch. */
|
|
144
|
+
declare const Visitable: <T extends AnyClass>(value: T, context: ClassDecoratorContext) => T | void;
|
|
124
145
|
|
|
125
146
|
/**
|
|
126
147
|
* Stage 3 decorator backend, for the modern ECMAScript decorator standard
|
|
@@ -143,4 +164,4 @@ declare const IterateOver: <This, Value>(_value: undefined, context: ClassFieldD
|
|
|
143
164
|
/** Read the Stage 3 `Symbol.metadata` object from a class, if present. */
|
|
144
165
|
declare function getClassMetadata(cls: new (...args: any[]) => any): object | undefined;
|
|
145
166
|
|
|
146
|
-
export { Accessors, Builder, ChainOfResponsibility, Command, Data, Delegate, Equals, EqualsExclude, Factory, FieldDefaults, Getter, Handler, Iterable, IterateOver, Log, Memento, Memoize, NonNull, Observable, Observer, Prototype, Setter, Singleton, Stage3Backend, type Stage3ClassLogic, type Stage3FieldLogic, type Stage3GetterLogic, type Stage3MethodLogic, type Stage3SetterLogic, State, Strategy, ToString, Transition, UtilityClass, Value, With, defineClassDecorator, defineFieldDecorator, defineGetterDecorator, defineMethodDecorator, defineSetterDecorator, getClassMetadata, stage3Backend };
|
|
167
|
+
export { AbstractFactory, Accessors, Builder, ChainOfResponsibility, Command, Composite, Data, Delegate, Equals, EqualsExclude, Factory, FieldDefaults, Flyweight, Getter, Handler, Hook, Iterable, IterateOver, Log, Memento, Memoize, NonNull, Observable, Observer, Prototype, Proxy, Setter, Singleton, Stage3Backend, type Stage3ClassLogic, type Stage3FieldLogic, type Stage3GetterLogic, type Stage3MethodLogic, type Stage3SetterLogic, State, Strategy, TemplateMethod, ToString, Transition, UtilityClass, Value, Visitable, Visitor, With, Wraps, defineClassDecorator, defineFieldDecorator, defineGetterDecorator, defineMethodDecorator, defineSetterDecorator, getClassMetadata, stage3Backend };
|
package/dist/stage3/index.js
CHANGED
|
@@ -101,7 +101,12 @@ var MetadataKeys = {
|
|
|
101
101
|
// Class-level (GoF)
|
|
102
102
|
SINGLETON: `${PREFIX}singleton`,
|
|
103
103
|
FACTORY: `${PREFIX}factory`,
|
|
104
|
+
ABSTRACT_FACTORY: `${PREFIX}abstractFactory`,
|
|
104
105
|
PROTOTYPE: `${PREFIX}prototype`,
|
|
106
|
+
COMPOSITE: `${PREFIX}composite`,
|
|
107
|
+
WRAPS: `${PREFIX}wraps`,
|
|
108
|
+
FLYWEIGHT: `${PREFIX}flyweight`,
|
|
109
|
+
PROXY: `${PREFIX}proxy`,
|
|
105
110
|
CHAIN_OF_RESPONSIBILITY: `${PREFIX}chainOfResponsibility`,
|
|
106
111
|
COMMAND: `${PREFIX}command`,
|
|
107
112
|
ITERABLE: `${PREFIX}iterable`,
|
|
@@ -109,6 +114,9 @@ var MetadataKeys = {
|
|
|
109
114
|
MEMENTO_EXCLUDE: `${PREFIX}memento:exclude`,
|
|
110
115
|
STATE: `${PREFIX}state`,
|
|
111
116
|
STRATEGY: `${PREFIX}strategy`,
|
|
117
|
+
TEMPLATE_METHOD: `${PREFIX}templateMethod`,
|
|
118
|
+
VISITABLE: `${PREFIX}visitable`,
|
|
119
|
+
VISITOR: `${PREFIX}visitor`,
|
|
112
120
|
// Field-level
|
|
113
121
|
GETTER: `${PREFIX}getter`,
|
|
114
122
|
SETTER: `${PREFIX}setter`,
|
|
@@ -120,7 +128,8 @@ var MetadataKeys = {
|
|
|
120
128
|
// Method-level
|
|
121
129
|
MEMOIZE: `${PREFIX}memoize`,
|
|
122
130
|
HANDLER: `${PREFIX}handler`,
|
|
123
|
-
TRANSITION: `${PREFIX}transition
|
|
131
|
+
TRANSITION: `${PREFIX}transition`,
|
|
132
|
+
HOOK: `${PREFIX}hook`};
|
|
124
133
|
|
|
125
134
|
// src/decorators/shared/factory.ts
|
|
126
135
|
var factoryRegistry = /* @__PURE__ */ new Map();
|
|
@@ -874,6 +883,205 @@ function iterateOverFieldStage3(backend, context) {
|
|
|
874
883
|
registerStage3IterateField(context.metadata, context.name);
|
|
875
884
|
}
|
|
876
885
|
|
|
886
|
+
// src/decorators/shared/flyweight.ts
|
|
887
|
+
var pools = /* @__PURE__ */ new WeakMap();
|
|
888
|
+
function getPool(ctor) {
|
|
889
|
+
let pool = pools.get(ctor);
|
|
890
|
+
if (!pool) {
|
|
891
|
+
pool = /* @__PURE__ */ new Map();
|
|
892
|
+
pools.set(ctor, pool);
|
|
893
|
+
}
|
|
894
|
+
return pool;
|
|
895
|
+
}
|
|
896
|
+
function wrapFlyweightClass(target, options) {
|
|
897
|
+
const pool = getPool(target);
|
|
898
|
+
const FlyweightClass = class extends target {
|
|
899
|
+
constructor(...args) {
|
|
900
|
+
const key = options.key(...args);
|
|
901
|
+
const existing = pool.get(key);
|
|
902
|
+
if (existing) {
|
|
903
|
+
return existing;
|
|
904
|
+
}
|
|
905
|
+
super(...args);
|
|
906
|
+
pool.set(key, this);
|
|
907
|
+
}
|
|
908
|
+
};
|
|
909
|
+
return FlyweightClass;
|
|
910
|
+
}
|
|
911
|
+
function flyweightClassStage3(backend, value, context, options) {
|
|
912
|
+
if (typeof options?.key !== "function") {
|
|
913
|
+
throw new Error("@Flyweight requires a `key` function in options");
|
|
914
|
+
}
|
|
915
|
+
backend.metadata.set(MetadataKeys.FLYWEIGHT, context.metadata, void 0, options);
|
|
916
|
+
return wrapFlyweightClass(value, options);
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
// src/decorators/shared/composite.ts
|
|
920
|
+
var CHILDREN = /* @__PURE__ */ Symbol("lombok-ts:composite-children");
|
|
921
|
+
function getChildren(instance) {
|
|
922
|
+
const bag = instance;
|
|
923
|
+
if (!bag[CHILDREN]) {
|
|
924
|
+
bag[CHILDREN] = [];
|
|
925
|
+
}
|
|
926
|
+
return bag[CHILDREN];
|
|
927
|
+
}
|
|
928
|
+
function wrapCompositeClass(target) {
|
|
929
|
+
const CompositeClass = class extends target {
|
|
930
|
+
add(child) {
|
|
931
|
+
getChildren(this).push(child);
|
|
932
|
+
}
|
|
933
|
+
remove(child) {
|
|
934
|
+
const children = getChildren(this);
|
|
935
|
+
const index = children.indexOf(child);
|
|
936
|
+
if (index >= 0) {
|
|
937
|
+
children.splice(index, 1);
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
getChild(index) {
|
|
941
|
+
const children = getChildren(this);
|
|
942
|
+
const child = children[index];
|
|
943
|
+
if (child === void 0) {
|
|
944
|
+
throw new RangeError(`@Composite: no child at index ${index}`);
|
|
945
|
+
}
|
|
946
|
+
return child;
|
|
947
|
+
}
|
|
948
|
+
getChildren() {
|
|
949
|
+
return [...getChildren(this)];
|
|
950
|
+
}
|
|
951
|
+
traverse(callback) {
|
|
952
|
+
const visit = (node) => {
|
|
953
|
+
callback(node);
|
|
954
|
+
for (const child of getChildren(node)) {
|
|
955
|
+
visit(child);
|
|
956
|
+
}
|
|
957
|
+
};
|
|
958
|
+
visit(this);
|
|
959
|
+
}
|
|
960
|
+
*[Symbol.iterator]() {
|
|
961
|
+
yield* getChildren(this);
|
|
962
|
+
}
|
|
963
|
+
};
|
|
964
|
+
return CompositeClass;
|
|
965
|
+
}
|
|
966
|
+
function compositeClassStage3(backend, value, context) {
|
|
967
|
+
backend.metadata.set(MetadataKeys.COMPOSITE, context.metadata, void 0, true);
|
|
968
|
+
return wrapCompositeClass(value);
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
// src/decorators/shared/proxy.ts
|
|
972
|
+
function isMethod(key, value) {
|
|
973
|
+
return typeof key === "string" && key !== "constructor" && typeof value === "function";
|
|
974
|
+
}
|
|
975
|
+
function wrapProxyInstance(instance, hooks) {
|
|
976
|
+
const proto = Object.getPrototypeOf(instance);
|
|
977
|
+
return new Proxy(instance, {
|
|
978
|
+
get(target, prop, receiver) {
|
|
979
|
+
const value = Reflect.get(target, prop, receiver);
|
|
980
|
+
if (!isMethod(prop, value)) {
|
|
981
|
+
return value;
|
|
982
|
+
}
|
|
983
|
+
const original = Object.getOwnPropertyDescriptor(proto, prop)?.value ?? value;
|
|
984
|
+
return (...args) => {
|
|
985
|
+
const methodName = String(prop);
|
|
986
|
+
hooks.before?.(methodName, args);
|
|
987
|
+
const result = original.apply(target, args);
|
|
988
|
+
hooks.after?.(methodName, result);
|
|
989
|
+
return result;
|
|
990
|
+
};
|
|
991
|
+
}
|
|
992
|
+
});
|
|
993
|
+
}
|
|
994
|
+
function wrapProxyClass(target, hooks) {
|
|
995
|
+
const ProxyClass = class extends target {
|
|
996
|
+
constructor(...args) {
|
|
997
|
+
super(...args);
|
|
998
|
+
return wrapProxyInstance(this, hooks);
|
|
999
|
+
}
|
|
1000
|
+
};
|
|
1001
|
+
return ProxyClass;
|
|
1002
|
+
}
|
|
1003
|
+
function proxyClassStage3(backend, value, context, hooks = {}) {
|
|
1004
|
+
backend.metadata.set(MetadataKeys.PROXY, context.metadata, void 0, hooks);
|
|
1005
|
+
return wrapProxyClass(value, hooks);
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
// src/decorators/shared/wraps.ts
|
|
1009
|
+
var INNER = /* @__PURE__ */ Symbol("lombok-ts:wraps-inner");
|
|
1010
|
+
function wrapWrapsClass(target, InnerClass) {
|
|
1011
|
+
if (typeof InnerClass !== "function") {
|
|
1012
|
+
throw new TypeError("@Wraps requires a constructor function");
|
|
1013
|
+
}
|
|
1014
|
+
const WrapsClass = class extends target {
|
|
1015
|
+
inner;
|
|
1016
|
+
constructor(...args) {
|
|
1017
|
+
super();
|
|
1018
|
+
const inner = args[0];
|
|
1019
|
+
if (inner === void 0 || !(inner instanceof InnerClass)) {
|
|
1020
|
+
throw new TypeError(`@Wraps(${InnerClass.name}) expects an instance as the first argument`);
|
|
1021
|
+
}
|
|
1022
|
+
this.inner = inner;
|
|
1023
|
+
this[INNER] = inner;
|
|
1024
|
+
}
|
|
1025
|
+
};
|
|
1026
|
+
return WrapsClass;
|
|
1027
|
+
}
|
|
1028
|
+
function wrapsClassStage3(backend, value, context, InnerClass) {
|
|
1029
|
+
backend.metadata.set(MetadataKeys.WRAPS, context.metadata, void 0, InnerClass);
|
|
1030
|
+
return wrapWrapsClass(value, InnerClass);
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
// src/decorators/shared/template-method.ts
|
|
1034
|
+
function templateMethodClassStage3(backend, _value, context, options) {
|
|
1035
|
+
if (!Array.isArray(options?.steps) || options.steps.length === 0) {
|
|
1036
|
+
throw new Error("@TemplateMethod requires a non-empty `steps` array");
|
|
1037
|
+
}
|
|
1038
|
+
backend.metadata.set(
|
|
1039
|
+
MetadataKeys.TEMPLATE_METHOD,
|
|
1040
|
+
context.metadata,
|
|
1041
|
+
void 0,
|
|
1042
|
+
options
|
|
1043
|
+
);
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
// src/decorators/shared/hook.ts
|
|
1047
|
+
function hookMethodStage3(backend, _value, context, options) {
|
|
1048
|
+
backend.metadata.set(MetadataKeys.HOOK, context.metadata, context.name, options);
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
// src/decorators/shared/abstract-factory.ts
|
|
1052
|
+
function normalizeProducts(productsOrOptions) {
|
|
1053
|
+
const products = Array.isArray(productsOrOptions) ? productsOrOptions : productsOrOptions.products;
|
|
1054
|
+
if (!Array.isArray(products) || products.length === 0) {
|
|
1055
|
+
throw new Error("@AbstractFactory requires a non-empty product list");
|
|
1056
|
+
}
|
|
1057
|
+
return products;
|
|
1058
|
+
}
|
|
1059
|
+
function abstractFactoryClassStage3(backend, _value, context, productsOrOptions) {
|
|
1060
|
+
const products = normalizeProducts(productsOrOptions);
|
|
1061
|
+
backend.metadata.set(MetadataKeys.ABSTRACT_FACTORY, context.metadata, void 0, {
|
|
1062
|
+
products
|
|
1063
|
+
});
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
// src/decorators/shared/visitor.ts
|
|
1067
|
+
var visitableRegistry = /* @__PURE__ */ new Map();
|
|
1068
|
+
function registerVisitable(name, ctor) {
|
|
1069
|
+
visitableRegistry.set(name, ctor);
|
|
1070
|
+
}
|
|
1071
|
+
function getVisitableRegistry() {
|
|
1072
|
+
return visitableRegistry;
|
|
1073
|
+
}
|
|
1074
|
+
function visitorClassStage3(backend, _value, context, options) {
|
|
1075
|
+
if (!options?.visitMethods || typeof options.visitMethods !== "object") {
|
|
1076
|
+
throw new Error("@Visitor requires a `visitMethods` map");
|
|
1077
|
+
}
|
|
1078
|
+
backend.metadata.set(MetadataKeys.VISITOR, context.metadata, void 0, options);
|
|
1079
|
+
}
|
|
1080
|
+
function visitableClassStage3(backend, value, context, options = {}) {
|
|
1081
|
+
backend.metadata.set(MetadataKeys.VISITABLE, context.metadata, void 0, options);
|
|
1082
|
+
registerVisitable(value.name, value);
|
|
1083
|
+
}
|
|
1084
|
+
|
|
877
1085
|
// src/decorators/stage3/index.ts
|
|
878
1086
|
var NonNull = defineFieldDecorator(nonNullFieldStage3);
|
|
879
1087
|
var Singleton = defineClassDecorator(singletonClassStage3);
|
|
@@ -985,12 +1193,50 @@ function Handler(options) {
|
|
|
985
1193
|
}
|
|
986
1194
|
var Iterable = defineClassDecorator(iterableClassStage3);
|
|
987
1195
|
var IterateOver = defineFieldDecorator(iterateOverFieldStage3);
|
|
1196
|
+
function Flyweight(options) {
|
|
1197
|
+
return defineClassDecorator(
|
|
1198
|
+
(backend, value, context) => flyweightClassStage3(backend, value, context, options)
|
|
1199
|
+
);
|
|
1200
|
+
}
|
|
1201
|
+
var Composite = defineClassDecorator(compositeClassStage3);
|
|
1202
|
+
function Proxy2(hooks = {}) {
|
|
1203
|
+
return defineClassDecorator(
|
|
1204
|
+
(backend, value, context) => proxyClassStage3(backend, value, context, hooks)
|
|
1205
|
+
);
|
|
1206
|
+
}
|
|
1207
|
+
function Wraps(InnerClass) {
|
|
1208
|
+
return defineClassDecorator(
|
|
1209
|
+
(backend, value, context) => wrapsClassStage3(backend, value, context, InnerClass)
|
|
1210
|
+
);
|
|
1211
|
+
}
|
|
1212
|
+
function TemplateMethod(options) {
|
|
1213
|
+
return defineClassDecorator(
|
|
1214
|
+
(backend, value, context) => templateMethodClassStage3(backend, value, context, options)
|
|
1215
|
+
);
|
|
1216
|
+
}
|
|
1217
|
+
function Hook(options) {
|
|
1218
|
+
return defineMethodDecorator((backend, value, context) => {
|
|
1219
|
+
const name = options?.name ?? String(context.name);
|
|
1220
|
+
hookMethodStage3(backend, value, context, { name });
|
|
1221
|
+
});
|
|
1222
|
+
}
|
|
1223
|
+
function AbstractFactory(products) {
|
|
1224
|
+
return defineClassDecorator(
|
|
1225
|
+
(backend, value, context) => abstractFactoryClassStage3(backend, value, context, products)
|
|
1226
|
+
);
|
|
1227
|
+
}
|
|
1228
|
+
function Visitor(options) {
|
|
1229
|
+
return defineClassDecorator(
|
|
1230
|
+
(backend, value, context) => visitorClassStage3(backend, value, context, options)
|
|
1231
|
+
);
|
|
1232
|
+
}
|
|
1233
|
+
var Visitable = defineClassDecorator(visitableClassStage3);
|
|
988
1234
|
|
|
989
1235
|
// src/stage3/index.ts
|
|
990
1236
|
function getClassMetadata(cls) {
|
|
991
1237
|
return cls[Symbol.metadata];
|
|
992
1238
|
}
|
|
993
1239
|
|
|
994
|
-
export { Accessors, Builder, ChainOfResponsibility, Command, CommandHistory, Data, Delegate, Equals, EqualsExclude, Factory, FieldDefaults, Getter, Handler, Iterable, IterateOver, Log, Memento, Memoize, NonNull, Observable, Observer, Prototype, Setter, Singleton, Stage3Backend, State, Strategy, StrategyRegistry, ToString, Transition, UtilityClass, Value, With, createFromFactory, defineClassDecorator, defineFieldDecorator, defineGetterDecorator, defineMethodDecorator, defineSetterDecorator, getClassMetadata, getFactoryRegistry, getStrategyFromRegistry, getStrategyRegistry, listStrategies, registerFactory, registerStrategy, stage3Backend };
|
|
1240
|
+
export { AbstractFactory, Accessors, Builder, ChainOfResponsibility, Command, CommandHistory, Composite, Data, Delegate, Equals, EqualsExclude, Factory, FieldDefaults, Flyweight, Getter, Handler, Hook, Iterable, IterateOver, Log, Memento, Memoize, NonNull, Observable, Observer, Prototype, Proxy2 as Proxy, Setter, Singleton, Stage3Backend, State, Strategy, StrategyRegistry, TemplateMethod, ToString, Transition, UtilityClass, Value, Visitable, Visitor, With, Wraps, createFromFactory, defineClassDecorator, defineFieldDecorator, defineGetterDecorator, defineMethodDecorator, defineSetterDecorator, getClassMetadata, getFactoryRegistry, getStrategyFromRegistry, getStrategyRegistry, getVisitableRegistry, listStrategies, registerFactory, registerStrategy, stage3Backend };
|
|
995
1241
|
//# sourceMappingURL=index.js.map
|
|
996
1242
|
//# sourceMappingURL=index.js.map
|