@optique/core 1.0.0-dev.1596 → 1.0.0-dev.1602
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/dependency-metadata.cjs +140 -0
- package/dist/dependency-metadata.d.cts +108 -0
- package/dist/dependency-metadata.d.ts +108 -0
- package/dist/dependency-metadata.js +139 -0
- package/dist/dependency-runtime.d.cts +123 -0
- package/dist/dependency-runtime.d.ts +123 -0
- package/dist/dependency.cjs +14 -0
- package/dist/dependency.d.cts +19 -1
- package/dist/dependency.d.ts +19 -1
- package/dist/dependency.js +14 -1
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/modifiers.cjs +64 -0
- package/dist/modifiers.js +64 -0
- package/dist/parser.d.cts +17 -0
- package/dist/parser.d.ts +17 -0
- package/dist/primitives.cjs +7 -0
- package/dist/primitives.js +7 -0
- package/dist/valueparser.cjs +10 -14
- package/dist/valueparser.js +10 -14
- package/package.json +1 -1
package/dist/parser.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ import { Usage } from "./usage.js";
|
|
|
4
4
|
import { DocFragments, DocPage } from "./doc.js";
|
|
5
5
|
import { DependencyRegistryLike } from "./registry-types.js";
|
|
6
6
|
import { DeferredMap, ValueParserResult } from "./valueparser.js";
|
|
7
|
+
import { ParserDependencyMetadata } from "./dependency-metadata.js";
|
|
8
|
+
import { DependencyRuntimeContext } from "./dependency-runtime.js";
|
|
7
9
|
import { ConditionalErrorOptions, ConditionalOptions, DuplicateOptionError, GroupOptions, LongestMatchErrorOptions, LongestMatchOptions, MergeOptions, NoMatchContext, ObjectErrorOptions, ObjectOptions, OrErrorOptions, OrOptions, TupleOptions, concat, conditional, group, longestMatch, merge, object, or, tuple } from "./constructs.js";
|
|
8
10
|
import { MultipleErrorOptions, MultipleOptions, WithDefaultError, WithDefaultOptions, map, multiple, nonEmpty, optional, withDefault } from "./modifiers.js";
|
|
9
11
|
import { ArgumentErrorOptions, ArgumentOptions, CommandErrorOptions, CommandOptions, FlagErrorOptions, FlagOptions, OptionErrorOptions, OptionOptions, OptionState, PassThroughFormat, PassThroughOptions, argument, command, constant, fail, flag, option, passThrough } from "./primitives.js";
|
|
@@ -251,6 +253,14 @@ interface Parser<M extends Mode = "sync", TValue = unknown, TState = unknown> {
|
|
|
251
253
|
* @since 1.0.0
|
|
252
254
|
*/
|
|
253
255
|
normalizeValue?(value: TValue): TValue;
|
|
256
|
+
/**
|
|
257
|
+
* Internal dependency metadata describing this parser's dependency
|
|
258
|
+
* capabilities. Used by the dependency runtime to resolve dependencies
|
|
259
|
+
* without relying on state-shape protocols.
|
|
260
|
+
* @internal
|
|
261
|
+
* @since 1.0.0
|
|
262
|
+
*/
|
|
263
|
+
readonly dependencyMetadata?: ParserDependencyMetadata;
|
|
254
264
|
}
|
|
255
265
|
/**
|
|
256
266
|
* Parser-local frame data containing the input buffer and parser state.
|
|
@@ -308,6 +318,13 @@ interface ExecutionContext {
|
|
|
308
318
|
* @since 0.10.0
|
|
309
319
|
*/
|
|
310
320
|
readonly dependencyRegistry?: DependencyRegistryLike;
|
|
321
|
+
/**
|
|
322
|
+
* The dependency runtime context for dependency resolution.
|
|
323
|
+
* Coexists with `dependencyRegistry` during the transition period.
|
|
324
|
+
* @internal
|
|
325
|
+
* @since 1.0.0
|
|
326
|
+
*/
|
|
327
|
+
readonly dependencyRuntime?: DependencyRuntimeContext;
|
|
311
328
|
}
|
|
312
329
|
/**
|
|
313
330
|
* The context of the parser, which includes the input buffer and the state.
|
package/dist/primitives.cjs
CHANGED
|
@@ -6,6 +6,7 @@ const require_validate = require('./validate.cjs');
|
|
|
6
6
|
const require_usage = require('./usage.cjs');
|
|
7
7
|
const require_suggestion = require('./suggestion.cjs');
|
|
8
8
|
const require_usage_internals = require('./usage-internals.cjs');
|
|
9
|
+
const require_dependency_metadata = require('./dependency-metadata.cjs');
|
|
9
10
|
const require_valueparser = require('./valueparser.cjs');
|
|
10
11
|
|
|
11
12
|
//#region src/primitives.ts
|
|
@@ -598,6 +599,10 @@ function option(...args) {
|
|
|
598
599
|
enumerable: false,
|
|
599
600
|
writable: false
|
|
600
601
|
});
|
|
602
|
+
if (valueParser != null) {
|
|
603
|
+
const depMeta = require_dependency_metadata.extractDependencyMetadata(valueParser);
|
|
604
|
+
if (depMeta != null) result.dependencyMetadata = depMeta;
|
|
605
|
+
}
|
|
601
606
|
return result;
|
|
602
607
|
}
|
|
603
608
|
/**
|
|
@@ -963,6 +968,8 @@ function argument(valueParser, options = {}) {
|
|
|
963
968
|
configurable: true,
|
|
964
969
|
enumerable: false
|
|
965
970
|
});
|
|
971
|
+
const depMeta = require_dependency_metadata.extractDependencyMetadata(valueParser);
|
|
972
|
+
if (depMeta != null) result.dependencyMetadata = depMeta;
|
|
966
973
|
return result;
|
|
967
974
|
}
|
|
968
975
|
function* suggestCommandSync(context, prefix, name, parser, options) {
|
package/dist/primitives.js
CHANGED
|
@@ -6,6 +6,7 @@ import { validateCommandNames, validateOptionNames } from "./validate.js";
|
|
|
6
6
|
import { extractOptionNames, isDocHidden, isSuggestionHidden } from "./usage.js";
|
|
7
7
|
import { DEFAULT_FIND_SIMILAR_OPTIONS, createErrorWithSuggestions, createSuggestionMessage, findSimilar } from "./suggestion.js";
|
|
8
8
|
import { extractLeadingCommandNames } from "./usage-internals.js";
|
|
9
|
+
import { extractDependencyMetadata } from "./dependency-metadata.js";
|
|
9
10
|
import { isValueParser } from "./valueparser.js";
|
|
10
11
|
|
|
11
12
|
//#region src/primitives.ts
|
|
@@ -598,6 +599,10 @@ function option(...args) {
|
|
|
598
599
|
enumerable: false,
|
|
599
600
|
writable: false
|
|
600
601
|
});
|
|
602
|
+
if (valueParser != null) {
|
|
603
|
+
const depMeta = extractDependencyMetadata(valueParser);
|
|
604
|
+
if (depMeta != null) result.dependencyMetadata = depMeta;
|
|
605
|
+
}
|
|
601
606
|
return result;
|
|
602
607
|
}
|
|
603
608
|
/**
|
|
@@ -963,6 +968,8 @@ function argument(valueParser, options = {}) {
|
|
|
963
968
|
configurable: true,
|
|
964
969
|
enumerable: false
|
|
965
970
|
});
|
|
971
|
+
const depMeta = extractDependencyMetadata(valueParser);
|
|
972
|
+
if (depMeta != null) result.dependencyMetadata = depMeta;
|
|
966
973
|
return result;
|
|
967
974
|
}
|
|
968
975
|
function* suggestCommandSync(context, prefix, name, parser, options) {
|
package/dist/valueparser.cjs
CHANGED
|
@@ -1745,21 +1745,24 @@ function socketAddress(options) {
|
|
|
1745
1745
|
},
|
|
1746
1746
|
parse(input) {
|
|
1747
1747
|
const trimmed = input.trim();
|
|
1748
|
+
const searchInput = input.trimStart();
|
|
1748
1749
|
const canOmitPort = defaultPort !== void 0 && !requirePort;
|
|
1749
1750
|
let firstHostError;
|
|
1750
1751
|
let validHostInvalidPortError;
|
|
1751
1752
|
let trailingSepHost;
|
|
1752
1753
|
let trailingSepHostError;
|
|
1753
1754
|
let anySeparatorFound = false;
|
|
1754
|
-
let
|
|
1755
|
+
let trailingSepInTrimmedRegion = false;
|
|
1756
|
+
let searchFrom = searchInput.length;
|
|
1755
1757
|
while (searchFrom > 0) {
|
|
1756
|
-
const separatorIndex =
|
|
1758
|
+
const separatorIndex = searchInput.lastIndexOf(separator, searchFrom - 1);
|
|
1757
1759
|
if (separatorIndex === -1) break;
|
|
1758
1760
|
anySeparatorFound = true;
|
|
1759
|
-
const hostPart =
|
|
1760
|
-
const portPart =
|
|
1761
|
+
const hostPart = searchInput.substring(0, separatorIndex).trim();
|
|
1762
|
+
const portPart = searchInput.substring(separatorIndex + separator.length).trim();
|
|
1761
1763
|
if (portPart === "") {
|
|
1762
1764
|
if (trailingSepHost === void 0 && trailingSepHostError === void 0) {
|
|
1765
|
+
if (separatorIndex + separator.length > trimmed.length) trailingSepInTrimmedRegion = true;
|
|
1763
1766
|
const hostResult = parseHost(hostPart);
|
|
1764
1767
|
if (hostResult.success) trailingSepHost = hostResult.value;
|
|
1765
1768
|
else trailingSepHostError = {
|
|
@@ -1856,7 +1859,7 @@ function socketAddress(options) {
|
|
|
1856
1859
|
let hostOnlyResult;
|
|
1857
1860
|
if (!requirePort || trailingSepHost !== void 0 || trailingSepHostError !== void 0) {
|
|
1858
1861
|
hostOnlyResult = parseHost(trimmed);
|
|
1859
|
-
if (canOmitPort && hostOnlyResult.success) return {
|
|
1862
|
+
if (canOmitPort && hostOnlyResult.success && !trailingSepInTrimmedRegion) return {
|
|
1860
1863
|
success: true,
|
|
1861
1864
|
value: {
|
|
1862
1865
|
host: hostOnlyResult.value,
|
|
@@ -1864,14 +1867,7 @@ function socketAddress(options) {
|
|
|
1864
1867
|
}
|
|
1865
1868
|
};
|
|
1866
1869
|
}
|
|
1867
|
-
if (trailingSepHost !== void 0 && hostOnlyResult !== void 0 && !hostOnlyResult.success) {
|
|
1868
|
-
if (canOmitPort) return {
|
|
1869
|
-
success: true,
|
|
1870
|
-
value: {
|
|
1871
|
-
host: trailingSepHost,
|
|
1872
|
-
port: defaultPort
|
|
1873
|
-
}
|
|
1874
|
-
};
|
|
1870
|
+
if (trailingSepHost !== void 0 && hostOnlyResult !== void 0 && (!hostOnlyResult.success || trailingSepInTrimmedRegion)) {
|
|
1875
1871
|
const errorMsg$1 = options?.errors?.missingPort;
|
|
1876
1872
|
const msg = typeof errorMsg$1 === "function" ? errorMsg$1(input) : errorMsg$1 ?? require_message.message`Port number is required but was not specified.`;
|
|
1877
1873
|
return {
|
|
@@ -1879,7 +1875,7 @@ function socketAddress(options) {
|
|
|
1879
1875
|
error: msg
|
|
1880
1876
|
};
|
|
1881
1877
|
}
|
|
1882
|
-
if (trailingSepHostError !== void 0 && hostOnlyResult !== void 0 && !hostOnlyResult.success) {
|
|
1878
|
+
if (trailingSepHostError !== void 0 && hostOnlyResult !== void 0 && (!hostOnlyResult.success || trailingSepInTrimmedRegion)) {
|
|
1883
1879
|
const errorMsg$1 = options?.errors?.invalidFormat;
|
|
1884
1880
|
if (errorMsg$1) {
|
|
1885
1881
|
const msg = typeof errorMsg$1 === "function" ? errorMsg$1(input) : errorMsg$1;
|
package/dist/valueparser.js
CHANGED
|
@@ -1745,21 +1745,24 @@ function socketAddress(options) {
|
|
|
1745
1745
|
},
|
|
1746
1746
|
parse(input) {
|
|
1747
1747
|
const trimmed = input.trim();
|
|
1748
|
+
const searchInput = input.trimStart();
|
|
1748
1749
|
const canOmitPort = defaultPort !== void 0 && !requirePort;
|
|
1749
1750
|
let firstHostError;
|
|
1750
1751
|
let validHostInvalidPortError;
|
|
1751
1752
|
let trailingSepHost;
|
|
1752
1753
|
let trailingSepHostError;
|
|
1753
1754
|
let anySeparatorFound = false;
|
|
1754
|
-
let
|
|
1755
|
+
let trailingSepInTrimmedRegion = false;
|
|
1756
|
+
let searchFrom = searchInput.length;
|
|
1755
1757
|
while (searchFrom > 0) {
|
|
1756
|
-
const separatorIndex =
|
|
1758
|
+
const separatorIndex = searchInput.lastIndexOf(separator, searchFrom - 1);
|
|
1757
1759
|
if (separatorIndex === -1) break;
|
|
1758
1760
|
anySeparatorFound = true;
|
|
1759
|
-
const hostPart =
|
|
1760
|
-
const portPart =
|
|
1761
|
+
const hostPart = searchInput.substring(0, separatorIndex).trim();
|
|
1762
|
+
const portPart = searchInput.substring(separatorIndex + separator.length).trim();
|
|
1761
1763
|
if (portPart === "") {
|
|
1762
1764
|
if (trailingSepHost === void 0 && trailingSepHostError === void 0) {
|
|
1765
|
+
if (separatorIndex + separator.length > trimmed.length) trailingSepInTrimmedRegion = true;
|
|
1763
1766
|
const hostResult = parseHost(hostPart);
|
|
1764
1767
|
if (hostResult.success) trailingSepHost = hostResult.value;
|
|
1765
1768
|
else trailingSepHostError = {
|
|
@@ -1856,7 +1859,7 @@ function socketAddress(options) {
|
|
|
1856
1859
|
let hostOnlyResult;
|
|
1857
1860
|
if (!requirePort || trailingSepHost !== void 0 || trailingSepHostError !== void 0) {
|
|
1858
1861
|
hostOnlyResult = parseHost(trimmed);
|
|
1859
|
-
if (canOmitPort && hostOnlyResult.success) return {
|
|
1862
|
+
if (canOmitPort && hostOnlyResult.success && !trailingSepInTrimmedRegion) return {
|
|
1860
1863
|
success: true,
|
|
1861
1864
|
value: {
|
|
1862
1865
|
host: hostOnlyResult.value,
|
|
@@ -1864,14 +1867,7 @@ function socketAddress(options) {
|
|
|
1864
1867
|
}
|
|
1865
1868
|
};
|
|
1866
1869
|
}
|
|
1867
|
-
if (trailingSepHost !== void 0 && hostOnlyResult !== void 0 && !hostOnlyResult.success) {
|
|
1868
|
-
if (canOmitPort) return {
|
|
1869
|
-
success: true,
|
|
1870
|
-
value: {
|
|
1871
|
-
host: trailingSepHost,
|
|
1872
|
-
port: defaultPort
|
|
1873
|
-
}
|
|
1874
|
-
};
|
|
1870
|
+
if (trailingSepHost !== void 0 && hostOnlyResult !== void 0 && (!hostOnlyResult.success || trailingSepInTrimmedRegion)) {
|
|
1875
1871
|
const errorMsg$1 = options?.errors?.missingPort;
|
|
1876
1872
|
const msg = typeof errorMsg$1 === "function" ? errorMsg$1(input) : errorMsg$1 ?? message`Port number is required but was not specified.`;
|
|
1877
1873
|
return {
|
|
@@ -1879,7 +1875,7 @@ function socketAddress(options) {
|
|
|
1879
1875
|
error: msg
|
|
1880
1876
|
};
|
|
1881
1877
|
}
|
|
1882
|
-
if (trailingSepHostError !== void 0 && hostOnlyResult !== void 0 && !hostOnlyResult.success) {
|
|
1878
|
+
if (trailingSepHostError !== void 0 && hostOnlyResult !== void 0 && (!hostOnlyResult.success || trailingSepInTrimmedRegion)) {
|
|
1883
1879
|
const errorMsg$1 = options?.errors?.invalidFormat;
|
|
1884
1880
|
if (errorMsg$1) {
|
|
1885
1881
|
const msg = typeof errorMsg$1 === "function" ? errorMsg$1(input) : errorMsg$1;
|