@optique/core 1.0.0-dev.1903 → 1.0.0-dev.1970
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/annotation-state.cjs +66 -31
- package/dist/annotation-state.d.cts +24 -0
- package/dist/annotation-state.d.ts +24 -0
- package/dist/annotation-state.js +65 -31
- package/dist/annotations.cjs +2 -267
- package/dist/annotations.d.cts +2 -152
- package/dist/annotations.d.ts +2 -152
- package/dist/annotations.js +2 -256
- package/dist/completion.d.cts +1 -1
- package/dist/completion.d.ts +1 -1
- package/dist/constructs.cjs +206 -238
- package/dist/constructs.d.cts +1 -1
- package/dist/constructs.d.ts +1 -1
- package/dist/constructs.js +96 -128
- package/dist/context.d.cts +1 -1
- package/dist/context.d.ts +1 -1
- package/dist/dependency-metadata.cjs +1 -1
- package/dist/dependency-metadata.d.cts +1 -1
- package/dist/dependency-metadata.d.ts +1 -1
- package/dist/dependency-metadata.js +1 -1
- package/dist/dependency-runtime.cjs +2 -2
- package/dist/dependency-runtime.js +2 -2
- package/dist/dependency.cjs +7 -1111
- package/dist/dependency.d.cts +2 -838
- package/dist/dependency.d.ts +2 -838
- package/dist/dependency.js +2 -1078
- package/dist/execution-context.cjs +56 -0
- package/dist/execution-context.js +53 -0
- package/dist/extension.cjs +87 -0
- package/dist/extension.d.cts +97 -0
- package/dist/extension.d.ts +97 -0
- package/dist/extension.js +76 -0
- package/dist/facade.cjs +19 -19
- package/dist/facade.d.cts +1 -1
- package/dist/facade.d.ts +1 -1
- package/dist/facade.js +19 -19
- package/dist/index.cjs +4 -41
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +5 -5
- package/dist/internal/annotations.cjs +316 -0
- package/dist/internal/annotations.d.cts +140 -0
- package/dist/internal/annotations.d.ts +140 -0
- package/dist/internal/annotations.js +306 -0
- package/dist/internal/dependency.cjs +984 -0
- package/dist/internal/dependency.d.cts +539 -0
- package/dist/internal/dependency.d.ts +539 -0
- package/dist/internal/dependency.js +964 -0
- package/dist/{mode-dispatch.cjs → internal/mode-dispatch.cjs} +1 -3
- package/dist/{mode-dispatch.d.cts → internal/mode-dispatch.d.cts} +3 -7
- package/dist/{mode-dispatch.d.ts → internal/mode-dispatch.d.ts} +3 -7
- package/dist/{mode-dispatch.js → internal/mode-dispatch.js} +1 -3
- package/dist/internal/parser.cjs +728 -0
- package/dist/internal/parser.d.cts +947 -0
- package/dist/internal/parser.d.ts +947 -0
- package/dist/internal/parser.js +711 -0
- package/dist/modifiers.cjs +67 -95
- package/dist/modifiers.d.cts +1 -1
- package/dist/modifiers.d.ts +1 -1
- package/dist/modifiers.js +51 -79
- package/dist/parser.cjs +11 -743
- package/dist/parser.d.cts +3 -991
- package/dist/parser.d.ts +3 -991
- package/dist/parser.js +2 -704
- package/dist/phase2-seed.cjs +4 -4
- package/dist/phase2-seed.js +4 -4
- package/dist/primitives.cjs +39 -74
- package/dist/primitives.d.cts +1 -1
- package/dist/primitives.d.ts +1 -1
- package/dist/primitives.js +26 -61
- package/dist/program.d.cts +1 -1
- package/dist/program.d.ts +1 -1
- package/dist/valueparser.cjs +23 -23
- package/dist/valueparser.d.cts +3 -3
- package/dist/valueparser.d.ts +3 -3
- package/dist/valueparser.js +23 -23
- package/package.json +9 -9
package/dist/valueparser.cjs
CHANGED
|
@@ -6,12 +6,12 @@ const require_nonempty = require('./nonempty.cjs');
|
|
|
6
6
|
* A predicate function that checks if an object is a {@link ValueParser}.
|
|
7
7
|
* @param object The object to check.
|
|
8
8
|
* @return `true` if the object is a {@link ValueParser}, `false` otherwise.
|
|
9
|
-
* @throws {TypeError} If the object looks like a value parser (has
|
|
9
|
+
* @throws {TypeError} If the object looks like a value parser (has `mode`,
|
|
10
10
|
* `metavar`, `parse`, and `format`) but is missing the required
|
|
11
11
|
* `placeholder` property.
|
|
12
12
|
*/
|
|
13
13
|
function isValueParser(object) {
|
|
14
|
-
if (typeof object !== "object" || object == null || !("
|
|
14
|
+
if (typeof object !== "object" || object == null || !("mode" in object) || object.mode !== "sync" && object.mode !== "async") return false;
|
|
15
15
|
const hasMetavar = "metavar" in object && typeof object.metavar === "string";
|
|
16
16
|
const hasParse = "parse" in object && typeof object.parse === "function";
|
|
17
17
|
const hasFormat = "format" in object && typeof object.format === "function";
|
|
@@ -56,7 +56,7 @@ function choice(choices, options = {}) {
|
|
|
56
56
|
const numberStrings = numberChoices.map((v) => Object.is(v, -0) ? "-0" : String(v));
|
|
57
57
|
const frozenNumberChoices = Object.freeze(numberChoices);
|
|
58
58
|
return {
|
|
59
|
-
|
|
59
|
+
mode: "sync",
|
|
60
60
|
metavar,
|
|
61
61
|
placeholder: choices[0],
|
|
62
62
|
choices: frozenNumberChoices,
|
|
@@ -138,7 +138,7 @@ function choice(choices, options = {}) {
|
|
|
138
138
|
}
|
|
139
139
|
const stringInvalidChoice = stringOptions.errors?.invalidChoice;
|
|
140
140
|
return {
|
|
141
|
-
|
|
141
|
+
mode: "sync",
|
|
142
142
|
metavar,
|
|
143
143
|
placeholder: choices[0],
|
|
144
144
|
choices: stringChoices,
|
|
@@ -300,7 +300,7 @@ function string(options = {}) {
|
|
|
300
300
|
const patternFlags = options.pattern?.flags ?? null;
|
|
301
301
|
const patternMismatch = options.errors?.patternMismatch;
|
|
302
302
|
return {
|
|
303
|
-
|
|
303
|
+
mode: "sync",
|
|
304
304
|
metavar,
|
|
305
305
|
placeholder: options.placeholder ?? "",
|
|
306
306
|
parse(input) {
|
|
@@ -373,7 +373,7 @@ function integer(options) {
|
|
|
373
373
|
const metavar$1 = options.metavar ?? "INTEGER";
|
|
374
374
|
require_nonempty.ensureNonEmptyString(metavar$1);
|
|
375
375
|
return {
|
|
376
|
-
|
|
376
|
+
mode: "sync",
|
|
377
377
|
metavar: metavar$1,
|
|
378
378
|
placeholder: options?.placeholder ?? (options?.min != null && options.min > 0n ? options.min : options?.max != null && options.max < 0n ? options.max : 0n),
|
|
379
379
|
parse(input) {
|
|
@@ -417,7 +417,7 @@ function integer(options) {
|
|
|
417
417
|
};
|
|
418
418
|
}
|
|
419
419
|
return {
|
|
420
|
-
|
|
420
|
+
mode: "sync",
|
|
421
421
|
metavar,
|
|
422
422
|
placeholder: options?.placeholder ?? (firstAllowed > 0 ? firstAllowed : lastAllowed < 0 ? lastAllowed : 0),
|
|
423
423
|
parse(input) {
|
|
@@ -468,7 +468,7 @@ function float(options = {}) {
|
|
|
468
468
|
const metavar = options.metavar ?? "NUMBER";
|
|
469
469
|
require_nonempty.ensureNonEmptyString(metavar);
|
|
470
470
|
return {
|
|
471
|
-
|
|
471
|
+
mode: "sync",
|
|
472
472
|
metavar,
|
|
473
473
|
placeholder: options?.placeholder ?? (options?.min != null && options.min > 0 ? options.min : options?.max != null && options.max < 0 ? options.max : 0),
|
|
474
474
|
parse(input) {
|
|
@@ -553,7 +553,7 @@ function url(options = {}) {
|
|
|
553
553
|
const invalidUrl = options.errors?.invalidUrl;
|
|
554
554
|
const disallowedProtocol = options.errors?.disallowedProtocol;
|
|
555
555
|
return {
|
|
556
|
-
|
|
556
|
+
mode: "sync",
|
|
557
557
|
metavar,
|
|
558
558
|
get placeholder() {
|
|
559
559
|
return new URL(`${allowedProtocols?.[0] ?? "http:"}//0.invalid`);
|
|
@@ -625,7 +625,7 @@ function locale(options = {}) {
|
|
|
625
625
|
const metavar = options.metavar ?? "LOCALE";
|
|
626
626
|
require_nonempty.ensureNonEmptyString(metavar);
|
|
627
627
|
return {
|
|
628
|
-
|
|
628
|
+
mode: "sync",
|
|
629
629
|
metavar,
|
|
630
630
|
placeholder: new Intl.Locale("und"),
|
|
631
631
|
parse(input) {
|
|
@@ -921,7 +921,7 @@ function uuid(options = {}) {
|
|
|
921
921
|
const disallowedVersion = options.errors?.disallowedVersion;
|
|
922
922
|
const invalidVariant = options.errors?.invalidVariant;
|
|
923
923
|
return {
|
|
924
|
-
|
|
924
|
+
mode: "sync",
|
|
925
925
|
metavar,
|
|
926
926
|
placeholder: "00000000-0000-0000-0000-000000000000",
|
|
927
927
|
parse(input) {
|
|
@@ -1029,7 +1029,7 @@ function port(options) {
|
|
|
1029
1029
|
if (min$1 > max$1) throw new RangeError(`Expected min to be less than or equal to max, but got min: ${min$1} and max: ${max$1}.`);
|
|
1030
1030
|
if (options.disallowWellKnown && min$1 < 1024n && max$1 < 1024n) throw new RangeError(`disallowWellKnown is incompatible with the configured port range: all ports ${min$1}..${max$1} are well-known.`);
|
|
1031
1031
|
return {
|
|
1032
|
-
|
|
1032
|
+
mode: "sync",
|
|
1033
1033
|
metavar: metavar$1,
|
|
1034
1034
|
placeholder: options.placeholder ?? (options.disallowWellKnown && min$1 < 1024n ? 1024n > min$1 ? 1024n : min$1 : min$1),
|
|
1035
1035
|
parse(input) {
|
|
@@ -1069,7 +1069,7 @@ function port(options) {
|
|
|
1069
1069
|
if (min > max) throw new RangeError(`Expected min to be less than or equal to max, but got min: ${min} and max: ${max}.`);
|
|
1070
1070
|
if (options?.disallowWellKnown && min < 1024 && max < 1024) throw new RangeError(`disallowWellKnown is incompatible with the configured port range: all ports ${min}..${max} are well-known.`);
|
|
1071
1071
|
return {
|
|
1072
|
-
|
|
1072
|
+
mode: "sync",
|
|
1073
1073
|
metavar,
|
|
1074
1074
|
placeholder: options?.placeholder ?? (options?.disallowWellKnown && min < 1024 ? Math.max(1024, min) : min),
|
|
1075
1075
|
parse(input) {
|
|
@@ -1163,7 +1163,7 @@ function ipv4(options) {
|
|
|
1163
1163
|
const allowBroadcast = options?.allowBroadcast ?? true;
|
|
1164
1164
|
const allowZero = options?.allowZero ?? true;
|
|
1165
1165
|
return {
|
|
1166
|
-
|
|
1166
|
+
mode: "sync",
|
|
1167
1167
|
metavar,
|
|
1168
1168
|
placeholder: allowZero ? "0.0.0.0" : allowLoopback ? "127.0.0.1" : "192.0.2.1",
|
|
1169
1169
|
parse(input) {
|
|
@@ -1280,7 +1280,7 @@ function hostname(options) {
|
|
|
1280
1280
|
const maxLength = options?.maxLength ?? 253;
|
|
1281
1281
|
if (!Number.isInteger(maxLength) || maxLength < 1) throw new RangeError("maxLength must be an integer greater than or equal to 1.");
|
|
1282
1282
|
return {
|
|
1283
|
-
|
|
1283
|
+
mode: "sync",
|
|
1284
1284
|
metavar,
|
|
1285
1285
|
placeholder: options?.placeholder ?? (allowLocalhost ? maxLength >= 9 ? "localhost" : "a.bc" : maxLength >= 11 ? "example.com" : "a.bc"),
|
|
1286
1286
|
parse(input) {
|
|
@@ -1500,7 +1500,7 @@ function email(options) {
|
|
|
1500
1500
|
return result;
|
|
1501
1501
|
}
|
|
1502
1502
|
return {
|
|
1503
|
-
|
|
1503
|
+
mode: "sync",
|
|
1504
1504
|
metavar,
|
|
1505
1505
|
placeholder: options?.placeholder ?? (options?.allowMultiple ? [`user@${options?.allowedDomains?.[0] ?? "example.com"}`] : `user@${options?.allowedDomains?.[0] ?? "example.com"}`),
|
|
1506
1506
|
parse(input) {
|
|
@@ -1735,7 +1735,7 @@ function socketAddress(options) {
|
|
|
1735
1735
|
}
|
|
1736
1736
|
}
|
|
1737
1737
|
return {
|
|
1738
|
-
|
|
1738
|
+
mode: "sync",
|
|
1739
1739
|
metavar,
|
|
1740
1740
|
get placeholder() {
|
|
1741
1741
|
return {
|
|
@@ -1973,7 +1973,7 @@ function portRange(options) {
|
|
|
1973
1973
|
errors: options?.errors
|
|
1974
1974
|
});
|
|
1975
1975
|
return {
|
|
1976
|
-
|
|
1976
|
+
mode: "sync",
|
|
1977
1977
|
metavar,
|
|
1978
1978
|
get placeholder() {
|
|
1979
1979
|
return isBigInt ? {
|
|
@@ -2181,7 +2181,7 @@ function macAddress(options) {
|
|
|
2181
2181
|
return joinOctets(octets, sep);
|
|
2182
2182
|
}
|
|
2183
2183
|
const parserObj = {
|
|
2184
|
-
|
|
2184
|
+
mode: "sync",
|
|
2185
2185
|
metavar,
|
|
2186
2186
|
get placeholder() {
|
|
2187
2187
|
const octets = [
|
|
@@ -2374,7 +2374,7 @@ function domain(options) {
|
|
|
2374
2374
|
const subdomainsNotAllowed = options?.errors?.subdomainsNotAllowed;
|
|
2375
2375
|
const tldNotAllowed = options?.errors?.tldNotAllowed;
|
|
2376
2376
|
const domainParserObj = {
|
|
2377
|
-
|
|
2377
|
+
mode: "sync",
|
|
2378
2378
|
metavar,
|
|
2379
2379
|
placeholder: options?.placeholder ?? `example.${allowedTldsLower?.[0] ?? "com"}`,
|
|
2380
2380
|
parse(input) {
|
|
@@ -2658,7 +2658,7 @@ function ipv6(options) {
|
|
|
2658
2658
|
const errors = options?.errors;
|
|
2659
2659
|
const metavar = options?.metavar ?? "IPV6";
|
|
2660
2660
|
const ipv6ParserObj = {
|
|
2661
|
-
|
|
2661
|
+
mode: "sync",
|
|
2662
2662
|
metavar,
|
|
2663
2663
|
placeholder: allowZero ? "::" : allowLoopback ? "::1" : "2001:db8::1",
|
|
2664
2664
|
parse(input) {
|
|
@@ -3137,7 +3137,7 @@ function ip(options) {
|
|
|
3137
3137
|
zeroNotAllowed: errors?.zeroNotAllowed
|
|
3138
3138
|
} : void 0;
|
|
3139
3139
|
const ipParserObj = {
|
|
3140
|
-
|
|
3140
|
+
mode: "sync",
|
|
3141
3141
|
metavar,
|
|
3142
3142
|
placeholder: version === 6 ? ipv6Parser.placeholder : ipv4Parser.placeholder,
|
|
3143
3143
|
parse(input) {
|
|
@@ -3316,7 +3316,7 @@ function cidr(options) {
|
|
|
3316
3316
|
zeroNotAllowed: errors?.zeroNotAllowed
|
|
3317
3317
|
} : void 0;
|
|
3318
3318
|
const cidrParserObj = {
|
|
3319
|
-
|
|
3319
|
+
mode: "sync",
|
|
3320
3320
|
metavar,
|
|
3321
3321
|
get placeholder() {
|
|
3322
3322
|
return version === 6 || version === "both" && (minPrefix ?? 0) > 32 ? {
|
package/dist/valueparser.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NonEmptyString, ensureNonEmptyString, isNonEmptyString } from "./nonempty.cjs";
|
|
2
2
|
import { Message } from "./message.cjs";
|
|
3
|
-
import { Mode, ModeIterable, ModeValue, Suggestion } from "./parser.cjs";
|
|
3
|
+
import { Mode, ModeIterable, ModeValue, Suggestion } from "./internal/parser.cjs";
|
|
4
4
|
|
|
5
5
|
//#region src/valueparser.d.ts
|
|
6
6
|
|
|
@@ -23,7 +23,7 @@ interface ValueParser<M extends Mode = "sync", T = unknown> {
|
|
|
23
23
|
*
|
|
24
24
|
* @since 0.9.0
|
|
25
25
|
*/
|
|
26
|
-
readonly
|
|
26
|
+
readonly mode: M;
|
|
27
27
|
/**
|
|
28
28
|
* The metavariable name for this parser. Used in help messages
|
|
29
29
|
* to indicate what kind of value this parser expects. Usually
|
|
@@ -279,7 +279,7 @@ type ChoiceOptions = ChoiceOptionsString;
|
|
|
279
279
|
* A predicate function that checks if an object is a {@link ValueParser}.
|
|
280
280
|
* @param object The object to check.
|
|
281
281
|
* @return `true` if the object is a {@link ValueParser}, `false` otherwise.
|
|
282
|
-
* @throws {TypeError} If the object looks like a value parser (has
|
|
282
|
+
* @throws {TypeError} If the object looks like a value parser (has `mode`,
|
|
283
283
|
* `metavar`, `parse`, and `format`) but is missing the required
|
|
284
284
|
* `placeholder` property.
|
|
285
285
|
*/
|
package/dist/valueparser.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NonEmptyString, ensureNonEmptyString, isNonEmptyString } from "./nonempty.js";
|
|
2
2
|
import { Message } from "./message.js";
|
|
3
|
-
import { Mode, ModeIterable, ModeValue, Suggestion } from "./parser.js";
|
|
3
|
+
import { Mode, ModeIterable, ModeValue, Suggestion } from "./internal/parser.js";
|
|
4
4
|
|
|
5
5
|
//#region src/valueparser.d.ts
|
|
6
6
|
|
|
@@ -23,7 +23,7 @@ interface ValueParser<M extends Mode = "sync", T = unknown> {
|
|
|
23
23
|
*
|
|
24
24
|
* @since 0.9.0
|
|
25
25
|
*/
|
|
26
|
-
readonly
|
|
26
|
+
readonly mode: M;
|
|
27
27
|
/**
|
|
28
28
|
* The metavariable name for this parser. Used in help messages
|
|
29
29
|
* to indicate what kind of value this parser expects. Usually
|
|
@@ -279,7 +279,7 @@ type ChoiceOptions = ChoiceOptionsString;
|
|
|
279
279
|
* A predicate function that checks if an object is a {@link ValueParser}.
|
|
280
280
|
* @param object The object to check.
|
|
281
281
|
* @return `true` if the object is a {@link ValueParser}, `false` otherwise.
|
|
282
|
-
* @throws {TypeError} If the object looks like a value parser (has
|
|
282
|
+
* @throws {TypeError} If the object looks like a value parser (has `mode`,
|
|
283
283
|
* `metavar`, `parse`, and `format`) but is missing the required
|
|
284
284
|
* `placeholder` property.
|
|
285
285
|
*/
|
package/dist/valueparser.js
CHANGED
|
@@ -6,12 +6,12 @@ import { ensureNonEmptyString, isNonEmptyString } from "./nonempty.js";
|
|
|
6
6
|
* A predicate function that checks if an object is a {@link ValueParser}.
|
|
7
7
|
* @param object The object to check.
|
|
8
8
|
* @return `true` if the object is a {@link ValueParser}, `false` otherwise.
|
|
9
|
-
* @throws {TypeError} If the object looks like a value parser (has
|
|
9
|
+
* @throws {TypeError} If the object looks like a value parser (has `mode`,
|
|
10
10
|
* `metavar`, `parse`, and `format`) but is missing the required
|
|
11
11
|
* `placeholder` property.
|
|
12
12
|
*/
|
|
13
13
|
function isValueParser(object) {
|
|
14
|
-
if (typeof object !== "object" || object == null || !("
|
|
14
|
+
if (typeof object !== "object" || object == null || !("mode" in object) || object.mode !== "sync" && object.mode !== "async") return false;
|
|
15
15
|
const hasMetavar = "metavar" in object && typeof object.metavar === "string";
|
|
16
16
|
const hasParse = "parse" in object && typeof object.parse === "function";
|
|
17
17
|
const hasFormat = "format" in object && typeof object.format === "function";
|
|
@@ -56,7 +56,7 @@ function choice(choices, options = {}) {
|
|
|
56
56
|
const numberStrings = numberChoices.map((v) => Object.is(v, -0) ? "-0" : String(v));
|
|
57
57
|
const frozenNumberChoices = Object.freeze(numberChoices);
|
|
58
58
|
return {
|
|
59
|
-
|
|
59
|
+
mode: "sync",
|
|
60
60
|
metavar,
|
|
61
61
|
placeholder: choices[0],
|
|
62
62
|
choices: frozenNumberChoices,
|
|
@@ -138,7 +138,7 @@ function choice(choices, options = {}) {
|
|
|
138
138
|
}
|
|
139
139
|
const stringInvalidChoice = stringOptions.errors?.invalidChoice;
|
|
140
140
|
return {
|
|
141
|
-
|
|
141
|
+
mode: "sync",
|
|
142
142
|
metavar,
|
|
143
143
|
placeholder: choices[0],
|
|
144
144
|
choices: stringChoices,
|
|
@@ -300,7 +300,7 @@ function string(options = {}) {
|
|
|
300
300
|
const patternFlags = options.pattern?.flags ?? null;
|
|
301
301
|
const patternMismatch = options.errors?.patternMismatch;
|
|
302
302
|
return {
|
|
303
|
-
|
|
303
|
+
mode: "sync",
|
|
304
304
|
metavar,
|
|
305
305
|
placeholder: options.placeholder ?? "",
|
|
306
306
|
parse(input) {
|
|
@@ -373,7 +373,7 @@ function integer(options) {
|
|
|
373
373
|
const metavar$1 = options.metavar ?? "INTEGER";
|
|
374
374
|
ensureNonEmptyString(metavar$1);
|
|
375
375
|
return {
|
|
376
|
-
|
|
376
|
+
mode: "sync",
|
|
377
377
|
metavar: metavar$1,
|
|
378
378
|
placeholder: options?.placeholder ?? (options?.min != null && options.min > 0n ? options.min : options?.max != null && options.max < 0n ? options.max : 0n),
|
|
379
379
|
parse(input) {
|
|
@@ -417,7 +417,7 @@ function integer(options) {
|
|
|
417
417
|
};
|
|
418
418
|
}
|
|
419
419
|
return {
|
|
420
|
-
|
|
420
|
+
mode: "sync",
|
|
421
421
|
metavar,
|
|
422
422
|
placeholder: options?.placeholder ?? (firstAllowed > 0 ? firstAllowed : lastAllowed < 0 ? lastAllowed : 0),
|
|
423
423
|
parse(input) {
|
|
@@ -468,7 +468,7 @@ function float(options = {}) {
|
|
|
468
468
|
const metavar = options.metavar ?? "NUMBER";
|
|
469
469
|
ensureNonEmptyString(metavar);
|
|
470
470
|
return {
|
|
471
|
-
|
|
471
|
+
mode: "sync",
|
|
472
472
|
metavar,
|
|
473
473
|
placeholder: options?.placeholder ?? (options?.min != null && options.min > 0 ? options.min : options?.max != null && options.max < 0 ? options.max : 0),
|
|
474
474
|
parse(input) {
|
|
@@ -553,7 +553,7 @@ function url(options = {}) {
|
|
|
553
553
|
const invalidUrl = options.errors?.invalidUrl;
|
|
554
554
|
const disallowedProtocol = options.errors?.disallowedProtocol;
|
|
555
555
|
return {
|
|
556
|
-
|
|
556
|
+
mode: "sync",
|
|
557
557
|
metavar,
|
|
558
558
|
get placeholder() {
|
|
559
559
|
return new URL(`${allowedProtocols?.[0] ?? "http:"}//0.invalid`);
|
|
@@ -625,7 +625,7 @@ function locale(options = {}) {
|
|
|
625
625
|
const metavar = options.metavar ?? "LOCALE";
|
|
626
626
|
ensureNonEmptyString(metavar);
|
|
627
627
|
return {
|
|
628
|
-
|
|
628
|
+
mode: "sync",
|
|
629
629
|
metavar,
|
|
630
630
|
placeholder: new Intl.Locale("und"),
|
|
631
631
|
parse(input) {
|
|
@@ -921,7 +921,7 @@ function uuid(options = {}) {
|
|
|
921
921
|
const disallowedVersion = options.errors?.disallowedVersion;
|
|
922
922
|
const invalidVariant = options.errors?.invalidVariant;
|
|
923
923
|
return {
|
|
924
|
-
|
|
924
|
+
mode: "sync",
|
|
925
925
|
metavar,
|
|
926
926
|
placeholder: "00000000-0000-0000-0000-000000000000",
|
|
927
927
|
parse(input) {
|
|
@@ -1029,7 +1029,7 @@ function port(options) {
|
|
|
1029
1029
|
if (min$1 > max$1) throw new RangeError(`Expected min to be less than or equal to max, but got min: ${min$1} and max: ${max$1}.`);
|
|
1030
1030
|
if (options.disallowWellKnown && min$1 < 1024n && max$1 < 1024n) throw new RangeError(`disallowWellKnown is incompatible with the configured port range: all ports ${min$1}..${max$1} are well-known.`);
|
|
1031
1031
|
return {
|
|
1032
|
-
|
|
1032
|
+
mode: "sync",
|
|
1033
1033
|
metavar: metavar$1,
|
|
1034
1034
|
placeholder: options.placeholder ?? (options.disallowWellKnown && min$1 < 1024n ? 1024n > min$1 ? 1024n : min$1 : min$1),
|
|
1035
1035
|
parse(input) {
|
|
@@ -1069,7 +1069,7 @@ function port(options) {
|
|
|
1069
1069
|
if (min > max) throw new RangeError(`Expected min to be less than or equal to max, but got min: ${min} and max: ${max}.`);
|
|
1070
1070
|
if (options?.disallowWellKnown && min < 1024 && max < 1024) throw new RangeError(`disallowWellKnown is incompatible with the configured port range: all ports ${min}..${max} are well-known.`);
|
|
1071
1071
|
return {
|
|
1072
|
-
|
|
1072
|
+
mode: "sync",
|
|
1073
1073
|
metavar,
|
|
1074
1074
|
placeholder: options?.placeholder ?? (options?.disallowWellKnown && min < 1024 ? Math.max(1024, min) : min),
|
|
1075
1075
|
parse(input) {
|
|
@@ -1163,7 +1163,7 @@ function ipv4(options) {
|
|
|
1163
1163
|
const allowBroadcast = options?.allowBroadcast ?? true;
|
|
1164
1164
|
const allowZero = options?.allowZero ?? true;
|
|
1165
1165
|
return {
|
|
1166
|
-
|
|
1166
|
+
mode: "sync",
|
|
1167
1167
|
metavar,
|
|
1168
1168
|
placeholder: allowZero ? "0.0.0.0" : allowLoopback ? "127.0.0.1" : "192.0.2.1",
|
|
1169
1169
|
parse(input) {
|
|
@@ -1280,7 +1280,7 @@ function hostname(options) {
|
|
|
1280
1280
|
const maxLength = options?.maxLength ?? 253;
|
|
1281
1281
|
if (!Number.isInteger(maxLength) || maxLength < 1) throw new RangeError("maxLength must be an integer greater than or equal to 1.");
|
|
1282
1282
|
return {
|
|
1283
|
-
|
|
1283
|
+
mode: "sync",
|
|
1284
1284
|
metavar,
|
|
1285
1285
|
placeholder: options?.placeholder ?? (allowLocalhost ? maxLength >= 9 ? "localhost" : "a.bc" : maxLength >= 11 ? "example.com" : "a.bc"),
|
|
1286
1286
|
parse(input) {
|
|
@@ -1500,7 +1500,7 @@ function email(options) {
|
|
|
1500
1500
|
return result;
|
|
1501
1501
|
}
|
|
1502
1502
|
return {
|
|
1503
|
-
|
|
1503
|
+
mode: "sync",
|
|
1504
1504
|
metavar,
|
|
1505
1505
|
placeholder: options?.placeholder ?? (options?.allowMultiple ? [`user@${options?.allowedDomains?.[0] ?? "example.com"}`] : `user@${options?.allowedDomains?.[0] ?? "example.com"}`),
|
|
1506
1506
|
parse(input) {
|
|
@@ -1735,7 +1735,7 @@ function socketAddress(options) {
|
|
|
1735
1735
|
}
|
|
1736
1736
|
}
|
|
1737
1737
|
return {
|
|
1738
|
-
|
|
1738
|
+
mode: "sync",
|
|
1739
1739
|
metavar,
|
|
1740
1740
|
get placeholder() {
|
|
1741
1741
|
return {
|
|
@@ -1973,7 +1973,7 @@ function portRange(options) {
|
|
|
1973
1973
|
errors: options?.errors
|
|
1974
1974
|
});
|
|
1975
1975
|
return {
|
|
1976
|
-
|
|
1976
|
+
mode: "sync",
|
|
1977
1977
|
metavar,
|
|
1978
1978
|
get placeholder() {
|
|
1979
1979
|
return isBigInt ? {
|
|
@@ -2181,7 +2181,7 @@ function macAddress(options) {
|
|
|
2181
2181
|
return joinOctets(octets, sep);
|
|
2182
2182
|
}
|
|
2183
2183
|
const parserObj = {
|
|
2184
|
-
|
|
2184
|
+
mode: "sync",
|
|
2185
2185
|
metavar,
|
|
2186
2186
|
get placeholder() {
|
|
2187
2187
|
const octets = [
|
|
@@ -2374,7 +2374,7 @@ function domain(options) {
|
|
|
2374
2374
|
const subdomainsNotAllowed = options?.errors?.subdomainsNotAllowed;
|
|
2375
2375
|
const tldNotAllowed = options?.errors?.tldNotAllowed;
|
|
2376
2376
|
const domainParserObj = {
|
|
2377
|
-
|
|
2377
|
+
mode: "sync",
|
|
2378
2378
|
metavar,
|
|
2379
2379
|
placeholder: options?.placeholder ?? `example.${allowedTldsLower?.[0] ?? "com"}`,
|
|
2380
2380
|
parse(input) {
|
|
@@ -2658,7 +2658,7 @@ function ipv6(options) {
|
|
|
2658
2658
|
const errors = options?.errors;
|
|
2659
2659
|
const metavar = options?.metavar ?? "IPV6";
|
|
2660
2660
|
const ipv6ParserObj = {
|
|
2661
|
-
|
|
2661
|
+
mode: "sync",
|
|
2662
2662
|
metavar,
|
|
2663
2663
|
placeholder: allowZero ? "::" : allowLoopback ? "::1" : "2001:db8::1",
|
|
2664
2664
|
parse(input) {
|
|
@@ -3137,7 +3137,7 @@ function ip(options) {
|
|
|
3137
3137
|
zeroNotAllowed: errors?.zeroNotAllowed
|
|
3138
3138
|
} : void 0;
|
|
3139
3139
|
const ipParserObj = {
|
|
3140
|
-
|
|
3140
|
+
mode: "sync",
|
|
3141
3141
|
metavar,
|
|
3142
3142
|
placeholder: version === 6 ? ipv6Parser.placeholder : ipv4Parser.placeholder,
|
|
3143
3143
|
parse(input) {
|
|
@@ -3316,7 +3316,7 @@ function cidr(options) {
|
|
|
3316
3316
|
zeroNotAllowed: errors?.zeroNotAllowed
|
|
3317
3317
|
} : void 0;
|
|
3318
3318
|
const cidrParserObj = {
|
|
3319
|
-
|
|
3319
|
+
mode: "sync",
|
|
3320
3320
|
metavar,
|
|
3321
3321
|
get placeholder() {
|
|
3322
3322
|
return version === 6 || version === "both" && (minPrefix ?? 0) > 32 ? {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@optique/core",
|
|
3
|
-
"version": "1.0.0-dev.
|
|
3
|
+
"version": "1.0.0-dev.1970+0182ae32",
|
|
4
4
|
"description": "Type-safe combinatorial command-line interface parser",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"CLI",
|
|
@@ -99,6 +99,14 @@
|
|
|
99
99
|
"import": "./dist/doc.js",
|
|
100
100
|
"require": "./dist/doc.cjs"
|
|
101
101
|
},
|
|
102
|
+
"./extension": {
|
|
103
|
+
"types": {
|
|
104
|
+
"import": "./dist/extension.d.ts",
|
|
105
|
+
"require": "./dist/extension.d.cts"
|
|
106
|
+
},
|
|
107
|
+
"import": "./dist/extension.js",
|
|
108
|
+
"require": "./dist/extension.cjs"
|
|
109
|
+
},
|
|
102
110
|
"./facade": {
|
|
103
111
|
"types": {
|
|
104
112
|
"import": "./dist/facade.d.ts",
|
|
@@ -115,14 +123,6 @@
|
|
|
115
123
|
"import": "./dist/message.js",
|
|
116
124
|
"require": "./dist/message.cjs"
|
|
117
125
|
},
|
|
118
|
-
"./mode-dispatch": {
|
|
119
|
-
"types": {
|
|
120
|
-
"import": "./dist/mode-dispatch.d.ts",
|
|
121
|
-
"require": "./dist/mode-dispatch.d.cts"
|
|
122
|
-
},
|
|
123
|
-
"import": "./dist/mode-dispatch.js",
|
|
124
|
-
"require": "./dist/mode-dispatch.cjs"
|
|
125
|
-
},
|
|
126
126
|
"./modifiers": {
|
|
127
127
|
"types": {
|
|
128
128
|
"import": "./dist/modifiers.d.ts",
|