@optique/core 1.2.0-dev.2318 → 1.2.0-dev.2322
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/valueparser.cjs +10 -5
- package/dist/valueparser.js +12 -7
- package/package.json +2 -2
package/dist/valueparser.cjs
CHANGED
|
@@ -24,7 +24,11 @@ function transformValueParserResult(result, mapping) {
|
|
|
24
24
|
deferred: true
|
|
25
25
|
});
|
|
26
26
|
} catch {
|
|
27
|
-
return preserveSnapshot(
|
|
27
|
+
return preserveSnapshot({
|
|
28
|
+
success: true,
|
|
29
|
+
value: void 0,
|
|
30
|
+
deferred: true
|
|
31
|
+
});
|
|
28
32
|
}
|
|
29
33
|
try {
|
|
30
34
|
return preserveSnapshot({
|
|
@@ -262,8 +266,6 @@ function biject(mapping) {
|
|
|
262
266
|
} catch {
|
|
263
267
|
input = "";
|
|
264
268
|
}
|
|
265
|
-
const result = source.parse(input);
|
|
266
|
-
if (!result.success) return result;
|
|
267
269
|
return {
|
|
268
270
|
success: false,
|
|
269
271
|
error: formatDefaultChoiceError(input, keys)
|
|
@@ -302,6 +304,7 @@ function biject(mapping) {
|
|
|
302
304
|
* @since 1.2.0
|
|
303
305
|
*/
|
|
304
306
|
function transform(parser, mapping) {
|
|
307
|
+
if (require_internal_dependency.isDependencySource(parser)) throw new TypeError("Cannot transform a dependency source directly.");
|
|
305
308
|
const normalize = parser.normalize?.bind(parser);
|
|
306
309
|
const suggest = parser.suggest?.bind(parser);
|
|
307
310
|
const transformedChoices = parser.choices == null ? void 0 : Object.freeze(parser.choices.map((choice$1) => mapping.map(choice$1)));
|
|
@@ -390,10 +393,12 @@ function transform(parser, mapping) {
|
|
|
390
393
|
value
|
|
391
394
|
};
|
|
392
395
|
}
|
|
396
|
+
if (typeof formatted !== "string") return transformMappingFailure();
|
|
393
397
|
let result;
|
|
394
398
|
try {
|
|
395
|
-
result = syncParser.parse(formatted);
|
|
396
|
-
} catch {
|
|
399
|
+
result = require_mode_dispatch.wrapForMode("sync", syncParser.parse(formatted));
|
|
400
|
+
} catch (error) {
|
|
401
|
+
if (error instanceof TypeError && error.message.includes("Promise")) throw error;
|
|
397
402
|
return transformMappingFailure();
|
|
398
403
|
}
|
|
399
404
|
if (!result.success) return result;
|
package/dist/valueparser.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { cloneMessage, lineBreak, message, metavar, text, valueSet } from "./message.js";
|
|
2
|
-
import { mapMaybePromiseByMode, wrapIterableForMode } from "./internal/mode-dispatch.js";
|
|
3
|
-
import { defaultValues, dependencyId, dependencyIds, derivedValueParserMarker, getSnapshottedDefaultDependencyValues, isDerivedValueParser, parseWithDependency, singleDefaultValue, snapshotDefaultDependencyValues, suggestWithDependency } from "./internal/dependency.js";
|
|
2
|
+
import { mapMaybePromiseByMode, wrapForMode, wrapIterableForMode } from "./internal/mode-dispatch.js";
|
|
3
|
+
import { defaultValues, dependencyId, dependencyIds, derivedValueParserMarker, getSnapshottedDefaultDependencyValues, isDependencySource, isDerivedValueParser, parseWithDependency, singleDefaultValue, snapshotDefaultDependencyValues, suggestWithDependency } from "./internal/dependency.js";
|
|
4
4
|
import { appendValueHint, appendValueSuggestions, deduplicateSuggestions } from "./suggestion.js";
|
|
5
5
|
import { ensureNonEmptyString, isNonEmptyString } from "./nonempty.js";
|
|
6
6
|
|
|
@@ -24,7 +24,11 @@ function transformValueParserResult(result, mapping) {
|
|
|
24
24
|
deferred: true
|
|
25
25
|
});
|
|
26
26
|
} catch {
|
|
27
|
-
return preserveSnapshot(
|
|
27
|
+
return preserveSnapshot({
|
|
28
|
+
success: true,
|
|
29
|
+
value: void 0,
|
|
30
|
+
deferred: true
|
|
31
|
+
});
|
|
28
32
|
}
|
|
29
33
|
try {
|
|
30
34
|
return preserveSnapshot({
|
|
@@ -262,8 +266,6 @@ function biject(mapping) {
|
|
|
262
266
|
} catch {
|
|
263
267
|
input = "";
|
|
264
268
|
}
|
|
265
|
-
const result = source.parse(input);
|
|
266
|
-
if (!result.success) return result;
|
|
267
269
|
return {
|
|
268
270
|
success: false,
|
|
269
271
|
error: formatDefaultChoiceError(input, keys)
|
|
@@ -302,6 +304,7 @@ function biject(mapping) {
|
|
|
302
304
|
* @since 1.2.0
|
|
303
305
|
*/
|
|
304
306
|
function transform(parser, mapping) {
|
|
307
|
+
if (isDependencySource(parser)) throw new TypeError("Cannot transform a dependency source directly.");
|
|
305
308
|
const normalize = parser.normalize?.bind(parser);
|
|
306
309
|
const suggest = parser.suggest?.bind(parser);
|
|
307
310
|
const transformedChoices = parser.choices == null ? void 0 : Object.freeze(parser.choices.map((choice$1) => mapping.map(choice$1)));
|
|
@@ -390,10 +393,12 @@ function transform(parser, mapping) {
|
|
|
390
393
|
value
|
|
391
394
|
};
|
|
392
395
|
}
|
|
396
|
+
if (typeof formatted !== "string") return transformMappingFailure();
|
|
393
397
|
let result;
|
|
394
398
|
try {
|
|
395
|
-
result = syncParser.parse(formatted);
|
|
396
|
-
} catch {
|
|
399
|
+
result = wrapForMode("sync", syncParser.parse(formatted));
|
|
400
|
+
} catch (error) {
|
|
401
|
+
if (error instanceof TypeError && error.message.includes("Promise")) throw error;
|
|
397
402
|
return transformMappingFailure();
|
|
398
403
|
}
|
|
399
404
|
if (!result.success) return result;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@optique/core",
|
|
3
|
-
"version": "1.2.0-dev.
|
|
3
|
+
"version": "1.2.0-dev.2322",
|
|
4
4
|
"description": "Type-safe combinatorial command-line interface parser",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"CLI",
|
|
@@ -225,7 +225,7 @@
|
|
|
225
225
|
"fast-check": "^4.7.0",
|
|
226
226
|
"tsdown": "^0.13.0",
|
|
227
227
|
"typescript": "^5.8.3",
|
|
228
|
-
"@optique/env": "1.2.0-dev.
|
|
228
|
+
"@optique/env": "1.2.0-dev.2322+fa56f91e"
|
|
229
229
|
},
|
|
230
230
|
"scripts": {
|
|
231
231
|
"build": "tsdown",
|