@optique/core 1.0.0-dev.1699 → 1.0.0-dev.1703
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 +71 -73
- package/dist/constructs.js +71 -73
- package/dist/modifiers.cjs +4 -4
- package/dist/modifiers.d.cts +4 -4
- package/dist/modifiers.d.ts +4 -4
- package/dist/modifiers.js +4 -4
- package/package.json +1 -1
package/dist/constructs.cjs
CHANGED
|
@@ -513,81 +513,77 @@ function createExclusiveComplete(parsers, options, noMatchContext, mode) {
|
|
|
513
513
|
const syncParsers = parsers;
|
|
514
514
|
return (state, exec) => {
|
|
515
515
|
const activeState = normalizeExclusiveState(state);
|
|
516
|
-
if (activeState == null) {
|
|
517
|
-
const
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
if (parseResult.success) {
|
|
546
|
-
const annotatedState = getAnnotatedChildState(state, parseResult.next.state, p);
|
|
547
|
-
return p.complete(annotatedState, withChildExecPath(exec, candidateIndex));
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
return {
|
|
551
|
-
success: false,
|
|
552
|
-
error: getNoMatchError(options, noMatchContext)
|
|
553
|
-
};
|
|
554
|
-
}, async () => {
|
|
555
|
-
const emptyCtx = {
|
|
556
|
-
buffer: [],
|
|
557
|
-
optionsTerminated: false,
|
|
558
|
-
usage: []
|
|
559
|
-
};
|
|
560
|
-
let candidateIndex = -1;
|
|
561
|
-
let candidateCount = 0;
|
|
562
|
-
for (let i$1 = 0; i$1 < parsers.length; i$1++) {
|
|
563
|
-
const p = parsers[i$1];
|
|
564
|
-
if (p.leadingNames.size > 0 || p.acceptingAnyToken) continue;
|
|
565
|
-
const parseResult = await p.parse({
|
|
566
|
-
...emptyCtx,
|
|
567
|
-
state: annotateInitial(p.initialState)
|
|
568
|
-
});
|
|
569
|
-
if (!parseResult.success || parseResult.provisional) continue;
|
|
570
|
-
candidateCount++;
|
|
571
|
-
if (candidateIndex < 0) candidateIndex = i$1;
|
|
572
|
-
if (candidateCount > 1) break;
|
|
516
|
+
if (activeState == null) return require_mode_dispatch.dispatchByMode(mode, () => {
|
|
517
|
+
const emptyCtx = {
|
|
518
|
+
buffer: [],
|
|
519
|
+
optionsTerminated: false,
|
|
520
|
+
usage: []
|
|
521
|
+
};
|
|
522
|
+
let candidateIndex = -1;
|
|
523
|
+
let candidateCount = 0;
|
|
524
|
+
for (let i$1 = 0; i$1 < syncParsers.length; i$1++) {
|
|
525
|
+
const p = syncParsers[i$1];
|
|
526
|
+
if (p.leadingNames.size > 0 || p.acceptingAnyToken) continue;
|
|
527
|
+
const parseResult = p.parse({
|
|
528
|
+
...emptyCtx,
|
|
529
|
+
state: getAnnotatedChildState(state, p.initialState, p)
|
|
530
|
+
});
|
|
531
|
+
if (!parseResult.success || parseResult.provisional) continue;
|
|
532
|
+
candidateCount++;
|
|
533
|
+
if (candidateIndex < 0) candidateIndex = i$1;
|
|
534
|
+
if (candidateCount > 1) break;
|
|
535
|
+
}
|
|
536
|
+
if (candidateCount === 1 && candidateIndex >= 0) {
|
|
537
|
+
const p = syncParsers[candidateIndex];
|
|
538
|
+
const parseResult = p.parse({
|
|
539
|
+
...emptyCtx,
|
|
540
|
+
state: getAnnotatedChildState(state, p.initialState, p)
|
|
541
|
+
});
|
|
542
|
+
if (parseResult.success) {
|
|
543
|
+
const annotatedState = getAnnotatedChildState(state, parseResult.next.state, p);
|
|
544
|
+
return p.complete(annotatedState, withChildExecPath(exec, candidateIndex));
|
|
573
545
|
}
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
546
|
+
}
|
|
547
|
+
return {
|
|
548
|
+
success: false,
|
|
549
|
+
error: getNoMatchError(options, noMatchContext)
|
|
550
|
+
};
|
|
551
|
+
}, async () => {
|
|
552
|
+
const emptyCtx = {
|
|
553
|
+
buffer: [],
|
|
554
|
+
optionsTerminated: false,
|
|
555
|
+
usage: []
|
|
556
|
+
};
|
|
557
|
+
let candidateIndex = -1;
|
|
558
|
+
let candidateCount = 0;
|
|
559
|
+
for (let i$1 = 0; i$1 < parsers.length; i$1++) {
|
|
560
|
+
const p = parsers[i$1];
|
|
561
|
+
if (p.leadingNames.size > 0 || p.acceptingAnyToken) continue;
|
|
562
|
+
const parseResult = await p.parse({
|
|
563
|
+
...emptyCtx,
|
|
564
|
+
state: getAnnotatedChildState(state, p.initialState, p)
|
|
565
|
+
});
|
|
566
|
+
if (!parseResult.success || parseResult.provisional) continue;
|
|
567
|
+
candidateCount++;
|
|
568
|
+
if (candidateIndex < 0) candidateIndex = i$1;
|
|
569
|
+
if (candidateCount > 1) break;
|
|
570
|
+
}
|
|
571
|
+
if (candidateCount === 1 && candidateIndex >= 0 && (parsers[candidateIndex].$mode === "sync" || exec?.phase !== "parse" && exec?.phase !== "suggest")) {
|
|
572
|
+
const p = parsers[candidateIndex];
|
|
573
|
+
const parseResult = await p.parse({
|
|
574
|
+
...emptyCtx,
|
|
575
|
+
state: getAnnotatedChildState(state, p.initialState, p)
|
|
576
|
+
});
|
|
577
|
+
if (parseResult.success) {
|
|
578
|
+
const annotatedState = getAnnotatedChildState(state, parseResult.next.state, p);
|
|
579
|
+
return await p.complete(annotatedState, withChildExecPath(exec, candidateIndex));
|
|
584
580
|
}
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
}
|
|
590
|
-
}
|
|
581
|
+
}
|
|
582
|
+
return {
|
|
583
|
+
success: false,
|
|
584
|
+
error: getNoMatchError(options, noMatchContext)
|
|
585
|
+
};
|
|
586
|
+
});
|
|
591
587
|
const [i, result] = activeState;
|
|
592
588
|
if (!result.success) return {
|
|
593
589
|
success: false,
|
|
@@ -3843,6 +3839,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
3843
3839
|
consumed: defaultResult.consumed
|
|
3844
3840
|
};
|
|
3845
3841
|
}
|
|
3842
|
+
if (!defaultResult.success && defaultResult.consumed > 0) return defaultResult;
|
|
3846
3843
|
}
|
|
3847
3844
|
return {
|
|
3848
3845
|
success: false,
|
|
@@ -4013,6 +4010,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4013
4010
|
consumed: defaultResult.consumed
|
|
4014
4011
|
};
|
|
4015
4012
|
}
|
|
4013
|
+
if (!defaultResult.success && defaultResult.consumed > 0) return defaultResult;
|
|
4016
4014
|
}
|
|
4017
4015
|
return {
|
|
4018
4016
|
success: false,
|
package/dist/constructs.js
CHANGED
|
@@ -513,81 +513,77 @@ function createExclusiveComplete(parsers, options, noMatchContext, mode) {
|
|
|
513
513
|
const syncParsers = parsers;
|
|
514
514
|
return (state, exec) => {
|
|
515
515
|
const activeState = normalizeExclusiveState(state);
|
|
516
|
-
if (activeState == null) {
|
|
517
|
-
const
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
if (parseResult.success) {
|
|
546
|
-
const annotatedState = getAnnotatedChildState(state, parseResult.next.state, p);
|
|
547
|
-
return p.complete(annotatedState, withChildExecPath(exec, candidateIndex));
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
return {
|
|
551
|
-
success: false,
|
|
552
|
-
error: getNoMatchError(options, noMatchContext)
|
|
553
|
-
};
|
|
554
|
-
}, async () => {
|
|
555
|
-
const emptyCtx = {
|
|
556
|
-
buffer: [],
|
|
557
|
-
optionsTerminated: false,
|
|
558
|
-
usage: []
|
|
559
|
-
};
|
|
560
|
-
let candidateIndex = -1;
|
|
561
|
-
let candidateCount = 0;
|
|
562
|
-
for (let i$1 = 0; i$1 < parsers.length; i$1++) {
|
|
563
|
-
const p = parsers[i$1];
|
|
564
|
-
if (p.leadingNames.size > 0 || p.acceptingAnyToken) continue;
|
|
565
|
-
const parseResult = await p.parse({
|
|
566
|
-
...emptyCtx,
|
|
567
|
-
state: annotateInitial(p.initialState)
|
|
568
|
-
});
|
|
569
|
-
if (!parseResult.success || parseResult.provisional) continue;
|
|
570
|
-
candidateCount++;
|
|
571
|
-
if (candidateIndex < 0) candidateIndex = i$1;
|
|
572
|
-
if (candidateCount > 1) break;
|
|
516
|
+
if (activeState == null) return dispatchByMode(mode, () => {
|
|
517
|
+
const emptyCtx = {
|
|
518
|
+
buffer: [],
|
|
519
|
+
optionsTerminated: false,
|
|
520
|
+
usage: []
|
|
521
|
+
};
|
|
522
|
+
let candidateIndex = -1;
|
|
523
|
+
let candidateCount = 0;
|
|
524
|
+
for (let i$1 = 0; i$1 < syncParsers.length; i$1++) {
|
|
525
|
+
const p = syncParsers[i$1];
|
|
526
|
+
if (p.leadingNames.size > 0 || p.acceptingAnyToken) continue;
|
|
527
|
+
const parseResult = p.parse({
|
|
528
|
+
...emptyCtx,
|
|
529
|
+
state: getAnnotatedChildState(state, p.initialState, p)
|
|
530
|
+
});
|
|
531
|
+
if (!parseResult.success || parseResult.provisional) continue;
|
|
532
|
+
candidateCount++;
|
|
533
|
+
if (candidateIndex < 0) candidateIndex = i$1;
|
|
534
|
+
if (candidateCount > 1) break;
|
|
535
|
+
}
|
|
536
|
+
if (candidateCount === 1 && candidateIndex >= 0) {
|
|
537
|
+
const p = syncParsers[candidateIndex];
|
|
538
|
+
const parseResult = p.parse({
|
|
539
|
+
...emptyCtx,
|
|
540
|
+
state: getAnnotatedChildState(state, p.initialState, p)
|
|
541
|
+
});
|
|
542
|
+
if (parseResult.success) {
|
|
543
|
+
const annotatedState = getAnnotatedChildState(state, parseResult.next.state, p);
|
|
544
|
+
return p.complete(annotatedState, withChildExecPath(exec, candidateIndex));
|
|
573
545
|
}
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
546
|
+
}
|
|
547
|
+
return {
|
|
548
|
+
success: false,
|
|
549
|
+
error: getNoMatchError(options, noMatchContext)
|
|
550
|
+
};
|
|
551
|
+
}, async () => {
|
|
552
|
+
const emptyCtx = {
|
|
553
|
+
buffer: [],
|
|
554
|
+
optionsTerminated: false,
|
|
555
|
+
usage: []
|
|
556
|
+
};
|
|
557
|
+
let candidateIndex = -1;
|
|
558
|
+
let candidateCount = 0;
|
|
559
|
+
for (let i$1 = 0; i$1 < parsers.length; i$1++) {
|
|
560
|
+
const p = parsers[i$1];
|
|
561
|
+
if (p.leadingNames.size > 0 || p.acceptingAnyToken) continue;
|
|
562
|
+
const parseResult = await p.parse({
|
|
563
|
+
...emptyCtx,
|
|
564
|
+
state: getAnnotatedChildState(state, p.initialState, p)
|
|
565
|
+
});
|
|
566
|
+
if (!parseResult.success || parseResult.provisional) continue;
|
|
567
|
+
candidateCount++;
|
|
568
|
+
if (candidateIndex < 0) candidateIndex = i$1;
|
|
569
|
+
if (candidateCount > 1) break;
|
|
570
|
+
}
|
|
571
|
+
if (candidateCount === 1 && candidateIndex >= 0 && (parsers[candidateIndex].$mode === "sync" || exec?.phase !== "parse" && exec?.phase !== "suggest")) {
|
|
572
|
+
const p = parsers[candidateIndex];
|
|
573
|
+
const parseResult = await p.parse({
|
|
574
|
+
...emptyCtx,
|
|
575
|
+
state: getAnnotatedChildState(state, p.initialState, p)
|
|
576
|
+
});
|
|
577
|
+
if (parseResult.success) {
|
|
578
|
+
const annotatedState = getAnnotatedChildState(state, parseResult.next.state, p);
|
|
579
|
+
return await p.complete(annotatedState, withChildExecPath(exec, candidateIndex));
|
|
584
580
|
}
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
}
|
|
590
|
-
}
|
|
581
|
+
}
|
|
582
|
+
return {
|
|
583
|
+
success: false,
|
|
584
|
+
error: getNoMatchError(options, noMatchContext)
|
|
585
|
+
};
|
|
586
|
+
});
|
|
591
587
|
const [i, result] = activeState;
|
|
592
588
|
if (!result.success) return {
|
|
593
589
|
success: false,
|
|
@@ -3843,6 +3839,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
3843
3839
|
consumed: defaultResult.consumed
|
|
3844
3840
|
};
|
|
3845
3841
|
}
|
|
3842
|
+
if (!defaultResult.success && defaultResult.consumed > 0) return defaultResult;
|
|
3846
3843
|
}
|
|
3847
3844
|
return {
|
|
3848
3845
|
success: false,
|
|
@@ -4013,6 +4010,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4013
4010
|
consumed: defaultResult.consumed
|
|
4014
4011
|
};
|
|
4015
4012
|
}
|
|
4013
|
+
if (!defaultResult.success && defaultResult.consumed > 0) return defaultResult;
|
|
4016
4014
|
}
|
|
4017
4015
|
return {
|
|
4018
4016
|
success: false,
|
package/dist/modifiers.cjs
CHANGED
|
@@ -6,10 +6,10 @@ const require_parser = require('./parser.cjs');
|
|
|
6
6
|
|
|
7
7
|
//#region src/modifiers.ts
|
|
8
8
|
/**
|
|
9
|
-
* Internal marker for
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
9
|
+
* Internal marker for wrappers that should be skipped by `object()`'s
|
|
10
|
+
* zero-consumption pass. Set on `optional()`, `withDefault()`, and
|
|
11
|
+
* `prompt()`, since these wrappers have their own completion semantics
|
|
12
|
+
* that should not be short-circuited during parse.
|
|
13
13
|
*
|
|
14
14
|
* @internal
|
|
15
15
|
*/
|
package/dist/modifiers.d.cts
CHANGED
|
@@ -4,10 +4,10 @@ import { Mode, Parser } from "./parser.cjs";
|
|
|
4
4
|
//#region src/modifiers.d.ts
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Internal marker for
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* Internal marker for wrappers that should be skipped by `object()`'s
|
|
8
|
+
* zero-consumption pass. Set on `optional()`, `withDefault()`, and
|
|
9
|
+
* `prompt()`, since these wrappers have their own completion semantics
|
|
10
|
+
* that should not be short-circuited during parse.
|
|
11
11
|
*
|
|
12
12
|
* @internal
|
|
13
13
|
*/
|
package/dist/modifiers.d.ts
CHANGED
|
@@ -4,10 +4,10 @@ import { Mode, Parser } from "./parser.js";
|
|
|
4
4
|
//#region src/modifiers.d.ts
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Internal marker for
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* Internal marker for wrappers that should be skipped by `object()`'s
|
|
8
|
+
* zero-consumption pass. Set on `optional()`, `withDefault()`, and
|
|
9
|
+
* `prompt()`, since these wrappers have their own completion semantics
|
|
10
|
+
* that should not be short-circuited during parse.
|
|
11
11
|
*
|
|
12
12
|
* @internal
|
|
13
13
|
*/
|
package/dist/modifiers.js
CHANGED
|
@@ -6,10 +6,10 @@ import { defineInheritedAnnotationParser, defineSourceBindingOnlyAnnotationCompl
|
|
|
6
6
|
|
|
7
7
|
//#region src/modifiers.ts
|
|
8
8
|
/**
|
|
9
|
-
* Internal marker for
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
9
|
+
* Internal marker for wrappers that should be skipped by `object()`'s
|
|
10
|
+
* zero-consumption pass. Set on `optional()`, `withDefault()`, and
|
|
11
|
+
* `prompt()`, since these wrappers have their own completion semantics
|
|
12
|
+
* that should not be short-circuited during parse.
|
|
13
13
|
*
|
|
14
14
|
* @internal
|
|
15
15
|
*/
|