@twin.org/nameof-transformer 0.0.1-next.2 → 0.0.1-next.20

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.
@@ -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
- const nameRegEx = /nameof<(.*?)>\(\)/g;
124
- let matchName;
125
- do {
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
- let matchProp;
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-next.2";
165
+ const version = "0.0.1-next.20"; // x-release-please-version
177
166
  /**
178
167
  * Exports the factory name.
179
168
  * @returns The factory.
@@ -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
- const nameRegEx = /nameof<(.*?)>\(\)/g;
101
- let matchName;
102
- do {
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
- let matchProp;
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-next.2";
142
+ const version = "0.0.1-next.20"; // 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-next.20";
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,6 @@
1
+ /**
2
+ * Replace the transformers manually.
3
+ * @param content The content to replace the transformers in.
4
+ * @returns The content with the transformers replace.
5
+ */
6
+ export declare function manual(content: string): string;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Return a function that can be used as a svelte preprocessor.
3
+ * @returns The preprocessor.
4
+ */
5
+ export declare function tsTransformersPreProcess(): {
6
+ markup: unknown;
7
+ };
@@ -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,20 @@
1
1
  # @twin.org/nameof-transformer - Changelog
2
2
 
3
- ## v0.0.1-next.2
3
+ ## [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)
4
+
5
+
6
+ ### Features
7
+
8
+ * add version type ([#27](https://github.com/twinfoundation/tools/issues/27)) ([058d4b0](https://github.com/twinfoundation/tools/commit/058d4b0ba9201ea2803e59f25e741788ceb1063f))
9
+ * automation workflows ([#29](https://github.com/twinfoundation/tools/issues/29)) ([02fa98f](https://github.com/twinfoundation/tools/commit/02fa98f534d6e5fcfe59eefc2ff0e20bffd9c0f7))
10
+
11
+ ## [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)
12
+
13
+
14
+ ### Features
15
+
16
+ * add version type ([#27](https://github.com/twinfoundation/tools/issues/27)) ([058d4b0](https://github.com/twinfoundation/tools/commit/058d4b0ba9201ea2803e59f25e741788ceb1063f))
17
+
18
+ ## v0.0.1-next.18
4
19
 
5
20
  - Initial Release
@@ -17,7 +17,7 @@ Modify your build script in `package.json`
17
17
  ```shell
18
18
  {
19
19
  "scripts": {
20
- "compile": "tspc"
20
+ "prepare": "ts-patch install -s"
21
21
  }
22
22
  }
23
23
  ```
@@ -6,7 +6,9 @@ Replace the transformers manually.
6
6
 
7
7
  ## Parameters
8
8
 
9
- **content**: `string`
9
+ ### content
10
+
11
+ `string`
10
12
 
11
13
  The content to replace the transformers in.
12
14
 
@@ -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)
@@ -3,3 +3,7 @@
3
3
  > `const` **name**: `"@twin.org/nameof-transformer"` = `"@twin.org/nameof-transformer"`
4
4
 
5
5
  Exports the factory name.
6
+
7
+ ## Returns
8
+
9
+ The factory.
@@ -1,5 +1,9 @@
1
1
  # Variable: version
2
2
 
3
- > `const` **version**: `"0.0.1-next.2"` = `"0.0.1-next.2"`
3
+ > `const` **version**: `"0.0.1-next.20"` = `"0.0.1-next.20"`
4
4
 
5
5
  Exports the factory version.
6
+
7
+ ## Returns
8
+
9
+ The factory.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/nameof-transformer",
3
- "version": "0.0.1-next.2",
3
+ "version": "0.0.1-next.20",
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",
@@ -13,37 +13,14 @@
13
13
  "engines": {
14
14
  "node": ">=20.0.0"
15
15
  },
16
- "scripts": {
17
- "clean": "rimraf dist coverage",
18
- "build": "tsc",
19
- "test": "vitest --run --config ./vitest.config.ts --no-cache",
20
- "coverage": "vitest --run --coverage --config ./vitest.config.ts --no-cache",
21
- "bundle:esm": "rollup --config rollup.config.mjs --environment MODULE:esm",
22
- "bundle:cjs": "rollup --config rollup.config.mjs --environment MODULE:cjs",
23
- "bundle": "npm run bundle:esm && npm run bundle:cjs",
24
- "docs:clean": "rimraf docs/reference",
25
- "docs:generate": "typedoc",
26
- "docs": "npm run docs:clean && npm run docs:generate",
27
- "dist": "npm run clean && npm run build && npm run test && npm run bundle && npm run docs"
28
- },
29
16
  "dependencies": {
30
- "typescript": "5.6.2"
31
- },
32
- "devDependencies": {
33
- "@vitest/coverage-v8": "2.1.1",
34
- "copyfiles": "2.4.1",
35
- "rimraf": "6.0.1",
36
- "rollup": "4.21.3",
37
- "rollup-plugin-typescript2": "0.36.0",
38
- "typedoc": "0.26.7",
39
- "typedoc-plugin-markdown": "4.2.7",
40
- "typescript": "5.6.2",
41
- "vitest": "2.1.1"
17
+ "typescript": "5.8.2"
42
18
  },
43
19
  "main": "./dist/cjs/index.cjs",
44
20
  "module": "./dist/esm/index.mjs",
45
21
  "exports": {
46
22
  ".": {
23
+ "types": "./dist/types/index.d.ts",
47
24
  "require": "./dist/cjs/index.cjs",
48
25
  "import": "./dist/esm/index.mjs"
49
26
  }