@rushstack/typings-generator 0.12.10 → 0.12.11

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/LICENSE CHANGED
@@ -1,24 +1,24 @@
1
- @rushstack/typings-generator
2
-
3
- Copyright (c) Microsoft Corporation. All rights reserved.
4
-
5
- MIT License
6
-
7
- Permission is hereby granted, free of charge, to any person obtaining
8
- a copy of this software and associated documentation files (the
9
- "Software"), to deal in the Software without restriction, including
10
- without limitation the rights to use, copy, modify, merge, publish,
11
- distribute, sublicense, and/or sell copies of the Software, and to
12
- permit persons to whom the Software is furnished to do so, subject to
13
- the following conditions:
14
-
15
- The above copyright notice and this permission notice shall be
16
- included in all copies or substantial portions of the Software.
17
-
18
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ @rushstack/typings-generator
2
+
3
+ Copyright (c) Microsoft Corporation. All rights reserved.
4
+
5
+ MIT License
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining
8
+ a copy of this software and associated documentation files (the
9
+ "Software"), to deal in the Software without restriction, including
10
+ without limitation the rights to use, copy, modify, merge, publish,
11
+ distribute, sublicense, and/or sell copies of the Software, and to
12
+ permit persons to whom the Software is furnished to do so, subject to
13
+ the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be
16
+ included in all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,163 +1,163 @@
1
- # @rushstack/typings-generator
2
-
3
- ## Installation
4
-
5
- `npm install @rushstack/typings-generator --save-dev`
6
-
7
- ## Overview
8
-
9
- This is a utility for generating typings for non-TS files. It can operate in either a single-run mode or
10
- a watch mode. It is designed to generate `.d.ts` files with a specified generation function for all files matching
11
- specified file extensions, with an option to ignore individual files.
12
-
13
- ## Usage
14
-
15
- ```TypeScript
16
- import { TypingsGenerator } from '@rushstack/typings-generator';
17
-
18
- const typingsGenerator: TypingsGenerator = new TypingsGenerator({
19
- srcFolder: '/repo/package/src',
20
- generatedTsFolder: '/repo/package/temp/generated-typings',
21
- fileExtensions: ['file-extension'],
22
- parseAndGenerateTypings: (fileContents: string, filePath: string) => {
23
- const parsedFile = parseFile(fileContents);
24
- const typings: string = generateTypings(parsedFile);
25
- return typings;
26
- }
27
- });
28
-
29
- // To run once before a compilation:
30
- await typingsGenerator.generateTypings();
31
-
32
- // To start a watcher:
33
- await typingsGenerator.runWatcher();
34
- ```
35
-
36
- ```TypeScript
37
- import { TypingsGenerator } from '@rushstack/typings-generator';
38
-
39
- const assetTypingsGenerator: TypingsGenerator = new TypingsGenerator({
40
- srcFolder: '/repo/package/src',
41
- generatedTsFolder: '/repo/package/temp/generated-typings',
42
- fileExtensions: ['.jpg'],
43
- parseAndGenerateTypings: (fileContents: false, filePath: string) => {
44
- const parsedFile = parseFile(fileContents);
45
- const typings: string = 'declare const path: string;\nexport default path;';
46
- return typings;
47
- },
48
- // Don't read files at all
49
- readFile: (filePath: string, relativePath: string) => false
50
- });
51
-
52
- // To run once before a compilation:
53
- await typingsGenerator.generateTypings();
54
-
55
- // To start a watcher:
56
- await typingsGenerator.runWatcher();
57
- ```
58
-
59
- ## Options
60
-
61
- ### `srcFolder = '...'`
62
-
63
- This property is used as the source root folder for discovery of files for which typings should be generated.
64
-
65
- ### `generatedTsFolder = '...'`
66
-
67
- This property specifies the folder in which `.d.ts` files should be dropped. It is recommended
68
- that this be a folder parallel to the source folder, specified in addition to the source folder in the
69
- [`rootDirs` `tsconfig.json` option](https://www.typescriptlang.org/docs/handbook/compiler-options.html).
70
- **The folder specified by this option is emptied when the utility is invoked.**
71
-
72
- ### `fileExtensions = [...]`
73
-
74
- This property enumerates the file extensions that should be handled.
75
-
76
- ### `parseAndGenerateTypings = (fileContents: TFileContents, filePath: string, relativePath: string) => string | Promise<string>`
77
-
78
- This property is used to specify the function that should be called on every file for which typings
79
- are being generated. In watch mode, this is called on every file creation and file update. It should
80
- return TypeScript declarations for the file it is called with.
81
-
82
- ### `readFile = (filePath: string, relativePath: string) => TFileContents | Promise<TFileContents>`
83
-
84
- This property allows customizing the process by which files are read from the specified paths.
85
- Use cases include:
86
- - Disabling reads altogether, if the typings don't depend on file content
87
- - Reading from an alternate data source
88
- - Reading files with a different encoding than 'utf-8'
89
-
90
- ### `terminal`
91
-
92
- Optionally provide a [Terminal](https://github.com/microsoft/rushstack/blob/main/libraries/node-core-library/src/Terminal/Terminal.ts)
93
- object for logging. If one isn't provided, logs will go to the console.
94
-
95
- ### `globsToIgnore`
96
-
97
- Optionally, provide an array of globs matching files that should be ignored. These globs are evaluated
98
- under [`srcFolder`](#srcFolder--)
99
-
100
- ## `StringValuesTypingsGenerator`
101
-
102
- There is an extension of this utility specifically for file types where typings should be a simple
103
- set of exported string values. This is useful for file types like CSS and RESX. This class takes
104
- the same options as the standard `TypingsGenerator`, with one additional option ([`exportAsDefault`](#exportAsDefault--)) and a different return value for `parseAndGenerateTypings`.
105
-
106
- ### `parseAndGenerateTypings = (fileContents: string, filePath: string) => { typings: ({ exportName: string, comment?: string })[] } | Promise<{ typings: ({ exportName: string, comment?: string })[] }>`
107
-
108
- This function should behave the same as the `parseAndGenerateTypings` function for the standard
109
- `TypingsGenerator`, except that it should return an object with a `typings` property, set to
110
- an array of objects with an `exportName` property and an optional `comment` property.
111
- See the example below.
112
-
113
- #### Example return value:
114
-
115
- ```TypeScript
116
- {
117
- typings: [
118
- {
119
- exportName: 'myExport'
120
- },
121
- {
122
- exportName: 'myOtherExport',
123
- comment: 'This is the other export'
124
- }
125
- ]
126
- }
127
- ```
128
-
129
- #### Example generated declaration file:
130
-
131
- ```TypeScript
132
- // This file was generated by a tool. Modifying it will produce unexpected behavior
133
-
134
- export declare const myExport: string;
135
-
136
- /**
137
- * This is the other export
138
- */
139
- export declare const myOtherExport: string;
140
-
141
- ```
142
-
143
- ### `exportAsDefault = true | false`
144
-
145
- If this option is set to `true`, the typings will be exported wrapped in a `default` property. This
146
- allows the file to be imported by using the `import myFile from './myFile.my-extension';` syntax instead of
147
- the `import { myExport } from './myFile.my-extension';` or the `import * as myFile from './myFile.my-extension';`
148
- syntax. This style of export is not recommended as it can prevent tree-shaking optimization.
149
-
150
- ### `exportAsDefaultInterfaceName = true | false`
151
-
152
- When `exportAsDefault` is true, this optional setting determines the interface name
153
- for the default wrapped export. For example, in the Sass Typings plugin, the interface name
154
- is set to `IExportStyles`. If not specified, the interface name will be `IExport`.
155
- (This setting is ignored when `exportAsDefault` is false).
156
-
157
- ## Links
158
-
159
- - [CHANGELOG.md](https://github.com/microsoft/rushstack/blob/main/libraries/typings-generator/CHANGELOG.md) - Find
160
- out what's new in the latest version
161
- - [API Reference](https://rushstack.io/pages/api/typings-generator/)
162
-
163
- `@rushstack/typings-generator` is part of the [Rush Stack](https://rushstack.io/) family of projects.
1
+ # @rushstack/typings-generator
2
+
3
+ ## Installation
4
+
5
+ `npm install @rushstack/typings-generator --save-dev`
6
+
7
+ ## Overview
8
+
9
+ This is a utility for generating typings for non-TS files. It can operate in either a single-run mode or
10
+ a watch mode. It is designed to generate `.d.ts` files with a specified generation function for all files matching
11
+ specified file extensions, with an option to ignore individual files.
12
+
13
+ ## Usage
14
+
15
+ ```TypeScript
16
+ import { TypingsGenerator } from '@rushstack/typings-generator';
17
+
18
+ const typingsGenerator: TypingsGenerator = new TypingsGenerator({
19
+ srcFolder: '/repo/package/src',
20
+ generatedTsFolder: '/repo/package/temp/generated-typings',
21
+ fileExtensions: ['file-extension'],
22
+ parseAndGenerateTypings: (fileContents: string, filePath: string) => {
23
+ const parsedFile = parseFile(fileContents);
24
+ const typings: string = generateTypings(parsedFile);
25
+ return typings;
26
+ }
27
+ });
28
+
29
+ // To run once before a compilation:
30
+ await typingsGenerator.generateTypings();
31
+
32
+ // To start a watcher:
33
+ await typingsGenerator.runWatcher();
34
+ ```
35
+
36
+ ```TypeScript
37
+ import { TypingsGenerator } from '@rushstack/typings-generator';
38
+
39
+ const assetTypingsGenerator: TypingsGenerator = new TypingsGenerator({
40
+ srcFolder: '/repo/package/src',
41
+ generatedTsFolder: '/repo/package/temp/generated-typings',
42
+ fileExtensions: ['.jpg'],
43
+ parseAndGenerateTypings: (fileContents: false, filePath: string) => {
44
+ const parsedFile = parseFile(fileContents);
45
+ const typings: string = 'declare const path: string;\nexport default path;';
46
+ return typings;
47
+ },
48
+ // Don't read files at all
49
+ readFile: (filePath: string, relativePath: string) => false
50
+ });
51
+
52
+ // To run once before a compilation:
53
+ await typingsGenerator.generateTypings();
54
+
55
+ // To start a watcher:
56
+ await typingsGenerator.runWatcher();
57
+ ```
58
+
59
+ ## Options
60
+
61
+ ### `srcFolder = '...'`
62
+
63
+ This property is used as the source root folder for discovery of files for which typings should be generated.
64
+
65
+ ### `generatedTsFolder = '...'`
66
+
67
+ This property specifies the folder in which `.d.ts` files should be dropped. It is recommended
68
+ that this be a folder parallel to the source folder, specified in addition to the source folder in the
69
+ [`rootDirs` `tsconfig.json` option](https://www.typescriptlang.org/docs/handbook/compiler-options.html).
70
+ **The folder specified by this option is emptied when the utility is invoked.**
71
+
72
+ ### `fileExtensions = [...]`
73
+
74
+ This property enumerates the file extensions that should be handled.
75
+
76
+ ### `parseAndGenerateTypings = (fileContents: TFileContents, filePath: string, relativePath: string) => string | Promise<string>`
77
+
78
+ This property is used to specify the function that should be called on every file for which typings
79
+ are being generated. In watch mode, this is called on every file creation and file update. It should
80
+ return TypeScript declarations for the file it is called with.
81
+
82
+ ### `readFile = (filePath: string, relativePath: string) => TFileContents | Promise<TFileContents>`
83
+
84
+ This property allows customizing the process by which files are read from the specified paths.
85
+ Use cases include:
86
+ - Disabling reads altogether, if the typings don't depend on file content
87
+ - Reading from an alternate data source
88
+ - Reading files with a different encoding than 'utf-8'
89
+
90
+ ### `terminal`
91
+
92
+ Optionally provide a [Terminal](https://github.com/microsoft/rushstack/blob/main/libraries/node-core-library/src/Terminal/Terminal.ts)
93
+ object for logging. If one isn't provided, logs will go to the console.
94
+
95
+ ### `globsToIgnore`
96
+
97
+ Optionally, provide an array of globs matching files that should be ignored. These globs are evaluated
98
+ under [`srcFolder`](#srcFolder--)
99
+
100
+ ## `StringValuesTypingsGenerator`
101
+
102
+ There is an extension of this utility specifically for file types where typings should be a simple
103
+ set of exported string values. This is useful for file types like CSS and RESX. This class takes
104
+ the same options as the standard `TypingsGenerator`, with one additional option ([`exportAsDefault`](#exportAsDefault--)) and a different return value for `parseAndGenerateTypings`.
105
+
106
+ ### `parseAndGenerateTypings = (fileContents: string, filePath: string) => { typings: ({ exportName: string, comment?: string })[] } | Promise<{ typings: ({ exportName: string, comment?: string })[] }>`
107
+
108
+ This function should behave the same as the `parseAndGenerateTypings` function for the standard
109
+ `TypingsGenerator`, except that it should return an object with a `typings` property, set to
110
+ an array of objects with an `exportName` property and an optional `comment` property.
111
+ See the example below.
112
+
113
+ #### Example return value:
114
+
115
+ ```TypeScript
116
+ {
117
+ typings: [
118
+ {
119
+ exportName: 'myExport'
120
+ },
121
+ {
122
+ exportName: 'myOtherExport',
123
+ comment: 'This is the other export'
124
+ }
125
+ ]
126
+ }
127
+ ```
128
+
129
+ #### Example generated declaration file:
130
+
131
+ ```TypeScript
132
+ // This file was generated by a tool. Modifying it will produce unexpected behavior
133
+
134
+ export declare const myExport: string;
135
+
136
+ /**
137
+ * This is the other export
138
+ */
139
+ export declare const myOtherExport: string;
140
+
141
+ ```
142
+
143
+ ### `exportAsDefault = true | false`
144
+
145
+ If this option is set to `true`, the typings will be exported wrapped in a `default` property. This
146
+ allows the file to be imported by using the `import myFile from './myFile.my-extension';` syntax instead of
147
+ the `import { myExport } from './myFile.my-extension';` or the `import * as myFile from './myFile.my-extension';`
148
+ syntax. This style of export is not recommended as it can prevent tree-shaking optimization.
149
+
150
+ ### `exportAsDefaultInterfaceName = true | false`
151
+
152
+ When `exportAsDefault` is true, this optional setting determines the interface name
153
+ for the default wrapped export. For example, in the Sass Typings plugin, the interface name
154
+ is set to `IExportStyles`. If not specified, the interface name will be `IExport`.
155
+ (This setting is ignored when `exportAsDefault` is false).
156
+
157
+ ## Links
158
+
159
+ - [CHANGELOG.md](https://github.com/microsoft/rushstack/blob/main/libraries/typings-generator/CHANGELOG.md) - Find
160
+ out what's new in the latest version
161
+ - [API Reference](https://rushstack.io/pages/api/typings-generator/)
162
+
163
+ `@rushstack/typings-generator` is part of the [Rush Stack](https://rushstack.io/) family of projects.
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.38.0"
8
+ "packageVersion": "7.38.1"
9
9
  }
10
10
  ]
11
11
  }
@@ -1 +1 @@
1
- {"version":3,"file":"StringValuesTypingsGenerator.js","sourceRoot":"","sources":["../src/StringValuesTypingsGenerator.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DA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ACrE;SACF;QAED,IAAI,OAAO,CAAC,eAAe,EAAE;YAC3B,WAAW,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,EAAE,0BAA0B,aAAa,GAAG,EAAE,EAAE,EAAE,yBAAyB,CAAC,CAAC;SACtG;QAED,OAAO,WAAW,CAAC,IAAI,CAAC,QAAG,CAAC,CAAC;IAC/B,CAAC;IAED,MAAM,gBAAgB,mCACjB,OAAO,KACV,uBAAuB,GACxB,CAAC;IAEF,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED;;;;;GAKG;AACH,MAAa,4BAAqD,SAAQ,mCAA+B;IAKvG,YAAmB,OAA8E;QAC/F,KAAK,CAAC,gCAAgC,CAAC,OAAO,CAAC,CAAC,CAAC;IACnD,CAAC;CACF;AARD,oEAQC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport { EOL } from 'os';\r\n\r\nimport {\r\n type ITypingsGeneratorOptions,\r\n TypingsGenerator,\r\n type ITypingsGeneratorOptionsWithCustomReadFile\r\n} from './TypingsGenerator';\r\n\r\n/**\r\n * @public\r\n */\r\nexport interface IStringValueTyping {\r\n exportName: string;\r\n comment?: string;\r\n}\r\n\r\n/**\r\n * @public\r\n */\r\nexport interface IStringValueTypings {\r\n typings: IStringValueTyping[];\r\n}\r\n\r\n/**\r\n * @public\r\n */\r\nexport interface IStringValuesTypingsGeneratorBaseOptions {\r\n /**\r\n * Setting this option wraps the typings export in a default property.\r\n */\r\n exportAsDefault?: boolean;\r\n\r\n /**\r\n * When `exportAsDefault` is true, this optional setting determines the interface name\r\n * for the default wrapped export. Ignored when `exportAsDefault` is false.\r\n */\r\n exportAsDefaultInterfaceName?: string;\r\n}\r\n\r\n/**\r\n * @public\r\n */\r\nexport interface IStringValuesTypingsGeneratorOptions<TFileContents extends string = string>\r\n extends ITypingsGeneratorOptions<IStringValueTypings | undefined, TFileContents>,\r\n IStringValuesTypingsGeneratorBaseOptions {\r\n // Nothing added.\r\n}\r\n\r\n/**\r\n * @public\r\n */\r\nexport interface IStringValuesTypingsGeneratorOptionsWithCustomReadFile<TFileContents = string>\r\n extends ITypingsGeneratorOptionsWithCustomReadFile<IStringValueTypings | undefined, TFileContents>,\r\n IStringValuesTypingsGeneratorBaseOptions {\r\n // Nothing added.\r\n}\r\n\r\nconst EXPORT_AS_DEFAULT_INTERFACE_NAME: string = 'IExport';\r\n\r\nfunction convertToTypingsGeneratorOptions<TFileContents>(\r\n options: IStringValuesTypingsGeneratorOptionsWithCustomReadFile<TFileContents>\r\n): ITypingsGeneratorOptionsWithCustomReadFile<string | undefined, TFileContents> {\r\n async function parseAndGenerateTypings(\r\n fileContents: TFileContents,\r\n filePath: string,\r\n relativePath: string\r\n ): Promise<string | undefined> {\r\n const stringValueTypings: IStringValueTypings | undefined = await options.parseAndGenerateTypings(\r\n fileContents,\r\n filePath,\r\n relativePath\r\n );\r\n\r\n if (stringValueTypings === undefined) {\r\n return;\r\n }\r\n\r\n const outputLines: string[] = [];\r\n const interfaceName: string = options.exportAsDefaultInterfaceName\r\n ? options.exportAsDefaultInterfaceName\r\n : EXPORT_AS_DEFAULT_INTERFACE_NAME;\r\n let indent: string = '';\r\n if (options.exportAsDefault) {\r\n outputLines.push(`export interface ${interfaceName} {`);\r\n indent = ' ';\r\n }\r\n\r\n for (const stringValueTyping of stringValueTypings.typings) {\r\n const { exportName, comment } = stringValueTyping;\r\n\r\n if (comment && comment.trim() !== '') {\r\n outputLines.push(`${indent}/**`, `${indent} * ${comment.replace(/\\*\\//g, '*\\\\/')}`, `${indent} */`);\r\n }\r\n\r\n if (options.exportAsDefault) {\r\n outputLines.push(`${indent}'${exportName}': string;`, '');\r\n } else {\r\n outputLines.push(`export declare const ${exportName}: string;`, '');\r\n }\r\n }\r\n\r\n if (options.exportAsDefault) {\r\n outputLines.push('}', '', `declare const strings: ${interfaceName};`, '', 'export default strings;');\r\n }\r\n\r\n return outputLines.join(EOL);\r\n }\r\n\r\n const convertedOptions: ITypingsGeneratorOptionsWithCustomReadFile<string | undefined, TFileContents> = {\r\n ...options,\r\n parseAndGenerateTypings\r\n };\r\n\r\n return convertedOptions;\r\n}\r\n\r\n/**\r\n * This is a simple tool that generates .d.ts files for non-TS files that can be represented as\r\n * a simple set of named string exports.\r\n *\r\n * @public\r\n */\r\nexport class StringValuesTypingsGenerator<TFileContents = string> extends TypingsGenerator<TFileContents> {\r\n public constructor(\r\n options: TFileContents extends string ? IStringValuesTypingsGeneratorOptions<TFileContents> : never\r\n );\r\n public constructor(options: IStringValuesTypingsGeneratorOptionsWithCustomReadFile<TFileContents>);\r\n public constructor(options: IStringValuesTypingsGeneratorOptionsWithCustomReadFile<TFileContents>) {\r\n super(convertToTypingsGeneratorOptions(options));\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"StringValuesTypingsGenerator.js","sourceRoot":"","sources":["../src/StringValuesTypingsGenerator.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,2BAAyB;AAEzB,yDAI4B;AAmD5B,MAAM,gCAAgC,GAAW,SAAS,CAAC;AAE3D,SAAS,gCAAgC,CACvC,OAA8E;IAE9E,KAAK,UAAU,uBAAuB,CACpC,YAA2B,EAC3B,QAAgB,EAChB,YAAoB;QAEpB,MAAM,kBAAkB,GAAoC,MAAM,OAAO,CAAC,uBAAuB,CAC/F,YAAY,EACZ,QAAQ,EACR,YAAY,CACb,CAAC;QAEF,IAAI,kBAAkB,KAAK,SAAS,EAAE;YACpC,OAAO;SACR;QAED,MAAM,WAAW,GAAa,EAAE,CAAC;QACjC,MAAM,aAAa,GAAW,OAAO,CAAC,4BAA4B;YAChE,CAAC,CAAC,OAAO,CAAC,4BAA4B;YACtC,CAAC,CAAC,gCAAgC,CAAC;QACrC,IAAI,MAAM,GAAW,EAAE,CAAC;QACxB,IAAI,OAAO,CAAC,eAAe,EAAE;YAC3B,WAAW,CAAC,IAAI,CAAC,oBAAoB,aAAa,IAAI,CAAC,CAAC;YACxD,MAAM,GAAG,IAAI,CAAC;SACf;QAED,KAAK,MAAM,iBAAiB,IAAI,kBAAkB,CAAC,OAAO,EAAE;YAC1D,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,iBAAiB,CAAC;YAElD,IAAI,OAAO,IAAI,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;gBACpC,WAAW,CAAC,IAAI,CAAC,GAAG,MAAM,KAAK,EAAE,GAAG,MAAM,MAAM,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,EAAE,GAAG,MAAM,KAAK,CAAC,CAAC;aACrG;YAED,IAAI,OAAO,CAAC,eAAe,EAAE;gBAC3B,WAAW,CAAC,IAAI,CAAC,GAAG,MAAM,IAAI,UAAU,YAAY,EAAE,EAAE,CAAC,CAAC;aAC3D;iBAAM;gBACL,WAAW,CAAC,IAAI,CAAC,wBAAwB,UAAU,WAAW,EAAE,EAAE,CAAC,CAAC;aACrE;SACF;QAED,IAAI,OAAO,CAAC,eAAe,EAAE;YAC3B,WAAW,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,EAAE,0BAA0B,aAAa,GAAG,EAAE,EAAE,EAAE,yBAAyB,CAAC,CAAC;SACtG;QAED,OAAO,WAAW,CAAC,IAAI,CAAC,QAAG,CAAC,CAAC;IAC/B,CAAC;IAED,MAAM,gBAAgB,mCACjB,OAAO,KACV,uBAAuB,GACxB,CAAC;IAEF,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED;;;;;GAKG;AACH,MAAa,4BAAqD,SAAQ,mCAA+B;IAKvG,YAAmB,OAA8E;QAC/F,KAAK,CAAC,gCAAgC,CAAC,OAAO,CAAC,CAAC,CAAC;IACnD,CAAC;CACF;AARD,oEAQC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { EOL } from 'os';\n\nimport {\n type ITypingsGeneratorOptions,\n TypingsGenerator,\n type ITypingsGeneratorOptionsWithCustomReadFile\n} from './TypingsGenerator';\n\n/**\n * @public\n */\nexport interface IStringValueTyping {\n exportName: string;\n comment?: string;\n}\n\n/**\n * @public\n */\nexport interface IStringValueTypings {\n typings: IStringValueTyping[];\n}\n\n/**\n * @public\n */\nexport interface IStringValuesTypingsGeneratorBaseOptions {\n /**\n * Setting this option wraps the typings export in a default property.\n */\n exportAsDefault?: boolean;\n\n /**\n * When `exportAsDefault` is true, this optional setting determines the interface name\n * for the default wrapped export. Ignored when `exportAsDefault` is false.\n */\n exportAsDefaultInterfaceName?: string;\n}\n\n/**\n * @public\n */\nexport interface IStringValuesTypingsGeneratorOptions<TFileContents extends string = string>\n extends ITypingsGeneratorOptions<IStringValueTypings | undefined, TFileContents>,\n IStringValuesTypingsGeneratorBaseOptions {\n // Nothing added.\n}\n\n/**\n * @public\n */\nexport interface IStringValuesTypingsGeneratorOptionsWithCustomReadFile<TFileContents = string>\n extends ITypingsGeneratorOptionsWithCustomReadFile<IStringValueTypings | undefined, TFileContents>,\n IStringValuesTypingsGeneratorBaseOptions {\n // Nothing added.\n}\n\nconst EXPORT_AS_DEFAULT_INTERFACE_NAME: string = 'IExport';\n\nfunction convertToTypingsGeneratorOptions<TFileContents>(\n options: IStringValuesTypingsGeneratorOptionsWithCustomReadFile<TFileContents>\n): ITypingsGeneratorOptionsWithCustomReadFile<string | undefined, TFileContents> {\n async function parseAndGenerateTypings(\n fileContents: TFileContents,\n filePath: string,\n relativePath: string\n ): Promise<string | undefined> {\n const stringValueTypings: IStringValueTypings | undefined = await options.parseAndGenerateTypings(\n fileContents,\n filePath,\n relativePath\n );\n\n if (stringValueTypings === undefined) {\n return;\n }\n\n const outputLines: string[] = [];\n const interfaceName: string = options.exportAsDefaultInterfaceName\n ? options.exportAsDefaultInterfaceName\n : EXPORT_AS_DEFAULT_INTERFACE_NAME;\n let indent: string = '';\n if (options.exportAsDefault) {\n outputLines.push(`export interface ${interfaceName} {`);\n indent = ' ';\n }\n\n for (const stringValueTyping of stringValueTypings.typings) {\n const { exportName, comment } = stringValueTyping;\n\n if (comment && comment.trim() !== '') {\n outputLines.push(`${indent}/**`, `${indent} * ${comment.replace(/\\*\\//g, '*\\\\/')}`, `${indent} */`);\n }\n\n if (options.exportAsDefault) {\n outputLines.push(`${indent}'${exportName}': string;`, '');\n } else {\n outputLines.push(`export declare const ${exportName}: string;`, '');\n }\n }\n\n if (options.exportAsDefault) {\n outputLines.push('}', '', `declare const strings: ${interfaceName};`, '', 'export default strings;');\n }\n\n return outputLines.join(EOL);\n }\n\n const convertedOptions: ITypingsGeneratorOptionsWithCustomReadFile<string | undefined, TFileContents> = {\n ...options,\n parseAndGenerateTypings\n };\n\n return convertedOptions;\n}\n\n/**\n * This is a simple tool that generates .d.ts files for non-TS files that can be represented as\n * a simple set of named string exports.\n *\n * @public\n */\nexport class StringValuesTypingsGenerator<TFileContents = string> extends TypingsGenerator<TFileContents> {\n public constructor(\n options: TFileContents extends string ? IStringValuesTypingsGeneratorOptions<TFileContents> : never\n );\n public constructor(options: IStringValuesTypingsGeneratorOptionsWithCustomReadFile<TFileContents>);\n public constructor(options: IStringValuesTypingsGeneratorOptionsWithCustomReadFile<TFileContents>) {\n super(convertToTypingsGeneratorOptions(options));\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"TypingsGenerator.js","sourceRoot":"","sources":["../src/TypingsGenerator.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,oEAQsC;AACtC,0DAA6B;AAC7B,2CAA6B;AAC7B,2BAAyB;AACzB,mDAAqC;AAiErC;;;;GAIG;AACH,MAAa,gBAAgB;IAiC3B,YAAmB,OAAsF;;QACvG,IAAI,CAAC,QAAQ,mCACR,OAAO,KACV,QAAQ,EACN,MAAA,OAAO,CAAC,QAAQ,mCAChB,CAAC,CAAC,QAAgB,EAAE,YAAoB,EAA0B,EAAE,CAClE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AAC,CAAC;IAC5B,CAAC;CACF;AA7TD,4CA6TC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport {\r\n FileSystem,\r\n type ITerminal,\r\n Terminal,\r\n ConsoleTerminalProvider,\r\n Path,\r\n NewlineKind,\r\n Async\r\n} from '@rushstack/node-core-library';\r\nimport glob from 'fast-glob';\r\nimport * as path from 'path';\r\nimport { EOL } from 'os';\r\nimport * as chokidar from 'chokidar';\r\n\r\n/**\r\n * @public\r\n */\r\nexport interface ITypingsGeneratorBaseOptions {\r\n srcFolder: string;\r\n generatedTsFolder: string;\r\n secondaryGeneratedTsFolders?: string[];\r\n globsToIgnore?: string[];\r\n terminal?: ITerminal;\r\n}\r\n\r\n/**\r\n * @public\r\n */\r\nexport interface ITypingsGeneratorOptionsWithoutReadFile<\r\n TTypingsResult = string | undefined,\r\n TFileContents = string\r\n> extends ITypingsGeneratorBaseOptions {\r\n fileExtensions: string[];\r\n parseAndGenerateTypings: (\r\n fileContents: TFileContents,\r\n filePath: string,\r\n relativePath: string\r\n ) => TTypingsResult | Promise<TTypingsResult>;\r\n getAdditionalOutputFiles?: (relativePath: string) => string[];\r\n /**\r\n * @deprecated\r\n *\r\n * TODO: Remove when version 1.0.0 is released.\r\n */\r\n filesToIgnore?: string[];\r\n}\r\n\r\n/**\r\n * @public\r\n */\r\nexport type ReadFile<TFileContents = string> = (\r\n filePath: string,\r\n relativePath: string\r\n) => Promise<TFileContents> | TFileContents;\r\n\r\n/**\r\n * @public\r\n */\r\nexport interface ITypingsGeneratorOptions<\r\n TTypingsResult = string | undefined,\r\n TFileContents extends string = string\r\n> extends ITypingsGeneratorOptionsWithoutReadFile<TTypingsResult, TFileContents> {\r\n readFile?: ReadFile<TFileContents>;\r\n}\r\n\r\n/**\r\n * Options for a TypingsGenerator that needs to customize how files are read.\r\n *\r\n * @public\r\n */\r\nexport interface ITypingsGeneratorOptionsWithCustomReadFile<\r\n TTypingsResult = string | undefined,\r\n TFileContents = string\r\n> extends ITypingsGeneratorOptionsWithoutReadFile<TTypingsResult, TFileContents> {\r\n readFile: ReadFile<TFileContents>;\r\n}\r\n\r\n/**\r\n * This is a simple tool that generates .d.ts files for non-TS files.\r\n *\r\n * @public\r\n */\r\nexport class TypingsGenerator<TFileContents = string> {\r\n // Map of resolved consumer file path -> Set<resolved dependency file path>\r\n private readonly _dependenciesOfFile: Map<string, Set<string>>;\r\n\r\n // Map of resolved dependency file path -> Set<resolved consumer file path>\r\n private readonly _consumersOfFile: Map<string, Set<string>>;\r\n\r\n // Map of resolved file path -> relative file path\r\n private readonly _relativePaths: Map<string, string>;\r\n\r\n protected _options: ITypingsGeneratorOptionsWithCustomReadFile<string | undefined, TFileContents>;\r\n\r\n /**\r\n * The folder path that contains all input source files.\r\n */\r\n public readonly sourceFolderPath: string;\r\n\r\n /**\r\n * The glob pattern used to find input files to process.\r\n */\r\n public readonly inputFileGlob: string;\r\n\r\n /**\r\n * The glob patterns that should be ignored when finding input files to process.\r\n */\r\n public readonly ignoredFileGlobs: readonly string[];\r\n\r\n public constructor(\r\n options: TFileContents extends string\r\n ? ITypingsGeneratorOptions<string | undefined, TFileContents>\r\n : never\r\n );\r\n public constructor(options: ITypingsGeneratorOptionsWithCustomReadFile<string | undefined, TFileContents>);\r\n public constructor(options: ITypingsGeneratorOptionsWithCustomReadFile<string | undefined, TFileContents>) {\r\n this._options = {\r\n ...options,\r\n readFile:\r\n options.readFile ??\r\n ((filePath: string, relativePath: string): Promise<TFileContents> =>\r\n FileSystem.readFileAsync(filePath) as Promise<TFileContents>)\r\n };\r\n\r\n if (options.filesToIgnore) {\r\n throw new Error('The filesToIgnore option is no longer supported. Please use globsToIgnore instead.');\r\n }\r\n\r\n if (!options.generatedTsFolder) {\r\n throw new Error('generatedTsFolder must be provided');\r\n }\r\n\r\n if (!options.srcFolder) {\r\n throw new Error('srcFolder must be provided');\r\n }\r\n this.sourceFolderPath = options.srcFolder;\r\n\r\n if (Path.isUnder(options.srcFolder, options.generatedTsFolder)) {\r\n throw new Error('srcFolder must not be under generatedTsFolder');\r\n }\r\n\r\n if (Path.isUnder(options.generatedTsFolder, options.srcFolder)) {\r\n throw new Error('generatedTsFolder must not be under srcFolder');\r\n }\r\n\r\n if (!options.fileExtensions || options.fileExtensions.length === 0) {\r\n throw new Error('At least one file extension must be provided.');\r\n }\r\n\r\n this.ignoredFileGlobs = options.globsToIgnore || [];\r\n\r\n if (!options.terminal) {\r\n this._options.terminal = new Terminal(new ConsoleTerminalProvider({ verboseEnabled: true }));\r\n }\r\n\r\n this._options.fileExtensions = this._normalizeFileExtensions(options.fileExtensions);\r\n\r\n this._dependenciesOfFile = new Map();\r\n this._consumersOfFile = new Map();\r\n this._relativePaths = new Map();\r\n\r\n this.inputFileGlob = `**/*+(${this._options.fileExtensions.join('|')})`;\r\n }\r\n\r\n /**\r\n * Generate typings for the provided input files.\r\n *\r\n * @param relativeFilePaths - The input files to process, relative to the source folder. If not provided,\r\n * all input files will be processed.\r\n */\r\n public async generateTypingsAsync(relativeFilePaths?: string[]): Promise<void> {\r\n let checkFilePaths: boolean = true;\r\n if (!relativeFilePaths?.length) {\r\n checkFilePaths = false; // Don't check file paths if we generate them\r\n relativeFilePaths = await glob(this.inputFileGlob, {\r\n cwd: this.sourceFolderPath,\r\n ignore: this.ignoredFileGlobs as string[],\r\n onlyFiles: true\r\n });\r\n }\r\n\r\n await this._reprocessFiles(relativeFilePaths!, checkFilePaths);\r\n }\r\n\r\n public async runWatcherAsync(): Promise<void> {\r\n await FileSystem.ensureFolderAsync(this._options.generatedTsFolder);\r\n\r\n await new Promise((resolve, reject): void => {\r\n const watcher: chokidar.FSWatcher = chokidar.watch(this.inputFileGlob, {\r\n cwd: this.sourceFolderPath,\r\n ignored: this.ignoredFileGlobs\r\n });\r\n\r\n const queue: Set<string> = new Set();\r\n let timeout: NodeJS.Timeout | undefined;\r\n let processing: boolean = false;\r\n let flushAfterCompletion: boolean = false;\r\n\r\n const flushInternal: () => void = () => {\r\n processing = true;\r\n\r\n const toProcess: string[] = Array.from(queue);\r\n queue.clear();\r\n this._reprocessFiles(toProcess, false)\r\n .then(() => {\r\n processing = false;\r\n // If the timeout was invoked again, immediately reexecute with the changed files.\r\n if (flushAfterCompletion) {\r\n flushAfterCompletion = false;\r\n flushInternal();\r\n }\r\n })\r\n .catch(reject);\r\n };\r\n\r\n const debouncedFlush: () => void = () => {\r\n timeout = undefined;\r\n if (processing) {\r\n // If the callback was invoked while processing is ongoing, indicate that we should flush immediately\r\n // upon completion of the current change batch.\r\n flushAfterCompletion = true;\r\n return;\r\n }\r\n\r\n flushInternal();\r\n };\r\n\r\n const onChange: (relativePath: string) => void = (relativePath: string) => {\r\n queue.add(relativePath);\r\n if (timeout) {\r\n clearTimeout(timeout);\r\n }\r\n\r\n setTimeout(debouncedFlush, 100);\r\n };\r\n\r\n watcher.on('add', onChange);\r\n watcher.on('change', onChange);\r\n watcher.on('unlink', async (relativePath) => {\r\n await Promise.all(\r\n this._getOutputFilePathsWithoutCheck(relativePath).map(async (outputFile: string) => {\r\n await FileSystem.deleteFileAsync(outputFile);\r\n })\r\n );\r\n });\r\n watcher.on('error', reject);\r\n });\r\n }\r\n\r\n /**\r\n * Register file dependencies that may effect the typings of a consumer file.\r\n * Note: This feature is only useful in watch mode.\r\n * The registerDependency method must be called in the body of parseAndGenerateTypings every\r\n * time because the registry for a file is cleared at the beginning of processing.\r\n */\r\n public registerDependency(consumer: string, rawDependency: string): void {\r\n // Need to normalize slashes in the dependency path\r\n const dependency: string = path.resolve(this._options.srcFolder, rawDependency);\r\n\r\n let dependencies: Set<string> | undefined = this._dependenciesOfFile.get(consumer);\r\n if (!dependencies) {\r\n dependencies = new Set();\r\n this._dependenciesOfFile.set(consumer, dependencies);\r\n }\r\n dependencies.add(dependency);\r\n\r\n let consumers: Set<string> | undefined = this._consumersOfFile.get(dependency);\r\n if (!consumers) {\r\n consumers = new Set();\r\n this._consumersOfFile.set(dependency, consumers);\r\n }\r\n consumers.add(consumer);\r\n }\r\n\r\n public getOutputFilePaths(relativePath: string): string[] {\r\n if (path.isAbsolute(relativePath)) {\r\n throw new Error(`\"${relativePath}\" must be relative`);\r\n }\r\n\r\n return this._getOutputFilePathsWithoutCheck(relativePath);\r\n }\r\n\r\n private _getOutputFilePathsWithoutCheck(relativePath: string): string[] {\r\n const typingsFilePaths: Iterable<string> = this._getTypingsFilePaths(relativePath);\r\n const additionalPaths: string[] | undefined = this._options.getAdditionalOutputFiles?.(relativePath);\r\n return additionalPaths ? [...typingsFilePaths, ...additionalPaths] : Array.from(typingsFilePaths);\r\n }\r\n\r\n private async _reprocessFiles(relativePaths: Iterable<string>, checkFilePaths: boolean): Promise<void> {\r\n // Build a queue of resolved paths\r\n const toProcess: Set<string> = new Set();\r\n for (const rawPath of relativePaths) {\r\n if (checkFilePaths && path.isAbsolute(rawPath)) {\r\n throw new Error(`\"${rawPath}\" must be relative`);\r\n }\r\n\r\n const relativePath: string = Path.convertToSlashes(rawPath);\r\n const resolvedPath: string = path.resolve(this._options.srcFolder, rawPath);\r\n this._relativePaths.set(resolvedPath, relativePath);\r\n toProcess.add(resolvedPath);\r\n }\r\n\r\n // Expand out all registered consumers, according to the current dependency graph\r\n for (const file of toProcess) {\r\n const consumers: Set<string> | undefined = this._consumersOfFile.get(file);\r\n if (consumers) {\r\n for (const consumer of consumers) {\r\n toProcess.add(consumer);\r\n }\r\n }\r\n }\r\n\r\n // Map back to the relative paths so that the information is available\r\n await Async.forEachAsync(\r\n toProcess,\r\n async (resolvedPath: string) => {\r\n const relativePath: string | undefined = this._relativePaths.get(resolvedPath);\r\n if (!relativePath) {\r\n throw new Error(`Missing relative path for file ${resolvedPath}`);\r\n }\r\n await this._parseFileAndGenerateTypingsAsync(relativePath, resolvedPath);\r\n },\r\n { concurrency: 20 }\r\n );\r\n }\r\n\r\n private async _parseFileAndGenerateTypingsAsync(relativePath: string, resolvedPath: string): Promise<void> {\r\n // Clear registered dependencies prior to reprocessing.\r\n this._clearDependencies(resolvedPath);\r\n\r\n try {\r\n const fileContents: TFileContents = await this._options.readFile(resolvedPath, relativePath);\r\n const typingsData: string | undefined = await this._options.parseAndGenerateTypings(\r\n fileContents,\r\n resolvedPath,\r\n relativePath\r\n );\r\n\r\n // Typings data will be undefined when no types should be generated for the parsed file.\r\n if (typingsData === undefined) {\r\n return;\r\n }\r\n\r\n const prefixedTypingsData: string = [\r\n '// This file was generated by a tool. Modifying it will produce unexpected behavior',\r\n '',\r\n typingsData\r\n ].join(EOL);\r\n\r\n const generatedTsFilePaths: Iterable<string> = this._getTypingsFilePaths(relativePath);\r\n for (const generatedTsFilePath of generatedTsFilePaths) {\r\n await FileSystem.writeFileAsync(generatedTsFilePath, prefixedTypingsData, {\r\n ensureFolderExists: true,\r\n convertLineEndings: NewlineKind.OsDefault\r\n });\r\n }\r\n } catch (e) {\r\n this._options.terminal!.writeError(\r\n `Error occurred parsing and generating typings for file \"${resolvedPath}\": ${e}`\r\n );\r\n }\r\n }\r\n\r\n /**\r\n * Removes the consumer from all extant dependencies\r\n */\r\n private _clearDependencies(consumer: string): void {\r\n const dependencies: Set<string> | undefined = this._dependenciesOfFile.get(consumer);\r\n if (dependencies) {\r\n for (const dependency of dependencies) {\r\n this._consumersOfFile.get(dependency)!.delete(consumer);\r\n }\r\n dependencies.clear();\r\n }\r\n }\r\n\r\n private *_getTypingsFilePaths(relativePath: string): Iterable<string> {\r\n const { generatedTsFolder, secondaryGeneratedTsFolders } = this._options;\r\n const dtsFilename: string = `${relativePath}.d.ts`;\r\n yield path.resolve(generatedTsFolder, dtsFilename);\r\n if (secondaryGeneratedTsFolders) {\r\n for (const secondaryGeneratedTsFolder of secondaryGeneratedTsFolders) {\r\n yield path.resolve(secondaryGeneratedTsFolder, dtsFilename);\r\n }\r\n }\r\n }\r\n\r\n private _normalizeFileExtensions(fileExtensions: string[]): string[] {\r\n const result: Set<string> = new Set();\r\n for (const fileExtension of fileExtensions) {\r\n if (!fileExtension.startsWith('.')) {\r\n result.add(`.${fileExtension}`);\r\n } else {\r\n result.add(fileExtension);\r\n }\r\n }\r\n\r\n return Array.from(result);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"TypingsGenerator.js","sourceRoot":"","sources":["../src/TypingsGenerator.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,oEAQsC;AACtC,0DAA6B;AAC7B,2CAA6B;AAC7B,2BAAyB;AACzB,mDAAqC;AAiErC;;;;GAIG;AACH,MAAa,gBAAgB;IAiC3B,YAAmB,OAAsF;;QACvG,IAAI,CAAC,QAAQ,mCACR,OAAO,KACV,QAAQ,EACN,MAAA,OAAO,CAAC,QAAQ,mCAChB,CAAC,CAAC,QAAgB,EAAE,YAAoB,EAA0B,EAAE,CAClE,8BAAU,CAAC,aAAa,CAAC,QAAQ,CAA2B,CAAC,GAClE,CAAC;QAEF,IAAI,OAAO,CAAC,aAAa,EAAE;YACzB,MAAM,IAAI,KAAK,CAAC,oFAAoF,CAAC,CAAC;SACvG;QAED,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE;YAC9B,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;SACvD;QAED,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE;YACtB,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;SAC/C;QACD,IAAI,CAAC,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC;QAE1C,IAAI,wBAAI,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,iBAAiB,CAAC,EAAE;YAC9D,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;SAClE;QAED,IAAI,wBAAI,CAAC,OAAO,CAAC,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC,SAAS,CAAC,EAAE;YAC9D,MAAM,IAAI,KAAK,CAAC,+CAA+C,C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W,CAAC,CAAC;QACnD,IAAI,2BAA2B,EAAE;YAC/B,KAAK,MAAM,0BAA0B,IAAI,2BAA2B,EAAE;gBACpE,MAAM,IAAI,CAAC,OAAO,CAAC,0BAA0B,EAAE,WAAW,CAAC,CAAC;aAC7D;SACF;IACH,CAAC;IAEO,wBAAwB,CAAC,cAAwB;QACvD,MAAM,MAAM,GAAgB,IAAI,GAAG,EAAE,CAAC;QACtC,KAAK,MAAM,aAAa,IAAI,cAAc,EAAE;YAC1C,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;gBAClC,MAAM,CAAC,GAAG,CAAC,IAAI,aAAa,EAAE,CAAC,CAAC;aACjC;iBAAM;gBACL,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;aAC3B;SACF;QAED,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC5B,CAAC;CACF;AA7TD,4CA6TC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport {\n FileSystem,\n type ITerminal,\n Terminal,\n ConsoleTerminalProvider,\n Path,\n NewlineKind,\n Async\n} from '@rushstack/node-core-library';\nimport glob from 'fast-glob';\nimport * as path from 'path';\nimport { EOL } from 'os';\nimport * as chokidar from 'chokidar';\n\n/**\n * @public\n */\nexport interface ITypingsGeneratorBaseOptions {\n srcFolder: string;\n generatedTsFolder: string;\n secondaryGeneratedTsFolders?: string[];\n globsToIgnore?: string[];\n terminal?: ITerminal;\n}\n\n/**\n * @public\n */\nexport interface ITypingsGeneratorOptionsWithoutReadFile<\n TTypingsResult = string | undefined,\n TFileContents = string\n> extends ITypingsGeneratorBaseOptions {\n fileExtensions: string[];\n parseAndGenerateTypings: (\n fileContents: TFileContents,\n filePath: string,\n relativePath: string\n ) => TTypingsResult | Promise<TTypingsResult>;\n getAdditionalOutputFiles?: (relativePath: string) => string[];\n /**\n * @deprecated\n *\n * TODO: Remove when version 1.0.0 is released.\n */\n filesToIgnore?: string[];\n}\n\n/**\n * @public\n */\nexport type ReadFile<TFileContents = string> = (\n filePath: string,\n relativePath: string\n) => Promise<TFileContents> | TFileContents;\n\n/**\n * @public\n */\nexport interface ITypingsGeneratorOptions<\n TTypingsResult = string | undefined,\n TFileContents extends string = string\n> extends ITypingsGeneratorOptionsWithoutReadFile<TTypingsResult, TFileContents> {\n readFile?: ReadFile<TFileContents>;\n}\n\n/**\n * Options for a TypingsGenerator that needs to customize how files are read.\n *\n * @public\n */\nexport interface ITypingsGeneratorOptionsWithCustomReadFile<\n TTypingsResult = string | undefined,\n TFileContents = string\n> extends ITypingsGeneratorOptionsWithoutReadFile<TTypingsResult, TFileContents> {\n readFile: ReadFile<TFileContents>;\n}\n\n/**\n * This is a simple tool that generates .d.ts files for non-TS files.\n *\n * @public\n */\nexport class TypingsGenerator<TFileContents = string> {\n // Map of resolved consumer file path -> Set<resolved dependency file path>\n private readonly _dependenciesOfFile: Map<string, Set<string>>;\n\n // Map of resolved dependency file path -> Set<resolved consumer file path>\n private readonly _consumersOfFile: Map<string, Set<string>>;\n\n // Map of resolved file path -> relative file path\n private readonly _relativePaths: Map<string, string>;\n\n protected _options: ITypingsGeneratorOptionsWithCustomReadFile<string | undefined, TFileContents>;\n\n /**\n * The folder path that contains all input source files.\n */\n public readonly sourceFolderPath: string;\n\n /**\n * The glob pattern used to find input files to process.\n */\n public readonly inputFileGlob: string;\n\n /**\n * The glob patterns that should be ignored when finding input files to process.\n */\n public readonly ignoredFileGlobs: readonly string[];\n\n public constructor(\n options: TFileContents extends string\n ? ITypingsGeneratorOptions<string | undefined, TFileContents>\n : never\n );\n public constructor(options: ITypingsGeneratorOptionsWithCustomReadFile<string | undefined, TFileContents>);\n public constructor(options: ITypingsGeneratorOptionsWithCustomReadFile<string | undefined, TFileContents>) {\n this._options = {\n ...options,\n readFile:\n options.readFile ??\n ((filePath: string, relativePath: string): Promise<TFileContents> =>\n FileSystem.readFileAsync(filePath) as Promise<TFileContents>)\n };\n\n if (options.filesToIgnore) {\n throw new Error('The filesToIgnore option is no longer supported. Please use globsToIgnore instead.');\n }\n\n if (!options.generatedTsFolder) {\n throw new Error('generatedTsFolder must be provided');\n }\n\n if (!options.srcFolder) {\n throw new Error('srcFolder must be provided');\n }\n this.sourceFolderPath = options.srcFolder;\n\n if (Path.isUnder(options.srcFolder, options.generatedTsFolder)) {\n throw new Error('srcFolder must not be under generatedTsFolder');\n }\n\n if (Path.isUnder(options.generatedTsFolder, options.srcFolder)) {\n throw new Error('generatedTsFolder must not be under srcFolder');\n }\n\n if (!options.fileExtensions || options.fileExtensions.length === 0) {\n throw new Error('At least one file extension must be provided.');\n }\n\n this.ignoredFileGlobs = options.globsToIgnore || [];\n\n if (!options.terminal) {\n this._options.terminal = new Terminal(new ConsoleTerminalProvider({ verboseEnabled: true }));\n }\n\n this._options.fileExtensions = this._normalizeFileExtensions(options.fileExtensions);\n\n this._dependenciesOfFile = new Map();\n this._consumersOfFile = new Map();\n this._relativePaths = new Map();\n\n this.inputFileGlob = `**/*+(${this._options.fileExtensions.join('|')})`;\n }\n\n /**\n * Generate typings for the provided input files.\n *\n * @param relativeFilePaths - The input files to process, relative to the source folder. If not provided,\n * all input files will be processed.\n */\n public async generateTypingsAsync(relativeFilePaths?: string[]): Promise<void> {\n let checkFilePaths: boolean = true;\n if (!relativeFilePaths?.length) {\n checkFilePaths = false; // Don't check file paths if we generate them\n relativeFilePaths = await glob(this.inputFileGlob, {\n cwd: this.sourceFolderPath,\n ignore: this.ignoredFileGlobs as string[],\n onlyFiles: true\n });\n }\n\n await this._reprocessFiles(relativeFilePaths!, checkFilePaths);\n }\n\n public async runWatcherAsync(): Promise<void> {\n await FileSystem.ensureFolderAsync(this._options.generatedTsFolder);\n\n await new Promise((resolve, reject): void => {\n const watcher: chokidar.FSWatcher = chokidar.watch(this.inputFileGlob, {\n cwd: this.sourceFolderPath,\n ignored: this.ignoredFileGlobs\n });\n\n const queue: Set<string> = new Set();\n let timeout: NodeJS.Timeout | undefined;\n let processing: boolean = false;\n let flushAfterCompletion: boolean = false;\n\n const flushInternal: () => void = () => {\n processing = true;\n\n const toProcess: string[] = Array.from(queue);\n queue.clear();\n this._reprocessFiles(toProcess, false)\n .then(() => {\n processing = false;\n // If the timeout was invoked again, immediately reexecute with the changed files.\n if (flushAfterCompletion) {\n flushAfterCompletion = false;\n flushInternal();\n }\n })\n .catch(reject);\n };\n\n const debouncedFlush: () => void = () => {\n timeout = undefined;\n if (processing) {\n // If the callback was invoked while processing is ongoing, indicate that we should flush immediately\n // upon completion of the current change batch.\n flushAfterCompletion = true;\n return;\n }\n\n flushInternal();\n };\n\n const onChange: (relativePath: string) => void = (relativePath: string) => {\n queue.add(relativePath);\n if (timeout) {\n clearTimeout(timeout);\n }\n\n setTimeout(debouncedFlush, 100);\n };\n\n watcher.on('add', onChange);\n watcher.on('change', onChange);\n watcher.on('unlink', async (relativePath) => {\n await Promise.all(\n this._getOutputFilePathsWithoutCheck(relativePath).map(async (outputFile: string) => {\n await FileSystem.deleteFileAsync(outputFile);\n })\n );\n });\n watcher.on('error', reject);\n });\n }\n\n /**\n * Register file dependencies that may effect the typings of a consumer file.\n * Note: This feature is only useful in watch mode.\n * The registerDependency method must be called in the body of parseAndGenerateTypings every\n * time because the registry for a file is cleared at the beginning of processing.\n */\n public registerDependency(consumer: string, rawDependency: string): void {\n // Need to normalize slashes in the dependency path\n const dependency: string = path.resolve(this._options.srcFolder, rawDependency);\n\n let dependencies: Set<string> | undefined = this._dependenciesOfFile.get(consumer);\n if (!dependencies) {\n dependencies = new Set();\n this._dependenciesOfFile.set(consumer, dependencies);\n }\n dependencies.add(dependency);\n\n let consumers: Set<string> | undefined = this._consumersOfFile.get(dependency);\n if (!consumers) {\n consumers = new Set();\n this._consumersOfFile.set(dependency, consumers);\n }\n consumers.add(consumer);\n }\n\n public getOutputFilePaths(relativePath: string): string[] {\n if (path.isAbsolute(relativePath)) {\n throw new Error(`\"${relativePath}\" must be relative`);\n }\n\n return this._getOutputFilePathsWithoutCheck(relativePath);\n }\n\n private _getOutputFilePathsWithoutCheck(relativePath: string): string[] {\n const typingsFilePaths: Iterable<string> = this._getTypingsFilePaths(relativePath);\n const additionalPaths: string[] | undefined = this._options.getAdditionalOutputFiles?.(relativePath);\n return additionalPaths ? [...typingsFilePaths, ...additionalPaths] : Array.from(typingsFilePaths);\n }\n\n private async _reprocessFiles(relativePaths: Iterable<string>, checkFilePaths: boolean): Promise<void> {\n // Build a queue of resolved paths\n const toProcess: Set<string> = new Set();\n for (const rawPath of relativePaths) {\n if (checkFilePaths && path.isAbsolute(rawPath)) {\n throw new Error(`\"${rawPath}\" must be relative`);\n }\n\n const relativePath: string = Path.convertToSlashes(rawPath);\n const resolvedPath: string = path.resolve(this._options.srcFolder, rawPath);\n this._relativePaths.set(resolvedPath, relativePath);\n toProcess.add(resolvedPath);\n }\n\n // Expand out all registered consumers, according to the current dependency graph\n for (const file of toProcess) {\n const consumers: Set<string> | undefined = this._consumersOfFile.get(file);\n if (consumers) {\n for (const consumer of consumers) {\n toProcess.add(consumer);\n }\n }\n }\n\n // Map back to the relative paths so that the information is available\n await Async.forEachAsync(\n toProcess,\n async (resolvedPath: string) => {\n const relativePath: string | undefined = this._relativePaths.get(resolvedPath);\n if (!relativePath) {\n throw new Error(`Missing relative path for file ${resolvedPath}`);\n }\n await this._parseFileAndGenerateTypingsAsync(relativePath, resolvedPath);\n },\n { concurrency: 20 }\n );\n }\n\n private async _parseFileAndGenerateTypingsAsync(relativePath: string, resolvedPath: string): Promise<void> {\n // Clear registered dependencies prior to reprocessing.\n this._clearDependencies(resolvedPath);\n\n try {\n const fileContents: TFileContents = await this._options.readFile(resolvedPath, relativePath);\n const typingsData: string | undefined = await this._options.parseAndGenerateTypings(\n fileContents,\n resolvedPath,\n relativePath\n );\n\n // Typings data will be undefined when no types should be generated for the parsed file.\n if (typingsData === undefined) {\n return;\n }\n\n const prefixedTypingsData: string = [\n '// This file was generated by a tool. Modifying it will produce unexpected behavior',\n '',\n typingsData\n ].join(EOL);\n\n const generatedTsFilePaths: Iterable<string> = this._getTypingsFilePaths(relativePath);\n for (const generatedTsFilePath of generatedTsFilePaths) {\n await FileSystem.writeFileAsync(generatedTsFilePath, prefixedTypingsData, {\n ensureFolderExists: true,\n convertLineEndings: NewlineKind.OsDefault\n });\n }\n } catch (e) {\n this._options.terminal!.writeError(\n `Error occurred parsing and generating typings for file \"${resolvedPath}\": ${e}`\n );\n }\n }\n\n /**\n * Removes the consumer from all extant dependencies\n */\n private _clearDependencies(consumer: string): void {\n const dependencies: Set<string> | undefined = this._dependenciesOfFile.get(consumer);\n if (dependencies) {\n for (const dependency of dependencies) {\n this._consumersOfFile.get(dependency)!.delete(consumer);\n }\n dependencies.clear();\n }\n }\n\n private *_getTypingsFilePaths(relativePath: string): Iterable<string> {\n const { generatedTsFolder, secondaryGeneratedTsFolders } = this._options;\n const dtsFilename: string = `${relativePath}.d.ts`;\n yield path.resolve(generatedTsFolder, dtsFilename);\n if (secondaryGeneratedTsFolders) {\n for (const secondaryGeneratedTsFolder of secondaryGeneratedTsFolders) {\n yield path.resolve(secondaryGeneratedTsFolder, dtsFilename);\n }\n }\n }\n\n private _normalizeFileExtensions(fileExtensions: string[]): string[] {\n const result: Set<string> = new Set();\n for (const fileExtension of fileExtensions) {\n if (!fileExtension.startsWith('.')) {\n result.add(`.${fileExtension}`);\n } else {\n result.add(fileExtension);\n }\n }\n\n return Array.from(result);\n }\n}\n"]}
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D;;;;;;GAMG;AAEH,uDAO4B;AAD1B,oHAAA,gBAAgB,OAAA;AAGlB,+EAOwC;AADtC,4IAAA,4BAA4B,OAAA","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\n/**\r\n * An engine for generating TypeScript .d.ts files that provide type signatures\r\n * for non-TypeScript modules such as generated JavaScript or CSS. It can operate\r\n * in either a single-run mode or a watch mode.\r\n *\r\n * @packageDocumentation\r\n */\r\n\r\nexport {\r\n type ReadFile,\r\n type ITypingsGeneratorBaseOptions,\r\n type ITypingsGeneratorOptionsWithoutReadFile,\r\n type ITypingsGeneratorOptions,\r\n type ITypingsGeneratorOptionsWithCustomReadFile,\r\n TypingsGenerator\r\n} from './TypingsGenerator';\r\n\r\nexport {\r\n type IStringValueTyping,\r\n type IStringValueTypings,\r\n type IStringValuesTypingsGeneratorBaseOptions,\r\n type IStringValuesTypingsGeneratorOptions,\r\n type IStringValuesTypingsGeneratorOptionsWithCustomReadFile,\r\n StringValuesTypingsGenerator\r\n} from './StringValuesTypingsGenerator';\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D;;;;;;GAMG;AAEH,uDAO4B;AAD1B,oHAAA,gBAAgB,OAAA;AAGlB,+EAOwC;AADtC,4IAAA,4BAA4B,OAAA","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\n/**\n * An engine for generating TypeScript .d.ts files that provide type signatures\n * for non-TypeScript modules such as generated JavaScript or CSS. It can operate\n * in either a single-run mode or a watch mode.\n *\n * @packageDocumentation\n */\n\nexport {\n type ReadFile,\n type ITypingsGeneratorBaseOptions,\n type ITypingsGeneratorOptionsWithoutReadFile,\n type ITypingsGeneratorOptions,\n type ITypingsGeneratorOptionsWithCustomReadFile,\n TypingsGenerator\n} from './TypingsGenerator';\n\nexport {\n type IStringValueTyping,\n type IStringValueTypings,\n type IStringValuesTypingsGeneratorBaseOptions,\n type IStringValuesTypingsGeneratorOptions,\n type IStringValuesTypingsGeneratorOptionsWithCustomReadFile,\n StringValuesTypingsGenerator\n} from './StringValuesTypingsGenerator';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rushstack/typings-generator",
3
- "version": "0.12.10",
3
+ "version": "0.12.11",
4
4
  "description": "This library provides functionality for automatically generating typings for non-TS files.",
5
5
  "keywords": [
6
6
  "dts",
@@ -22,7 +22,7 @@
22
22
  },
23
23
  "devDependencies": {
24
24
  "@types/glob": "7.1.1",
25
- "@rushstack/heft": "0.63.0",
25
+ "@rushstack/heft": "0.63.1",
26
26
  "local-node-rig": "1.0.0"
27
27
  },
28
28
  "peerDependencies": {