@rushstack/typings-generator 0.15.14 → 0.16.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/CHANGELOG.json CHANGED
@@ -1,6 +1,52 @@
1
1
  {
2
2
  "name": "@rushstack/typings-generator",
3
3
  "entries": [
4
+ {
5
+ "version": "0.16.1",
6
+ "tag": "@rushstack/typings-generator_v0.16.1",
7
+ "date": "Fri, 20 Feb 2026 00:15:04 GMT",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "comment": "Add `\"node\"` condition before `\"import\"` in the `\"exports\"` map so that Node.js uses the CJS output (which handles extensionless imports), while bundlers still use ESM via `\"import\"`. Fixes https://github.com/microsoft/rushstack/issues/5644."
12
+ }
13
+ ],
14
+ "dependency": [
15
+ {
16
+ "comment": "Updating dependency \"@rushstack/node-core-library\" to `5.20.1`"
17
+ },
18
+ {
19
+ "comment": "Updating dependency \"@rushstack/terminal\" to `0.22.1`"
20
+ },
21
+ {
22
+ "comment": "Updating dependency \"@rushstack/heft\" to `1.2.1`"
23
+ }
24
+ ]
25
+ }
26
+ },
27
+ {
28
+ "version": "0.16.0",
29
+ "tag": "@rushstack/typings-generator_v0.16.0",
30
+ "date": "Thu, 19 Feb 2026 00:04:53 GMT",
31
+ "comments": {
32
+ "minor": [
33
+ {
34
+ "comment": "Normalize package layout. CommonJS is now under `lib-commonjs`, DTS is now under `lib-dts`, and ESM is now under `lib-esm`. Imports to `lib` still work as before, handled by the `\"exports\"` field in `package.json`."
35
+ }
36
+ ],
37
+ "dependency": [
38
+ {
39
+ "comment": "Updating dependency \"@rushstack/node-core-library\" to `5.20.0`"
40
+ },
41
+ {
42
+ "comment": "Updating dependency \"@rushstack/terminal\" to `0.22.0`"
43
+ },
44
+ {
45
+ "comment": "Updating dependency \"@rushstack/heft\" to `1.2.0`"
46
+ }
47
+ ]
48
+ }
49
+ },
4
50
  {
5
51
  "version": "0.15.14",
6
52
  "tag": "@rushstack/typings-generator_v0.15.14",
package/CHANGELOG.md CHANGED
@@ -1,6 +1,20 @@
1
1
  # Change Log - @rushstack/typings-generator
2
2
 
3
- This log was last generated on Sat, 07 Feb 2026 01:13:26 GMT and should not be manually modified.
3
+ This log was last generated on Fri, 20 Feb 2026 00:15:04 GMT and should not be manually modified.
4
+
5
+ ## 0.16.1
6
+ Fri, 20 Feb 2026 00:15:04 GMT
7
+
8
+ ### Patches
9
+
10
+ - Add `"node"` condition before `"import"` in the `"exports"` map so that Node.js uses the CJS output (which handles extensionless imports), while bundlers still use ESM via `"import"`. Fixes https://github.com/microsoft/rushstack/issues/5644.
11
+
12
+ ## 0.16.0
13
+ Thu, 19 Feb 2026 00:04:53 GMT
14
+
15
+ ### Minor changes
16
+
17
+ - Normalize package layout. CommonJS is now under `lib-commonjs`, DTS is now under `lib-dts`, and ESM is now under `lib-esm`. Imports to `lib` still work as before, handled by the `"exports"` field in `package.json`.
4
18
 
5
19
  ## 0.15.14
6
20
  Sat, 07 Feb 2026 01:13:26 GMT
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.56.2"
8
+ "packageVersion": "7.57.0"
9
9
  }
10
10
  ]
11
11
  }
@@ -0,0 +1,111 @@
1
+ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2
+ // See LICENSE in the project root for license information.
3
+ import { EOL } from 'node:os';
4
+ import { Text } from '@rushstack/node-core-library';
5
+ import { TypingsGenerator } from './TypingsGenerator';
6
+ const EXPORT_AS_DEFAULT_INTERFACE_NAME = 'IExport';
7
+ function convertToTypingsGeneratorOptions(options) {
8
+ var _a;
9
+ const { exportAsDefault: exportAsDefaultOptions, exportAsDefaultInterfaceName: exportAsDefaultInterfaceName_deprecated, parseAndGenerateTypings } = options;
10
+ let defaultSplitExportAsDefaultInterfaceDocumentationComment;
11
+ let defaultSplitExportAsDefaultValueDocumentationComment;
12
+ let defaultExportAsDefaultInterfaceName;
13
+ if (typeof exportAsDefaultOptions === 'object') {
14
+ const { interfaceDocumentationComment, documentationComment: interfaceDocumentationComment_deprecated, valueDocumentationComment, interfaceName } = exportAsDefaultOptions;
15
+ defaultSplitExportAsDefaultInterfaceDocumentationComment = Text.splitByNewLines(interfaceDocumentationComment !== null && interfaceDocumentationComment !== void 0 ? interfaceDocumentationComment : interfaceDocumentationComment_deprecated);
16
+ defaultSplitExportAsDefaultValueDocumentationComment = Text.splitByNewLines(valueDocumentationComment);
17
+ defaultExportAsDefaultInterfaceName =
18
+ (_a = interfaceName !== null && interfaceName !== void 0 ? interfaceName : exportAsDefaultInterfaceName_deprecated) !== null && _a !== void 0 ? _a : EXPORT_AS_DEFAULT_INTERFACE_NAME;
19
+ }
20
+ else if (exportAsDefaultOptions) {
21
+ defaultExportAsDefaultInterfaceName =
22
+ exportAsDefaultInterfaceName_deprecated !== null && exportAsDefaultInterfaceName_deprecated !== void 0 ? exportAsDefaultInterfaceName_deprecated : EXPORT_AS_DEFAULT_INTERFACE_NAME;
23
+ }
24
+ async function parseAndGenerateTypingsOuter(fileContents, filePath, relativePath) {
25
+ var _a, _b, _c, _d;
26
+ const stringValueTypings = await parseAndGenerateTypings(fileContents, filePath, relativePath);
27
+ if (stringValueTypings === undefined) {
28
+ return;
29
+ }
30
+ const { exportAsDefault: exportAsDefaultOptionsOverride, typings } = stringValueTypings;
31
+ let exportAsDefaultInterfaceName;
32
+ let interfaceDocumentationCommentLines;
33
+ let valueDocumentationCommentLines;
34
+ if (typeof exportAsDefaultOptionsOverride === 'boolean') {
35
+ if (exportAsDefaultOptionsOverride) {
36
+ exportAsDefaultInterfaceName =
37
+ defaultExportAsDefaultInterfaceName !== null && defaultExportAsDefaultInterfaceName !== void 0 ? defaultExportAsDefaultInterfaceName : EXPORT_AS_DEFAULT_INTERFACE_NAME;
38
+ interfaceDocumentationCommentLines = defaultSplitExportAsDefaultInterfaceDocumentationComment;
39
+ valueDocumentationCommentLines = defaultSplitExportAsDefaultValueDocumentationComment;
40
+ }
41
+ }
42
+ else if (exportAsDefaultOptionsOverride) {
43
+ const { interfaceName, documentationComment, interfaceDocumentationComment, valueDocumentationComment } = exportAsDefaultOptionsOverride;
44
+ exportAsDefaultInterfaceName =
45
+ (_a = interfaceName !== null && interfaceName !== void 0 ? interfaceName : defaultExportAsDefaultInterfaceName) !== null && _a !== void 0 ? _a : EXPORT_AS_DEFAULT_INTERFACE_NAME;
46
+ interfaceDocumentationCommentLines =
47
+ (_c = (_b = Text.splitByNewLines(interfaceDocumentationComment)) !== null && _b !== void 0 ? _b : Text.splitByNewLines(documentationComment)) !== null && _c !== void 0 ? _c : defaultSplitExportAsDefaultInterfaceDocumentationComment;
48
+ valueDocumentationCommentLines =
49
+ (_d = Text.splitByNewLines(valueDocumentationComment)) !== null && _d !== void 0 ? _d : defaultSplitExportAsDefaultValueDocumentationComment;
50
+ }
51
+ else {
52
+ exportAsDefaultInterfaceName = defaultExportAsDefaultInterfaceName;
53
+ interfaceDocumentationCommentLines = defaultSplitExportAsDefaultInterfaceDocumentationComment;
54
+ valueDocumentationCommentLines = defaultSplitExportAsDefaultValueDocumentationComment;
55
+ }
56
+ const outputLines = [];
57
+ let indent = '';
58
+ if (exportAsDefaultInterfaceName) {
59
+ if (interfaceDocumentationCommentLines) {
60
+ outputLines.push(`/**`);
61
+ for (const line of interfaceDocumentationCommentLines) {
62
+ outputLines.push(` * ${line}`);
63
+ }
64
+ outputLines.push(` */`);
65
+ }
66
+ outputLines.push(`export interface ${exportAsDefaultInterfaceName} {`);
67
+ indent = ' ';
68
+ }
69
+ for (const stringValueTyping of typings) {
70
+ const { exportName, comment } = stringValueTyping;
71
+ if (comment && comment.trim() !== '') {
72
+ outputLines.push(`${indent}/**`, `${indent} * ${comment.replace(/\*\//g, '*\\/')}`, `${indent} */`);
73
+ }
74
+ if (exportAsDefaultInterfaceName) {
75
+ outputLines.push(`${indent}'${exportName}': string;`, '');
76
+ }
77
+ else {
78
+ outputLines.push(`export declare const ${exportName}: string;`, '');
79
+ }
80
+ }
81
+ if (exportAsDefaultInterfaceName) {
82
+ outputLines.push('}', '');
83
+ if (valueDocumentationCommentLines) {
84
+ outputLines.push(`/**`);
85
+ for (const line of valueDocumentationCommentLines) {
86
+ outputLines.push(` * ${line}`);
87
+ }
88
+ outputLines.push(` */`);
89
+ }
90
+ outputLines.push(`declare const strings: ${exportAsDefaultInterfaceName};`, '', 'export default strings;');
91
+ }
92
+ return outputLines.join(EOL);
93
+ }
94
+ const convertedOptions = {
95
+ ...options,
96
+ parseAndGenerateTypings: parseAndGenerateTypingsOuter
97
+ };
98
+ return convertedOptions;
99
+ }
100
+ /**
101
+ * This is a simple tool that generates .d.ts files for non-TS files that can be represented as
102
+ * a simple set of named string exports.
103
+ *
104
+ * @public
105
+ */
106
+ export class StringValuesTypingsGenerator extends TypingsGenerator {
107
+ constructor(options) {
108
+ super(convertToTypingsGeneratorOptions(options));
109
+ }
110
+ }
111
+ //# sourceMappingURL=StringValuesTypingsGenerator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StringValuesTypingsGenerator.js","sourceRoot":"","sources":["../src/StringValuesTypingsGenerator.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAE3D,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AAEpD,OAAO,EAEL,gBAAgB,EAEjB,MAAM,oBAAoB,CAAC;AAsF5B,MAAM,gCAAgC,GAAW,SAAS,CAAC;AAE3D,SAAS,gCAAgC,CACvC,OAA8E;;IAE9E,MAAM,EACJ,eAAe,EAAE,sBAAsB,EACvC,4BAA4B,EAAE,uCAAuC,EACrE,uBAAuB,EACxB,GAAG,OAAO,CAAC;IACZ,IAAI,wDAA8E,CAAC;IACnF,IAAI,oDAA0E,CAAC;IAC/E,IAAI,mCAAuD,CAAC;IAC5D,IAAI,OAAO,sBAAsB,KAAK,QAAQ,EAAE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licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { EOL } from 'node:os';\n\nimport { Text } from '@rushstack/node-core-library';\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 * Options for default exports. Note that options provided here will override\n * options provided in {@link IStringValuesTypingsGeneratorBaseOptions.exportAsDefault}.\n */\n exportAsDefault?: boolean | IExportAsDefaultOptions;\n}\n\n/**\n * @public\n */\nexport interface IExportAsDefaultOptions {\n /**\n * This setting overrides the the interface name for the default wrapped export.\n *\n * @defaultValue \"IExport\"\n */\n interfaceName?: string;\n\n /**\n * @deprecated - Use {@link IExportAsDefaultOptions.interfaceDocumentationComment} instead.\n */\n documentationComment?: string;\n\n /**\n * This value is placed in a documentation comment for the\n * exported default interface.\n */\n interfaceDocumentationComment?: string;\n\n /**\n * This value is placed in a documentation comment for the\n * exported const value.\n */\n valueDocumentationComment?: string;\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 | IExportAsDefaultOptions;\n\n /**\n * @deprecated Use {@link IStringValuesTypingsGeneratorBaseOptions.exportAsDefault}'s\n * {@link IExportAsDefaultOptions.interfaceName} instead.\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 const {\n exportAsDefault: exportAsDefaultOptions,\n exportAsDefaultInterfaceName: exportAsDefaultInterfaceName_deprecated,\n parseAndGenerateTypings\n } = options;\n let defaultSplitExportAsDefaultInterfaceDocumentationComment: string[] | undefined;\n let defaultSplitExportAsDefaultValueDocumentationComment: string[] | undefined;\n let defaultExportAsDefaultInterfaceName: string | undefined;\n if (typeof exportAsDefaultOptions === 'object') {\n const {\n interfaceDocumentationComment,\n documentationComment: interfaceDocumentationComment_deprecated,\n valueDocumentationComment,\n interfaceName\n } = exportAsDefaultOptions;\n defaultSplitExportAsDefaultInterfaceDocumentationComment = Text.splitByNewLines(\n interfaceDocumentationComment ?? interfaceDocumentationComment_deprecated\n );\n defaultSplitExportAsDefaultValueDocumentationComment = Text.splitByNewLines(valueDocumentationComment);\n defaultExportAsDefaultInterfaceName =\n interfaceName ?? exportAsDefaultInterfaceName_deprecated ?? EXPORT_AS_DEFAULT_INTERFACE_NAME;\n } else if (exportAsDefaultOptions) {\n defaultExportAsDefaultInterfaceName =\n exportAsDefaultInterfaceName_deprecated ?? EXPORT_AS_DEFAULT_INTERFACE_NAME;\n }\n\n async function parseAndGenerateTypingsOuter(\n fileContents: TFileContents,\n filePath: string,\n relativePath: string\n ): Promise<string | undefined> {\n const stringValueTypings: IStringValueTypings | undefined = await parseAndGenerateTypings(\n fileContents,\n filePath,\n relativePath\n );\n\n if (stringValueTypings === undefined) {\n return;\n }\n\n const { exportAsDefault: exportAsDefaultOptionsOverride, typings } = stringValueTypings;\n let exportAsDefaultInterfaceName: string | undefined;\n let interfaceDocumentationCommentLines: string[] | undefined;\n let valueDocumentationCommentLines: string[] | undefined;\n if (typeof exportAsDefaultOptionsOverride === 'boolean') {\n if (exportAsDefaultOptionsOverride) {\n exportAsDefaultInterfaceName =\n defaultExportAsDefaultInterfaceName ?? EXPORT_AS_DEFAULT_INTERFACE_NAME;\n interfaceDocumentationCommentLines = defaultSplitExportAsDefaultInterfaceDocumentationComment;\n valueDocumentationCommentLines = defaultSplitExportAsDefaultValueDocumentationComment;\n }\n } else if (exportAsDefaultOptionsOverride) {\n const {\n interfaceName,\n documentationComment,\n interfaceDocumentationComment,\n valueDocumentationComment\n } = exportAsDefaultOptionsOverride;\n exportAsDefaultInterfaceName =\n interfaceName ?? defaultExportAsDefaultInterfaceName ?? EXPORT_AS_DEFAULT_INTERFACE_NAME;\n interfaceDocumentationCommentLines =\n Text.splitByNewLines(interfaceDocumentationComment) ??\n Text.splitByNewLines(documentationComment) ??\n defaultSplitExportAsDefaultInterfaceDocumentationComment;\n valueDocumentationCommentLines =\n Text.splitByNewLines(valueDocumentationComment) ??\n defaultSplitExportAsDefaultValueDocumentationComment;\n } else {\n exportAsDefaultInterfaceName = defaultExportAsDefaultInterfaceName;\n interfaceDocumentationCommentLines = defaultSplitExportAsDefaultInterfaceDocumentationComment;\n valueDocumentationCommentLines = defaultSplitExportAsDefaultValueDocumentationComment;\n }\n\n const outputLines: string[] = [];\n let indent: string = '';\n if (exportAsDefaultInterfaceName) {\n if (interfaceDocumentationCommentLines) {\n outputLines.push(`/**`);\n for (const line of interfaceDocumentationCommentLines) {\n outputLines.push(` * ${line}`);\n }\n\n outputLines.push(` */`);\n }\n\n outputLines.push(`export interface ${exportAsDefaultInterfaceName} {`);\n indent = ' ';\n }\n\n for (const stringValueTyping of 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 (exportAsDefaultInterfaceName) {\n outputLines.push(`${indent}'${exportName}': string;`, '');\n } else {\n outputLines.push(`export declare const ${exportName}: string;`, '');\n }\n }\n\n if (exportAsDefaultInterfaceName) {\n outputLines.push('}', '');\n\n if (valueDocumentationCommentLines) {\n outputLines.push(`/**`);\n for (const line of valueDocumentationCommentLines) {\n outputLines.push(` * ${line}`);\n }\n\n outputLines.push(` */`);\n }\n\n outputLines.push(\n `declare const strings: ${exportAsDefaultInterfaceName};`,\n '',\n 'export default strings;'\n );\n }\n\n return outputLines.join(EOL);\n }\n\n const convertedOptions: ITypingsGeneratorOptionsWithCustomReadFile<string | undefined, TFileContents> = {\n ...options,\n parseAndGenerateTypings: parseAndGenerateTypingsOuter\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"]}
@@ -0,0 +1,242 @@
1
+ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2
+ // See LICENSE in the project root for license information.
3
+ import * as path from 'node:path';
4
+ import { EOL } from 'node:os';
5
+ import glob from 'fast-glob';
6
+ import * as chokidar from 'chokidar';
7
+ import { Terminal, ConsoleTerminalProvider } from '@rushstack/terminal';
8
+ import { FileSystem, Path, NewlineKind, Async } from '@rushstack/node-core-library';
9
+ /**
10
+ * This is a simple tool that generates .d.ts files for non-TS files.
11
+ *
12
+ * @public
13
+ */
14
+ export class TypingsGenerator {
15
+ constructor(options) {
16
+ var _a, _b;
17
+ this._options = {
18
+ ...options,
19
+ readFile: (_a = options.readFile) !== null && _a !== void 0 ? _a : ((filePath, relativePath) => FileSystem.readFileAsync(filePath))
20
+ };
21
+ if (!options.generatedTsFolder) {
22
+ throw new Error('generatedTsFolder must be provided');
23
+ }
24
+ if (!options.srcFolder) {
25
+ throw new Error('srcFolder must be provided');
26
+ }
27
+ this.sourceFolderPath = options.srcFolder;
28
+ if (Path.isUnder(options.srcFolder, options.generatedTsFolder)) {
29
+ throw new Error('srcFolder must not be under generatedTsFolder');
30
+ }
31
+ if (Path.isUnder(options.generatedTsFolder, options.srcFolder)) {
32
+ throw new Error('generatedTsFolder must not be under srcFolder');
33
+ }
34
+ if (!options.fileExtensions || options.fileExtensions.length === 0) {
35
+ throw new Error('At least one file extension must be provided.');
36
+ }
37
+ this.ignoredFileGlobs = options.globsToIgnore || [];
38
+ this.terminal = (_b = options.terminal) !== null && _b !== void 0 ? _b : new Terminal(new ConsoleTerminalProvider({ verboseEnabled: true }));
39
+ this._options.fileExtensions = this._normalizeFileExtensions(options.fileExtensions);
40
+ this._dependenciesOfFile = new Map();
41
+ this._consumersOfFile = new Map();
42
+ this._relativePaths = new Map();
43
+ this.inputFileGlob = `**/*+(${this._options.fileExtensions.join('|')})`;
44
+ }
45
+ /**
46
+ * Generate typings for the provided input files.
47
+ *
48
+ * @param relativeFilePaths - The input files to process, relative to the source folder. If not provided,
49
+ * all input files will be processed.
50
+ */
51
+ async generateTypingsAsync(relativeFilePaths) {
52
+ let checkFilePaths = true;
53
+ if (!(relativeFilePaths === null || relativeFilePaths === void 0 ? void 0 : relativeFilePaths.length)) {
54
+ checkFilePaths = false; // Don't check file paths if we generate them
55
+ relativeFilePaths = await glob(this.inputFileGlob, {
56
+ cwd: this.sourceFolderPath,
57
+ ignore: this.ignoredFileGlobs,
58
+ onlyFiles: true
59
+ });
60
+ }
61
+ await this._reprocessFilesAsync(relativeFilePaths, checkFilePaths);
62
+ }
63
+ async runWatcherAsync() {
64
+ await FileSystem.ensureFolderAsync(this._options.generatedTsFolder);
65
+ await new Promise((resolve, reject) => {
66
+ const watcher = chokidar.watch(this.inputFileGlob, {
67
+ cwd: this.sourceFolderPath,
68
+ ignored: this.ignoredFileGlobs // `ignored` doesn't like the readonly array
69
+ });
70
+ const queue = new Set();
71
+ let timeout;
72
+ let processing = false;
73
+ let flushAfterCompletion = false;
74
+ const flushInternal = () => {
75
+ processing = true;
76
+ const toProcess = Array.from(queue);
77
+ queue.clear();
78
+ this._reprocessFilesAsync(toProcess, false)
79
+ .then(() => {
80
+ processing = false;
81
+ // If the timeout was invoked again, immediately reexecute with the changed files.
82
+ if (flushAfterCompletion) {
83
+ flushAfterCompletion = false;
84
+ flushInternal();
85
+ }
86
+ })
87
+ .catch(reject);
88
+ };
89
+ const debouncedFlush = () => {
90
+ timeout = undefined;
91
+ if (processing) {
92
+ // If the callback was invoked while processing is ongoing, indicate that we should flush immediately
93
+ // upon completion of the current change batch.
94
+ flushAfterCompletion = true;
95
+ return;
96
+ }
97
+ flushInternal();
98
+ };
99
+ const onChange = (relativePath) => {
100
+ queue.add(relativePath);
101
+ if (timeout) {
102
+ clearTimeout(timeout);
103
+ }
104
+ setTimeout(debouncedFlush, 100);
105
+ };
106
+ watcher.on('add', onChange);
107
+ watcher.on('change', onChange);
108
+ watcher.on('unlink', async (relativePath) => {
109
+ await Promise.all(this._getOutputFilePathsWithoutCheck(relativePath).map(async (outputFile) => {
110
+ await FileSystem.deleteFileAsync(outputFile);
111
+ }));
112
+ });
113
+ watcher.on('error', reject);
114
+ });
115
+ }
116
+ /**
117
+ * Register file dependencies that may effect the typings of a consumer file.
118
+ * Note: This feature is only useful in watch mode.
119
+ * The registerDependency method must be called in the body of parseAndGenerateTypings every
120
+ * time because the registry for a file is cleared at the beginning of processing.
121
+ */
122
+ registerDependency(consumer, rawDependency) {
123
+ // Need to normalize slashes in the dependency path
124
+ const dependency = path.resolve(this._options.srcFolder, rawDependency);
125
+ let dependencies = this._dependenciesOfFile.get(consumer);
126
+ if (!dependencies) {
127
+ dependencies = new Set();
128
+ this._dependenciesOfFile.set(consumer, dependencies);
129
+ }
130
+ dependencies.add(dependency);
131
+ let consumers = this._consumersOfFile.get(dependency);
132
+ if (!consumers) {
133
+ consumers = new Set();
134
+ this._consumersOfFile.set(dependency, consumers);
135
+ }
136
+ consumers.add(consumer);
137
+ }
138
+ getOutputFilePaths(relativePath) {
139
+ if (path.isAbsolute(relativePath)) {
140
+ throw new Error(`"${relativePath}" must be relative`);
141
+ }
142
+ return this._getOutputFilePathsWithoutCheck(relativePath);
143
+ }
144
+ _getOutputFilePathsWithoutCheck(relativePath) {
145
+ var _a, _b;
146
+ const typingsFilePaths = this._getTypingsFilePaths(relativePath);
147
+ const additionalPaths = (_b = (_a = this._options).getAdditionalOutputFiles) === null || _b === void 0 ? void 0 : _b.call(_a, relativePath);
148
+ return additionalPaths ? [...typingsFilePaths, ...additionalPaths] : Array.from(typingsFilePaths);
149
+ }
150
+ async _reprocessFilesAsync(relativePaths, checkFilePaths) {
151
+ // Build a queue of resolved paths
152
+ const toProcess = new Set();
153
+ for (const rawPath of relativePaths) {
154
+ if (checkFilePaths && path.isAbsolute(rawPath)) {
155
+ throw new Error(`"${rawPath}" must be relative`);
156
+ }
157
+ const relativePath = Path.convertToSlashes(rawPath);
158
+ const resolvedPath = path.resolve(this._options.srcFolder, rawPath);
159
+ this._relativePaths.set(resolvedPath, relativePath);
160
+ toProcess.add(resolvedPath);
161
+ }
162
+ // Expand out all registered consumers, according to the current dependency graph
163
+ for (const file of toProcess) {
164
+ const consumers = this._consumersOfFile.get(file);
165
+ if (consumers) {
166
+ for (const consumer of consumers) {
167
+ toProcess.add(consumer);
168
+ }
169
+ }
170
+ }
171
+ // Map back to the relative paths so that the information is available
172
+ await Async.forEachAsync(toProcess, async (resolvedPath) => {
173
+ const relativePath = this._relativePaths.get(resolvedPath);
174
+ if (!relativePath) {
175
+ throw new Error(`Missing relative path for file ${resolvedPath}`);
176
+ }
177
+ await this._parseFileAndGenerateTypingsAsync(relativePath, resolvedPath);
178
+ }, { concurrency: 20 });
179
+ }
180
+ async _parseFileAndGenerateTypingsAsync(relativePath, resolvedPath) {
181
+ // Clear registered dependencies prior to reprocessing.
182
+ this._clearDependencies(resolvedPath);
183
+ try {
184
+ const fileContents = await this._options.readFile(resolvedPath, relativePath);
185
+ const typingsData = await this._options.parseAndGenerateTypings(fileContents, resolvedPath, relativePath);
186
+ // Typings data will be undefined when no types should be generated for the parsed file.
187
+ if (typingsData === undefined) {
188
+ return;
189
+ }
190
+ const prefixedTypingsData = [
191
+ '// This file was generated by a tool. Modifying it will produce unexpected behavior',
192
+ '',
193
+ typingsData
194
+ ].join(EOL);
195
+ const generatedTsFilePaths = this._getTypingsFilePaths(relativePath);
196
+ for (const generatedTsFilePath of generatedTsFilePaths) {
197
+ await FileSystem.writeFileAsync(generatedTsFilePath, prefixedTypingsData, {
198
+ ensureFolderExists: true,
199
+ convertLineEndings: NewlineKind.OsDefault
200
+ });
201
+ }
202
+ }
203
+ catch (e) {
204
+ this.terminal.writeError(`Error occurred parsing and generating typings for file "${resolvedPath}": ${e}`);
205
+ }
206
+ }
207
+ /**
208
+ * Removes the consumer from all extant dependencies
209
+ */
210
+ _clearDependencies(consumer) {
211
+ const dependencies = this._dependenciesOfFile.get(consumer);
212
+ if (dependencies) {
213
+ for (const dependency of dependencies) {
214
+ this._consumersOfFile.get(dependency).delete(consumer);
215
+ }
216
+ dependencies.clear();
217
+ }
218
+ }
219
+ *_getTypingsFilePaths(relativePath) {
220
+ const { generatedTsFolder, secondaryGeneratedTsFolders } = this._options;
221
+ const dtsFilename = `${relativePath}.d.ts`;
222
+ yield `${generatedTsFolder}/${dtsFilename}`;
223
+ if (secondaryGeneratedTsFolders) {
224
+ for (const secondaryGeneratedTsFolder of secondaryGeneratedTsFolders) {
225
+ yield `${secondaryGeneratedTsFolder}/${dtsFilename}`;
226
+ }
227
+ }
228
+ }
229
+ _normalizeFileExtensions(fileExtensions) {
230
+ const result = new Set();
231
+ for (const fileExtension of fileExtensions) {
232
+ if (!fileExtension.startsWith('.')) {
233
+ result.add(`.${fileExtension}`);
234
+ }
235
+ else {
236
+ result.add(fileExtension);
237
+ }
238
+ }
239
+ return Array.from(result);
240
+ }
241
+ }
242
+ //# sourceMappingURL=TypingsGenerator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TypingsGenerator.js","sourceRoot":"","sources":["../src/TypingsGenerator.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAE3D,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AAE9B,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AAErC,OAAO,EAAkB,QAAQ,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AACxF,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AA2DpF;;;;GAIG;AACH,MAAM,OAAO,gBAAgB;IAmC3B,YAAmB,OAAsF;;QACvG,IAAI,CAAC,QAAQ,GAAG;YACd,GAAG,OAAO;YACV,QAAQ,EACN,MAAA,OAAO,CAAC,QAAQ,mCAChB,CAAC,CAAC,QAAgB,EAAE,YAAoB,EAA0B,EAAE,CAClE,UAAU,CAAC,aAAa,CAAC,QAAQ,CAA2B,CAAC;SAClE,CAAC;QAEF,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE,CAAC;YAC/B,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;QACxD,CAAC;QAED,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAChD,CAAC;QACD,IAAI,CAAC,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC;QAE1C,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,iBAAiB,CAAC,EAAE,CAAC;YAC/D,MAAM,IAAI,K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AY,EAAE,CAAC;gBACtC,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,UAAU,CAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC1D,CAAC;YACD,YAAY,CAAC,KAAK,EAAE,CAAC;QACvB,CAAC;IACH,CAAC;IAEO,CAAC,oBAAoB,CAAC,YAAoB;QAChD,MAAM,EAAE,iBAAiB,EAAE,2BAA2B,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC;QACzE,MAAM,WAAW,GAAW,GAAG,YAAY,OAAO,CAAC;QACnD,MAAM,GAAG,iBAAiB,IAAI,WAAW,EAAE,CAAC;QAC5C,IAAI,2BAA2B,EAAE,CAAC;YAChC,KAAK,MAAM,0BAA0B,IAAI,2BAA2B,EAAE,CAAC;gBACrE,MAAM,GAAG,0BAA0B,IAAI,WAAW,EAAE,CAAC;YACvD,CAAC;QACH,CAAC;IACH,CAAC;IAEO,wBAAwB,CAAC,cAAwB;QACvD,MAAM,MAAM,GAAgB,IAAI,GAAG,EAAE,CAAC;QACtC,KAAK,MAAM,aAAa,IAAI,cAAc,EAAE,CAAC;YAC3C,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;gBACnC,MAAM,CAAC,GAAG,CAAC,IAAI,aAAa,EAAE,CAAC,CAAC;YAClC,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;YAC5B,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC5B,CAAC;CACF","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 * as path from 'node:path';\nimport { EOL } from 'node:os';\n\nimport glob from 'fast-glob';\nimport * as chokidar from 'chokidar';\n\nimport { type ITerminal, Terminal, ConsoleTerminalProvider } from '@rushstack/terminal';\nimport { FileSystem, Path, NewlineKind, Async } from '@rushstack/node-core-library';\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\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 readonly _options: ITypingsGeneratorOptionsWithCustomReadFile<string | undefined, TFileContents>;\n\n protected readonly terminal: ITerminal;\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.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 this.terminal = options.terminal ?? new Terminal(new ConsoleTerminalProvider({ verboseEnabled: true }));\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._reprocessFilesAsync(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 as string[] // `ignored` doesn't like the readonly array\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._reprocessFilesAsync(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 _reprocessFilesAsync(\n relativePaths: Iterable<string>,\n checkFilePaths: boolean\n ): 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.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 `${generatedTsFolder}/${dtsFilename}`;\n if (secondaryGeneratedTsFolders) {\n for (const secondaryGeneratedTsFolder of secondaryGeneratedTsFolders) {\n yield `${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"]}
@@ -0,0 +1,12 @@
1
+ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2
+ // See LICENSE in the project root for license information.
3
+ /**
4
+ * An engine for generating TypeScript .d.ts files that provide type signatures
5
+ * for non-TypeScript modules such as generated JavaScript or CSS. It can operate
6
+ * in either a single-run mode or a watch mode.
7
+ *
8
+ * @packageDocumentation
9
+ */
10
+ export { TypingsGenerator } from './TypingsGenerator';
11
+ export { StringValuesTypingsGenerator } from './StringValuesTypingsGenerator';
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAE3D;;;;;;GAMG;AAEH,OAAO,EAML,gBAAgB,EACjB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAOL,4BAA4B,EAC7B,MAAM,gCAAgC,CAAC","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 IExportAsDefaultOptions,\n type IStringValuesTypingsGeneratorBaseOptions,\n type IStringValuesTypingsGeneratorOptions,\n type IStringValuesTypingsGeneratorOptionsWithCustomReadFile,\n StringValuesTypingsGenerator\n} from './StringValuesTypingsGenerator';\n"]}
package/package.json CHANGED
@@ -1,14 +1,37 @@
1
1
  {
2
2
  "name": "@rushstack/typings-generator",
3
- "version": "0.15.14",
3
+ "version": "0.16.1",
4
4
  "description": "This library provides functionality for automatically generating typings for non-TS files.",
5
5
  "keywords": [
6
6
  "dts",
7
7
  "typings",
8
8
  "generate"
9
9
  ],
10
- "main": "lib/index.js",
11
- "typings": "dist/typings-generator.d.ts",
10
+ "main": "./lib-commonjs/index.js",
11
+ "module": "./lib-esm/index.js",
12
+ "types": "./dist/typings-generator.d.ts",
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/typings-generator.d.ts",
16
+ "node": "./lib-commonjs/index.js",
17
+ "import": "./lib-esm/index.js",
18
+ "require": "./lib-commonjs/index.js"
19
+ },
20
+ "./lib/*": {
21
+ "types": "./lib-dts/*.d.ts",
22
+ "node": "./lib-commonjs/*.js",
23
+ "import": "./lib-esm/*.js",
24
+ "require": "./lib-commonjs/*.js"
25
+ },
26
+ "./package.json": "./package.json"
27
+ },
28
+ "typesVersions": {
29
+ "*": {
30
+ "lib/*": [
31
+ "lib-dts/*"
32
+ ]
33
+ }
34
+ },
12
35
  "license": "MIT",
13
36
  "repository": {
14
37
  "type": "git",
@@ -18,13 +41,13 @@
18
41
  "dependencies": {
19
42
  "chokidar": "~3.6.0",
20
43
  "fast-glob": "~3.3.1",
21
- "@rushstack/node-core-library": "5.19.1",
22
- "@rushstack/terminal": "0.21.0"
44
+ "@rushstack/node-core-library": "5.20.1",
45
+ "@rushstack/terminal": "0.22.1"
23
46
  },
24
47
  "devDependencies": {
25
48
  "eslint": "~9.37.0",
26
- "local-node-rig": "1.0.0",
27
- "@rushstack/heft": "1.1.14"
49
+ "@rushstack/heft": "1.2.1",
50
+ "local-node-rig": "1.0.0"
28
51
  },
29
52
  "peerDependencies": {
30
53
  "@types/node": "*"
@@ -34,6 +57,7 @@
34
57
  "optional": true
35
58
  }
36
59
  },
60
+ "sideEffects": false,
37
61
  "scripts": {
38
62
  "build": "heft build --clean",
39
63
  "_phase:build": "heft run --only build -- --clean",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes