@optique/core 1.3.1 → 1.3.3
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/constructs.cjs +260 -40
- package/dist/constructs.js +260 -40
- package/dist/doc.cjs +11 -3
- package/dist/doc.js +12 -4
- package/dist/extension.cjs +17 -0
- package/dist/extension.d.cts +13 -1
- package/dist/extension.d.ts +13 -1
- package/dist/extension.js +17 -1
- package/dist/internal/passthrough.cjs +230 -0
- package/dist/internal/passthrough.js +213 -0
- package/dist/message.cjs +32 -5
- package/dist/message.js +33 -6
- package/dist/modifiers.cjs +22 -0
- package/dist/modifiers.js +22 -0
- package/dist/primitives.cjs +45 -9
- package/dist/primitives.js +45 -9
- package/dist/suggestion.cjs +3 -1
- package/dist/suggestion.js +3 -1
- package/dist/terminal-internal.cjs +4 -1
- package/dist/terminal-internal.d.cts +5 -0
- package/dist/terminal-internal.d.ts +5 -0
- package/dist/terminal-internal.js +4 -1
- package/dist/terminal-separators.cjs +13 -0
- package/dist/terminal-separators.js +12 -0
- package/dist/terminal.cjs +4 -1
- package/dist/terminal.js +5 -1
- package/dist/text-layout.cjs +14 -1
- package/dist/text-layout.d.cts +8 -1
- package/dist/text-layout.d.ts +8 -1
- package/dist/text-layout.js +13 -1
- package/package.json +2 -2
package/dist/terminal.cjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const require_terminal_separators = require('./terminal-separators.cjs');
|
|
1
2
|
|
|
2
3
|
//#region src/terminal.ts
|
|
3
4
|
const plain = (text) => ({
|
|
@@ -9,6 +10,8 @@ const styled = (text, style) => ({
|
|
|
9
10
|
style,
|
|
10
11
|
children: [plain(text)]
|
|
11
12
|
});
|
|
13
|
+
const valuesSeparator = plain(" ");
|
|
14
|
+
require_terminal_separators.wrapTrimmableFragments.add(valuesSeparator);
|
|
12
15
|
/**
|
|
13
16
|
* Optique's built-in terminal theme, with every formatter available for delegation.
|
|
14
17
|
* @since 1.3.0
|
|
@@ -34,7 +37,7 @@ const defaultTerminalTheme = {
|
|
|
34
37
|
value: (_term, ctx) => ctx.usage === "literal" ? plain(ctx.text) : styled(ctx.text, { foreground: "green" }),
|
|
35
38
|
values: (term, ctx) => ({
|
|
36
39
|
type: "concat",
|
|
37
|
-
children: term.values.flatMap((value, i) => [...i === 0 ? [] : [
|
|
40
|
+
children: term.values.flatMap((value, i) => [...i === 0 ? [] : [valuesSeparator], ctx.format({
|
|
38
41
|
type: "value",
|
|
39
42
|
value
|
|
40
43
|
})])
|
package/dist/terminal.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { wrapTrimmableFragments } from "./terminal-separators.js";
|
|
2
|
+
|
|
1
3
|
//#region src/terminal.ts
|
|
2
4
|
const plain = (text) => ({
|
|
3
5
|
type: "text",
|
|
@@ -8,6 +10,8 @@ const styled = (text, style) => ({
|
|
|
8
10
|
style,
|
|
9
11
|
children: [plain(text)]
|
|
10
12
|
});
|
|
13
|
+
const valuesSeparator = plain(" ");
|
|
14
|
+
wrapTrimmableFragments.add(valuesSeparator);
|
|
11
15
|
/**
|
|
12
16
|
* Optique's built-in terminal theme, with every formatter available for delegation.
|
|
13
17
|
* @since 1.3.0
|
|
@@ -33,7 +37,7 @@ const defaultTerminalTheme = {
|
|
|
33
37
|
value: (_term, ctx) => ctx.usage === "literal" ? plain(ctx.text) : styled(ctx.text, { foreground: "green" }),
|
|
34
38
|
values: (term, ctx) => ({
|
|
35
39
|
type: "concat",
|
|
36
|
-
children: term.values.flatMap((value, i) => [...i === 0 ? [] : [
|
|
40
|
+
children: term.values.flatMap((value, i) => [...i === 0 ? [] : [valuesSeparator], ctx.format({
|
|
37
41
|
type: "value",
|
|
38
42
|
value
|
|
39
43
|
})])
|
package/dist/text-layout.cjs
CHANGED
|
@@ -51,6 +51,18 @@ function placeText(text, cursor, maxWidth, trailingRoom = 0) {
|
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
|
+
const leadingSpacePattern = /^((?:\x1B(?:\[[0-9;:]*[@-~]|\][^\x1B\x07]*(?:\x1B\\|\x07)))*)[^\S\n]+/;
|
|
55
|
+
/**
|
|
56
|
+
* Removes the whitespace that begins a text's first line, keeping any
|
|
57
|
+
* escape sequences before it. Used when layout moves text that starts with
|
|
58
|
+
* a separating space to a fresh line.
|
|
59
|
+
* @param text Rendered text, possibly containing ANSI styles or OSC links.
|
|
60
|
+
* @returns The text without its leading whitespace.
|
|
61
|
+
* @internal
|
|
62
|
+
*/
|
|
63
|
+
function trimLeadingSpace(text) {
|
|
64
|
+
return text.replace(leadingSpacePattern, "$1");
|
|
65
|
+
}
|
|
54
66
|
/**
|
|
55
67
|
* Measures an annotation's fixed text without invoking theme callbacks.
|
|
56
68
|
* @param prefix The already joined prefix and optional label.
|
|
@@ -84,4 +96,5 @@ function spaceAfterLabel(label) {
|
|
|
84
96
|
exports.measureAnnotation = measureAnnotation;
|
|
85
97
|
exports.measureText = measureText;
|
|
86
98
|
exports.placeText = placeText;
|
|
87
|
-
exports.spaceAfterLabel = spaceAfterLabel;
|
|
99
|
+
exports.spaceAfterLabel = spaceAfterLabel;
|
|
100
|
+
exports.trimLeadingSpace = trimLeadingSpace;
|
package/dist/text-layout.d.cts
CHANGED
|
@@ -41,7 +41,14 @@ declare function placeText(text: string, cursor: TextCursor, maxWidth?: number,
|
|
|
41
41
|
readonly text: string;
|
|
42
42
|
readonly cursor: TextCursor;
|
|
43
43
|
};
|
|
44
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* Removes the whitespace that begins a text's first line, keeping any
|
|
46
|
+
* escape sequences before it. Used when layout moves text that starts with
|
|
47
|
+
* a separating space to a fresh line.
|
|
48
|
+
* @param text Rendered text, possibly containing ANSI styles or OSC links.
|
|
49
|
+
* @returns The text without its leading whitespace.
|
|
50
|
+
* @internal
|
|
51
|
+
*/
|
|
45
52
|
|
|
46
53
|
/**
|
|
47
54
|
* Adds a separating space only when a label occupies its final physical line.
|
package/dist/text-layout.d.ts
CHANGED
|
@@ -41,7 +41,14 @@ declare function placeText(text: string, cursor: TextCursor, maxWidth?: number,
|
|
|
41
41
|
readonly text: string;
|
|
42
42
|
readonly cursor: TextCursor;
|
|
43
43
|
};
|
|
44
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* Removes the whitespace that begins a text's first line, keeping any
|
|
46
|
+
* escape sequences before it. Used when layout moves text that starts with
|
|
47
|
+
* a separating space to a fresh line.
|
|
48
|
+
* @param text Rendered text, possibly containing ANSI styles or OSC links.
|
|
49
|
+
* @returns The text without its leading whitespace.
|
|
50
|
+
* @internal
|
|
51
|
+
*/
|
|
45
52
|
|
|
46
53
|
/**
|
|
47
54
|
* Adds a separating space only when a label occupies its final physical line.
|
package/dist/text-layout.js
CHANGED
|
@@ -51,6 +51,18 @@ function placeText(text, cursor, maxWidth, trailingRoom = 0) {
|
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
|
+
const leadingSpacePattern = /^((?:\x1B(?:\[[0-9;:]*[@-~]|\][^\x1B\x07]*(?:\x1B\\|\x07)))*)[^\S\n]+/;
|
|
55
|
+
/**
|
|
56
|
+
* Removes the whitespace that begins a text's first line, keeping any
|
|
57
|
+
* escape sequences before it. Used when layout moves text that starts with
|
|
58
|
+
* a separating space to a fresh line.
|
|
59
|
+
* @param text Rendered text, possibly containing ANSI styles or OSC links.
|
|
60
|
+
* @returns The text without its leading whitespace.
|
|
61
|
+
* @internal
|
|
62
|
+
*/
|
|
63
|
+
function trimLeadingSpace(text) {
|
|
64
|
+
return text.replace(leadingSpacePattern, "$1");
|
|
65
|
+
}
|
|
54
66
|
/**
|
|
55
67
|
* Measures an annotation's fixed text without invoking theme callbacks.
|
|
56
68
|
* @param prefix The already joined prefix and optional label.
|
|
@@ -81,4 +93,4 @@ function spaceAfterLabel(label) {
|
|
|
81
93
|
}
|
|
82
94
|
|
|
83
95
|
//#endregion
|
|
84
|
-
export { measureAnnotation, measureText, placeText, spaceAfterLabel };
|
|
96
|
+
export { measureAnnotation, measureText, placeText, spaceAfterLabel, trimLeadingSpace };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@optique/core",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.3",
|
|
4
4
|
"description": "Type-safe combinatorial command-line interface parser",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"CLI",
|
|
@@ -237,7 +237,7 @@
|
|
|
237
237
|
},
|
|
238
238
|
"sideEffects": false,
|
|
239
239
|
"devDependencies": {
|
|
240
|
-
"@optique/env": "1.3.
|
|
240
|
+
"@optique/env": "1.3.3",
|
|
241
241
|
"@types/node": "^24.0.0",
|
|
242
242
|
"fast-check": "^4.7.0",
|
|
243
243
|
"tsdown": "^0.13.0",
|