lombok-typescript 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +98 -0
  3. package/dist/backend-CkLBcDd8.d.cts +59 -0
  4. package/dist/backend-CkLBcDd8.d.ts +59 -0
  5. package/dist/cli/index.cjs +585 -0
  6. package/dist/cli/index.cjs.map +1 -0
  7. package/dist/cli/index.d.cts +14 -0
  8. package/dist/cli/index.d.ts +14 -0
  9. package/dist/cli/index.js +579 -0
  10. package/dist/cli/index.js.map +1 -0
  11. package/dist/codegen/index.cjs +450 -0
  12. package/dist/codegen/index.cjs.map +1 -0
  13. package/dist/codegen/index.d.cts +109 -0
  14. package/dist/codegen/index.d.ts +109 -0
  15. package/dist/codegen/index.js +443 -0
  16. package/dist/codegen/index.js.map +1 -0
  17. package/dist/core/index.cjs +132 -0
  18. package/dist/core/index.cjs.map +1 -0
  19. package/dist/core/index.d.cts +73 -0
  20. package/dist/core/index.d.ts +73 -0
  21. package/dist/core/index.js +128 -0
  22. package/dist/core/index.js.map +1 -0
  23. package/dist/index.cjs +142 -0
  24. package/dist/index.cjs.map +1 -0
  25. package/dist/index.d.cts +93 -0
  26. package/dist/index.d.ts +93 -0
  27. package/dist/index.js +136 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/legacy/index.cjs +271 -0
  30. package/dist/legacy/index.cjs.map +1 -0
  31. package/dist/legacy/index.d.cts +32 -0
  32. package/dist/legacy/index.d.ts +32 -0
  33. package/dist/legacy/index.js +252 -0
  34. package/dist/legacy/index.js.map +1 -0
  35. package/dist/memoize-Bj9pm_cK.d.cts +48 -0
  36. package/dist/memoize-DvelzGDl.d.ts +48 -0
  37. package/dist/stage3/index.cjs +275 -0
  38. package/dist/stage3/index.cjs.map +1 -0
  39. package/dist/stage3/index.d.cts +97 -0
  40. package/dist/stage3/index.d.ts +97 -0
  41. package/dist/stage3/index.js +255 -0
  42. package/dist/stage3/index.js.map +1 -0
  43. package/package.json +120 -0
@@ -0,0 +1,443 @@
1
+ import { existsSync, mkdirSync, writeFileSync } from 'fs';
2
+ import { resolve, relative, dirname } from 'path';
3
+ import { Project, SyntaxKind } from 'ts-morph';
4
+
5
+ // src/codegen/generator.ts
6
+ function analyzeFile(sourceFile) {
7
+ return sourceFile.getClasses().map((cls) => analyzeClassDeclaration(cls));
8
+ }
9
+ function analyzeClassByName(sourceFile, className) {
10
+ const cls = sourceFile.getClass(className);
11
+ return cls ? analyzeClassDeclaration(cls) : void 0;
12
+ }
13
+ function analyzeSourceString(sourceCode, fileName = "analyze.ts") {
14
+ const project = new Project({ useInMemoryFileSystem: true });
15
+ const sourceFile = project.createSourceFile(fileName, sourceCode);
16
+ return analyzeFile(sourceFile);
17
+ }
18
+ function analyzeClass(sourceCode, className) {
19
+ const project = new Project({ useInMemoryFileSystem: true });
20
+ const sourceFile = project.createSourceFile("analyze.ts", sourceCode);
21
+ const result = analyzeClassByName(sourceFile, className);
22
+ if (!result) {
23
+ throw new Error(`No class named "${className}" found in source`);
24
+ }
25
+ return result;
26
+ }
27
+ function analyzeClassDeclaration(cls) {
28
+ const name = cls.getName() ?? "<anonymous>";
29
+ return {
30
+ name,
31
+ decorators: cls.getDecorators().map(toDecoratorInfo),
32
+ fields: cls.getProperties().map(toFieldInfo),
33
+ methods: cls.getMethods().map(toMethodInfo)
34
+ };
35
+ }
36
+ function toDecoratorInfo(decorator) {
37
+ return {
38
+ name: decorator.getName(),
39
+ arguments: decorator.getArguments().map((arg) => arg.getText())
40
+ };
41
+ }
42
+ function toFieldInfo(prop) {
43
+ const initializer = prop.getInitializer();
44
+ return {
45
+ name: prop.getName(),
46
+ type: prop.getType().getText(prop),
47
+ isOptional: prop.hasQuestionToken(),
48
+ isReadonly: prop.isReadonly(),
49
+ hasDefault: initializer !== void 0,
50
+ defaultValue: initializer?.getText(),
51
+ decorators: prop.getDecorators().map(toDecoratorInfo)
52
+ };
53
+ }
54
+ function toMethodInfo(method) {
55
+ return {
56
+ name: method.getName(),
57
+ returnType: method.getReturnType().getText(method),
58
+ parameters: method.getParameters().map(toParameterInfo),
59
+ decorators: method.getDecorators().map(toDecoratorInfo),
60
+ isAsync: method.isAsync(),
61
+ isStatic: method.isStatic()
62
+ };
63
+ }
64
+ function toParameterInfo(param) {
65
+ return {
66
+ name: param.getName(),
67
+ type: param.getType().getText(param),
68
+ isOptional: param.hasQuestionToken() || param.hasInitializer() || param.getDotDotDotToken()?.getKind() === SyntaxKind.DotDotDotToken,
69
+ decorators: param.getDecorators().map(toDecoratorInfo)
70
+ };
71
+ }
72
+ function toImportPath(sourcePath, fromDir) {
73
+ let rel = relative(fromDir, sourcePath).replace(/\\/g, "/");
74
+ if (!rel.startsWith(".")) rel = "./" + rel;
75
+ return rel.replace(/\.tsx?$/u, ".js");
76
+ }
77
+ function hasCodegenClassDecorator(info) {
78
+ return hasClassDecorator(info, "Builder") || hasClassDecorator(info, "Data") || hasClassDecorator(info, "ToString");
79
+ }
80
+ function hasClassDecorator(info, name) {
81
+ return info.decorators.some((d) => d.name === name);
82
+ }
83
+ function fieldExcludesToString(field) {
84
+ return field.decorators.some(
85
+ (d) => d.name === "ToStringExclude" || d.name === "ToString.Exclude"
86
+ );
87
+ }
88
+ function visibleFields(info) {
89
+ if (hasClassDecorator(info, "ToString")) {
90
+ return info.fields.filter((f) => !fieldExcludesToString(f));
91
+ }
92
+ return info.fields;
93
+ }
94
+ function builderClassName(className) {
95
+ return `${className}Builder`;
96
+ }
97
+
98
+ // src/codegen/emitters/builder.ts
99
+ function emitBuilderClass(info) {
100
+ if (!hasClassDecorator(info, "Builder")) {
101
+ return "";
102
+ }
103
+ const builderName = builderClassName(info.name);
104
+ const fieldLines = info.fields.map((f) => {
105
+ if (f.isOptional) {
106
+ return ` private _${f.name}?: ${f.type};`;
107
+ }
108
+ return ` private _${f.name}!: ${f.type};`;
109
+ });
110
+ const setterMethods = info.fields.map(
111
+ (f) => `
112
+ ${f.name}(value: ${f.type}): ${builderName} {
113
+ this._${f.name} = value;
114
+ return this;
115
+ }`.trim()
116
+ );
117
+ return `
118
+ export class ${builderName} {
119
+ ${fieldLines.join("\n")}
120
+
121
+ static builder(): ${builderName} {
122
+ return new ${builderName}();
123
+ }
124
+
125
+ ${setterMethods.join("\n\n")}
126
+
127
+ build(): ${info.name} {
128
+ const instance = new ${info.name}();
129
+ ${info.fields.map((f) => ` instance.${f.name} = this._${f.name}${f.isOptional ? "" : "!"};`).join("\n")}
130
+ return instance;
131
+ }
132
+ }`.trim();
133
+ }
134
+ function emitDeclarationShim(sourcePath, companionOutputPath, classes) {
135
+ const relSource = toImportPath(sourcePath, dirname(companionOutputPath));
136
+ const lines = [
137
+ "// Auto-generated type augmentation by lombok-typescript.",
138
+ "// Do not edit. Regenerate via `lombok-ts generate`.",
139
+ "",
140
+ "export {};",
141
+ "",
142
+ `declare module '${relSource}' {`
143
+ ];
144
+ for (const info of classes) {
145
+ if (hasClassDecorator(info, "Builder")) {
146
+ const builderName = builderClassName(info.name);
147
+ lines.push(` export class ${builderName} {`);
148
+ lines.push(` static builder(): ${builderName};`);
149
+ for (const f of info.fields) {
150
+ lines.push(` ${f.name}(value: ${f.type}): ${builderName};`);
151
+ }
152
+ lines.push(` build(): ${info.name};`);
153
+ lines.push(" }");
154
+ lines.push("");
155
+ }
156
+ if (hasClassDecorator(info, "Builder")) {
157
+ const builderName = builderClassName(info.name);
158
+ lines.push(` export class ${info.name} {`);
159
+ lines.push(` static builder(): ${builderName};`);
160
+ lines.push(" }");
161
+ lines.push("");
162
+ }
163
+ const augments = [];
164
+ if (hasClassDecorator(info, "Data")) {
165
+ for (const f of info.fields) {
166
+ const g = `get${f.name.charAt(0).toUpperCase()}${f.name.slice(1)}`;
167
+ augments.push(` ${g}(): ${f.type};`);
168
+ if (!f.isReadonly) {
169
+ const s = `set${f.name.charAt(0).toUpperCase()}${f.name.slice(1)}`;
170
+ augments.push(` ${s}(value: ${f.type}): void;`);
171
+ }
172
+ }
173
+ augments.push(` equals(other: ${info.name} | null | undefined): boolean;`);
174
+ augments.push(` toString(): string;`);
175
+ } else if (hasClassDecorator(info, "ToString")) {
176
+ augments.push(" toString(): string;");
177
+ }
178
+ if (augments.length > 0) {
179
+ lines.push(` interface ${info.name} {`);
180
+ lines.push(...augments);
181
+ lines.push(" }");
182
+ }
183
+ }
184
+ lines.push("}");
185
+ lines.push("");
186
+ return lines.join("\n");
187
+ }
188
+
189
+ // src/codegen/emitters/index.ts
190
+ function emitImports(classes, importPath) {
191
+ const names = classes.filter(hasCodegenClassDecorator).map((c) => c.name);
192
+ if (names.length === 0) return "";
193
+ return `import { ${names.join(", ")} } from '${importPath}';
194
+
195
+ `;
196
+ }
197
+ function emitToStringFn(info) {
198
+ if (!hasClassDecorator(info, "ToString") && !hasClassDecorator(info, "Data")) return "";
199
+ const fields = visibleFields(info);
200
+ const parts = fields.map((f) => `${f.name}=\${String(this.${f.name})}`).join(", ");
201
+ return `
202
+ function ${info.name}_toString(this: ${info.name}): string {
203
+ return \`${info.name}(${parts})\`;
204
+ }`.trim();
205
+ }
206
+ function emitApplyMixin(info) {
207
+ const assignments = [];
208
+ if (hasClassDecorator(info, "Data")) {
209
+ for (const f of info.fields) {
210
+ const g = `get${f.name.charAt(0).toUpperCase()}${f.name.slice(1)}`;
211
+ assignments.push(`prototype.${g} = ${info.name}_${g};`);
212
+ if (!f.isReadonly) {
213
+ const s = `set${f.name.charAt(0).toUpperCase()}${f.name.slice(1)}`;
214
+ assignments.push(`prototype.${s} = ${info.name}_${s};`);
215
+ }
216
+ }
217
+ assignments.push(`prototype.equals = ${info.name}_equals;`);
218
+ assignments.push(`prototype.toString = ${info.name}_toString;`);
219
+ } else if (hasClassDecorator(info, "ToString")) {
220
+ assignments.push(`prototype.toString = ${info.name}_toString;`);
221
+ }
222
+ if (hasClassDecorator(info, "Builder")) {
223
+ const bName = builderClassName(info.name);
224
+ assignments.push(
225
+ `(ctor as typeof ${info.name} & { builder(): ${bName} }).builder = ${info.name}_builder;`
226
+ );
227
+ }
228
+ if (assignments.length === 0) return "";
229
+ return `
230
+ export function apply${info.name}Generated(ctor: typeof ${info.name}): void {
231
+ const prototype = ctor.prototype as unknown as Record<string, unknown>;
232
+ ${assignments.join("\n ")}
233
+ }`.trim();
234
+ }
235
+ function emitDataFns(info) {
236
+ if (!hasClassDecorator(info, "Data")) return "";
237
+ const fns = [];
238
+ for (const f of info.fields) {
239
+ const g = `get${f.name.charAt(0).toUpperCase()}${f.name.slice(1)}`;
240
+ fns.push(
241
+ `
242
+ function ${info.name}_${g}(this: ${info.name}): ${f.type} {
243
+ return this.${f.name};
244
+ }`.trim()
245
+ );
246
+ if (!f.isReadonly) {
247
+ const s = `set${f.name.charAt(0).toUpperCase()}${f.name.slice(1)}`;
248
+ fns.push(
249
+ `
250
+ function ${info.name}_${s}(this: ${info.name}, value: ${f.type}): void {
251
+ this.${f.name} = value;
252
+ }`.trim()
253
+ );
254
+ }
255
+ }
256
+ const equalsBody = info.fields.map((f) => `this.${f.name} === other.${f.name}`).join(" &&\n ");
257
+ fns.push(
258
+ `
259
+ function ${info.name}_equals(this: ${info.name}, other: ${info.name} | null | undefined): boolean {
260
+ if (other === null || other === undefined) return false;
261
+ if (!(other instanceof (this.constructor as typeof ${info.name}))) return false;
262
+ return ${equalsBody || "true"};
263
+ }`.trim()
264
+ );
265
+ fns.push(emitToStringFn(info));
266
+ return fns.filter(Boolean).join("\n\n");
267
+ }
268
+ function emitBuilderFn(info) {
269
+ if (!hasClassDecorator(info, "Builder")) return "";
270
+ const bName = builderClassName(info.name);
271
+ return `
272
+ function ${info.name}_builder(): ${bName} {
273
+ return ${bName}.builder();
274
+ }`.trim();
275
+ }
276
+ function emitCompanionFile(sourcePath, companionOutputPath, classes, cwd) {
277
+ const header = [
278
+ "// Auto-generated by lombok-typescript.",
279
+ "// Source: " + relative(cwd, sourcePath).replace(/\\/g, "/"),
280
+ "// Do not edit. Regenerate via `lombok-ts generate`.",
281
+ ""
282
+ ].join("\n");
283
+ const importPath = toImportPath(sourcePath, dirname(companionOutputPath));
284
+ const blocks = [];
285
+ for (const info of classes) {
286
+ const builder = emitBuilderClass(info);
287
+ if (builder) blocks.push(builder);
288
+ if (hasClassDecorator(info, "Data")) {
289
+ blocks.push(emitDataFns(info));
290
+ } else {
291
+ const ts2 = emitToStringFn(info);
292
+ if (ts2) blocks.push(ts2);
293
+ }
294
+ const builderFn = emitBuilderFn(info);
295
+ if (builderFn) blocks.push(builderFn);
296
+ const apply = emitApplyMixin(info);
297
+ if (apply) blocks.push(apply);
298
+ }
299
+ const applyAll = classes.filter((c) => emitApplyMixin(c)).length > 0 ? `
300
+
301
+ export function applyAllGenerated(handlers: {
302
+ ${classes.filter((c) => emitApplyMixin(c)).map((c) => ` ${c.name}: typeof ${c.name};`).join("\n")}
303
+ }): void {
304
+ ${classes.filter((c) => emitApplyMixin(c)).map((c) => ` apply${c.name}Generated(handlers.${c.name});`).join("\n")}
305
+ }
306
+ ` : "\nexport {};\n";
307
+ const imports = emitImports(classes, importPath);
308
+ const ts = header + imports + blocks.join("\n\n") + applyAll;
309
+ const dts = emitDeclarationShim(sourcePath, companionOutputPath, classes);
310
+ return { ts, dts };
311
+ }
312
+
313
+ // src/codegen/generator.ts
314
+ var DEFAULT_OPTIONS = {
315
+ outputDir: ".lombok",
316
+ watch: false,
317
+ include: ["src/**/*.ts"],
318
+ exclude: ["node_modules", "**/*.test.ts", "**/*.spec.ts", "dist", ".lombok"],
319
+ tsConfigPath: "tsconfig.json"
320
+ };
321
+ var CodeGenerator = class {
322
+ options;
323
+ constructor(options = {}) {
324
+ this.options = { ...DEFAULT_OPTIONS, ...options };
325
+ }
326
+ /**
327
+ * Run codegen against all matching source files.
328
+ *
329
+ * Uses the project's `tsConfigPath` if it exists, otherwise an in-memory
330
+ * project that processes the configured globs. For each file with at least
331
+ * one class, writes a companion stub to `<outputDir>/<rel-path>.lombok.ts`.
332
+ */
333
+ async generate() {
334
+ const project = this.createProject();
335
+ const sourceFiles = project.getSourceFiles();
336
+ const generated = [];
337
+ for (const sourceFile of sourceFiles) {
338
+ if (!this.shouldProcess(sourceFile.getFilePath())) continue;
339
+ const classes = analyzeFile(sourceFile);
340
+ if (classes.length === 0) continue;
341
+ const sourcePath = sourceFile.getFilePath();
342
+ const outputPath = this.computeOutputPath(sourcePath);
343
+ const { ts, dts } = emitCompanionFile(sourcePath, outputPath, classes, process.cwd());
344
+ const content = ts;
345
+ this.writeOutput(outputPath, content);
346
+ this.writeOutput(outputPath.replace(/\.lombok\.ts$/u, ".lombok.d.ts"), dts);
347
+ generated.push({
348
+ sourcePath,
349
+ outputPath,
350
+ content,
351
+ processedClasses: classes.map((c) => c.name)
352
+ });
353
+ }
354
+ return generated;
355
+ }
356
+ /** Generate code for a single source file path. */
357
+ async generateForFile(filePath) {
358
+ const project = new Project({
359
+ useInMemoryFileSystem: false,
360
+ compilerOptions: { allowJs: false }
361
+ });
362
+ const sourceFile = project.addSourceFileAtPath(filePath);
363
+ const classes = analyzeFile(sourceFile);
364
+ if (classes.length === 0) return null;
365
+ const outputPath = this.computeOutputPath(filePath);
366
+ const { ts, dts } = emitCompanionFile(filePath, outputPath, classes, process.cwd());
367
+ const content = ts;
368
+ this.writeOutput(outputPath, content);
369
+ this.writeOutput(outputPath.replace(/\.lombok\.ts$/u, ".lombok.d.ts"), dts);
370
+ return {
371
+ sourcePath: filePath,
372
+ outputPath,
373
+ content,
374
+ processedClasses: classes.map((c) => c.name)
375
+ };
376
+ }
377
+ /** Watch mode is not implemented yet. Re-run `lombok-ts generate` for now. */
378
+ async watch() {
379
+ throw new Error(
380
+ "Watch mode is not implemented yet. Re-run `lombok-ts generate` after changes."
381
+ );
382
+ }
383
+ // Internal helpers
384
+ createProject() {
385
+ const tsConfig = resolve(this.options.tsConfigPath);
386
+ if (existsSync(tsConfig)) {
387
+ return new Project({ tsConfigFilePath: tsConfig });
388
+ }
389
+ const project = new Project({
390
+ compilerOptions: {
391
+ allowJs: false,
392
+ target: 99
393
+ /* ESNext */
394
+ }
395
+ });
396
+ if (this.options.include.length > 0) {
397
+ project.addSourceFilesAtPaths(this.options.include);
398
+ }
399
+ return project;
400
+ }
401
+ shouldProcess(filePath) {
402
+ const abs = filePath.replace(/\\/g, "/");
403
+ const rel = relative(process.cwd(), filePath).replace(/\\/g, "/");
404
+ const excluded = this.options.exclude.some(
405
+ (pat) => matchesGlob(rel, pat) || matchesGlob(abs, pat)
406
+ );
407
+ if (excluded) return false;
408
+ if (this.options.include.length === 0) return true;
409
+ return this.options.include.some((pat) => matchesGlob(rel, pat) || matchesGlob(abs, pat));
410
+ }
411
+ computeOutputPath(sourcePath) {
412
+ const cwd = process.cwd();
413
+ const rel = relative(cwd, sourcePath);
414
+ const base = rel.replace(/\.ts$/u, ".lombok.ts");
415
+ return resolve(cwd, this.options.outputDir, base);
416
+ }
417
+ renderCompanion(_sourcePath, _classes) {
418
+ return "export {};\n";
419
+ }
420
+ writeOutput(outputPath, content) {
421
+ mkdirSync(dirname(outputPath), { recursive: true });
422
+ writeFileSync(outputPath, content, "utf8");
423
+ }
424
+ };
425
+ function matchesGlob(filePath, pattern) {
426
+ const norm = filePath.replace(/\\/g, "/");
427
+ const regex = new RegExp(
428
+ "^" + pattern.replace(/[.+^$()|[\]{}]/g, "\\$&").replace(/\*\*\//g, "__GLOBSTAR_SLASH__").replace(/\*\*/g, "__GLOBSTAR__").replace(/\*/g, "[^/]*").replace(/__GLOBSTAR_SLASH__/g, "(?:.*/)?").replace(/__GLOBSTAR__/g, ".*") + "$",
429
+ "u"
430
+ );
431
+ return regex.test(norm);
432
+ }
433
+
434
+ // src/codegen/transformer.ts
435
+ var LombokTransformer = class {
436
+ constructor() {
437
+ throw new Error("LombokTransformer is not implemented yet. Use `lombok-ts generate` for now.");
438
+ }
439
+ };
440
+
441
+ export { CodeGenerator, LombokTransformer, analyzeClass, analyzeClassByName, analyzeFile, analyzeSourceString };
442
+ //# sourceMappingURL=index.js.map
443
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/codegen/analyzer.ts","../../src/codegen/emitters/helpers.ts","../../src/codegen/emitters/builder.ts","../../src/codegen/emitters/declaration.ts","../../src/codegen/emitters/index.ts","../../src/codegen/generator.ts","../../src/codegen/transformer.ts"],"names":["relative","dirname","ts","Project"],"mappings":";;;;;AAgBO,SAAS,YAAY,UAAA,EAAqC;AAC/D,EAAA,OAAO,UAAA,CAAW,YAAW,CAAE,GAAA,CAAI,CAAC,GAAA,KAAQ,uBAAA,CAAwB,GAAG,CAAC,CAAA;AAC1E;AAGO,SAAS,kBAAA,CACd,YACA,SAAA,EACuB;AACvB,EAAA,MAAM,GAAA,GAAM,UAAA,CAAW,QAAA,CAAS,SAAS,CAAA;AACzC,EAAA,OAAO,GAAA,GAAM,uBAAA,CAAwB,GAAG,CAAA,GAAI,MAAA;AAC9C;AAGO,SAAS,mBAAA,CAAoB,UAAA,EAAoB,QAAA,GAAW,YAAA,EAA2B;AAC5F,EAAA,MAAM,UAAU,IAAI,OAAA,CAAQ,EAAE,qBAAA,EAAuB,MAAM,CAAA;AAC3D,EAAA,MAAM,UAAA,GAAa,OAAA,CAAQ,gBAAA,CAAiB,QAAA,EAAU,UAAU,CAAA;AAChE,EAAA,OAAO,YAAY,UAAU,CAAA;AAC/B;AAGO,SAAS,YAAA,CAAa,YAAoB,SAAA,EAA8B;AAC7E,EAAA,MAAM,UAAU,IAAI,OAAA,CAAQ,EAAE,qBAAA,EAAuB,MAAM,CAAA;AAC3D,EAAA,MAAM,UAAA,GAAa,OAAA,CAAQ,gBAAA,CAAiB,YAAA,EAAc,UAAU,CAAA;AACpE,EAAA,MAAM,MAAA,GAAS,kBAAA,CAAmB,UAAA,EAAY,SAAS,CAAA;AACvD,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,gBAAA,EAAmB,SAAS,CAAA,iBAAA,CAAmB,CAAA;AAAA,EACj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AA,EACT;AAAA,EAEU,WAAA,CAAY,YAAoB,OAAA,EAAuB;AAC/D,IAAA,SAAA,CAAUC,QAAQ,UAAU,CAAA,EAAG,EAAE,SAAA,EAAW,MAAM,CAAA;AAClD,IAAA,aAAA,CAAc,UAAA,EAAY,SAAS,MAAM,CAAA;AAAA,EAC3C;AACF;AAMA,SAAS,WAAA,CAAY,UAAkB,OAAA,EAA0B;AAC/D,EAAA,MAAM,IAAA,GAAO,QAAA,CAAS,OAAA,CAAQ,KAAA,EAAO,GAAG,CAAA;AACxC,EAAA,MAAM,QAAQ,IAAI,MAAA;AAAA,IAChB,GAAA,GACE,OAAA,CACG,OAAA,CAAQ,iBAAA,EAAmB,MAAM,EACjC,OAAA,CAAQ,SAAA,EAAW,oBAAoB,CAAA,CACvC,OAAA,CAAQ,OAAA,EAAS,cAAc,CAAA,CAC/B,OAAA,CAAQ,KAAA,EAAO,OAAO,CAAA,CACtB,OAAA,CAAQ,qBAAA,EAAuB,UAAU,CAAA,CACzC,OAAA,CAAQ,eAAA,EAAiB,IAAI,CAAA,GAChC,GAAA;AAAA,IACF;AAAA,GACF;AACA,EAAA,OAAO,KAAA,CAAM,KAAK,IAAI,CAAA;AACxB;;;AC3JO,IAAM,oBAAN,MAAwB;AAAA,EAC7B,WAAA,GAAc;AACZ,IAAA,MAAM,IAAI,MAAM,6EAA6E,CAAA;AAAA,EAC/F;AACF","file":"index.js","sourcesContent":["import {\n type ClassDeclaration,\n type Decorator,\n type MethodDeclaration,\n type ParameterDeclaration,\n Project,\n type PropertyDeclaration,\n type SourceFile,\n SyntaxKind,\n} from 'ts-morph';\nimport type { ClassInfo, DecoratorInfo, FieldInfo, MethodInfo, ParameterInfo } from './types.js';\n\n/**\n * Walk every class in `sourceFile` and return their decorator/field/method\n * shapes as plain data. No ts-morph references leak out.\n */\nexport function analyzeFile(sourceFile: SourceFile): ClassInfo[] {\n return sourceFile.getClasses().map((cls) => analyzeClassDeclaration(cls));\n}\n\n/** Find one class by name in the source file. Returns `undefined` if missing. */\nexport function analyzeClassByName(\n sourceFile: SourceFile,\n className: string,\n): ClassInfo | undefined {\n const cls = sourceFile.getClass(className);\n return cls ? analyzeClassDeclaration(cls) : undefined;\n}\n\n/** Parse a source string in an in-memory project and analyze every class in it. */\nexport function analyzeSourceString(sourceCode: string, fileName = 'analyze.ts'): ClassInfo[] {\n const project = new Project({ useInMemoryFileSystem: true });\n const sourceFile = project.createSourceFile(fileName, sourceCode);\n return analyzeFile(sourceFile);\n}\n\n/** Analyze a single named class in a source string. Throws if not found. */\nexport function analyzeClass(sourceCode: string, className: string): ClassInfo {\n const project = new Project({ useInMemoryFileSystem: true });\n const sourceFile = project.createSourceFile('analyze.ts', sourceCode);\n const result = analyzeClassByName(sourceFile, className);\n if (!result) {\n throw new Error(`No class named \"${className}\" found in source`);\n }\n return result;\n}\n\n// Internal walkers\n\nfunction analyzeClassDeclaration(cls: ClassDeclaration): ClassInfo {\n const name = cls.getName() ?? '<anonymous>';\n return {\n name,\n decorators: cls.getDecorators().map(toDecoratorInfo),\n fields: cls.getProperties().map(toFieldInfo),\n methods: cls.getMethods().map(toMethodInfo),\n };\n}\n\nfunction toDecoratorInfo(decorator: Decorator): DecoratorInfo {\n return {\n name: decorator.getName(),\n arguments: decorator.getArguments().map((arg) => arg.getText()),\n };\n}\n\nfunction toFieldInfo(prop: PropertyDeclaration): FieldInfo {\n const initializer = prop.getInitializer();\n return {\n name: prop.getName(),\n type: prop.getType().getText(prop),\n isOptional: prop.hasQuestionToken(),\n isReadonly: prop.isReadonly(),\n hasDefault: initializer !== undefined,\n defaultValue: initializer?.getText(),\n decorators: prop.getDecorators().map(toDecoratorInfo),\n };\n}\n\nfunction toMethodInfo(method: MethodDeclaration): MethodInfo {\n return {\n name: method.getName(),\n returnType: method.getReturnType().getText(method),\n parameters: method.getParameters().map(toParameterInfo),\n decorators: method.getDecorators().map(toDecoratorInfo),\n isAsync: method.isAsync(),\n isStatic: method.isStatic(),\n };\n}\n\nfunction toParameterInfo(param: ParameterDeclaration): ParameterInfo {\n return {\n name: param.getName(),\n type: param.getType().getText(param),\n isOptional:\n param.hasQuestionToken() ||\n param.hasInitializer() ||\n param.getDotDotDotToken()?.getKind() === SyntaxKind.DotDotDotToken,\n decorators: param.getDecorators().map(toDecoratorInfo),\n };\n}\n","import { relative } from 'node:path';\nimport type { ClassInfo, FieldInfo } from '../types.js';\n\n/** ESM import path from `fromDir` to `sourcePath` (NodeNext requires a `.js` extension). */\nexport function toImportPath(sourcePath: string, fromDir: string): string {\n let rel = relative(fromDir, sourcePath).replace(/\\\\/g, '/');\n if (!rel.startsWith('.')) rel = './' + rel;\n return rel.replace(/\\.tsx?$/u, '.js');\n}\n\nexport function hasCodegenClassDecorator(info: ClassInfo): boolean {\n return (\n hasClassDecorator(info, 'Builder') ||\n hasClassDecorator(info, 'Data') ||\n hasClassDecorator(info, 'ToString')\n );\n}\n\nexport function hasClassDecorator(info: ClassInfo, name: string): boolean {\n return info.decorators.some((d) => d.name === name);\n}\n\nexport function fieldExcludesToString(field: FieldInfo): boolean {\n return field.decorators.some(\n (d) => d.name === 'ToStringExclude' || d.name === 'ToString.Exclude',\n );\n}\n\nexport function visibleFields(info: ClassInfo): FieldInfo[] {\n if (hasClassDecorator(info, 'ToString')) {\n return info.fields.filter((f) => !fieldExcludesToString(f));\n }\n return info.fields;\n}\n\nexport function getterName(fieldName: string): string {\n return `get${fieldName.charAt(0).toUpperCase()}${fieldName.slice(1)}`;\n}\n\nexport function setterName(fieldName: string): string {\n return `set${fieldName.charAt(0).toUpperCase()}${fieldName.slice(1)}`;\n}\n\nexport function builderClassName(className: string): string {\n return `${className}Builder`;\n}\n","import type { ClassInfo } from '../types.js';\nimport { builderClassName, hasClassDecorator } from './helpers.js';\n\nexport function emitBuilderClass(info: ClassInfo): string {\n if (!hasClassDecorator(info, 'Builder')) {\n return '';\n }\n\n const builderName = builderClassName(info.name);\n const fieldLines = info.fields.map((f) => {\n if (f.isOptional) {\n return ` private _${f.name}?: ${f.type};`;\n }\n return ` private _${f.name}!: ${f.type};`;\n });\n\n const setterMethods = info.fields.map((f) =>\n `\n ${f.name}(value: ${f.type}): ${builderName} {\n this._${f.name} = value;\n return this;\n }`.trim(),\n );\n\n return `\nexport class ${builderName} {\n${fieldLines.join('\\n')}\n\n static builder(): ${builderName} {\n return new ${builderName}();\n }\n\n${setterMethods.join('\\n\\n')}\n\n build(): ${info.name} {\n const instance = new ${info.name}();\n${info.fields.map((f) => ` instance.${f.name} = this._${f.name}${f.isOptional ? '' : '!'};`).join('\\n')}\n return instance;\n }\n}`.trim();\n}\n\nexport function emitBuilderStaticMethod(info: ClassInfo): string {\n if (!hasClassDecorator(info, 'Builder')) return '';\n const builderName = builderClassName(info.name);\n return `\n static builder(): ${builderName} {\n return ${builderName}.builder();\n }`.trim();\n}\n","import { dirname } from 'node:path';\nimport type { ClassInfo } from '../types.js';\nimport { builderClassName, hasClassDecorator, toImportPath } from './helpers.js';\n\nexport function emitDeclarationShim(\n sourcePath: string,\n companionOutputPath: string,\n classes: readonly ClassInfo[],\n): string {\n const relSource = toImportPath(sourcePath, dirname(companionOutputPath));\n const lines: string[] = [\n '// Auto-generated type augmentation by lombok-typescript.',\n '// Do not edit. Regenerate via `lombok-ts generate`.',\n '',\n 'export {};',\n '',\n `declare module '${relSource}' {`,\n ];\n\n for (const info of classes) {\n if (hasClassDecorator(info, 'Builder')) {\n const builderName = builderClassName(info.name);\n lines.push(` export class ${builderName} {`);\n lines.push(` static builder(): ${builderName};`);\n for (const f of info.fields) {\n lines.push(` ${f.name}(value: ${f.type}): ${builderName};`);\n }\n lines.push(` build(): ${info.name};`);\n lines.push(' }');\n lines.push('');\n }\n\n if (hasClassDecorator(info, 'Builder')) {\n const builderName = builderClassName(info.name);\n lines.push(` export class ${info.name} {`);\n lines.push(` static builder(): ${builderName};`);\n lines.push(' }');\n lines.push('');\n }\n\n const augments: string[] = [];\n if (hasClassDecorator(info, 'Data')) {\n for (const f of info.fields) {\n const g = `get${f.name.charAt(0).toUpperCase()}${f.name.slice(1)}`;\n augments.push(` ${g}(): ${f.type};`);\n if (!f.isReadonly) {\n const s = `set${f.name.charAt(0).toUpperCase()}${f.name.slice(1)}`;\n augments.push(` ${s}(value: ${f.type}): void;`);\n }\n }\n augments.push(` equals(other: ${info.name} | null | undefined): boolean;`);\n augments.push(` toString(): string;`);\n } else if (hasClassDecorator(info, 'ToString')) {\n augments.push(' toString(): string;');\n }\n\n if (augments.length > 0) {\n lines.push(` interface ${info.name} {`);\n lines.push(...augments);\n lines.push(' }');\n }\n }\n\n lines.push('}');\n lines.push('');\n return lines.join('\\n');\n}\n","import { dirname, relative } from 'node:path';\nimport type { ClassInfo } from '../types.js';\nimport { emitBuilderClass } from './builder.js';\nimport { emitDeclarationShim } from './declaration.js';\nimport {\n builderClassName,\n hasClassDecorator,\n hasCodegenClassDecorator,\n toImportPath,\n visibleFields,\n} from './helpers.js';\n\nfunction emitImports(classes: readonly ClassInfo[], importPath: string): string {\n const names = classes.filter(hasCodegenClassDecorator).map((c) => c.name);\n if (names.length === 0) return '';\n return `import { ${names.join(', ')} } from '${importPath}';\\n\\n`;\n}\n\nfunction emitToStringFn(info: ClassInfo): string {\n if (!hasClassDecorator(info, 'ToString') && !hasClassDecorator(info, 'Data')) return '';\n const fields = visibleFields(info);\n const parts = fields.map((f) => `${f.name}=\\${String(this.${f.name})}`).join(', ');\n return `\nfunction ${info.name}_toString(this: ${info.name}): string {\n return \\`${info.name}(${parts})\\`;\n}`.trim();\n}\n\nfunction emitApplyMixin(info: ClassInfo): string {\n const assignments: string[] = [];\n\n if (hasClassDecorator(info, 'Data')) {\n for (const f of info.fields) {\n const g = `get${f.name.charAt(0).toUpperCase()}${f.name.slice(1)}`;\n assignments.push(`prototype.${g} = ${info.name}_${g};`);\n if (!f.isReadonly) {\n const s = `set${f.name.charAt(0).toUpperCase()}${f.name.slice(1)}`;\n assignments.push(`prototype.${s} = ${info.name}_${s};`);\n }\n }\n assignments.push(`prototype.equals = ${info.name}_equals;`);\n assignments.push(`prototype.toString = ${info.name}_toString;`);\n } else if (hasClassDecorator(info, 'ToString')) {\n assignments.push(`prototype.toString = ${info.name}_toString;`);\n }\n\n if (hasClassDecorator(info, 'Builder')) {\n const bName = builderClassName(info.name);\n assignments.push(\n `(ctor as typeof ${info.name} & { builder(): ${bName} }).builder = ${info.name}_builder;`,\n );\n }\n\n if (assignments.length === 0) return '';\n\n return `\nexport function apply${info.name}Generated(ctor: typeof ${info.name}): void {\n const prototype = ctor.prototype as unknown as Record<string, unknown>;\n ${assignments.join('\\n ')}\n}`.trim();\n}\n\nfunction emitDataFns(info: ClassInfo): string {\n if (!hasClassDecorator(info, 'Data')) return '';\n\n const fns: string[] = [];\n\n for (const f of info.fields) {\n const g = `get${f.name.charAt(0).toUpperCase()}${f.name.slice(1)}`;\n fns.push(\n `\nfunction ${info.name}_${g}(this: ${info.name}): ${f.type} {\n return this.${f.name};\n}`.trim(),\n );\n if (!f.isReadonly) {\n const s = `set${f.name.charAt(0).toUpperCase()}${f.name.slice(1)}`;\n fns.push(\n `\nfunction ${info.name}_${s}(this: ${info.name}, value: ${f.type}): void {\n this.${f.name} = value;\n}`.trim(),\n );\n }\n }\n\n const equalsBody = info.fields.map((f) => `this.${f.name} === other.${f.name}`).join(' &&\\n ');\n\n fns.push(\n `\nfunction ${info.name}_equals(this: ${info.name}, other: ${info.name} | null | undefined): boolean {\n if (other === null || other === undefined) return false;\n if (!(other instanceof (this.constructor as typeof ${info.name}))) return false;\n return ${equalsBody || 'true'};\n}`.trim(),\n );\n\n fns.push(emitToStringFn(info));\n\n return fns.filter(Boolean).join('\\n\\n');\n}\n\nfunction emitBuilderFn(info: ClassInfo): string {\n if (!hasClassDecorator(info, 'Builder')) return '';\n const bName = builderClassName(info.name);\n return `\nfunction ${info.name}_builder(): ${bName} {\n return ${bName}.builder();\n}`.trim();\n}\n\nexport function emitCompanionFile(\n sourcePath: string,\n companionOutputPath: string,\n classes: readonly ClassInfo[],\n cwd: string,\n): { ts: string; dts: string } {\n const header = [\n '// Auto-generated by lombok-typescript.',\n '// Source: ' + relative(cwd, sourcePath).replace(/\\\\/g, '/'),\n '// Do not edit. Regenerate via `lombok-ts generate`.',\n '',\n ].join('\\n');\n\n const importPath = toImportPath(sourcePath, dirname(companionOutputPath));\n\n const blocks: string[] = [];\n\n for (const info of classes) {\n const builder = emitBuilderClass(info);\n if (builder) blocks.push(builder);\n\n if (hasClassDecorator(info, 'Data')) {\n blocks.push(emitDataFns(info));\n } else {\n const ts = emitToStringFn(info);\n if (ts) blocks.push(ts);\n }\n\n const builderFn = emitBuilderFn(info);\n if (builderFn) blocks.push(builderFn);\n\n const apply = emitApplyMixin(info);\n if (apply) blocks.push(apply);\n }\n\n const applyAll =\n classes.filter((c) => emitApplyMixin(c)).length > 0\n ? `\\n\\nexport function applyAllGenerated(handlers: {\\n${classes\n .filter((c) => emitApplyMixin(c))\n .map((c) => ` ${c.name}: typeof ${c.name};`)\n .join('\\n')}\\n}): void {\\n${classes\n .filter((c) => emitApplyMixin(c))\n .map((c) => ` apply${c.name}Generated(handlers.${c.name});`)\n .join('\\n')}\\n}\\n`\n : '\\nexport {};\\n';\n\n const imports = emitImports(classes, importPath);\n const ts = header + imports + blocks.join('\\n\\n') + applyAll;\n const dts = emitDeclarationShim(sourcePath, companionOutputPath, classes);\n\n return { ts, dts };\n}\n\nexport { emitDeclarationShim };\n","import { existsSync, mkdirSync, writeFileSync } from 'node:fs';\nimport { dirname, relative, resolve } from 'node:path';\nimport { Project } from 'ts-morph';\nimport { analyzeFile } from './analyzer.js';\nimport { emitCompanionFile } from './emitters/index.js';\nimport type { ClassInfo, GeneratedFile, GeneratorOptions } from './types.js';\n\nconst DEFAULT_OPTIONS: GeneratorOptions = {\n outputDir: '.lombok',\n watch: false,\n include: ['src/**/*.ts'],\n exclude: ['node_modules', '**/*.test.ts', '**/*.spec.ts', 'dist', '.lombok'],\n tsConfigPath: 'tsconfig.json',\n};\n\n/**\n * Codegen entry point.\n *\n * Walks the user's source files, finds decorated classes, and writes a\n * companion stub file per source. The stub today is just a comment-form\n * summary of each class. Once real decorators land, this is where their\n * generated TypeScript output will go.\n */\nexport class CodeGenerator {\n readonly options: GeneratorOptions;\n\n constructor(options: Partial<GeneratorOptions> = {}) {\n this.options = { ...DEFAULT_OPTIONS, ...options };\n }\n\n /**\n * Run codegen against all matching source files.\n *\n * Uses the project's `tsConfigPath` if it exists, otherwise an in-memory\n * project that processes the configured globs. For each file with at least\n * one class, writes a companion stub to `<outputDir>/<rel-path>.lombok.ts`.\n */\n async generate(): Promise<GeneratedFile[]> {\n const project = this.createProject();\n const sourceFiles = project.getSourceFiles();\n const generated: GeneratedFile[] = [];\n\n for (const sourceFile of sourceFiles) {\n if (!this.shouldProcess(sourceFile.getFilePath())) continue;\n\n const classes = analyzeFile(sourceFile);\n if (classes.length === 0) continue;\n\n const sourcePath = sourceFile.getFilePath();\n const outputPath = this.computeOutputPath(sourcePath);\n const { ts, dts } = emitCompanionFile(sourcePath, outputPath, classes, process.cwd());\n const content = ts;\n\n this.writeOutput(outputPath, content);\n this.writeOutput(outputPath.replace(/\\.lombok\\.ts$/u, '.lombok.d.ts'), dts);\n\n generated.push({\n sourcePath,\n outputPath,\n content,\n processedClasses: classes.map((c) => c.name),\n });\n }\n\n return generated;\n }\n\n /** Generate code for a single source file path. */\n async generateForFile(filePath: string): Promise<GeneratedFile | null> {\n const project = new Project({\n useInMemoryFileSystem: false,\n compilerOptions: { allowJs: false },\n });\n const sourceFile = project.addSourceFileAtPath(filePath);\n const classes = analyzeFile(sourceFile);\n if (classes.length === 0) return null;\n\n const outputPath = this.computeOutputPath(filePath);\n const { ts, dts } = emitCompanionFile(filePath, outputPath, classes, process.cwd());\n const content = ts;\n this.writeOutput(outputPath, content);\n this.writeOutput(outputPath.replace(/\\.lombok\\.ts$/u, '.lombok.d.ts'), dts);\n\n return {\n sourcePath: filePath,\n outputPath,\n content,\n processedClasses: classes.map((c) => c.name),\n };\n }\n\n /** Watch mode is not implemented yet. Re-run `lombok-ts generate` for now. */\n async watch(): Promise<void> {\n throw new Error(\n 'Watch mode is not implemented yet. Re-run `lombok-ts generate` after changes.',\n );\n }\n\n // Internal helpers\n\n protected createProject(): Project {\n const tsConfig = resolve(this.options.tsConfigPath);\n if (existsSync(tsConfig)) {\n return new Project({ tsConfigFilePath: tsConfig });\n }\n const project = new Project({\n compilerOptions: { allowJs: false, target: 99 /* ESNext */ },\n });\n if (this.options.include.length > 0) {\n project.addSourceFilesAtPaths(this.options.include);\n }\n return project;\n }\n\n protected shouldProcess(filePath: string): boolean {\n const abs = filePath.replace(/\\\\/g, '/');\n const rel = relative(process.cwd(), filePath).replace(/\\\\/g, '/');\n\n const excluded = this.options.exclude.some(\n (pat) => matchesGlob(rel, pat) || matchesGlob(abs, pat),\n );\n if (excluded) return false;\n\n if (this.options.include.length === 0) return true;\n return this.options.include.some((pat) => matchesGlob(rel, pat) || matchesGlob(abs, pat));\n }\n\n protected computeOutputPath(sourcePath: string): string {\n const cwd = process.cwd();\n const rel = relative(cwd, sourcePath);\n const base = rel.replace(/\\.ts$/u, '.lombok.ts');\n return resolve(cwd, this.options.outputDir, base);\n }\n\n protected renderCompanion(_sourcePath: string, _classes: readonly ClassInfo[]): string {\n return 'export {};\\n';\n }\n\n protected writeOutput(outputPath: string, content: string): void {\n mkdirSync(dirname(outputPath), { recursive: true });\n writeFileSync(outputPath, content, 'utf8');\n }\n}\n\n/**\n * Minimal glob match. Handles `**`, `*`, no brace expansion. If we need more\n * we'd pull in `picomatch`, but this keeps the dep tree small.\n */\nfunction matchesGlob(filePath: string, pattern: string): boolean {\n const norm = filePath.replace(/\\\\/g, '/');\n const regex = new RegExp(\n '^' +\n pattern\n .replace(/[.+^$()|[\\]{}]/g, '\\\\$&')\n .replace(/\\*\\*\\//g, '__GLOBSTAR_SLASH__')\n .replace(/\\*\\*/g, '__GLOBSTAR__')\n .replace(/\\*/g, '[^/]*')\n .replace(/__GLOBSTAR_SLASH__/g, '(?:.*/)?')\n .replace(/__GLOBSTAR__/g, '.*') +\n '$',\n 'u',\n );\n return regex.test(norm);\n}\n","/**\n * Placeholder for a TypeScript compiler transformer that would run codegen as\n * part of `tsc` itself (via `ts-patch` or `ttypescript`).\n *\n * For now the standalone `lombok-ts` CLI is the only codegen path. This file\n * exists so importing a transformer gives a clear \"not yet\" rather than a\n * module-not-found.\n */\nexport class LombokTransformer {\n constructor() {\n throw new Error('LombokTransformer is not implemented yet. Use `lombok-ts generate` for now.');\n }\n}\n"]}
@@ -0,0 +1,132 @@
1
+ 'use strict';
2
+
3
+ // src/core/metadata-store.ts
4
+ var WeakMapMetadataStore = class {
5
+ classScopes = /* @__PURE__ */ new WeakMap();
6
+ memberScopes = /* @__PURE__ */ new WeakMap();
7
+ set(key, target, propertyKey, value) {
8
+ const bucket = this.bucket(target, propertyKey, true);
9
+ bucket.set(key, value);
10
+ }
11
+ get(key, target, propertyKey) {
12
+ const bucket = this.bucket(target, propertyKey, false);
13
+ return bucket?.get(key);
14
+ }
15
+ has(key, target, propertyKey) {
16
+ const bucket = this.bucket(target, propertyKey, false);
17
+ return bucket?.has(key) ?? false;
18
+ }
19
+ delete(key, target, propertyKey) {
20
+ const bucket = this.bucket(target, propertyKey, false);
21
+ if (!bucket) return false;
22
+ return bucket.delete(key);
23
+ }
24
+ list(target, propertyKey) {
25
+ const bucket = this.bucket(target, propertyKey, false);
26
+ if (!bucket) return [];
27
+ return Array.from(bucket.keys());
28
+ }
29
+ bucket(target, propertyKey, createIfMissing) {
30
+ if (propertyKey === void 0) {
31
+ let bucket2 = this.classScopes.get(target);
32
+ if (!bucket2 && createIfMissing) {
33
+ bucket2 = /* @__PURE__ */ new Map();
34
+ this.classScopes.set(target, bucket2);
35
+ }
36
+ return bucket2;
37
+ }
38
+ let perTarget = this.memberScopes.get(target);
39
+ if (!perTarget) {
40
+ if (!createIfMissing) return void 0;
41
+ perTarget = /* @__PURE__ */ new Map();
42
+ this.memberScopes.set(target, perTarget);
43
+ }
44
+ let bucket = perTarget.get(propertyKey);
45
+ if (!bucket) {
46
+ if (!createIfMissing) return void 0;
47
+ bucket = /* @__PURE__ */ new Map();
48
+ perTarget.set(propertyKey, bucket);
49
+ }
50
+ return bucket;
51
+ }
52
+ };
53
+
54
+ // src/core/metadata-keys.ts
55
+ var PREFIX = "lombok-ts:";
56
+ var MetadataKeys = {
57
+ // Class-level (Lombok)
58
+ DATA: `${PREFIX}data`,
59
+ VALUE: `${PREFIX}value`,
60
+ BUILDER: `${PREFIX}builder`,
61
+ TO_STRING: `${PREFIX}toString`,
62
+ EQUALS: `${PREFIX}equals`,
63
+ UTILITY_CLASS: `${PREFIX}utilityClass`,
64
+ FIELD_DEFAULTS: `${PREFIX}fieldDefaults`,
65
+ ACCESSORS: `${PREFIX}accessors`,
66
+ LOG: `${PREFIX}log`,
67
+ // Class-level (TS-only)
68
+ OBSERVABLE: `${PREFIX}observable`,
69
+ SERIALIZABLE: `${PREFIX}serializable`,
70
+ DEEP_FREEZE: `${PREFIX}deepFreeze`,
71
+ TRACE: `${PREFIX}trace`,
72
+ // Class-level (GoF)
73
+ SINGLETON: `${PREFIX}singleton`,
74
+ FACTORY: `${PREFIX}factory`,
75
+ ABSTRACT_FACTORY: `${PREFIX}abstractFactory`,
76
+ PROTOTYPE: `${PREFIX}prototype`,
77
+ ADAPTER: `${PREFIX}adapter`,
78
+ BRIDGE: `${PREFIX}bridge`,
79
+ COMPOSITE: `${PREFIX}composite`,
80
+ WRAPS: `${PREFIX}wraps`,
81
+ FACADE: `${PREFIX}facade`,
82
+ FLYWEIGHT: `${PREFIX}flyweight`,
83
+ PROXY: `${PREFIX}proxy`,
84
+ CHAIN_OF_RESPONSIBILITY: `${PREFIX}chainOfResponsibility`,
85
+ COMMAND: `${PREFIX}command`,
86
+ INTERPRETER: `${PREFIX}interpreter`,
87
+ ITERABLE: `${PREFIX}iterable`,
88
+ MEDIATOR: `${PREFIX}mediator`,
89
+ MEMENTO: `${PREFIX}memento`,
90
+ STATE: `${PREFIX}state`,
91
+ STRATEGY: `${PREFIX}strategy`,
92
+ TEMPLATE_METHOD: `${PREFIX}templateMethod`,
93
+ VISITABLE: `${PREFIX}visitable`,
94
+ VISITOR: `${PREFIX}visitor`,
95
+ // Field-level
96
+ GETTER: `${PREFIX}getter`,
97
+ SETTER: `${PREFIX}setter`,
98
+ NON_NULL: `${PREFIX}nonNull`,
99
+ WITH: `${PREFIX}with`,
100
+ DELEGATE: `${PREFIX}delegate`,
101
+ VALIDATE: `${PREFIX}validate`,
102
+ TO_STRING_EXCLUDE: `${PREFIX}toString:exclude`,
103
+ TO_STRING_INCLUDE: `${PREFIX}toString:include`,
104
+ EQUALS_EXCLUDE: `${PREFIX}equals:exclude`,
105
+ SERIALIZABLE_EXCLUDE: `${PREFIX}serializable:exclude`,
106
+ SERIALIZABLE_TRANSFORM: `${PREFIX}serializable:transform`,
107
+ SERIALIZABLE_ALIAS: `${PREFIX}serializable:alias`,
108
+ BUILDER_DEFAULT: `${PREFIX}builder:default`,
109
+ SINGULAR: `${PREFIX}singular`,
110
+ ITERATE_OVER: `${PREFIX}iterateOver`,
111
+ // Method-level
112
+ MEMOIZE: `${PREFIX}memoize`,
113
+ DEBOUNCE: `${PREFIX}debounce`,
114
+ THROTTLE: `${PREFIX}throttle`,
115
+ RETRY: `${PREFIX}retry`,
116
+ HANDLER: `${PREFIX}handler`,
117
+ TRANSITION: `${PREFIX}transition`,
118
+ HOOK: `${PREFIX}hook`,
119
+ // Parameter-level
120
+ NON_NULL_PARAM: `${PREFIX}nonNull:param`,
121
+ // Internal, framework-managed
122
+ FIELDS: `${PREFIX}internal:fields`,
123
+ CONSTRUCTOR_PARAMS: `${PREFIX}internal:constructorParams`,
124
+ BACKEND: `${PREFIX}internal:backend`
125
+ };
126
+ var METADATA_KEY_PREFIX = PREFIX;
127
+
128
+ exports.METADATA_KEY_PREFIX = METADATA_KEY_PREFIX;
129
+ exports.MetadataKeys = MetadataKeys;
130
+ exports.WeakMapMetadataStore = WeakMapMetadataStore;
131
+ //# sourceMappingURL=index.cjs.map
132
+ //# sourceMappingURL=index.cjs.map