@travetto/transformer 3.1.0 → 3.1.3
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/package.json +3 -3
- package/src/state.ts +11 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/transformer",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.3",
|
|
4
4
|
"description": "Functionality for AST transformations, with transformer registration, and general utils",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@travetto/manifest": "^3.1.0",
|
|
28
|
-
"tslib": "^2.5.
|
|
29
|
-
"typescript": "^5.0.
|
|
28
|
+
"tslib": "^2.5.2",
|
|
29
|
+
"typescript": "^5.0.4"
|
|
30
30
|
},
|
|
31
31
|
"travetto": {
|
|
32
32
|
"displayName": "Transformation",
|
package/src/state.ts
CHANGED
|
@@ -295,24 +295,29 @@ export class TransformerState implements State {
|
|
|
295
295
|
* @param type
|
|
296
296
|
*/
|
|
297
297
|
generateUniqueIdentifier(node: ts.Node, type: AnyType): string {
|
|
298
|
-
let unique: string;
|
|
298
|
+
let unique: string | undefined;
|
|
299
299
|
try {
|
|
300
300
|
// Tie to source location if possible
|
|
301
301
|
const tgt = DeclarationUtil.getPrimaryDeclarationNode(type.original!);
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
302
|
+
const fileName = tgt.getSourceFile().fileName;
|
|
303
|
+
|
|
304
|
+
if (fileName === this.source.fileName) { // if in same file suffix with location
|
|
305
|
+
unique = `${ts.getLineAndCharacterOfPosition(tgt.getSourceFile(), tgt.getStart()).line}_${tgt.getEnd() - tgt.getStart()}`;
|
|
306
|
+
} else {
|
|
307
|
+
// Otherwise treat it as external and add nothing to it
|
|
305
308
|
}
|
|
306
309
|
} catch {
|
|
307
310
|
// Determine type unique ident
|
|
308
|
-
|
|
311
|
+
const imp = this.#resolver.getFileImportName(this.source.fileName);
|
|
312
|
+
unique = `${SystemUtil.naiveHash(`${imp}${type.name ?? 'unknown'}`)}`;
|
|
309
313
|
}
|
|
310
314
|
// Otherwise read name with uuid
|
|
311
315
|
let name = type.name && !type.name.startsWith('_') ? type.name : '';
|
|
312
316
|
if (!name && hasEscapedName(node)) {
|
|
313
317
|
name = `${node.name.escapedText}`;
|
|
314
318
|
}
|
|
315
|
-
|
|
319
|
+
name ||= 'Shape';
|
|
320
|
+
return unique ? `${name}_${unique}` : name;
|
|
316
321
|
}
|
|
317
322
|
|
|
318
323
|
/**
|