@optique/core 1.0.0-dev.559 → 1.0.0-dev.560
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/modifiers.cjs +11 -2
- package/dist/modifiers.js +11 -2
- package/package.json +1 -1
package/dist/modifiers.cjs
CHANGED
|
@@ -175,6 +175,16 @@ var WithDefaultError = class extends Error {
|
|
|
175
175
|
};
|
|
176
176
|
function withDefault(parser, defaultValue, options) {
|
|
177
177
|
const syncParser = parser;
|
|
178
|
+
const getDocDefaultValue = (upperDefaultValue) => {
|
|
179
|
+
if (upperDefaultValue != null) return upperDefaultValue;
|
|
180
|
+
if (options?.message) return void 0;
|
|
181
|
+
if (typeof defaultValue !== "function") return defaultValue;
|
|
182
|
+
try {
|
|
183
|
+
return defaultValue();
|
|
184
|
+
} catch {
|
|
185
|
+
return void 0;
|
|
186
|
+
}
|
|
187
|
+
};
|
|
178
188
|
function* suggestSync(context, prefix) {
|
|
179
189
|
const innerState = Array.isArray(context.state) ? context.state[0] : syncParser.initialState;
|
|
180
190
|
yield* syncParser.suggest({
|
|
@@ -318,8 +328,7 @@ function withDefault(parser, defaultValue, options) {
|
|
|
318
328
|
kind: "available",
|
|
319
329
|
state: state.state[0]
|
|
320
330
|
};
|
|
321
|
-
const
|
|
322
|
-
const fragments = syncParser.getDocFragments(innerState, actualDefaultValue);
|
|
331
|
+
const fragments = syncParser.getDocFragments(innerState, getDocDefaultValue(upperDefaultValue));
|
|
323
332
|
if (options?.message) {
|
|
324
333
|
const modifiedFragments = fragments.fragments.map((fragment) => {
|
|
325
334
|
if (fragment.type === "entry") return {
|
package/dist/modifiers.js
CHANGED
|
@@ -175,6 +175,16 @@ var WithDefaultError = class extends Error {
|
|
|
175
175
|
};
|
|
176
176
|
function withDefault(parser, defaultValue, options) {
|
|
177
177
|
const syncParser = parser;
|
|
178
|
+
const getDocDefaultValue = (upperDefaultValue) => {
|
|
179
|
+
if (upperDefaultValue != null) return upperDefaultValue;
|
|
180
|
+
if (options?.message) return void 0;
|
|
181
|
+
if (typeof defaultValue !== "function") return defaultValue;
|
|
182
|
+
try {
|
|
183
|
+
return defaultValue();
|
|
184
|
+
} catch {
|
|
185
|
+
return void 0;
|
|
186
|
+
}
|
|
187
|
+
};
|
|
178
188
|
function* suggestSync(context, prefix) {
|
|
179
189
|
const innerState = Array.isArray(context.state) ? context.state[0] : syncParser.initialState;
|
|
180
190
|
yield* syncParser.suggest({
|
|
@@ -318,8 +328,7 @@ function withDefault(parser, defaultValue, options) {
|
|
|
318
328
|
kind: "available",
|
|
319
329
|
state: state.state[0]
|
|
320
330
|
};
|
|
321
|
-
const
|
|
322
|
-
const fragments = syncParser.getDocFragments(innerState, actualDefaultValue);
|
|
331
|
+
const fragments = syncParser.getDocFragments(innerState, getDocDefaultValue(upperDefaultValue));
|
|
323
332
|
if (options?.message) {
|
|
324
333
|
const modifiedFragments = fragments.fragments.map((fragment) => {
|
|
325
334
|
if (fragment.type === "entry") return {
|