lombok-typescript 0.3.0 → 0.6.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 +48 -12
- package/dist/{log-Dpr79VRt.d.cts → chain-of-responsibility-CQ7votcC.d.cts} +45 -1
- package/dist/{log-Dbe0sSP1.d.ts → chain-of-responsibility-Dwsaoe4x.d.ts} +45 -1
- package/dist/cli/index.cjs +19 -1
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.d.cts +1 -1
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +19 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/codegen/index.cjs +18 -0
- package/dist/codegen/index.cjs.map +1 -1
- package/dist/codegen/index.js +18 -0
- package/dist/codegen/index.js.map +1 -1
- package/dist/core/index.cjs +1 -0
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +1 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.js +1 -0
- package/dist/core/index.js.map +1 -1
- package/dist/index.cjs +2 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/legacy/index.cjs +539 -0
- package/dist/legacy/index.cjs.map +1 -1
- package/dist/legacy/index.d.cts +29 -3
- package/dist/legacy/index.d.ts +29 -3
- package/dist/legacy/index.js +523 -1
- package/dist/legacy/index.js.map +1 -1
- package/dist/observable-AIiQMzLD.d.cts +6 -0
- package/dist/observable-AIiQMzLD.d.ts +6 -0
- package/dist/observers/mobx.cjs +17 -0
- package/dist/observers/mobx.cjs.map +1 -0
- package/dist/observers/mobx.d.cts +10 -0
- package/dist/observers/mobx.d.ts +10 -0
- package/dist/observers/mobx.js +12 -0
- package/dist/observers/mobx.js.map +1 -0
- package/dist/observers/rxjs.cjs +17 -0
- package/dist/observers/rxjs.cjs.map +1 -0
- package/dist/observers/rxjs.d.cts +10 -0
- package/dist/observers/rxjs.d.ts +10 -0
- package/dist/observers/rxjs.js +15 -0
- package/dist/observers/rxjs.js.map +1 -0
- package/dist/stage3/index.cjs +570 -1
- package/dist/stage3/index.cjs.map +1 -1
- package/dist/stage3/index.d.cts +31 -3
- package/dist/stage3/index.d.ts +31 -3
- package/dist/stage3/index.js +554 -2
- package/dist/stage3/index.js.map +1 -1
- package/package.json +40 -5
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/metadata-store.ts","../src/core/metadata-keys.ts","../src/config.ts","../src/index.ts"],"names":["bucket"],"mappings":";AA2BO,IAAM,uBAAN,MAAoD;AAAA,EACxC,WAAA,uBAAkB,OAAA,EAAsC;AAAA,EACxD,YAAA,uBAAmB,OAAA,EAA4D;AAAA,EAEhG,GAAA,CAAO,GAAA,EAAa,MAAA,EAAgB,WAAA,EAAuC,KAAA,EAAgB;AACzF,IAAA,MAAM,MAAA,GAAS,IAAA,CAAK,MAAA,CAAO,MAAA,EAAQ,aAAa,IAAI,CAAA;AACpD,IAAA,MAAA,CAAO,GAAA,CAAI,KAAK,KAAK,CAAA;AAAA,EACvB;AAAA,EAEA,GAAA,CAAO,GAAA,EAAa,MAAA,EAAgB,WAAA,EAA2C;AAC7E,IAAA,MAAM,MAAA,GAAS,IAAA,CAAK,MAAA,CAAO,MAAA,EAAQ,aAAa,KAAK,CAAA;AACrD,IAAA,OAAO,MAAA,EAAQ,IAAI,GAAG,CAAA;AAAA,EACxB;AAAA,EAEA,GAAA,CAAI,GAAA,EAAa,MAAA,EAAgB,WAAA,EAAqC;AACpE,IAAA,MAAM,MAAA,GAAS,IAAA,CAAK,MAAA,CAAO,MAAA,EAAQ,aAAa,KAAK,CAAA;AACrD,IAAA,OAAO,MAAA,EAAQ,GAAA,CAAI,GAAG,CAAA,IAAK,KAAA;AAAA,EAC7B;AAAA,EAEA,MAAA,CAAO,GAAA,EAAa,MAAA,EAAgB,WAAA,EAAqC;AACv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/D,EAAA,OAAO,MAAA;AACT;;;AC1DO,IAAM,OAAA,GAAU","file":"index.js","sourcesContent":["import type { MetadataKeyList, PropertyName } from './types.js';\n\n/**\n * Storage interface used by both decorator backends. Legacy delegates to\n * `reflect-metadata`; Stage 3 uses the WeakMap implementation below.\n */\nexport interface MetadataStore {\n /** Store `value` under `key`. Omit `propertyKey` for class-level scope. */\n set<V>(key: string, target: object, propertyKey: PropertyName | undefined, value: V): void;\n\n /** Read the value stored under `key`, or `undefined`. */\n get<V>(key: string, target: object, propertyKey?: PropertyName): V | undefined;\n\n /** True if `key` exists at the given scope. */\n has(key: string, target: object, propertyKey?: PropertyName): boolean;\n\n /** Remove the entry. Returns true if it existed. */\n delete(key: string, target: object, propertyKey?: PropertyName): boolean;\n\n /** All keys at the given scope. */\n list(target: object, propertyKey?: PropertyName): MetadataKeyList;\n}\n\n/**\n * WeakMap-backed `MetadataStore`. Used directly by the Stage 3 backend.\n * Layout: target -> (propertyKey or class-level) -> key -> value.\n */\nexport class WeakMapMetadataStore implements MetadataStore {\n private readonly classScopes = new WeakMap<object, Map<string, unknown>>();\n private readonly memberScopes = new WeakMap<object, Map<string | symbol, Map<string, unknown>>>();\n\n set<V>(key: string, target: object, propertyKey: PropertyName | undefined, value: V): void {\n const bucket = this.bucket(target, propertyKey, true)!;\n bucket.set(key, value);\n }\n\n get<V>(key: string, target: object, propertyKey?: PropertyName): V | undefined {\n const bucket = this.bucket(target, propertyKey, false);\n return bucket?.get(key) as V | undefined;\n }\n\n has(key: string, target: object, propertyKey?: PropertyName): boolean {\n const bucket = this.bucket(target, propertyKey, false);\n return bucket?.has(key) ?? false;\n }\n\n delete(key: string, target: object, propertyKey?: PropertyName): boolean {\n const bucket = this.bucket(target, propertyKey, false);\n if (!bucket) return false;\n return bucket.delete(key);\n }\n\n list(target: object, propertyKey?: PropertyName): MetadataKeyList {\n const bucket = this.bucket(target, propertyKey, false);\n if (!bucket) return [];\n return Array.from(bucket.keys());\n }\n\n private bucket(\n target: object,\n propertyKey: PropertyName | undefined,\n createIfMissing: boolean,\n ): Map<string, unknown> | undefined {\n if (propertyKey === undefined) {\n let bucket = this.classScopes.get(target);\n if (!bucket && createIfMissing) {\n bucket = new Map();\n this.classScopes.set(target, bucket);\n }\n return bucket;\n }\n\n let perTarget = this.memberScopes.get(target);\n if (!perTarget) {\n if (!createIfMissing) return undefined;\n perTarget = new Map();\n this.memberScopes.set(target, perTarget);\n }\n\n let bucket = perTarget.get(propertyKey);\n if (!bucket) {\n if (!createIfMissing) return undefined;\n bucket = new Map();\n perTarget.set(propertyKey, bucket);\n }\n return bucket;\n }\n}\n","/**\n * Metadata keys used across the library. Adding one? Use the `lombok-ts:`\n * prefix and check `metadata-keys.test.ts` so uniqueness stays enforced.\n */\n\nconst PREFIX = 'lombok-ts:';\n\nexport const MetadataKeys = {\n // Class-level (Lombok)\n DATA: `${PREFIX}data`,\n VALUE: `${PREFIX}value`,\n BUILDER: `${PREFIX}builder`,\n TO_STRING: `${PREFIX}toString`,\n EQUALS: `${PREFIX}equals`,\n UTILITY_CLASS: `${PREFIX}utilityClass`,\n FIELD_DEFAULTS: `${PREFIX}fieldDefaults`,\n ACCESSORS: `${PREFIX}accessors`,\n LOG: `${PREFIX}log`,\n\n // Class-level (TS-only)\n OBSERVABLE: `${PREFIX}observable`,\n SERIALIZABLE: `${PREFIX}serializable`,\n DEEP_FREEZE: `${PREFIX}deepFreeze`,\n TRACE: `${PREFIX}trace`,\n\n // Class-level (GoF)\n SINGLETON: `${PREFIX}singleton`,\n FACTORY: `${PREFIX}factory`,\n ABSTRACT_FACTORY: `${PREFIX}abstractFactory`,\n PROTOTYPE: `${PREFIX}prototype`,\n ADAPTER: `${PREFIX}adapter`,\n BRIDGE: `${PREFIX}bridge`,\n COMPOSITE: `${PREFIX}composite`,\n WRAPS: `${PREFIX}wraps`,\n FACADE: `${PREFIX}facade`,\n FLYWEIGHT: `${PREFIX}flyweight`,\n PROXY: `${PREFIX}proxy`,\n CHAIN_OF_RESPONSIBILITY: `${PREFIX}chainOfResponsibility`,\n COMMAND: `${PREFIX}command`,\n INTERPRETER: `${PREFIX}interpreter`,\n ITERABLE: `${PREFIX}iterable`,\n MEDIATOR: `${PREFIX}mediator`,\n MEMENTO: `${PREFIX}memento`,\n STATE: `${PREFIX}state`,\n STRATEGY: `${PREFIX}strategy`,\n TEMPLATE_METHOD: `${PREFIX}templateMethod`,\n VISITABLE: `${PREFIX}visitable`,\n VISITOR: `${PREFIX}visitor`,\n\n // Field-level\n GETTER: `${PREFIX}getter`,\n SETTER: `${PREFIX}setter`,\n NON_NULL: `${PREFIX}nonNull`,\n WITH: `${PREFIX}with`,\n DELEGATE: `${PREFIX}delegate`,\n VALIDATE: `${PREFIX}validate`,\n TO_STRING_EXCLUDE: `${PREFIX}toString:exclude`,\n TO_STRING_INCLUDE: `${PREFIX}toString:include`,\n EQUALS_EXCLUDE: `${PREFIX}equals:exclude`,\n SERIALIZABLE_EXCLUDE: `${PREFIX}serializable:exclude`,\n SERIALIZABLE_TRANSFORM: `${PREFIX}serializable:transform`,\n SERIALIZABLE_ALIAS: `${PREFIX}serializable:alias`,\n BUILDER_DEFAULT: `${PREFIX}builder:default`,\n SINGULAR: `${PREFIX}singular`,\n ITERATE_OVER: `${PREFIX}iterateOver`,\n\n // Method-level\n MEMOIZE: `${PREFIX}memoize`,\n DEBOUNCE: `${PREFIX}debounce`,\n THROTTLE: `${PREFIX}throttle`,\n RETRY: `${PREFIX}retry`,\n HANDLER: `${PREFIX}handler`,\n TRANSITION: `${PREFIX}transition`,\n HOOK: `${PREFIX}hook`,\n\n // Parameter-level\n NON_NULL_PARAM: `${PREFIX}nonNull:param`,\n\n // Internal, framework-managed\n FIELDS: `${PREFIX}internal:fields`,\n CONSTRUCTOR_PARAMS: `${PREFIX}internal:constructorParams`,\n BACKEND: `${PREFIX}internal:backend`,\n} as const;\n\nexport type MetadataKey = (typeof MetadataKeys)[keyof typeof MetadataKeys];\n\nexport const METADATA_KEY_PREFIX = PREFIX;\n","import type { BackendKind } from './core/types.js';\n\nexport interface LogConfig {\n /** Logging provider. Default `'console'`. */\n provider: 'console' | 'winston' | 'pino' | 'bunyan';\n\n /** Default log level. Default `'info'`. */\n defaultLevel: 'debug' | 'info' | 'warn' | 'error';\n}\n\nexport interface BuilderConfig {\n /** Prefix for builder setter methods. Default `''` (so `name()`, not `withName()`). */\n prefix: string;\n\n /** Name of the build method. Default `'build'`. */\n buildMethodName: string;\n\n /** Name of the static builder method. Default `'builder'`. */\n builderMethodName: string;\n}\n\nexport interface ToStringConfig {\n /** Output format. Default `'pretty'`. */\n format: 'pretty' | 'json' | 'compact';\n\n /** Include the class name in output. Default `true`. */\n includeClassName: boolean;\n}\n\nexport interface ValidateConfig {\n /** Validation library. Default `'zod'`. */\n provider: 'zod' | 'yup' | 'class-validator';\n\n /** Throw on validation failure. Default `true`. */\n throwOnError: boolean;\n}\n\nexport interface CodegenConfig {\n /** Where to write generated companion files. Default `'.lombok'`. */\n outputDir: string;\n\n /** Glob patterns for files to process. Default `['src/** /*.ts']`. */\n include: string[];\n\n /** Glob patterns for files to skip. Defaults exclude tests, `dist`, and `.lombok`. */\n exclude: string[];\n\n /** Path to the project's tsconfig. Default `'tsconfig.json'`. */\n tsConfigPath: string;\n\n /** Watch for source changes and regenerate companions. Default `false`. */\n watch: boolean;\n}\n\n/**\n * Top-level lombok-typescript config.\n *\n * `backend` chooses which decorator standard to assume:\n * - `'legacy'`: `experimentalDecorators` (NestJS / class-validator ecosystem)\n * - `'stage3'`: Stage 3 ECMAScript decorators (TS 5.0+)\n * - `'auto'`: detect from the project's tsconfig\n *\n * The `@ToString` config field is named `formatToString` (not `toString`) so it\n * doesn't clash with `Object.prototype.toString`.\n */\nexport interface LombokConfig {\n /** Decorator backend. Default `'auto'`. */\n backend?: BackendKind | 'auto';\n\n log?: Partial<LogConfig>;\n builder?: Partial<BuilderConfig>;\n /** Settings for the `@ToString` decorator. */\n formatToString?: Partial<ToStringConfig>;\n validate?: Partial<ValidateConfig>;\n codegen?: Partial<CodegenConfig>;\n}\n\n/**\n * Identity helper that gives you autocomplete in `lombok.config.ts`.\n *\n * @example\n * import { defineConfig } from 'lombok-typescript';\n *\n * export default defineConfig({\n * backend: 'legacy',\n * log: { provider: 'winston' },\n * builder: { prefix: 'with' },\n * });\n */\nexport function defineConfig(config: LombokConfig): LombokConfig {\n return config;\n}\n","/**\n * `lombok-typescript`: a TypeScript port of Project Lombok plus GoF design\n * patterns as decorators.\n *\n * Sub-paths:\n * - `lombok-typescript/legacy`: legacy `experimentalDecorators` backend\n * - `lombok-typescript/stage3`: Stage 3 ECMAScript decorators backend\n * - `lombok-typescript/core`: backend-agnostic primitives\n * - `lombok-typescript/codegen`: ts-morph powered code generation\n *\n * @see https://github.com/A-Dev-Kit/lombok-typescript\n */\n\nexport type {\n Backend,\n MetadataStore,\n BackendKind,\n DecoratorKind,\n PropertyName,\n} from './core/index.js';\nexport { MetadataKeys, METADATA_KEY_PREFIX, WeakMapMetadataStore } from './core/index.js';\nexport type { MetadataKey } from './core/index.js';\n\nexport { defineConfig } from './config.js';\nexport type {\n LombokConfig,\n LogConfig,\n BuilderConfig,\n ToStringConfig,\n ValidateConfig,\n CodegenConfig,\n} from './config.js';\n\nexport const VERSION = '0.4.0-pre';\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/core/metadata-store.ts","../src/core/metadata-keys.ts","../src/config.ts","../src/index.ts"],"names":["bucket"],"mappings":";AA2BO,IAAM,uBAAN,MAAoD;AAAA,EACxC,WAAA,uBAAkB,OAAA,EAAsC;AAAA,EACxD,YAAA,uBAAmB,OAAA,EAA4D;AAAA,EAEhG,GAAA,CAAO,GAAA,EAAa,MAAA,EAAgB,WAAA,EAAuC,KAAA,EAAgB;AACzF,IAAA,MAAM,MAAA,GAAS,IAAA,CAAK,MAAA,CAAO,MAAA,EAAQ,aAAa,IAAI,CAAA;AACpD,IAAA,MAAA,CAAO,GAAA,CAAI,KAAK,KAAK,CAAA;AAAA,EACvB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,QAAA,EAAU,GAAG,MAAM,CAAA,QAAA,CAAA;AAAA,EACnB,KAAA,EAAO,GAAG,MAAM,CAAA,KAAA,CAAA;AAAA,EAChB,OAAA,EAAS,GAAG,MAAM,CAAA,OAAA,CAAA;AAAA,EAClB,UAAA,EAAY,GAAG,MAAM,CAAA,UAAA,CAAA;AAAA,EACrB,IAAA,EAAM,GAAG,MAAM,CAAA,IAAA,CAAA;AAAA;AAAA,EAGf,cAAA,EAAgB,GAAG,MAAM,CAAA,aAAA,CAAA;AAAA;AAAA,EAGzB,MAAA,EAAQ,GAAG,MAAM,CAAA,eAAA,CAAA;AAAA,EACjB,kBAAA,EAAoB,GAAG,MAAM,CAAA,0BAAA,CAAA;AAAA,EAC7B,OAAA,EAAS,GAAG,MAAM,CAAA,gBAAA;AACpB;AAIO,IAAM,mBAAA,GAAsB;;;ACE5B,SAAS,aAAa,MAAA,EAAoC;AAC/D,EAAA,OAAO,MAAA;AACT;;;AC1DO,IAAM,OAAA,GAAU","file":"index.js","sourcesContent":["import type { MetadataKeyList, PropertyName } from './types.js';\n\n/**\n * Storage interface used by both decorator backends. Legacy delegates to\n * `reflect-metadata`; Stage 3 uses the WeakMap implementation below.\n */\nexport interface MetadataStore {\n /** Store `value` under `key`. Omit `propertyKey` for class-level scope. */\n set<V>(key: string, target: object, propertyKey: PropertyName | undefined, value: V): void;\n\n /** Read the value stored under `key`, or `undefined`. */\n get<V>(key: string, target: object, propertyKey?: PropertyName): V | undefined;\n\n /** True if `key` exists at the given scope. */\n has(key: string, target: object, propertyKey?: PropertyName): boolean;\n\n /** Remove the entry. Returns true if it existed. */\n delete(key: string, target: object, propertyKey?: PropertyName): boolean;\n\n /** All keys at the given scope. */\n list(target: object, propertyKey?: PropertyName): MetadataKeyList;\n}\n\n/**\n * WeakMap-backed `MetadataStore`. Used directly by the Stage 3 backend.\n * Layout: target -> (propertyKey or class-level) -> key -> value.\n */\nexport class WeakMapMetadataStore implements MetadataStore {\n private readonly classScopes = new WeakMap<object, Map<string, unknown>>();\n private readonly memberScopes = new WeakMap<object, Map<string | symbol, Map<string, unknown>>>();\n\n set<V>(key: string, target: object, propertyKey: PropertyName | undefined, value: V): void {\n const bucket = this.bucket(target, propertyKey, true)!;\n bucket.set(key, value);\n }\n\n get<V>(key: string, target: object, propertyKey?: PropertyName): V | undefined {\n const bucket = this.bucket(target, propertyKey, false);\n return bucket?.get(key) as V | undefined;\n }\n\n has(key: string, target: object, propertyKey?: PropertyName): boolean {\n const bucket = this.bucket(target, propertyKey, false);\n return bucket?.has(key) ?? false;\n }\n\n delete(key: string, target: object, propertyKey?: PropertyName): boolean {\n const bucket = this.bucket(target, propertyKey, false);\n if (!bucket) return false;\n return bucket.delete(key);\n }\n\n list(target: object, propertyKey?: PropertyName): MetadataKeyList {\n const bucket = this.bucket(target, propertyKey, false);\n if (!bucket) return [];\n return Array.from(bucket.keys());\n }\n\n private bucket(\n target: object,\n propertyKey: PropertyName | undefined,\n createIfMissing: boolean,\n ): Map<string, unknown> | undefined {\n if (propertyKey === undefined) {\n let bucket = this.classScopes.get(target);\n if (!bucket && createIfMissing) {\n bucket = new Map();\n this.classScopes.set(target, bucket);\n }\n return bucket;\n }\n\n let perTarget = this.memberScopes.get(target);\n if (!perTarget) {\n if (!createIfMissing) return undefined;\n perTarget = new Map();\n this.memberScopes.set(target, perTarget);\n }\n\n let bucket = perTarget.get(propertyKey);\n if (!bucket) {\n if (!createIfMissing) return undefined;\n bucket = new Map();\n perTarget.set(propertyKey, bucket);\n }\n return bucket;\n }\n}\n","/**\n * Metadata keys used across the library. Adding one? Use the `lombok-ts:`\n * prefix and check `metadata-keys.test.ts` so uniqueness stays enforced.\n */\n\nconst PREFIX = 'lombok-ts:';\n\nexport const MetadataKeys = {\n // Class-level (Lombok)\n DATA: `${PREFIX}data`,\n VALUE: `${PREFIX}value`,\n BUILDER: `${PREFIX}builder`,\n TO_STRING: `${PREFIX}toString`,\n EQUALS: `${PREFIX}equals`,\n UTILITY_CLASS: `${PREFIX}utilityClass`,\n FIELD_DEFAULTS: `${PREFIX}fieldDefaults`,\n ACCESSORS: `${PREFIX}accessors`,\n LOG: `${PREFIX}log`,\n\n // Class-level (TS-only)\n OBSERVABLE: `${PREFIX}observable`,\n SERIALIZABLE: `${PREFIX}serializable`,\n DEEP_FREEZE: `${PREFIX}deepFreeze`,\n TRACE: `${PREFIX}trace`,\n\n // Class-level (GoF)\n SINGLETON: `${PREFIX}singleton`,\n FACTORY: `${PREFIX}factory`,\n ABSTRACT_FACTORY: `${PREFIX}abstractFactory`,\n PROTOTYPE: `${PREFIX}prototype`,\n ADAPTER: `${PREFIX}adapter`,\n BRIDGE: `${PREFIX}bridge`,\n COMPOSITE: `${PREFIX}composite`,\n WRAPS: `${PREFIX}wraps`,\n FACADE: `${PREFIX}facade`,\n FLYWEIGHT: `${PREFIX}flyweight`,\n PROXY: `${PREFIX}proxy`,\n CHAIN_OF_RESPONSIBILITY: `${PREFIX}chainOfResponsibility`,\n COMMAND: `${PREFIX}command`,\n INTERPRETER: `${PREFIX}interpreter`,\n ITERABLE: `${PREFIX}iterable`,\n MEDIATOR: `${PREFIX}mediator`,\n MEMENTO: `${PREFIX}memento`,\n MEMENTO_EXCLUDE: `${PREFIX}memento:exclude`,\n STATE: `${PREFIX}state`,\n STRATEGY: `${PREFIX}strategy`,\n TEMPLATE_METHOD: `${PREFIX}templateMethod`,\n VISITABLE: `${PREFIX}visitable`,\n VISITOR: `${PREFIX}visitor`,\n\n // Field-level\n GETTER: `${PREFIX}getter`,\n SETTER: `${PREFIX}setter`,\n NON_NULL: `${PREFIX}nonNull`,\n WITH: `${PREFIX}with`,\n DELEGATE: `${PREFIX}delegate`,\n VALIDATE: `${PREFIX}validate`,\n TO_STRING_EXCLUDE: `${PREFIX}toString:exclude`,\n TO_STRING_INCLUDE: `${PREFIX}toString:include`,\n EQUALS_EXCLUDE: `${PREFIX}equals:exclude`,\n SERIALIZABLE_EXCLUDE: `${PREFIX}serializable:exclude`,\n SERIALIZABLE_TRANSFORM: `${PREFIX}serializable:transform`,\n SERIALIZABLE_ALIAS: `${PREFIX}serializable:alias`,\n BUILDER_DEFAULT: `${PREFIX}builder:default`,\n SINGULAR: `${PREFIX}singular`,\n ITERATE_OVER: `${PREFIX}iterateOver`,\n\n // Method-level\n MEMOIZE: `${PREFIX}memoize`,\n DEBOUNCE: `${PREFIX}debounce`,\n THROTTLE: `${PREFIX}throttle`,\n RETRY: `${PREFIX}retry`,\n HANDLER: `${PREFIX}handler`,\n TRANSITION: `${PREFIX}transition`,\n HOOK: `${PREFIX}hook`,\n\n // Parameter-level\n NON_NULL_PARAM: `${PREFIX}nonNull:param`,\n\n // Internal, framework-managed\n FIELDS: `${PREFIX}internal:fields`,\n CONSTRUCTOR_PARAMS: `${PREFIX}internal:constructorParams`,\n BACKEND: `${PREFIX}internal:backend`,\n} as const;\n\nexport type MetadataKey = (typeof MetadataKeys)[keyof typeof MetadataKeys];\n\nexport const METADATA_KEY_PREFIX = PREFIX;\n","import type { BackendKind } from './core/types.js';\n\nexport interface LogConfig {\n /** Logging provider. Default `'console'`. */\n provider: 'console' | 'winston' | 'pino' | 'bunyan';\n\n /** Default log level. Default `'info'`. */\n defaultLevel: 'debug' | 'info' | 'warn' | 'error';\n}\n\nexport interface BuilderConfig {\n /** Prefix for builder setter methods. Default `''` (so `name()`, not `withName()`). */\n prefix: string;\n\n /** Name of the build method. Default `'build'`. */\n buildMethodName: string;\n\n /** Name of the static builder method. Default `'builder'`. */\n builderMethodName: string;\n}\n\nexport interface ToStringConfig {\n /** Output format. Default `'pretty'`. */\n format: 'pretty' | 'json' | 'compact';\n\n /** Include the class name in output. Default `true`. */\n includeClassName: boolean;\n}\n\nexport interface ValidateConfig {\n /** Validation library. Default `'zod'`. */\n provider: 'zod' | 'yup' | 'class-validator';\n\n /** Throw on validation failure. Default `true`. */\n throwOnError: boolean;\n}\n\nexport interface CodegenConfig {\n /** Where to write generated companion files. Default `'.lombok'`. */\n outputDir: string;\n\n /** Glob patterns for files to process. Default `['src/** /*.ts']`. */\n include: string[];\n\n /** Glob patterns for files to skip. Defaults exclude tests, `dist`, and `.lombok`. */\n exclude: string[];\n\n /** Path to the project's tsconfig. Default `'tsconfig.json'`. */\n tsConfigPath: string;\n\n /** Watch for source changes and regenerate companions. Default `false`. */\n watch: boolean;\n}\n\n/**\n * Top-level lombok-typescript config.\n *\n * `backend` chooses which decorator standard to assume:\n * - `'legacy'`: `experimentalDecorators` (NestJS / class-validator ecosystem)\n * - `'stage3'`: Stage 3 ECMAScript decorators (TS 5.0+)\n * - `'auto'`: detect from the project's tsconfig\n *\n * The `@ToString` config field is named `formatToString` (not `toString`) so it\n * doesn't clash with `Object.prototype.toString`.\n */\nexport interface LombokConfig {\n /** Decorator backend. Default `'auto'`. */\n backend?: BackendKind | 'auto';\n\n log?: Partial<LogConfig>;\n builder?: Partial<BuilderConfig>;\n /** Settings for the `@ToString` decorator. */\n formatToString?: Partial<ToStringConfig>;\n validate?: Partial<ValidateConfig>;\n codegen?: Partial<CodegenConfig>;\n}\n\n/**\n * Identity helper that gives you autocomplete in `lombok.config.ts`.\n *\n * @example\n * import { defineConfig } from 'lombok-typescript';\n *\n * export default defineConfig({\n * backend: 'legacy',\n * log: { provider: 'winston' },\n * builder: { prefix: 'with' },\n * });\n */\nexport function defineConfig(config: LombokConfig): LombokConfig {\n return config;\n}\n","/**\n * `lombok-typescript`: a TypeScript port of Project Lombok plus GoF design\n * patterns as decorators.\n *\n * Sub-paths:\n * - `lombok-typescript/legacy`: legacy `experimentalDecorators` backend\n * - `lombok-typescript/stage3`: Stage 3 ECMAScript decorators backend\n * - `lombok-typescript/core`: backend-agnostic primitives\n * - `lombok-typescript/codegen`: ts-morph powered code generation\n *\n * @see https://github.com/A-Dev-Kit/lombok-typescript\n */\n\nexport type {\n Backend,\n MetadataStore,\n BackendKind,\n DecoratorKind,\n PropertyName,\n} from './core/index.js';\nexport { MetadataKeys, METADATA_KEY_PREFIX, WeakMapMetadataStore } from './core/index.js';\nexport type { MetadataKey } from './core/index.js';\n\nexport { defineConfig } from './config.js';\nexport type {\n LombokConfig,\n LogConfig,\n BuilderConfig,\n ToStringConfig,\n ValidateConfig,\n CodegenConfig,\n} from './config.js';\n\nexport const VERSION = '0.6.0-pre';\n"]}
|
package/dist/legacy/index.cjs
CHANGED
|
@@ -79,10 +79,19 @@ var MetadataKeys = {
|
|
|
79
79
|
FIELD_DEFAULTS: `${PREFIX}fieldDefaults`,
|
|
80
80
|
ACCESSORS: `${PREFIX}accessors`,
|
|
81
81
|
LOG: `${PREFIX}log`,
|
|
82
|
+
// Class-level (TS-only)
|
|
83
|
+
OBSERVABLE: `${PREFIX}observable`,
|
|
82
84
|
// Class-level (GoF)
|
|
83
85
|
SINGLETON: `${PREFIX}singleton`,
|
|
84
86
|
FACTORY: `${PREFIX}factory`,
|
|
85
87
|
PROTOTYPE: `${PREFIX}prototype`,
|
|
88
|
+
CHAIN_OF_RESPONSIBILITY: `${PREFIX}chainOfResponsibility`,
|
|
89
|
+
COMMAND: `${PREFIX}command`,
|
|
90
|
+
ITERABLE: `${PREFIX}iterable`,
|
|
91
|
+
MEMENTO: `${PREFIX}memento`,
|
|
92
|
+
MEMENTO_EXCLUDE: `${PREFIX}memento:exclude`,
|
|
93
|
+
STATE: `${PREFIX}state`,
|
|
94
|
+
STRATEGY: `${PREFIX}strategy`,
|
|
86
95
|
// Field-level
|
|
87
96
|
GETTER: `${PREFIX}getter`,
|
|
88
97
|
SETTER: `${PREFIX}setter`,
|
|
@@ -90,8 +99,11 @@ var MetadataKeys = {
|
|
|
90
99
|
WITH: `${PREFIX}with`,
|
|
91
100
|
DELEGATE: `${PREFIX}delegate`,
|
|
92
101
|
EQUALS_EXCLUDE: `${PREFIX}equals:exclude`,
|
|
102
|
+
ITERATE_OVER: `${PREFIX}iterateOver`,
|
|
93
103
|
// Method-level
|
|
94
104
|
MEMOIZE: `${PREFIX}memoize`,
|
|
105
|
+
HANDLER: `${PREFIX}handler`,
|
|
106
|
+
TRANSITION: `${PREFIX}transition`,
|
|
95
107
|
// Parameter-level
|
|
96
108
|
NON_NULL_PARAM: `${PREFIX}nonNull:param`};
|
|
97
109
|
|
|
@@ -359,6 +371,484 @@ function withFieldLegacy(backend, targetPrototype, propertyKey) {
|
|
|
359
371
|
fieldMarkerLegacy(backend, targetPrototype, propertyKey, MetadataKeys.WITH);
|
|
360
372
|
}
|
|
361
373
|
|
|
374
|
+
// src/decorators/shared/strategy.ts
|
|
375
|
+
var strategyRegistry = /* @__PURE__ */ new Map();
|
|
376
|
+
function familyBucket(family, create = false) {
|
|
377
|
+
let bucket = strategyRegistry.get(family);
|
|
378
|
+
if (!bucket && create) {
|
|
379
|
+
bucket = /* @__PURE__ */ new Map();
|
|
380
|
+
strategyRegistry.set(family, bucket);
|
|
381
|
+
}
|
|
382
|
+
return bucket;
|
|
383
|
+
}
|
|
384
|
+
function registerStrategy(family, name, ctor) {
|
|
385
|
+
const bucket = familyBucket(family, true);
|
|
386
|
+
bucket.set(name, ctor);
|
|
387
|
+
}
|
|
388
|
+
function getStrategyFromRegistry(family, name) {
|
|
389
|
+
const ctor = familyBucket(family)?.get(name);
|
|
390
|
+
if (!ctor) {
|
|
391
|
+
throw new Error(`No strategy registered for family "${family}" and name "${name}"`);
|
|
392
|
+
}
|
|
393
|
+
return new ctor();
|
|
394
|
+
}
|
|
395
|
+
function listStrategies(family) {
|
|
396
|
+
const bucket = familyBucket(family);
|
|
397
|
+
return bucket ? Array.from(bucket.keys()) : [];
|
|
398
|
+
}
|
|
399
|
+
function getStrategyRegistry() {
|
|
400
|
+
return strategyRegistry;
|
|
401
|
+
}
|
|
402
|
+
var StrategyRegistry = {
|
|
403
|
+
get: getStrategyFromRegistry,
|
|
404
|
+
list: listStrategies
|
|
405
|
+
};
|
|
406
|
+
function strategyClassLegacy(backend, target, family, name) {
|
|
407
|
+
backend.metadata.set(MetadataKeys.STRATEGY, target, void 0, { family, name });
|
|
408
|
+
registerStrategy(family, name, target);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
// src/decorators/shared/transition.ts
|
|
412
|
+
function normalizeFromStates(from) {
|
|
413
|
+
return Array.isArray(from) ? from : [from];
|
|
414
|
+
}
|
|
415
|
+
function transitionMethodLegacy(backend, targetPrototype, propertyKey, descriptor, options) {
|
|
416
|
+
backend.metadata.set(MetadataKeys.TRANSITION, targetPrototype, propertyKey, options);
|
|
417
|
+
return descriptor;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
// src/decorators/shared/state.ts
|
|
421
|
+
var STATE_SYMBOL = /* @__PURE__ */ Symbol("lombok-ts:state");
|
|
422
|
+
function collectTransitionMethods(metadata, proto, classMetadata) {
|
|
423
|
+
const transitions = /* @__PURE__ */ new Map();
|
|
424
|
+
for (const key of Object.getOwnPropertyNames(proto)) {
|
|
425
|
+
if (key === "constructor") continue;
|
|
426
|
+
const options = metadata.get(MetadataKeys.TRANSITION, proto, key) ?? (void 0);
|
|
427
|
+
if (!options) continue;
|
|
428
|
+
const desc = Object.getOwnPropertyDescriptor(proto, key);
|
|
429
|
+
if (!desc || typeof desc.value !== "function") continue;
|
|
430
|
+
transitions.set(key, { options, original: desc.value });
|
|
431
|
+
}
|
|
432
|
+
return transitions;
|
|
433
|
+
}
|
|
434
|
+
function applyStateWrapping(backend, target, options, classMetadata) {
|
|
435
|
+
const { states, initial, onEnter, onExit, onTransition } = options;
|
|
436
|
+
if (!states.includes(initial)) {
|
|
437
|
+
throw new Error(`@State initial state "${initial}" is not in states: [${states.join(", ")}]`);
|
|
438
|
+
}
|
|
439
|
+
const transitions = collectTransitionMethods(
|
|
440
|
+
backend.metadata,
|
|
441
|
+
target.prototype);
|
|
442
|
+
const StateClass = class extends target {
|
|
443
|
+
constructor(...args) {
|
|
444
|
+
super(...args);
|
|
445
|
+
Object.defineProperty(this, STATE_SYMBOL, {
|
|
446
|
+
value: initial,
|
|
447
|
+
writable: true,
|
|
448
|
+
enumerable: false,
|
|
449
|
+
configurable: false
|
|
450
|
+
});
|
|
451
|
+
onEnter?.(initial);
|
|
452
|
+
}
|
|
453
|
+
get state() {
|
|
454
|
+
return this[STATE_SYMBOL] ?? initial;
|
|
455
|
+
}
|
|
456
|
+
};
|
|
457
|
+
const stateProto = StateClass.prototype;
|
|
458
|
+
for (const [methodName, { options: transition, original }] of transitions) {
|
|
459
|
+
const fromStates = normalizeFromStates(transition.from);
|
|
460
|
+
const toState = transition.to;
|
|
461
|
+
if (!states.includes(toState)) {
|
|
462
|
+
throw new Error(`@Transition on "${methodName}" targets unknown state "${toState}"`);
|
|
463
|
+
}
|
|
464
|
+
for (const from of fromStates) {
|
|
465
|
+
if (!states.includes(from)) {
|
|
466
|
+
throw new Error(`@Transition on "${methodName}" references unknown state "${from}"`);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
Object.defineProperty(stateProto, methodName, {
|
|
470
|
+
configurable: true,
|
|
471
|
+
enumerable: false,
|
|
472
|
+
writable: true,
|
|
473
|
+
value: function stateTransitionWrapper(...args) {
|
|
474
|
+
const self = this;
|
|
475
|
+
const current = self[STATE_SYMBOL] ?? "";
|
|
476
|
+
if (!fromStates.includes(current)) {
|
|
477
|
+
throw new Error(
|
|
478
|
+
`Cannot transition from "${current}" to "${toState}" via ${methodName}()`
|
|
479
|
+
);
|
|
480
|
+
}
|
|
481
|
+
onExit?.(current);
|
|
482
|
+
const result = original.apply(this, args);
|
|
483
|
+
self[STATE_SYMBOL] = toState;
|
|
484
|
+
onTransition?.(current, toState);
|
|
485
|
+
onEnter?.(toState);
|
|
486
|
+
return result;
|
|
487
|
+
}
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
return StateClass;
|
|
491
|
+
}
|
|
492
|
+
function stateClassLegacy(backend, target, options) {
|
|
493
|
+
backend.metadata.set(MetadataKeys.STATE, target, void 0, options);
|
|
494
|
+
return applyStateWrapping(backend, target, options);
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
// src/decorators/shared/command.ts
|
|
498
|
+
function assertCommand(target) {
|
|
499
|
+
const proto = target.prototype;
|
|
500
|
+
if (typeof proto.execute !== "function") {
|
|
501
|
+
throw new Error(`@Command class ${target.name} must define execute()`);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
function commandClassLegacy(backend, target) {
|
|
505
|
+
assertCommand(target);
|
|
506
|
+
backend.metadata.set(MetadataKeys.COMMAND, target, void 0, true);
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
// src/decorators/shared/command-history.ts
|
|
510
|
+
var CommandHistory = class {
|
|
511
|
+
undoStack = [];
|
|
512
|
+
redoStack = [];
|
|
513
|
+
execute(cmd) {
|
|
514
|
+
const result = cmd.execute();
|
|
515
|
+
this.undoStack.push(cmd);
|
|
516
|
+
this.redoStack.length = 0;
|
|
517
|
+
return result;
|
|
518
|
+
}
|
|
519
|
+
undo() {
|
|
520
|
+
const cmd = this.undoStack.pop();
|
|
521
|
+
if (!cmd) {
|
|
522
|
+
throw new Error("Nothing to undo");
|
|
523
|
+
}
|
|
524
|
+
if (typeof cmd.undo !== "function") {
|
|
525
|
+
this.undoStack.push(cmd);
|
|
526
|
+
throw new Error("Command does not support undo()");
|
|
527
|
+
}
|
|
528
|
+
const result = cmd.undo();
|
|
529
|
+
this.redoStack.push(cmd);
|
|
530
|
+
return result;
|
|
531
|
+
}
|
|
532
|
+
redo() {
|
|
533
|
+
const cmd = this.redoStack.pop();
|
|
534
|
+
if (!cmd) {
|
|
535
|
+
throw new Error("Nothing to redo");
|
|
536
|
+
}
|
|
537
|
+
const result = cmd.execute();
|
|
538
|
+
this.undoStack.push(cmd);
|
|
539
|
+
return result;
|
|
540
|
+
}
|
|
541
|
+
get canUndo() {
|
|
542
|
+
return this.undoStack.length > 0;
|
|
543
|
+
}
|
|
544
|
+
get canRedo() {
|
|
545
|
+
return this.redoStack.length > 0;
|
|
546
|
+
}
|
|
547
|
+
clear() {
|
|
548
|
+
this.undoStack.length = 0;
|
|
549
|
+
this.redoStack.length = 0;
|
|
550
|
+
}
|
|
551
|
+
};
|
|
552
|
+
|
|
553
|
+
// src/decorators/shared/memento.ts
|
|
554
|
+
var MEMENTO_SNAPSHOT = /* @__PURE__ */ Symbol("lombok-ts:memento-snapshot");
|
|
555
|
+
var legacyMementoExcluded = /* @__PURE__ */ new WeakMap();
|
|
556
|
+
function registerLegacyMementoExclude(proto, field) {
|
|
557
|
+
const set = legacyMementoExcluded.get(proto) ?? /* @__PURE__ */ new Set();
|
|
558
|
+
set.add(field);
|
|
559
|
+
legacyMementoExcluded.set(proto, set);
|
|
560
|
+
}
|
|
561
|
+
function isMementoSnapshot(value) {
|
|
562
|
+
return typeof value === "object" && value !== null && value[MEMENTO_SNAPSHOT] === true;
|
|
563
|
+
}
|
|
564
|
+
function collectExcludedFields(metadata, proto, classMetadata) {
|
|
565
|
+
const excluded = /* @__PURE__ */ new Set();
|
|
566
|
+
for (const key of Object.getOwnPropertyNames(proto)) {
|
|
567
|
+
if (key === "constructor") continue;
|
|
568
|
+
if (metadata.has(MetadataKeys.MEMENTO_EXCLUDE, proto, key) || classMetadata) {
|
|
569
|
+
excluded.add(key);
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
for (const key of legacyMementoExcluded.get(proto) ?? []) {
|
|
573
|
+
excluded.add(key);
|
|
574
|
+
}
|
|
575
|
+
return excluded;
|
|
576
|
+
}
|
|
577
|
+
function snapshotInstance(instance, excluded) {
|
|
578
|
+
const data = {};
|
|
579
|
+
for (const key of Object.keys(instance)) {
|
|
580
|
+
if (excluded.has(key)) continue;
|
|
581
|
+
if (key === "save" || key === "restore") continue;
|
|
582
|
+
data[key] = deepClone(instance[key]);
|
|
583
|
+
}
|
|
584
|
+
return { [MEMENTO_SNAPSHOT]: true, data };
|
|
585
|
+
}
|
|
586
|
+
function applySnapshot(instance, snapshot) {
|
|
587
|
+
for (const [key, value] of Object.entries(snapshot.data)) {
|
|
588
|
+
instance[key] = deepClone(value);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
function wrapMementoClass(backend, target, classMetadata) {
|
|
592
|
+
const excluded = collectExcludedFields(
|
|
593
|
+
backend.metadata,
|
|
594
|
+
target.prototype,
|
|
595
|
+
classMetadata
|
|
596
|
+
);
|
|
597
|
+
const MementoClass = class extends target {
|
|
598
|
+
save() {
|
|
599
|
+
return snapshotInstance(this, excluded);
|
|
600
|
+
}
|
|
601
|
+
restore(snapshot) {
|
|
602
|
+
if (!isMementoSnapshot(snapshot)) {
|
|
603
|
+
throw new TypeError("restore() expects a snapshot returned from save()");
|
|
604
|
+
}
|
|
605
|
+
applySnapshot(this, snapshot);
|
|
606
|
+
}
|
|
607
|
+
};
|
|
608
|
+
return MementoClass;
|
|
609
|
+
}
|
|
610
|
+
function mementoClassLegacy(backend, target) {
|
|
611
|
+
backend.metadata.set(MetadataKeys.MEMENTO, target, void 0, true);
|
|
612
|
+
return wrapMementoClass(backend, target);
|
|
613
|
+
}
|
|
614
|
+
function mementoExcludeFieldLegacy(backend, targetPrototype, propertyKey) {
|
|
615
|
+
backend.metadata.set(MetadataKeys.MEMENTO_EXCLUDE, targetPrototype, propertyKey, true);
|
|
616
|
+
registerLegacyMementoExclude(targetPrototype, String(propertyKey));
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
// src/decorators/shared/observable.ts
|
|
620
|
+
var LISTENERS = /* @__PURE__ */ Symbol("lombok-ts:observable-listeners");
|
|
621
|
+
function findGetter(proto, key) {
|
|
622
|
+
let current = proto;
|
|
623
|
+
while (current) {
|
|
624
|
+
const desc = Object.getOwnPropertyDescriptor(current, key);
|
|
625
|
+
if (desc?.get) return desc.get;
|
|
626
|
+
current = Object.getPrototypeOf(current);
|
|
627
|
+
}
|
|
628
|
+
return void 0;
|
|
629
|
+
}
|
|
630
|
+
function getInternals(target) {
|
|
631
|
+
const bag = target;
|
|
632
|
+
if (!bag[LISTENERS]) {
|
|
633
|
+
bag[LISTENERS] = {
|
|
634
|
+
listeners: /* @__PURE__ */ new Map(),
|
|
635
|
+
wildcards: /* @__PURE__ */ new Set(),
|
|
636
|
+
derivedKeys: /* @__PURE__ */ new Set(),
|
|
637
|
+
derivedCache: /* @__PURE__ */ new Map()
|
|
638
|
+
};
|
|
639
|
+
}
|
|
640
|
+
return bag[LISTENERS];
|
|
641
|
+
}
|
|
642
|
+
function notify(internals, key, next, prev) {
|
|
643
|
+
const keyListeners = internals.listeners.get(key);
|
|
644
|
+
if (keyListeners) {
|
|
645
|
+
for (const listener of keyListeners) {
|
|
646
|
+
listener(next, prev);
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
for (const listener of internals.wildcards) {
|
|
650
|
+
listener(key, next, prev);
|
|
651
|
+
}
|
|
652
|
+
if (internals.derivedKeys.size > 0) {
|
|
653
|
+
const instance = targetWithInternals(internals);
|
|
654
|
+
for (const derivedKey of internals.derivedKeys) {
|
|
655
|
+
const prevDerived = internals.derivedCache.get(derivedKey);
|
|
656
|
+
internals.derivedCache.delete(derivedKey);
|
|
657
|
+
const getter = findGetter(Object.getPrototypeOf(instance), derivedKey);
|
|
658
|
+
if (!getter) continue;
|
|
659
|
+
const newDerived = getter.call(instance);
|
|
660
|
+
internals.derivedCache.set(derivedKey, newDerived);
|
|
661
|
+
if (prevDerived !== newDerived) {
|
|
662
|
+
const derivedListeners = internals.listeners.get(derivedKey);
|
|
663
|
+
if (derivedListeners) {
|
|
664
|
+
for (const listener of derivedListeners) {
|
|
665
|
+
listener(newDerived, prevDerived);
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
var INSTANCE = /* @__PURE__ */ Symbol("lombok-ts:observable-instance");
|
|
673
|
+
function targetWithInternals(internals) {
|
|
674
|
+
return internals[INSTANCE] ?? {};
|
|
675
|
+
}
|
|
676
|
+
function installSubscribe(proto) {
|
|
677
|
+
Object.defineProperty(proto, "subscribe", {
|
|
678
|
+
configurable: true,
|
|
679
|
+
enumerable: false,
|
|
680
|
+
writable: true,
|
|
681
|
+
value: function subscribe(key, listener) {
|
|
682
|
+
const internals = getInternals(this);
|
|
683
|
+
internals[INSTANCE] = this;
|
|
684
|
+
if (key === "*") {
|
|
685
|
+
const wildcardListener = listener;
|
|
686
|
+
internals.wildcards.add(wildcardListener);
|
|
687
|
+
return () => internals.wildcards.delete(wildcardListener);
|
|
688
|
+
}
|
|
689
|
+
const keyListener = listener;
|
|
690
|
+
let set = internals.listeners.get(key);
|
|
691
|
+
if (!set) {
|
|
692
|
+
set = /* @__PURE__ */ new Set();
|
|
693
|
+
internals.listeners.set(key, set);
|
|
694
|
+
}
|
|
695
|
+
set.add(keyListener);
|
|
696
|
+
const proto2 = Object.getPrototypeOf(this);
|
|
697
|
+
if (findGetter(proto2, key)) {
|
|
698
|
+
internals.derivedKeys.add(key);
|
|
699
|
+
}
|
|
700
|
+
return () => set.delete(keyListener);
|
|
701
|
+
}
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
function wrapObservableInstance(instance) {
|
|
705
|
+
const internals = getInternals(instance);
|
|
706
|
+
internals[INSTANCE] = instance;
|
|
707
|
+
return new Proxy(instance, {
|
|
708
|
+
set(target, prop, value, receiver) {
|
|
709
|
+
if (typeof prop === "symbol") {
|
|
710
|
+
return Reflect.set(target, prop, value, receiver);
|
|
711
|
+
}
|
|
712
|
+
const prev = Reflect.get(target, prop, receiver);
|
|
713
|
+
const result = Reflect.set(target, prop, value, receiver);
|
|
714
|
+
if (prev !== value) {
|
|
715
|
+
notify(internals, prop, value, prev);
|
|
716
|
+
}
|
|
717
|
+
return result;
|
|
718
|
+
}
|
|
719
|
+
});
|
|
720
|
+
}
|
|
721
|
+
function wrapObservableClass(target) {
|
|
722
|
+
installSubscribe(target.prototype);
|
|
723
|
+
const ObservableClass = class extends target {
|
|
724
|
+
constructor(...args) {
|
|
725
|
+
super(...args);
|
|
726
|
+
return wrapObservableInstance(this);
|
|
727
|
+
}
|
|
728
|
+
};
|
|
729
|
+
return ObservableClass;
|
|
730
|
+
}
|
|
731
|
+
function observableClassLegacy(backend, target) {
|
|
732
|
+
backend.metadata.set(MetadataKeys.OBSERVABLE, target, void 0, true);
|
|
733
|
+
return wrapObservableClass(target);
|
|
734
|
+
}
|
|
735
|
+
function observableDerivedLegacy(backend, targetPrototype, propertyKey, descriptor) {
|
|
736
|
+
backend.metadata.set(MetadataKeys.OBSERVABLE, targetPrototype, propertyKey, { derived: true });
|
|
737
|
+
const originalGet = descriptor.get;
|
|
738
|
+
if (!originalGet) return;
|
|
739
|
+
const key = propertyKey;
|
|
740
|
+
return {
|
|
741
|
+
...descriptor,
|
|
742
|
+
get() {
|
|
743
|
+
const internals = getInternals(this);
|
|
744
|
+
internals[INSTANCE] = this;
|
|
745
|
+
internals.derivedKeys.add(key);
|
|
746
|
+
if (internals.derivedCache.has(key)) {
|
|
747
|
+
return internals.derivedCache.get(key);
|
|
748
|
+
}
|
|
749
|
+
const value = originalGet.call(this);
|
|
750
|
+
internals.derivedCache.set(key, value);
|
|
751
|
+
return value;
|
|
752
|
+
}
|
|
753
|
+
};
|
|
754
|
+
}
|
|
755
|
+
function observerClassLegacy(backend, target) {
|
|
756
|
+
return observableClassLegacy(backend, target);
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
// src/decorators/shared/chain-of-responsibility.ts
|
|
760
|
+
function collectHandlers(backend, proto, classMetadata) {
|
|
761
|
+
const handlers = [];
|
|
762
|
+
for (const key of Object.getOwnPropertyNames(proto)) {
|
|
763
|
+
if (key === "constructor") continue;
|
|
764
|
+
const options = backend.metadata.get(MetadataKeys.HANDLER, proto, key) ?? (void 0);
|
|
765
|
+
if (!options) continue;
|
|
766
|
+
const desc = Object.getOwnPropertyDescriptor(proto, key);
|
|
767
|
+
if (!desc || typeof desc.value !== "function") continue;
|
|
768
|
+
handlers.push({
|
|
769
|
+
order: options.order,
|
|
770
|
+
method: key,
|
|
771
|
+
fn: desc.value
|
|
772
|
+
});
|
|
773
|
+
}
|
|
774
|
+
handlers.sort((a, b) => a.order - b.order);
|
|
775
|
+
return handlers;
|
|
776
|
+
}
|
|
777
|
+
function wrapChainClass(backend, target, classMetadata) {
|
|
778
|
+
const handlers = collectHandlers(backend, target.prototype);
|
|
779
|
+
const ChainClass = class extends target {
|
|
780
|
+
handle(context) {
|
|
781
|
+
for (const handler of handlers) {
|
|
782
|
+
const result = handler.fn.call(this, context);
|
|
783
|
+
if (result === true || result !== void 0 && result !== false) {
|
|
784
|
+
return true;
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
return false;
|
|
788
|
+
}
|
|
789
|
+
};
|
|
790
|
+
return ChainClass;
|
|
791
|
+
}
|
|
792
|
+
function chainOfResponsibilityClassLegacy(backend, target) {
|
|
793
|
+
backend.metadata.set(MetadataKeys.CHAIN_OF_RESPONSIBILITY, target, void 0, true);
|
|
794
|
+
return wrapChainClass(backend, target);
|
|
795
|
+
}
|
|
796
|
+
function handlerMethodLegacy(backend, targetPrototype, propertyKey, descriptor, options) {
|
|
797
|
+
backend.metadata.set(MetadataKeys.HANDLER, targetPrototype, propertyKey, options);
|
|
798
|
+
return descriptor;
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
// src/decorators/shared/iterable.ts
|
|
802
|
+
var ITERATE_FIELD = /* @__PURE__ */ Symbol("lombok-ts:iterate-over-field");
|
|
803
|
+
var legacyIterateFields = /* @__PURE__ */ new WeakMap();
|
|
804
|
+
function registerLegacyIterateField(proto, field) {
|
|
805
|
+
const existing = legacyIterateFields.get(proto) ?? [];
|
|
806
|
+
existing.push(field);
|
|
807
|
+
legacyIterateFields.set(proto, existing);
|
|
808
|
+
}
|
|
809
|
+
function resolveIterateField(backend, proto, classMetadata) {
|
|
810
|
+
const fields = [];
|
|
811
|
+
for (const key of [
|
|
812
|
+
...Object.getOwnPropertyNames(proto),
|
|
813
|
+
...Object.getOwnPropertySymbols(proto)
|
|
814
|
+
]) {
|
|
815
|
+
if (key === "constructor") continue;
|
|
816
|
+
if (backend.metadata.has(MetadataKeys.ITERATE_OVER, proto, key) || classMetadata) {
|
|
817
|
+
fields.push(key);
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
fields.push(...legacyIterateFields.get(proto) ?? []);
|
|
821
|
+
if (fields.length === 0) {
|
|
822
|
+
throw new Error("@Iterable requires exactly one @IterateOver field");
|
|
823
|
+
}
|
|
824
|
+
if (fields.length > 1) {
|
|
825
|
+
throw new Error("@Iterable allows only one @IterateOver field");
|
|
826
|
+
}
|
|
827
|
+
return fields[0];
|
|
828
|
+
}
|
|
829
|
+
function installIterator(target, fieldKey) {
|
|
830
|
+
Object.defineProperty(target.prototype, Symbol.iterator, {
|
|
831
|
+
configurable: true,
|
|
832
|
+
enumerable: false,
|
|
833
|
+
writable: true,
|
|
834
|
+
value: function* iterateOver() {
|
|
835
|
+
const collection = this[fieldKey];
|
|
836
|
+
if (collection == null) return;
|
|
837
|
+
yield* collection;
|
|
838
|
+
}
|
|
839
|
+
});
|
|
840
|
+
}
|
|
841
|
+
function iterableClassLegacy(backend, target) {
|
|
842
|
+
backend.metadata.set(MetadataKeys.ITERABLE, target, void 0, true);
|
|
843
|
+
const fieldKey = resolveIterateField(backend, target.prototype);
|
|
844
|
+
target[ITERATE_FIELD] = fieldKey;
|
|
845
|
+
installIterator(target, fieldKey);
|
|
846
|
+
}
|
|
847
|
+
function iterateOverFieldLegacy(backend, targetPrototype, propertyKey) {
|
|
848
|
+
backend.metadata.set(MetadataKeys.ITERATE_OVER, targetPrototype, propertyKey, true);
|
|
849
|
+
registerLegacyIterateField(targetPrototype, propertyKey);
|
|
850
|
+
}
|
|
851
|
+
|
|
362
852
|
// src/decorators/legacy/index.ts
|
|
363
853
|
var NonNull = defineFieldDecorator(nonNullFieldLegacy);
|
|
364
854
|
function NonNullParam() {
|
|
@@ -432,9 +922,44 @@ function Delegate(...methods) {
|
|
|
432
922
|
);
|
|
433
923
|
}
|
|
434
924
|
var EqualsExclude = defineFieldDecorator(equalsExcludeFieldLegacy);
|
|
925
|
+
function Strategy(family, name) {
|
|
926
|
+
return defineClassDecorator((backend, target) => {
|
|
927
|
+
strategyClassLegacy(backend, target, family, name);
|
|
928
|
+
});
|
|
929
|
+
}
|
|
930
|
+
function State(options) {
|
|
931
|
+
return defineClassDecorator((backend, target) => stateClassLegacy(backend, target, options));
|
|
932
|
+
}
|
|
933
|
+
function Transition(options) {
|
|
934
|
+
return defineMethodDecorator(
|
|
935
|
+
(backend, target, key, descriptor) => transitionMethodLegacy(backend, target, key, descriptor, options)
|
|
936
|
+
);
|
|
937
|
+
}
|
|
938
|
+
var Command = defineClassDecorator(commandClassLegacy);
|
|
939
|
+
var Observable = defineClassDecorator(observableClassLegacy);
|
|
940
|
+
Observable.Derived = ((target, propertyKey, descriptor) => {
|
|
941
|
+
if (descriptor === void 0 || typeof descriptor.get !== "function") {
|
|
942
|
+
throw new TypeError("@Observable.Derived requires a getter");
|
|
943
|
+
}
|
|
944
|
+
observableDerivedLegacy(legacyBackend, target, propertyKey, descriptor);
|
|
945
|
+
});
|
|
946
|
+
var Observer = defineClassDecorator(observerClassLegacy);
|
|
947
|
+
var Memento = defineClassDecorator(mementoClassLegacy);
|
|
948
|
+
Memento.Exclude = defineFieldDecorator(mementoExcludeFieldLegacy);
|
|
949
|
+
var ChainOfResponsibility = defineClassDecorator(chainOfResponsibilityClassLegacy);
|
|
950
|
+
function Handler(options) {
|
|
951
|
+
return defineMethodDecorator(
|
|
952
|
+
(backend, target, key, descriptor) => handlerMethodLegacy(backend, target, key, descriptor, options)
|
|
953
|
+
);
|
|
954
|
+
}
|
|
955
|
+
var Iterable = defineClassDecorator(iterableClassLegacy);
|
|
956
|
+
var IterateOver = defineFieldDecorator(iterateOverFieldLegacy);
|
|
435
957
|
|
|
436
958
|
exports.Accessors = Accessors;
|
|
437
959
|
exports.Builder = Builder;
|
|
960
|
+
exports.ChainOfResponsibility = ChainOfResponsibility;
|
|
961
|
+
exports.Command = Command;
|
|
962
|
+
exports.CommandHistory = CommandHistory;
|
|
438
963
|
exports.Data = Data;
|
|
439
964
|
exports.Delegate = Delegate;
|
|
440
965
|
exports.Equals = Equals;
|
|
@@ -442,15 +967,25 @@ exports.EqualsExclude = EqualsExclude;
|
|
|
442
967
|
exports.Factory = Factory;
|
|
443
968
|
exports.FieldDefaults = FieldDefaults;
|
|
444
969
|
exports.Getter = Getter;
|
|
970
|
+
exports.Handler = Handler;
|
|
971
|
+
exports.Iterable = Iterable;
|
|
972
|
+
exports.IterateOver = IterateOver;
|
|
445
973
|
exports.LegacyBackend = LegacyBackend;
|
|
446
974
|
exports.Log = Log;
|
|
975
|
+
exports.Memento = Memento;
|
|
447
976
|
exports.Memoize = Memoize;
|
|
448
977
|
exports.NonNull = NonNull;
|
|
449
978
|
exports.NonNullParam = NonNullParam;
|
|
979
|
+
exports.Observable = Observable;
|
|
980
|
+
exports.Observer = Observer;
|
|
450
981
|
exports.Prototype = Prototype;
|
|
451
982
|
exports.Setter = Setter;
|
|
452
983
|
exports.Singleton = Singleton;
|
|
984
|
+
exports.State = State;
|
|
985
|
+
exports.Strategy = Strategy;
|
|
986
|
+
exports.StrategyRegistry = StrategyRegistry;
|
|
453
987
|
exports.ToString = ToString;
|
|
988
|
+
exports.Transition = Transition;
|
|
454
989
|
exports.UtilityClass = UtilityClass;
|
|
455
990
|
exports.Value = Value;
|
|
456
991
|
exports.With = With;
|
|
@@ -460,7 +995,11 @@ exports.defineFieldDecorator = defineFieldDecorator;
|
|
|
460
995
|
exports.defineMethodDecorator = defineMethodDecorator;
|
|
461
996
|
exports.defineParameterDecorator = defineParameterDecorator;
|
|
462
997
|
exports.getFactoryRegistry = getFactoryRegistry;
|
|
998
|
+
exports.getStrategyFromRegistry = getStrategyFromRegistry;
|
|
999
|
+
exports.getStrategyRegistry = getStrategyRegistry;
|
|
463
1000
|
exports.legacyBackend = legacyBackend;
|
|
1001
|
+
exports.listStrategies = listStrategies;
|
|
464
1002
|
exports.registerFactory = registerFactory;
|
|
1003
|
+
exports.registerStrategy = registerStrategy;
|
|
465
1004
|
//# sourceMappingURL=index.cjs.map
|
|
466
1005
|
//# sourceMappingURL=index.cjs.map
|