versioned-d.ts-tools 0.7.3 → 0.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dts-utilities.d.ts +1 -1
- package/dist/dts-utilities.js +24 -4
- package/dist/version-remover.js +3 -3
- package/dist/whats-new.js +1 -1
- package/package.json +1 -1
package/dist/dts-utilities.d.ts
CHANGED
|
@@ -76,7 +76,7 @@ export declare class APISet {
|
|
|
76
76
|
* This is called during markdown generation after field exclusions have been applied.
|
|
77
77
|
*/
|
|
78
78
|
private shouldExcludeClassForUnionFiltering;
|
|
79
|
-
diff(other: APISet): APISet;
|
|
79
|
+
diff(other: APISet, filterUnionAdditions?: boolean): APISet;
|
|
80
80
|
getAsDTS(): string;
|
|
81
81
|
/**
|
|
82
82
|
* Generates markdown documentation for API differences.
|
package/dist/dts-utilities.js
CHANGED
|
@@ -174,14 +174,26 @@ class APISet {
|
|
|
174
174
|
if (newDeclaration === oldDeclaration) {
|
|
175
175
|
return false;
|
|
176
176
|
}
|
|
177
|
+
// Quick check: if the method/field names are different, this is not a union addition
|
|
178
|
+
// Extract method/field name from the beginning of each declaration
|
|
179
|
+
const getMethodName = (decl) => {
|
|
180
|
+
const match = decl.match(/^\s*(\w+)\s*[\(:]/) || decl.match(/^\s*(\w+)\s*\??\s*:/);
|
|
181
|
+
return match ? match[1] : '';
|
|
182
|
+
};
|
|
183
|
+
const oldMethodName = getMethodName(oldDeclaration);
|
|
184
|
+
const newMethodName = getMethodName(newDeclaration);
|
|
185
|
+
// If method names are different, this is a new method, not a union addition
|
|
186
|
+
if (oldMethodName !== newMethodName || !oldMethodName) {
|
|
187
|
+
return false;
|
|
188
|
+
}
|
|
177
189
|
// More sophisticated approach: extract and compare union types from specific parameters
|
|
178
190
|
// This handles cases where union additions are in the middle of parameter lists
|
|
179
191
|
// Normalize whitespace first
|
|
180
192
|
const oldNormalized = oldDeclaration.replace(/\s+/g, ' ').trim();
|
|
181
193
|
const newNormalized = newDeclaration.replace(/\s+/g, ' ').trim();
|
|
182
194
|
// Find all union type patterns in both declarations
|
|
183
|
-
// Pattern matches: paramName?: Type1 | Type2 | Type3
|
|
184
|
-
const unionPattern = /(\w
|
|
195
|
+
// Pattern matches: paramName: Type1 | Type2 | Type3 or paramName?: Type1 | Type2 | Type3
|
|
196
|
+
const unionPattern = /(\w+\??\s*:\s*)([^;,)]+)/g;
|
|
185
197
|
const oldUnions = new Map();
|
|
186
198
|
const newUnions = new Map();
|
|
187
199
|
let match;
|
|
@@ -285,13 +297,21 @@ class APISet {
|
|
|
285
297
|
return false;
|
|
286
298
|
}
|
|
287
299
|
// finds the new fields and classes
|
|
288
|
-
diff(other) {
|
|
300
|
+
diff(other, filterUnionAdditions = false) {
|
|
289
301
|
const diffAPI = new APISet();
|
|
290
302
|
this.api.forEach((element) => {
|
|
291
303
|
if (other.containsClass(element)) {
|
|
292
304
|
let classShell = null;
|
|
293
305
|
element.fields.forEach((field) => {
|
|
294
|
-
|
|
306
|
+
let fieldExists;
|
|
307
|
+
if (filterUnionAdditions) {
|
|
308
|
+
// Use union-aware field comparison when filtering is enabled
|
|
309
|
+
fieldExists = other.containsFieldOrUnionAddition(element, field);
|
|
310
|
+
}
|
|
311
|
+
else {
|
|
312
|
+
// Use exact match comparison
|
|
313
|
+
fieldExists = other.containsField(element, field);
|
|
314
|
+
}
|
|
295
315
|
if (!fieldExists) {
|
|
296
316
|
if (classShell === null) {
|
|
297
317
|
classShell = element.copyWithoutFields();
|
package/dist/version-remover.js
CHANGED
|
@@ -114,9 +114,9 @@ if (require.main === module) {
|
|
|
114
114
|
const args = process.argv.slice(2);
|
|
115
115
|
const hasHelp = args.find((x) => x === "-?" || x === "--help");
|
|
116
116
|
if ((args.length !== 3 && args.length !== 4) || hasHelp) {
|
|
117
|
-
console.log("usage:
|
|
118
|
-
console.log("example:
|
|
119
|
-
console.log("example:
|
|
117
|
+
console.log("usage: version-remover [source d.ts] [output file name] [version string] [optional config file]");
|
|
118
|
+
console.log("example: version-remover excel.d.ts excel_1_7.d.ts \"Api set: ExcelApi 1.8\"");
|
|
119
|
+
console.log("example: version-remover excel.d.ts excel_1_18.d.ts \"Api set: ExcelApi 1.19\" my-config.json");
|
|
120
120
|
console.log("");
|
|
121
121
|
console.log("Note: For specific API sets that require custom replacements, you may need to create");
|
|
122
122
|
console.log("configuration files to handle type union cleanups and parameter removals.");
|
package/dist/whats-new.js
CHANGED
|
@@ -119,7 +119,7 @@ function generateWhatsNew(options) {
|
|
|
119
119
|
let wholePreview = fsx.readFileSync(options.newDtsPath).toString();
|
|
120
120
|
const releaseAPI = (0, dts_utilities_1.parseDTS)("release", wholeRelease);
|
|
121
121
|
const previewAPI = (0, dts_utilities_1.parseDTS)("preview", wholePreview);
|
|
122
|
-
const diffAPI = previewAPI.diff(releaseAPI);
|
|
122
|
+
const diffAPI = previewAPI.diff(releaseAPI, effectiveFilterUnionAdditions);
|
|
123
123
|
if (!fsx.existsSync(options.outputPath + ".md")) {
|
|
124
124
|
fsx.createFileSync(options.outputPath + ".md");
|
|
125
125
|
}
|