@optique/core 1.0.0-dev.1300 → 1.0.0-dev.1309
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/doc.cjs +8 -12
- package/dist/doc.js +8 -12
- package/dist/suggestion.cjs +18 -7
- package/dist/suggestion.js +18 -7
- package/package.json +1 -1
package/dist/doc.cjs
CHANGED
|
@@ -87,24 +87,20 @@ function formatDocPage(programName, page, options = {}) {
|
|
|
87
87
|
...page,
|
|
88
88
|
sections: filteredSections
|
|
89
89
|
};
|
|
90
|
+
const hasContent = (msg) => Array.isArray(msg) && msg.length > 0;
|
|
90
91
|
if (options.maxWidth != null) {
|
|
91
92
|
const hasEntries = page.sections.some((s) => s.entries.length > 0);
|
|
92
|
-
const
|
|
93
|
-
const needsDescColumn = hasEntries && page.sections.some((s) => s.entries.some((e) => hasContent(e.description) || options.showDefault && e.default != null || options.showChoices && e.choices != null));
|
|
93
|
+
const needsDescColumn = hasEntries && page.sections.some((s) => s.entries.some((e) => hasContent(e.description) || options.showDefault && hasContent(e.default) || options.showChoices && hasContent(e.choices)));
|
|
94
94
|
let minDescWidth = 1;
|
|
95
95
|
if (needsDescColumn) {
|
|
96
|
-
if (options.showDefault && page.sections.some((s) => s.entries.some((e) => e.default
|
|
96
|
+
if (options.showDefault && page.sections.some((s) => s.entries.some((e) => hasContent(e.default)))) {
|
|
97
97
|
const prefix = typeof options.showDefault === "object" ? options.showDefault.prefix ?? " [" : " [";
|
|
98
|
-
|
|
99
|
-
const hasEmptyDefault = page.sections.some((s) => s.entries.some((e) => e.default != null && Array.isArray(e.default) && e.default.length === 0));
|
|
100
|
-
minDescWidth = Math.max(minDescWidth, hasEmptyDefault ? prefix.length + suffix.length : prefix.length);
|
|
98
|
+
minDescWidth = Math.max(minDescWidth, prefix.length);
|
|
101
99
|
}
|
|
102
|
-
if (options.showChoices && page.sections.some((s) => s.entries.some((e) => e.choices
|
|
100
|
+
if (options.showChoices && page.sections.some((s) => s.entries.some((e) => hasContent(e.choices)))) {
|
|
103
101
|
const prefix = typeof options.showChoices === "object" ? options.showChoices.prefix ?? " (" : " (";
|
|
104
|
-
const suffix = typeof options.showChoices === "object" ? options.showChoices.suffix ?? ")" : ")";
|
|
105
102
|
const label = typeof options.showChoices === "object" ? options.showChoices.label ?? "choices: " : "choices: ";
|
|
106
|
-
|
|
107
|
-
minDescWidth = Math.max(minDescWidth, hasEmptyChoices ? prefix.length + label.length + suffix.length : prefix.length + label.length);
|
|
103
|
+
minDescWidth = Math.max(minDescWidth, prefix.length + label.length);
|
|
108
104
|
}
|
|
109
105
|
}
|
|
110
106
|
const splitEntryMin = termIndent + 2 + Math.max(2, 2 * minDescWidth - 1);
|
|
@@ -196,7 +192,7 @@ function formatDocPage(programName, page, options = {}) {
|
|
|
196
192
|
startWidth: extraTermOffset > 0 ? extraTermOffset : void 0
|
|
197
193
|
};
|
|
198
194
|
let description = entry.description == null ? "" : require_message.formatMessage(entry.description, descFormatOptions);
|
|
199
|
-
if (options.showDefault && entry.default
|
|
195
|
+
if (options.showDefault && hasContent(entry.default)) {
|
|
200
196
|
const prefix = typeof options.showDefault === "object" ? options.showDefault.prefix ?? " [" : " [";
|
|
201
197
|
const suffix = typeof options.showDefault === "object" ? options.showDefault.suffix ?? "]" : "]";
|
|
202
198
|
let defaultStartWidth;
|
|
@@ -219,7 +215,7 @@ function formatDocPage(programName, page, options = {}) {
|
|
|
219
215
|
const formattedDefault = options.colors ? `\x1b[2m${defaultText}\x1b[0m` : defaultText;
|
|
220
216
|
description += formattedDefault;
|
|
221
217
|
}
|
|
222
|
-
if (options.showChoices && entry.choices
|
|
218
|
+
if (options.showChoices && hasContent(entry.choices)) {
|
|
223
219
|
const prefix = typeof options.showChoices === "object" ? options.showChoices.prefix ?? " (" : " (";
|
|
224
220
|
const suffix = typeof options.showChoices === "object" ? options.showChoices.suffix ?? ")" : ")";
|
|
225
221
|
const label = typeof options.showChoices === "object" ? options.showChoices.label ?? "choices: " : "choices: ";
|
package/dist/doc.js
CHANGED
|
@@ -87,24 +87,20 @@ function formatDocPage(programName, page, options = {}) {
|
|
|
87
87
|
...page,
|
|
88
88
|
sections: filteredSections
|
|
89
89
|
};
|
|
90
|
+
const hasContent = (msg) => Array.isArray(msg) && msg.length > 0;
|
|
90
91
|
if (options.maxWidth != null) {
|
|
91
92
|
const hasEntries = page.sections.some((s) => s.entries.length > 0);
|
|
92
|
-
const
|
|
93
|
-
const needsDescColumn = hasEntries && page.sections.some((s) => s.entries.some((e) => hasContent(e.description) || options.showDefault && e.default != null || options.showChoices && e.choices != null));
|
|
93
|
+
const needsDescColumn = hasEntries && page.sections.some((s) => s.entries.some((e) => hasContent(e.description) || options.showDefault && hasContent(e.default) || options.showChoices && hasContent(e.choices)));
|
|
94
94
|
let minDescWidth = 1;
|
|
95
95
|
if (needsDescColumn) {
|
|
96
|
-
if (options.showDefault && page.sections.some((s) => s.entries.some((e) => e.default
|
|
96
|
+
if (options.showDefault && page.sections.some((s) => s.entries.some((e) => hasContent(e.default)))) {
|
|
97
97
|
const prefix = typeof options.showDefault === "object" ? options.showDefault.prefix ?? " [" : " [";
|
|
98
|
-
|
|
99
|
-
const hasEmptyDefault = page.sections.some((s) => s.entries.some((e) => e.default != null && Array.isArray(e.default) && e.default.length === 0));
|
|
100
|
-
minDescWidth = Math.max(minDescWidth, hasEmptyDefault ? prefix.length + suffix.length : prefix.length);
|
|
98
|
+
minDescWidth = Math.max(minDescWidth, prefix.length);
|
|
101
99
|
}
|
|
102
|
-
if (options.showChoices && page.sections.some((s) => s.entries.some((e) => e.choices
|
|
100
|
+
if (options.showChoices && page.sections.some((s) => s.entries.some((e) => hasContent(e.choices)))) {
|
|
103
101
|
const prefix = typeof options.showChoices === "object" ? options.showChoices.prefix ?? " (" : " (";
|
|
104
|
-
const suffix = typeof options.showChoices === "object" ? options.showChoices.suffix ?? ")" : ")";
|
|
105
102
|
const label = typeof options.showChoices === "object" ? options.showChoices.label ?? "choices: " : "choices: ";
|
|
106
|
-
|
|
107
|
-
minDescWidth = Math.max(minDescWidth, hasEmptyChoices ? prefix.length + label.length + suffix.length : prefix.length + label.length);
|
|
103
|
+
minDescWidth = Math.max(minDescWidth, prefix.length + label.length);
|
|
108
104
|
}
|
|
109
105
|
}
|
|
110
106
|
const splitEntryMin = termIndent + 2 + Math.max(2, 2 * minDescWidth - 1);
|
|
@@ -196,7 +192,7 @@ function formatDocPage(programName, page, options = {}) {
|
|
|
196
192
|
startWidth: extraTermOffset > 0 ? extraTermOffset : void 0
|
|
197
193
|
};
|
|
198
194
|
let description = entry.description == null ? "" : formatMessage(entry.description, descFormatOptions);
|
|
199
|
-
if (options.showDefault && entry.default
|
|
195
|
+
if (options.showDefault && hasContent(entry.default)) {
|
|
200
196
|
const prefix = typeof options.showDefault === "object" ? options.showDefault.prefix ?? " [" : " [";
|
|
201
197
|
const suffix = typeof options.showDefault === "object" ? options.showDefault.suffix ?? "]" : "]";
|
|
202
198
|
let defaultStartWidth;
|
|
@@ -219,7 +215,7 @@ function formatDocPage(programName, page, options = {}) {
|
|
|
219
215
|
const formattedDefault = options.colors ? `\x1b[2m${defaultText}\x1b[0m` : defaultText;
|
|
220
216
|
description += formattedDefault;
|
|
221
217
|
}
|
|
222
|
-
if (options.showChoices && entry.choices
|
|
218
|
+
if (options.showChoices && hasContent(entry.choices)) {
|
|
223
219
|
const prefix = typeof options.showChoices === "object" ? options.showChoices.prefix ?? " (" : " (";
|
|
224
220
|
const suffix = typeof options.showChoices === "object" ? options.showChoices.suffix ?? ")" : ")";
|
|
225
221
|
const label = typeof options.showChoices === "object" ? options.showChoices.label ?? "choices: " : "choices: ";
|
package/dist/suggestion.cjs
CHANGED
|
@@ -201,7 +201,11 @@ function getSuggestionKey(suggestion) {
|
|
|
201
201
|
* - Literal suggestions: same text
|
|
202
202
|
* - File suggestions: same type, extensions, and pattern
|
|
203
203
|
*
|
|
204
|
-
* The first occurrence of each unique suggestion is kept.
|
|
204
|
+
* The first occurrence of each unique suggestion is kept. For file
|
|
205
|
+
* suggestions, `includeHidden` is merged across duplicates: if any
|
|
206
|
+
* duplicate has `includeHidden: true`, the kept suggestion is upgraded
|
|
207
|
+
* to `includeHidden: true` because it is a superset of the non-hidden
|
|
208
|
+
* variant.
|
|
205
209
|
*
|
|
206
210
|
* @param suggestions Array of suggestions that may contain duplicates
|
|
207
211
|
* @returns A new array with duplicates removed, preserving order of first occurrences
|
|
@@ -220,13 +224,20 @@ function getSuggestionKey(suggestion) {
|
|
|
220
224
|
* @since 0.9.0
|
|
221
225
|
*/
|
|
222
226
|
function deduplicateSuggestions(suggestions) {
|
|
223
|
-
const
|
|
224
|
-
|
|
227
|
+
const entries = /* @__PURE__ */ new Map();
|
|
228
|
+
const order = [];
|
|
229
|
+
for (const suggestion of suggestions) {
|
|
225
230
|
const key = getSuggestionKey(suggestion);
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
231
|
+
const existing = entries.get(key);
|
|
232
|
+
if (existing == null) {
|
|
233
|
+
entries.set(key, suggestion);
|
|
234
|
+
order.push(key);
|
|
235
|
+
} else if (suggestion.kind === "file" && existing.kind === "file" && suggestion.includeHidden === true && existing.includeHidden !== true) entries.set(key, {
|
|
236
|
+
...existing,
|
|
237
|
+
includeHidden: true
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
return order.map((key) => entries.get(key));
|
|
230
241
|
}
|
|
231
242
|
|
|
232
243
|
//#endregion
|
package/dist/suggestion.js
CHANGED
|
@@ -201,7 +201,11 @@ function getSuggestionKey(suggestion) {
|
|
|
201
201
|
* - Literal suggestions: same text
|
|
202
202
|
* - File suggestions: same type, extensions, and pattern
|
|
203
203
|
*
|
|
204
|
-
* The first occurrence of each unique suggestion is kept.
|
|
204
|
+
* The first occurrence of each unique suggestion is kept. For file
|
|
205
|
+
* suggestions, `includeHidden` is merged across duplicates: if any
|
|
206
|
+
* duplicate has `includeHidden: true`, the kept suggestion is upgraded
|
|
207
|
+
* to `includeHidden: true` because it is a superset of the non-hidden
|
|
208
|
+
* variant.
|
|
205
209
|
*
|
|
206
210
|
* @param suggestions Array of suggestions that may contain duplicates
|
|
207
211
|
* @returns A new array with duplicates removed, preserving order of first occurrences
|
|
@@ -220,13 +224,20 @@ function getSuggestionKey(suggestion) {
|
|
|
220
224
|
* @since 0.9.0
|
|
221
225
|
*/
|
|
222
226
|
function deduplicateSuggestions(suggestions) {
|
|
223
|
-
const
|
|
224
|
-
|
|
227
|
+
const entries = /* @__PURE__ */ new Map();
|
|
228
|
+
const order = [];
|
|
229
|
+
for (const suggestion of suggestions) {
|
|
225
230
|
const key = getSuggestionKey(suggestion);
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
231
|
+
const existing = entries.get(key);
|
|
232
|
+
if (existing == null) {
|
|
233
|
+
entries.set(key, suggestion);
|
|
234
|
+
order.push(key);
|
|
235
|
+
} else if (suggestion.kind === "file" && existing.kind === "file" && suggestion.includeHidden === true && existing.includeHidden !== true) entries.set(key, {
|
|
236
|
+
...existing,
|
|
237
|
+
includeHidden: true
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
return order.map((key) => entries.get(key));
|
|
230
241
|
}
|
|
231
242
|
|
|
232
243
|
//#endregion
|