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/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+).
|
|
@@ -127,6 +127,21 @@ declare function Flyweight(options: FlyweightOptions): <T extends AnyClass>(valu
|
|
|
127
127
|
declare const Composite: <T extends AnyClass>(value: T, context: ClassDecoratorContext) => T | void;
|
|
128
128
|
/** Runtime method interception via Proxy. */
|
|
129
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;
|
|
130
145
|
|
|
131
146
|
/**
|
|
132
147
|
* Stage 3 decorator backend, for the modern ECMAScript decorator standard
|
|
@@ -149,4 +164,4 @@ declare function Proxy(hooks?: ProxyHooks): <T extends AnyClass>(value: T, conte
|
|
|
149
164
|
/** Read the Stage 3 `Symbol.metadata` object from a class, if present. */
|
|
150
165
|
declare function getClassMetadata(cls: new (...args: any[]) => any): object | undefined;
|
|
151
166
|
|
|
152
|
-
export { Accessors, Builder, ChainOfResponsibility, Command, Composite, Data, Delegate, Equals, EqualsExclude, Factory, FieldDefaults, Flyweight, Getter, Handler, 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, 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+).
|
|
@@ -127,6 +127,21 @@ declare function Flyweight(options: FlyweightOptions): <T extends AnyClass>(valu
|
|
|
127
127
|
declare const Composite: <T extends AnyClass>(value: T, context: ClassDecoratorContext) => T | void;
|
|
128
128
|
/** Runtime method interception via Proxy. */
|
|
129
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;
|
|
130
145
|
|
|
131
146
|
/**
|
|
132
147
|
* Stage 3 decorator backend, for the modern ECMAScript decorator standard
|
|
@@ -149,4 +164,4 @@ declare function Proxy(hooks?: ProxyHooks): <T extends AnyClass>(value: T, conte
|
|
|
149
164
|
/** Read the Stage 3 `Symbol.metadata` object from a class, if present. */
|
|
150
165
|
declare function getClassMetadata(cls: new (...args: any[]) => any): object | undefined;
|
|
151
166
|
|
|
152
|
-
export { Accessors, Builder, ChainOfResponsibility, Command, Composite, Data, Delegate, Equals, EqualsExclude, Factory, FieldDefaults, Flyweight, Getter, Handler, 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, 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,8 +101,10 @@ 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`,
|
|
105
106
|
COMPOSITE: `${PREFIX}composite`,
|
|
107
|
+
WRAPS: `${PREFIX}wraps`,
|
|
106
108
|
FLYWEIGHT: `${PREFIX}flyweight`,
|
|
107
109
|
PROXY: `${PREFIX}proxy`,
|
|
108
110
|
CHAIN_OF_RESPONSIBILITY: `${PREFIX}chainOfResponsibility`,
|
|
@@ -112,6 +114,9 @@ var MetadataKeys = {
|
|
|
112
114
|
MEMENTO_EXCLUDE: `${PREFIX}memento:exclude`,
|
|
113
115
|
STATE: `${PREFIX}state`,
|
|
114
116
|
STRATEGY: `${PREFIX}strategy`,
|
|
117
|
+
TEMPLATE_METHOD: `${PREFIX}templateMethod`,
|
|
118
|
+
VISITABLE: `${PREFIX}visitable`,
|
|
119
|
+
VISITOR: `${PREFIX}visitor`,
|
|
115
120
|
// Field-level
|
|
116
121
|
GETTER: `${PREFIX}getter`,
|
|
117
122
|
SETTER: `${PREFIX}setter`,
|
|
@@ -123,7 +128,8 @@ var MetadataKeys = {
|
|
|
123
128
|
// Method-level
|
|
124
129
|
MEMOIZE: `${PREFIX}memoize`,
|
|
125
130
|
HANDLER: `${PREFIX}handler`,
|
|
126
|
-
TRANSITION: `${PREFIX}transition
|
|
131
|
+
TRANSITION: `${PREFIX}transition`,
|
|
132
|
+
HOOK: `${PREFIX}hook`};
|
|
127
133
|
|
|
128
134
|
// src/decorators/shared/factory.ts
|
|
129
135
|
var factoryRegistry = /* @__PURE__ */ new Map();
|
|
@@ -999,6 +1005,83 @@ function proxyClassStage3(backend, value, context, hooks = {}) {
|
|
|
999
1005
|
return wrapProxyClass(value, hooks);
|
|
1000
1006
|
}
|
|
1001
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
|
+
|
|
1002
1085
|
// src/decorators/stage3/index.ts
|
|
1003
1086
|
var NonNull = defineFieldDecorator(nonNullFieldStage3);
|
|
1004
1087
|
var Singleton = defineClassDecorator(singletonClassStage3);
|
|
@@ -1121,12 +1204,39 @@ function Proxy2(hooks = {}) {
|
|
|
1121
1204
|
(backend, value, context) => proxyClassStage3(backend, value, context, hooks)
|
|
1122
1205
|
);
|
|
1123
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);
|
|
1124
1234
|
|
|
1125
1235
|
// src/stage3/index.ts
|
|
1126
1236
|
function getClassMetadata(cls) {
|
|
1127
1237
|
return cls[Symbol.metadata];
|
|
1128
1238
|
}
|
|
1129
1239
|
|
|
1130
|
-
export { Accessors, Builder, ChainOfResponsibility, Command, CommandHistory, Composite, Data, Delegate, Equals, EqualsExclude, Factory, FieldDefaults, Flyweight, Getter, Handler, Iterable, IterateOver, Log, Memento, Memoize, NonNull, Observable, Observer, Prototype, Proxy2 as Proxy, 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 };
|
|
1131
1241
|
//# sourceMappingURL=index.js.map
|
|
1132
1242
|
//# sourceMappingURL=index.js.map
|