@twin.org/nameof-transformer 0.0.1-next.8 → 0.0.1
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/dist/cjs/index.cjs +6 -17
- package/dist/esm/index.mjs +6 -17
- package/dist/types/index.d.ts +19 -0
- package/dist/types/manual.d.ts +6 -0
- package/dist/types/svelte.d.ts +7 -0
- package/dist/types/transformer.d.ts +13 -0
- package/docs/changelog.md +111 -1
- package/docs/reference/functions/manual.md +3 -1
- package/docs/reference/index.md +6 -6
- package/docs/reference/variables/name.md +4 -0
- package/docs/reference/variables/version.md +5 -1
- package/package.json +4 -3
package/dist/cjs/index.cjs
CHANGED
|
@@ -116,27 +116,16 @@ function visitNode(node) {
|
|
|
116
116
|
* @returns The content with the transformers replace.
|
|
117
117
|
*/
|
|
118
118
|
function manual(content) {
|
|
119
|
-
if (content.includes("nameof")) {
|
|
119
|
+
if (typeof content === "string" && content.includes("nameof")) {
|
|
120
120
|
// Remove the import
|
|
121
121
|
content = content.replace(/import.*from "@twin\.org\/nameof";/g, "");
|
|
122
122
|
// Replace the nameof<IMyObject>() with "IMyObject"
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
matchName = nameRegEx.exec(content);
|
|
127
|
-
if (matchName && matchName.length === 2) {
|
|
128
|
-
content = content.replace(matchName[0], `"${matchName[1].replace(/\?/g, "")}"`);
|
|
129
|
-
}
|
|
130
|
-
} while (matchName);
|
|
123
|
+
// or the nameof<IMyObject<IType2>>() with "IMyObject"
|
|
124
|
+
const nameRegEx = /nameof<(.*?)(?:<.*>)?>\(\)/g;
|
|
125
|
+
content = content.replace(nameRegEx, '"$1"');
|
|
131
126
|
// Replace the nameof(object?.prop) with "object.prop"
|
|
132
127
|
const propRegEx = /nameof\((.*?)\)/g;
|
|
133
|
-
|
|
134
|
-
do {
|
|
135
|
-
matchProp = propRegEx.exec(content);
|
|
136
|
-
if (matchProp && matchProp.length === 2) {
|
|
137
|
-
content = content.replace(matchProp[0], `"${matchProp[1].replace(/\?/g, "")}"`);
|
|
138
|
-
}
|
|
139
|
-
} while (matchProp);
|
|
128
|
+
content = content.replace(propRegEx, '"$1"');
|
|
140
129
|
}
|
|
141
130
|
return content;
|
|
142
131
|
}
|
|
@@ -173,7 +162,7 @@ const factory = () => transformerFactory;
|
|
|
173
162
|
* Exports the factory version.
|
|
174
163
|
* @returns The factory.
|
|
175
164
|
*/
|
|
176
|
-
const version = "0.0.1
|
|
165
|
+
const version = "0.0.1"; // x-release-please-version
|
|
177
166
|
/**
|
|
178
167
|
* Exports the factory name.
|
|
179
168
|
* @returns The factory.
|
package/dist/esm/index.mjs
CHANGED
|
@@ -93,27 +93,16 @@ function visitNode(node) {
|
|
|
93
93
|
* @returns The content with the transformers replace.
|
|
94
94
|
*/
|
|
95
95
|
function manual(content) {
|
|
96
|
-
if (content.includes("nameof")) {
|
|
96
|
+
if (typeof content === "string" && content.includes("nameof")) {
|
|
97
97
|
// Remove the import
|
|
98
98
|
content = content.replace(/import.*from "@twin\.org\/nameof";/g, "");
|
|
99
99
|
// Replace the nameof<IMyObject>() with "IMyObject"
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
matchName = nameRegEx.exec(content);
|
|
104
|
-
if (matchName && matchName.length === 2) {
|
|
105
|
-
content = content.replace(matchName[0], `"${matchName[1].replace(/\?/g, "")}"`);
|
|
106
|
-
}
|
|
107
|
-
} while (matchName);
|
|
100
|
+
// or the nameof<IMyObject<IType2>>() with "IMyObject"
|
|
101
|
+
const nameRegEx = /nameof<(.*?)(?:<.*>)?>\(\)/g;
|
|
102
|
+
content = content.replace(nameRegEx, '"$1"');
|
|
108
103
|
// Replace the nameof(object?.prop) with "object.prop"
|
|
109
104
|
const propRegEx = /nameof\((.*?)\)/g;
|
|
110
|
-
|
|
111
|
-
do {
|
|
112
|
-
matchProp = propRegEx.exec(content);
|
|
113
|
-
if (matchProp && matchProp.length === 2) {
|
|
114
|
-
content = content.replace(matchProp[0], `"${matchProp[1].replace(/\?/g, "")}"`);
|
|
115
|
-
}
|
|
116
|
-
} while (matchProp);
|
|
105
|
+
content = content.replace(propRegEx, '"$1"');
|
|
117
106
|
}
|
|
118
107
|
return content;
|
|
119
108
|
}
|
|
@@ -150,7 +139,7 @@ const factory = () => transformerFactory;
|
|
|
150
139
|
* Exports the factory version.
|
|
151
140
|
* @returns The factory.
|
|
152
141
|
*/
|
|
153
|
-
const version = "0.0.1
|
|
142
|
+
const version = "0.0.1"; // x-release-please-version
|
|
154
143
|
/**
|
|
155
144
|
* Exports the factory name.
|
|
156
145
|
* @returns The factory.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type * as ts from "typescript";
|
|
2
|
+
/**
|
|
3
|
+
* Exports the factory.
|
|
4
|
+
* @returns The factory.
|
|
5
|
+
*/
|
|
6
|
+
export declare const factory: () => ts.TransformerFactory<ts.Node>;
|
|
7
|
+
/**
|
|
8
|
+
* Exports the factory version.
|
|
9
|
+
* @returns The factory.
|
|
10
|
+
*/
|
|
11
|
+
export declare const version = "0.0.1";
|
|
12
|
+
/**
|
|
13
|
+
* Exports the factory name.
|
|
14
|
+
* @returns The factory.
|
|
15
|
+
*/
|
|
16
|
+
export declare const name = "@twin.org/nameof-transformer";
|
|
17
|
+
export * from "./manual";
|
|
18
|
+
export * from "./svelte";
|
|
19
|
+
export default factory;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as ts from "typescript";
|
|
2
|
+
/**
|
|
3
|
+
* The transformer factory entry point.
|
|
4
|
+
* @param context The context for the factory.
|
|
5
|
+
* @returns The transformed node.
|
|
6
|
+
*/
|
|
7
|
+
export declare const transformerFactory: ts.TransformerFactory<ts.Node>;
|
|
8
|
+
/**
|
|
9
|
+
* Transform all the nodes in a context.
|
|
10
|
+
* @param context The context to traverse.
|
|
11
|
+
* @returns A transformer for the context.
|
|
12
|
+
*/
|
|
13
|
+
export declare function transformer(context: ts.TransformationContext): ts.Transformer<ts.Node>;
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,115 @@
|
|
|
1
1
|
# @twin.org/nameof-transformer - Changelog
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 0.0.1 (2025-07-03)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* release to production ([829d53d](https://github.com/twinfoundation/framework/commit/829d53d3953b1e1b40b0243c04cfdfd3842aac7b))
|
|
9
|
+
* release to production ([5cf3a76](https://github.com/twinfoundation/framework/commit/5cf3a76a09eff2e6414d0cba846c7c37400a11d6))
|
|
10
|
+
|
|
11
|
+
## [0.0.1-next.70](https://github.com/twinfoundation/framework/compare/nameof-transformer-v0.0.1-next.69...nameof-transformer-v0.0.1-next.70) (2025-07-02)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* relocate core packages from tools ([bcab8f3](https://github.com/twinfoundation/framework/commit/bcab8f3160442ea4fcaf442947462504f3d6a17d))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
* repo urls in package.json for moved packages ([31ae463](https://github.com/twinfoundation/framework/commit/31ae463095dfa8c0e48bb5bb12316f1e8abb9a4c))
|
|
22
|
+
|
|
23
|
+
## [0.0.1-next.69](https://github.com/twinfoundation/framework/compare/nameof-transformer-v0.0.1-next.68...nameof-transformer-v0.0.1-next.69) (2025-07-02)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Features
|
|
27
|
+
|
|
28
|
+
* relocate core packages from tools ([bcab8f3](https://github.com/twinfoundation/framework/commit/bcab8f3160442ea4fcaf442947462504f3d6a17d))
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Bug Fixes
|
|
32
|
+
|
|
33
|
+
* repo urls in package.json for moved packages ([31ae463](https://github.com/twinfoundation/framework/commit/31ae463095dfa8c0e48bb5bb12316f1e8abb9a4c))
|
|
34
|
+
|
|
35
|
+
## [0.0.1-next.68](https://github.com/twinfoundation/framework/compare/nameof-transformer-v0.0.1-next.67...nameof-transformer-v0.0.1-next.68) (2025-07-02)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
### Features
|
|
39
|
+
|
|
40
|
+
* relocate core packages from tools ([bcab8f3](https://github.com/twinfoundation/framework/commit/bcab8f3160442ea4fcaf442947462504f3d6a17d))
|
|
41
|
+
|
|
42
|
+
## [0.0.1-next.28](https://github.com/twinfoundation/tools/compare/nameof-transformer-v0.0.1-next.27...nameof-transformer-v0.0.1-next.28) (2025-06-18)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
### Miscellaneous Chores
|
|
46
|
+
|
|
47
|
+
* **nameof-transformer:** Synchronize repo versions
|
|
48
|
+
|
|
49
|
+
## [0.0.1-next.27](https://github.com/twinfoundation/tools/compare/nameof-transformer-v0.0.1-next.26...nameof-transformer-v0.0.1-next.27) (2025-06-17)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
### Features
|
|
53
|
+
|
|
54
|
+
* add latest json schema features ([494293f](https://github.com/twinfoundation/tools/commit/494293f4252b9c7d4a20790ec157fc9d8c96c3d2))
|
|
55
|
+
|
|
56
|
+
## [0.0.1-next.26](https://github.com/twinfoundation/tools/compare/nameof-transformer-v0.0.1-next.25...nameof-transformer-v0.0.1-next.26) (2025-06-11)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
### Features
|
|
60
|
+
|
|
61
|
+
* use most recent JSON schema specs ([4598cbf](https://github.com/twinfoundation/tools/commit/4598cbf29f7b82dba4a9f3b19f81dfe66f5a6060))
|
|
62
|
+
|
|
63
|
+
## [0.0.1-next.25](https://github.com/twinfoundation/tools/compare/nameof-transformer-v0.0.1-next.24...nameof-transformer-v0.0.1-next.25) (2025-06-10)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
### Features
|
|
67
|
+
|
|
68
|
+
* add ts-to-schema overrides ([3c54504](https://github.com/twinfoundation/tools/commit/3c5450468eb998204a75576b7791a7ca4027da62))
|
|
69
|
+
|
|
70
|
+
## [0.0.1-next.24](https://github.com/twinfoundation/tools/compare/nameof-transformer-v0.0.1-next.23...nameof-transformer-v0.0.1-next.24) (2025-06-05)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
### Miscellaneous Chores
|
|
74
|
+
|
|
75
|
+
* **nameof-transformer:** Synchronize repo versions
|
|
76
|
+
|
|
77
|
+
## [0.0.1-next.23](https://github.com/twinfoundation/tools/compare/nameof-transformer-v0.0.1-next.22...nameof-transformer-v0.0.1-next.23) (2025-06-03)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
### Miscellaneous Chores
|
|
81
|
+
|
|
82
|
+
* **nameof-transformer:** Synchronize repo versions
|
|
83
|
+
|
|
84
|
+
## [0.0.1-next.22](https://github.com/twinfoundation/tools/compare/nameof-transformer-v0.0.1-next.21...nameof-transformer-v0.0.1-next.22) (2025-06-03)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
### Miscellaneous Chores
|
|
88
|
+
|
|
89
|
+
* **nameof-transformer:** Synchronize repo versions
|
|
90
|
+
|
|
91
|
+
## [0.0.1-next.21](https://github.com/twinfoundation/tools/compare/nameof-transformer-v0.0.1-next.20...nameof-transformer-v0.0.1-next.21) (2025-04-17)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
### Features
|
|
95
|
+
|
|
96
|
+
* use shared store mechanism ([#31](https://github.com/twinfoundation/tools/issues/31)) ([d9fe68b](https://github.com/twinfoundation/tools/commit/d9fe68b903d1268c7cb3c64772df5cb78fd63667))
|
|
97
|
+
|
|
98
|
+
## [0.0.1-next.20](https://github.com/twinfoundation/tools/compare/nameof-transformer-v0.0.1-next.19...nameof-transformer-v0.0.1-next.20) (2025-03-28)
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
### Features
|
|
102
|
+
|
|
103
|
+
* add version type ([#27](https://github.com/twinfoundation/tools/issues/27)) ([058d4b0](https://github.com/twinfoundation/tools/commit/058d4b0ba9201ea2803e59f25e741788ceb1063f))
|
|
104
|
+
* automation workflows ([#29](https://github.com/twinfoundation/tools/issues/29)) ([02fa98f](https://github.com/twinfoundation/tools/commit/02fa98f534d6e5fcfe59eefc2ff0e20bffd9c0f7))
|
|
105
|
+
|
|
106
|
+
## [0.0.1-next.19](https://github.com/twinfoundation/tools/compare/nameof-transformer-v0.0.1-next.18...nameof-transformer-v0.0.1-next.19) (2025-03-26)
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
### Features
|
|
110
|
+
|
|
111
|
+
* add version type ([#27](https://github.com/twinfoundation/tools/issues/27)) ([058d4b0](https://github.com/twinfoundation/tools/commit/058d4b0ba9201ea2803e59f25e741788ceb1063f))
|
|
112
|
+
|
|
113
|
+
## v0.0.1-next.18
|
|
4
114
|
|
|
5
115
|
- Initial Release
|
package/docs/reference/index.md
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
# @twin.org/nameof-transformer
|
|
2
2
|
|
|
3
|
-
## References
|
|
4
|
-
|
|
5
|
-
### default
|
|
6
|
-
|
|
7
|
-
Renames and re-exports [factory](functions/factory.md)
|
|
8
|
-
|
|
9
3
|
## Variables
|
|
10
4
|
|
|
11
5
|
- [version](variables/version.md)
|
|
@@ -16,3 +10,9 @@ Renames and re-exports [factory](functions/factory.md)
|
|
|
16
10
|
- [factory](functions/factory.md)
|
|
17
11
|
- [manual](functions/manual.md)
|
|
18
12
|
- [tsTransformersPreProcess](functions/tsTransformersPreProcess.md)
|
|
13
|
+
|
|
14
|
+
## References
|
|
15
|
+
|
|
16
|
+
### default
|
|
17
|
+
|
|
18
|
+
Renames and re-exports [factory](functions/factory.md)
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/nameof-transformer",
|
|
3
|
-
"version": "0.0.1
|
|
3
|
+
"version": "0.0.1",
|
|
4
4
|
"description": "A TypeScript transformer which converts types and properties to their actual name for use at runtime",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "git+https://github.com/twinfoundation/
|
|
7
|
+
"url": "git+https://github.com/twinfoundation/framework.git",
|
|
8
8
|
"directory": "packages/nameof-transformer"
|
|
9
9
|
},
|
|
10
10
|
"author": "martyn.janes@iota.org",
|
|
@@ -14,12 +14,13 @@
|
|
|
14
14
|
"node": ">=20.0.0"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"typescript": "5.
|
|
17
|
+
"typescript": "5.8.3"
|
|
18
18
|
},
|
|
19
19
|
"main": "./dist/cjs/index.cjs",
|
|
20
20
|
"module": "./dist/esm/index.mjs",
|
|
21
21
|
"exports": {
|
|
22
22
|
".": {
|
|
23
|
+
"types": "./dist/types/index.d.ts",
|
|
23
24
|
"require": "./dist/cjs/index.cjs",
|
|
24
25
|
"import": "./dist/esm/index.mjs"
|
|
25
26
|
}
|