@twin.org/nameof-transformer 0.0.1-next.11 → 0.0.1-next.12
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 +4 -3
- package/dist/esm/index.mjs +4 -3
- 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 +1 -1
- package/docs/reference/variables/version.md +1 -1
- package/package.json +3 -2
package/dist/cjs/index.cjs
CHANGED
|
@@ -116,11 +116,12 @@ 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
|
-
|
|
123
|
+
// or the nameof<IMyObject<IType2>>() with "IMyObject"
|
|
124
|
+
const nameRegEx = /nameof<(.*?)(?:<.*>)?>\(\)/g;
|
|
124
125
|
let matchName;
|
|
125
126
|
do {
|
|
126
127
|
matchName = nameRegEx.exec(content);
|
|
@@ -173,7 +174,7 @@ const factory = () => transformerFactory;
|
|
|
173
174
|
* Exports the factory version.
|
|
174
175
|
* @returns The factory.
|
|
175
176
|
*/
|
|
176
|
-
const version = "0.0.1-next.
|
|
177
|
+
const version = "0.0.1-next.12";
|
|
177
178
|
/**
|
|
178
179
|
* Exports the factory name.
|
|
179
180
|
* @returns The factory.
|
package/dist/esm/index.mjs
CHANGED
|
@@ -93,11 +93,12 @@ 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
|
-
|
|
100
|
+
// or the nameof<IMyObject<IType2>>() with "IMyObject"
|
|
101
|
+
const nameRegEx = /nameof<(.*?)(?:<.*>)?>\(\)/g;
|
|
101
102
|
let matchName;
|
|
102
103
|
do {
|
|
103
104
|
matchName = nameRegEx.exec(content);
|
|
@@ -150,7 +151,7 @@ const factory = () => transformerFactory;
|
|
|
150
151
|
* Exports the factory version.
|
|
151
152
|
* @returns The factory.
|
|
152
153
|
*/
|
|
153
|
-
const version = "0.0.1-next.
|
|
154
|
+
const version = "0.0.1-next.12";
|
|
154
155
|
/**
|
|
155
156
|
* Exports the factory name.
|
|
156
157
|
* @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-next.12";
|
|
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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/nameof-transformer",
|
|
3
|
-
"version": "0.0.1-next.
|
|
3
|
+
"version": "0.0.1-next.12",
|
|
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",
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
"exports": {
|
|
22
22
|
".": {
|
|
23
23
|
"require": "./dist/cjs/index.cjs",
|
|
24
|
-
"import": "./dist/esm/index.mjs"
|
|
24
|
+
"import": "./dist/esm/index.mjs",
|
|
25
|
+
"types": "./dist/types/index.d.ts"
|
|
25
26
|
}
|
|
26
27
|
},
|
|
27
28
|
"files": [
|