@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.
@@ -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
- const nameRegEx = /nameof<(.*?)>\(\)/g;
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.11";
177
+ const version = "0.0.1-next.12";
177
178
  /**
178
179
  * Exports the factory name.
179
180
  * @returns The factory.
@@ -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
- const nameRegEx = /nameof<(.*?)>\(\)/g;
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.11";
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,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,5 @@
1
1
  # @twin.org/nameof-transformer - Changelog
2
2
 
3
- ## v0.0.1-next.11
3
+ ## v0.0.1-next.12
4
4
 
5
5
  - Initial Release
@@ -1,6 +1,6 @@
1
1
  # Variable: version
2
2
 
3
- > `const` **version**: `"0.0.1-next.11"` = `"0.0.1-next.11"`
3
+ > `const` **version**: `"0.0.1-next.12"` = `"0.0.1-next.12"`
4
4
 
5
5
  Exports the factory version.
6
6
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/nameof-transformer",
3
- "version": "0.0.1-next.11",
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": [