lombok-typescript 0.7.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 +18 -6
- package/dist/cli/index.cjs +149 -5
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.js +149 -5
- package/dist/cli/index.js.map +1 -1
- package/dist/codegen/index.cjs +149 -5
- package/dist/codegen/index.cjs.map +1 -1
- package/dist/codegen/index.js +149 -5
- package/dist/codegen/index.js.map +1 -1
- package/dist/legacy/index.cjs +106 -0
- package/dist/legacy/index.cjs.map +1 -1
- package/dist/legacy/index.d.cts +18 -3
- package/dist/legacy/index.d.ts +18 -3
- package/dist/legacy/index.js +100 -1
- package/dist/legacy/index.js.map +1 -1
- package/dist/stage3/index.cjs +118 -1
- package/dist/stage3/index.cjs.map +1 -1
- package/dist/stage3/index.d.cts +18 -3
- package/dist/stage3/index.d.ts +18 -3
- package/dist/stage3/index.js +112 -2
- package/dist/stage3/index.js.map +1 -1
- package/dist/{proxy-BJ6_DDQ0.d.cts → visitor-B5ByGIWE.d.cts} +17 -1
- package/dist/{proxy-BQ3WvvT_.d.ts → visitor-BqARKwCX.d.ts} +17 -1
- package/package.json +2 -2
package/dist/legacy/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as Backend, M as MetadataStore } from '../backend-CkLBcDd8.cjs';
|
|
2
|
-
import { A as AccessorsOptions, F as FieldDefaultsOptions, a as FlyweightOptions, H as HandlerOptions, L as LogOptions, M as MemoizeOptions, P as ProxyHooks, S as StateOptions, T as TransitionOptions } from '../
|
|
3
|
-
export { C as ClassDecoratorLogic,
|
|
2
|
+
import { 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, d as AnyClass } from '../visitor-B5ByGIWE.cjs';
|
|
3
|
+
export { C as ClassDecoratorLogic, e as CommandHistory, f as FieldDecoratorLogic, g as MethodDecoratorLogic, h as ParameterDecoratorLogic, i as StrategyRegistry, j as createFromFactory, k as defineClassDecorator, l as defineFieldDecorator, m as defineMethodDecorator, n as defineParameterDecorator, 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
|
/** Backend for the legacy `experimentalDecorators` standard. Use the singleton `legacyBackend`. */
|
|
6
6
|
declare class LegacyBackend implements Backend {
|
|
@@ -81,5 +81,20 @@ declare function Flyweight(options: FlyweightOptions): ClassDecorator;
|
|
|
81
81
|
declare const Composite: ClassDecorator;
|
|
82
82
|
/** Runtime method interception via Proxy. */
|
|
83
83
|
declare function Proxy(hooks?: ProxyHooks): ClassDecorator;
|
|
84
|
+
/**
|
|
85
|
+
* GoF Decorator — wraps an inner instance as `protected inner`.
|
|
86
|
+
* @see GoF Decorator Pattern (ADR-15)
|
|
87
|
+
*/
|
|
88
|
+
declare function Wraps(InnerClass: AnyClass): ClassDecorator;
|
|
89
|
+
/** Codegen template method with ordered `@Hook` steps. */
|
|
90
|
+
declare function TemplateMethod(options: TemplateMethodOptions): ClassDecorator;
|
|
91
|
+
/** Marks a method as a template hook step. */
|
|
92
|
+
declare function Hook(options?: Partial<HookOptions>): MethodDecorator;
|
|
93
|
+
/** Helper scaffold — codegen emits abstract product factory methods. */
|
|
94
|
+
declare function AbstractFactory(products: string[]): ClassDecorator;
|
|
95
|
+
/** Double-dispatch visitor — calls `visit{ClassName}` on the visitor. */
|
|
96
|
+
declare function Visitor(options: VisitorOptions): ClassDecorator;
|
|
97
|
+
/** Registers a node type for visitor dispatch. */
|
|
98
|
+
declare const Visitable: ClassDecorator;
|
|
84
99
|
|
|
85
|
-
export { Accessors, Builder, ChainOfResponsibility, Command, Composite, Data, Delegate, Equals, EqualsExclude, Factory, FieldDefaults, Flyweight, Getter, Handler, Iterable, IterateOver, LegacyBackend, Log, Memento, Memoize, NonNull, NonNullParam, Observable, Observer, Prototype, Proxy, Setter, Singleton, State, Strategy, ToString, Transition, UtilityClass, Value, With, legacyBackend };
|
|
100
|
+
export { AbstractFactory, Accessors, Builder, ChainOfResponsibility, Command, Composite, Data, Delegate, Equals, EqualsExclude, Factory, FieldDefaults, Flyweight, Getter, Handler, Hook, Iterable, IterateOver, LegacyBackend, Log, Memento, Memoize, NonNull, NonNullParam, Observable, Observer, Prototype, Proxy, Setter, Singleton, State, Strategy, TemplateMethod, ToString, Transition, UtilityClass, Value, Visitable, Visitor, With, Wraps, legacyBackend };
|
package/dist/legacy/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as Backend, M as MetadataStore } from '../backend-CkLBcDd8.js';
|
|
2
|
-
import { A as AccessorsOptions, F as FieldDefaultsOptions, a as FlyweightOptions, H as HandlerOptions, L as LogOptions, M as MemoizeOptions, P as ProxyHooks, S as StateOptions, T as TransitionOptions } from '../
|
|
3
|
-
export { C as ClassDecoratorLogic,
|
|
2
|
+
import { 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, d as AnyClass } from '../visitor-BqARKwCX.js';
|
|
3
|
+
export { C as ClassDecoratorLogic, e as CommandHistory, f as FieldDecoratorLogic, g as MethodDecoratorLogic, h as ParameterDecoratorLogic, i as StrategyRegistry, j as createFromFactory, k as defineClassDecorator, l as defineFieldDecorator, m as defineMethodDecorator, n as defineParameterDecorator, 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
|
/** Backend for the legacy `experimentalDecorators` standard. Use the singleton `legacyBackend`. */
|
|
6
6
|
declare class LegacyBackend implements Backend {
|
|
@@ -81,5 +81,20 @@ declare function Flyweight(options: FlyweightOptions): ClassDecorator;
|
|
|
81
81
|
declare const Composite: ClassDecorator;
|
|
82
82
|
/** Runtime method interception via Proxy. */
|
|
83
83
|
declare function Proxy(hooks?: ProxyHooks): ClassDecorator;
|
|
84
|
+
/**
|
|
85
|
+
* GoF Decorator — wraps an inner instance as `protected inner`.
|
|
86
|
+
* @see GoF Decorator Pattern (ADR-15)
|
|
87
|
+
*/
|
|
88
|
+
declare function Wraps(InnerClass: AnyClass): ClassDecorator;
|
|
89
|
+
/** Codegen template method with ordered `@Hook` steps. */
|
|
90
|
+
declare function TemplateMethod(options: TemplateMethodOptions): ClassDecorator;
|
|
91
|
+
/** Marks a method as a template hook step. */
|
|
92
|
+
declare function Hook(options?: Partial<HookOptions>): MethodDecorator;
|
|
93
|
+
/** Helper scaffold — codegen emits abstract product factory methods. */
|
|
94
|
+
declare function AbstractFactory(products: string[]): ClassDecorator;
|
|
95
|
+
/** Double-dispatch visitor — calls `visit{ClassName}` on the visitor. */
|
|
96
|
+
declare function Visitor(options: VisitorOptions): ClassDecorator;
|
|
97
|
+
/** Registers a node type for visitor dispatch. */
|
|
98
|
+
declare const Visitable: ClassDecorator;
|
|
84
99
|
|
|
85
|
-
export { Accessors, Builder, ChainOfResponsibility, Command, Composite, Data, Delegate, Equals, EqualsExclude, Factory, FieldDefaults, Flyweight, Getter, Handler, Iterable, IterateOver, LegacyBackend, Log, Memento, Memoize, NonNull, NonNullParam, Observable, Observer, Prototype, Proxy, Setter, Singleton, State, Strategy, ToString, Transition, UtilityClass, Value, With, legacyBackend };
|
|
100
|
+
export { AbstractFactory, Accessors, Builder, ChainOfResponsibility, Command, Composite, Data, Delegate, Equals, EqualsExclude, Factory, FieldDefaults, Flyweight, Getter, Handler, Hook, Iterable, IterateOver, LegacyBackend, Log, Memento, Memoize, NonNull, NonNullParam, Observable, Observer, Prototype, Proxy, Setter, Singleton, State, Strategy, TemplateMethod, ToString, Transition, UtilityClass, Value, Visitable, Visitor, With, Wraps, legacyBackend };
|
package/dist/legacy/index.js
CHANGED
|
@@ -82,8 +82,10 @@ var MetadataKeys = {
|
|
|
82
82
|
// Class-level (GoF)
|
|
83
83
|
SINGLETON: `${PREFIX}singleton`,
|
|
84
84
|
FACTORY: `${PREFIX}factory`,
|
|
85
|
+
ABSTRACT_FACTORY: `${PREFIX}abstractFactory`,
|
|
85
86
|
PROTOTYPE: `${PREFIX}prototype`,
|
|
86
87
|
COMPOSITE: `${PREFIX}composite`,
|
|
88
|
+
WRAPS: `${PREFIX}wraps`,
|
|
87
89
|
FLYWEIGHT: `${PREFIX}flyweight`,
|
|
88
90
|
PROXY: `${PREFIX}proxy`,
|
|
89
91
|
CHAIN_OF_RESPONSIBILITY: `${PREFIX}chainOfResponsibility`,
|
|
@@ -93,6 +95,9 @@ var MetadataKeys = {
|
|
|
93
95
|
MEMENTO_EXCLUDE: `${PREFIX}memento:exclude`,
|
|
94
96
|
STATE: `${PREFIX}state`,
|
|
95
97
|
STRATEGY: `${PREFIX}strategy`,
|
|
98
|
+
TEMPLATE_METHOD: `${PREFIX}templateMethod`,
|
|
99
|
+
VISITABLE: `${PREFIX}visitable`,
|
|
100
|
+
VISITOR: `${PREFIX}visitor`,
|
|
96
101
|
// Field-level
|
|
97
102
|
GETTER: `${PREFIX}getter`,
|
|
98
103
|
SETTER: `${PREFIX}setter`,
|
|
@@ -105,6 +110,7 @@ var MetadataKeys = {
|
|
|
105
110
|
MEMOIZE: `${PREFIX}memoize`,
|
|
106
111
|
HANDLER: `${PREFIX}handler`,
|
|
107
112
|
TRANSITION: `${PREFIX}transition`,
|
|
113
|
+
HOOK: `${PREFIX}hook`,
|
|
108
114
|
// Parameter-level
|
|
109
115
|
NON_NULL_PARAM: `${PREFIX}nonNull:param`};
|
|
110
116
|
|
|
@@ -972,6 +978,76 @@ function proxyClassLegacy(backend, target, hooks = {}) {
|
|
|
972
978
|
return wrapProxyClass(target, hooks);
|
|
973
979
|
}
|
|
974
980
|
|
|
981
|
+
// src/decorators/shared/wraps.ts
|
|
982
|
+
var INNER = /* @__PURE__ */ Symbol("lombok-ts:wraps-inner");
|
|
983
|
+
function wrapWrapsClass(target, InnerClass) {
|
|
984
|
+
if (typeof InnerClass !== "function") {
|
|
985
|
+
throw new TypeError("@Wraps requires a constructor function");
|
|
986
|
+
}
|
|
987
|
+
const WrapsClass = class extends target {
|
|
988
|
+
inner;
|
|
989
|
+
constructor(...args) {
|
|
990
|
+
super();
|
|
991
|
+
const inner = args[0];
|
|
992
|
+
if (inner === void 0 || !(inner instanceof InnerClass)) {
|
|
993
|
+
throw new TypeError(`@Wraps(${InnerClass.name}) expects an instance as the first argument`);
|
|
994
|
+
}
|
|
995
|
+
this.inner = inner;
|
|
996
|
+
this[INNER] = inner;
|
|
997
|
+
}
|
|
998
|
+
};
|
|
999
|
+
return WrapsClass;
|
|
1000
|
+
}
|
|
1001
|
+
function wrapsClassLegacy(backend, target, InnerClass) {
|
|
1002
|
+
backend.metadata.set(MetadataKeys.WRAPS, target, void 0, InnerClass);
|
|
1003
|
+
return wrapWrapsClass(target, InnerClass);
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
// src/decorators/shared/template-method.ts
|
|
1007
|
+
function templateMethodClassLegacy(backend, target, options) {
|
|
1008
|
+
if (!Array.isArray(options?.steps) || options.steps.length === 0) {
|
|
1009
|
+
throw new Error("@TemplateMethod requires a non-empty `steps` array");
|
|
1010
|
+
}
|
|
1011
|
+
backend.metadata.set(MetadataKeys.TEMPLATE_METHOD, target, void 0, options);
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
// src/decorators/shared/hook.ts
|
|
1015
|
+
function hookMethodLegacy(backend, targetPrototype, propertyKey, options) {
|
|
1016
|
+
backend.metadata.set(MetadataKeys.HOOK, targetPrototype, propertyKey, options);
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
// src/decorators/shared/abstract-factory.ts
|
|
1020
|
+
function normalizeProducts(productsOrOptions) {
|
|
1021
|
+
const products = Array.isArray(productsOrOptions) ? productsOrOptions : productsOrOptions.products;
|
|
1022
|
+
if (!Array.isArray(products) || products.length === 0) {
|
|
1023
|
+
throw new Error("@AbstractFactory requires a non-empty product list");
|
|
1024
|
+
}
|
|
1025
|
+
return products;
|
|
1026
|
+
}
|
|
1027
|
+
function abstractFactoryClassLegacy(backend, target, productsOrOptions) {
|
|
1028
|
+
const products = normalizeProducts(productsOrOptions);
|
|
1029
|
+
backend.metadata.set(MetadataKeys.ABSTRACT_FACTORY, target, void 0, { products });
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
// src/decorators/shared/visitor.ts
|
|
1033
|
+
var visitableRegistry = /* @__PURE__ */ new Map();
|
|
1034
|
+
function registerVisitable(name, ctor) {
|
|
1035
|
+
visitableRegistry.set(name, ctor);
|
|
1036
|
+
}
|
|
1037
|
+
function getVisitableRegistry() {
|
|
1038
|
+
return visitableRegistry;
|
|
1039
|
+
}
|
|
1040
|
+
function visitorClassLegacy(backend, target, options) {
|
|
1041
|
+
if (!options?.visitMethods || typeof options.visitMethods !== "object") {
|
|
1042
|
+
throw new Error("@Visitor requires a `visitMethods` map");
|
|
1043
|
+
}
|
|
1044
|
+
backend.metadata.set(MetadataKeys.VISITOR, target, void 0, options);
|
|
1045
|
+
}
|
|
1046
|
+
function visitableClassLegacy(backend, target, options = {}) {
|
|
1047
|
+
backend.metadata.set(MetadataKeys.VISITABLE, target, void 0, options);
|
|
1048
|
+
registerVisitable(target.name, target);
|
|
1049
|
+
}
|
|
1050
|
+
|
|
975
1051
|
// src/decorators/legacy/index.ts
|
|
976
1052
|
var NonNull = defineFieldDecorator(nonNullFieldLegacy);
|
|
977
1053
|
function NonNullParam() {
|
|
@@ -1084,7 +1160,30 @@ var Composite = defineClassDecorator(compositeClassLegacy);
|
|
|
1084
1160
|
function Proxy2(hooks = {}) {
|
|
1085
1161
|
return defineClassDecorator((backend, target) => proxyClassLegacy(backend, target, hooks));
|
|
1086
1162
|
}
|
|
1163
|
+
function Wraps(InnerClass) {
|
|
1164
|
+
return defineClassDecorator((backend, target) => wrapsClassLegacy(backend, target, InnerClass));
|
|
1165
|
+
}
|
|
1166
|
+
function TemplateMethod(options) {
|
|
1167
|
+
return defineClassDecorator(
|
|
1168
|
+
(backend, target) => templateMethodClassLegacy(backend, target, options)
|
|
1169
|
+
);
|
|
1170
|
+
}
|
|
1171
|
+
function Hook(options) {
|
|
1172
|
+
return defineMethodDecorator((backend, target, key) => {
|
|
1173
|
+
const name = options?.name ?? String(key);
|
|
1174
|
+
hookMethodLegacy(backend, target, key, { name });
|
|
1175
|
+
});
|
|
1176
|
+
}
|
|
1177
|
+
function AbstractFactory(products) {
|
|
1178
|
+
return defineClassDecorator(
|
|
1179
|
+
(backend, target) => abstractFactoryClassLegacy(backend, target, products)
|
|
1180
|
+
);
|
|
1181
|
+
}
|
|
1182
|
+
function Visitor(options) {
|
|
1183
|
+
return defineClassDecorator((backend, target) => visitorClassLegacy(backend, target, options));
|
|
1184
|
+
}
|
|
1185
|
+
var Visitable = defineClassDecorator(visitableClassLegacy);
|
|
1087
1186
|
|
|
1088
|
-
export { Accessors, Builder, ChainOfResponsibility, Command, CommandHistory, Composite, Data, Delegate, Equals, EqualsExclude, Factory, FieldDefaults, Flyweight, Getter, Handler, Iterable, IterateOver, LegacyBackend, Log, Memento, Memoize, NonNull, NonNullParam, Observable, Observer, Prototype, Proxy2 as Proxy, Setter, Singleton, State, Strategy, StrategyRegistry, ToString, Transition, UtilityClass, Value, With, createFromFactory, defineClassDecorator, defineFieldDecorator, defineMethodDecorator, defineParameterDecorator, getFactoryRegistry, getStrategyFromRegistry, getStrategyRegistry, legacyBackend, listStrategies, registerFactory, registerStrategy };
|
|
1187
|
+
export { AbstractFactory, Accessors, Builder, ChainOfResponsibility, Command, CommandHistory, Composite, Data, Delegate, Equals, EqualsExclude, Factory, FieldDefaults, Flyweight, Getter, Handler, Hook, Iterable, IterateOver, LegacyBackend, Log, Memento, Memoize, NonNull, NonNullParam, Observable, Observer, Prototype, Proxy2 as Proxy, Setter, Singleton, State, Strategy, StrategyRegistry, TemplateMethod, ToString, Transition, UtilityClass, Value, Visitable, Visitor, With, Wraps, createFromFactory, defineClassDecorator, defineFieldDecorator, defineMethodDecorator, defineParameterDecorator, getFactoryRegistry, getStrategyFromRegistry, getStrategyRegistry, getVisitableRegistry, legacyBackend, listStrategies, registerFactory, registerStrategy };
|
|
1089
1188
|
//# sourceMappingURL=index.js.map
|
|
1090
1189
|
//# sourceMappingURL=index.js.map
|