gitea push

This commit is contained in:
2026-05-09 12:19:29 -06:00
parent 06113c95b8
commit 429461e985
1481 changed files with 74306 additions and 52475 deletions
+11 -8
View File
@@ -1,4 +1,4 @@
import { isScalar, isAlias, isSeq, isMap } from '../../nodes/identity.js';
import { isScalar, isSeq, isAlias, isMap } from '../../nodes/identity.js';
import { Scalar } from '../../nodes/Scalar.js';
// If the value associated with a merge key is a single mapping node, each of
@@ -26,18 +26,18 @@ const isMergeKey = (ctx, key) => (merge.identify(key) ||
merge.identify(key.value))) &&
ctx?.doc.schema.tags.some(tag => tag.tag === merge.tag && tag.default);
function addMergeToJSMap(ctx, map, value) {
value = ctx && isAlias(value) ? value.resolve(ctx.doc) : value;
if (isSeq(value))
for (const it of value.items)
const source = resolveAliasValue(ctx, value);
if (isSeq(source))
for (const it of source.items)
mergeValue(ctx, map, it);
else if (Array.isArray(value))
for (const it of value)
else if (Array.isArray(source))
for (const it of source)
mergeValue(ctx, map, it);
else
mergeValue(ctx, map, value);
mergeValue(ctx, map, source);
}
function mergeValue(ctx, map, value) {
const source = ctx && isAlias(value) ? value.resolve(ctx.doc) : value;
const source = resolveAliasValue(ctx, value);
if (!isMap(source))
throw new Error('Merge sources must be maps or map aliases');
const srcMap = source.toJSON(null, ctx, Map);
@@ -60,5 +60,8 @@ function mergeValue(ctx, map, value) {
}
return map;
}
function resolveAliasValue(ctx, value) {
return ctx && isAlias(value) ? value.resolve(ctx.doc, ctx) : value;
}
export { addMergeToJSMap, isMergeKey, merge };