@@ -116116,7 +116116,7 @@ function isInterestingFile(path) {
116116116116}
116117116117
116118116118;// CONCATENATED MODULE: ./node_modules/js-yaml/dist/js-yaml.mjs
116119- /*! js-yaml 5.0 .0 https://github.com/nodeca/js-yaml @license MIT */
116119+ /*! js-yaml 5.1 .0 https://github.com/nodeca/js-yaml @license MIT */
116120116120//#region src/tag.ts
116121116121var NOT_RESOLVED = Symbol("NOT_RESOLVED");
116122116122var MERGE_KEY = Symbol("MERGE_KEY");
@@ -116134,19 +116134,23 @@ function defineScalarTag(tagName, options) {
116134116134 };
116135116135}
116136116136function defineSequenceTag(tagName, options) {
116137+ const carrierIsResult = options.finalize === void 0;
116137116138 return {
116138116139 tagName,
116139116140 nodeKind: "sequence",
116140116141 implicit: false,
116141116142 matchByTagPrefix: options.matchByTagPrefix ?? false,
116142116143 create: options.create,
116143116144 addItem: options.addItem,
116145+ finalize: options.finalize ?? ((carrier) => carrier),
116146+ carrierIsResult,
116144116147 identify: options.identify ?? null,
116145116148 represent: options.represent ?? ((data) => data),
116146116149 representTagName: options.representTagName ?? null
116147116150 };
116148116151}
116149116152function defineMappingTag(tagName, options) {
116153+ const carrierIsResult = options.finalize === void 0;
116150116154 return {
116151116155 tagName,
116152116156 nodeKind: "mapping",
@@ -116157,6 +116161,8 @@ function defineMappingTag(tagName, options) {
116157116161 has: options.has,
116158116162 keys: options.keys,
116159116163 get: options.get,
116164+ finalize: options.finalize ?? ((carrier) => carrier),
116165+ carrierIsResult,
116160116166 identify: options.identify ?? null,
116161116167 represent: options.represent ?? ((data) => data),
116162116168 representTagName: options.representTagName ?? null
@@ -117260,6 +117266,14 @@ function eventPosition$1(event) {
117260117266function throwError$1(state, message) {
117261117267 throwErrorAt(state.source, state.position, message, state.filename);
117262117268}
117269+ function finalizeCollection(state, position, tag, carrier) {
117270+ try {
117271+ return tag.finalize(carrier);
117272+ } catch (error) {
117273+ if (error instanceof YAMLException) throw error;
117274+ throwErrorAt(state.source, position, error instanceof Error ? error.message : String(error), state.filename);
117275+ }
117276+ }
117263117277function lookupTag(exact, prefix, tagName) {
117264117278 const exactTag = exact[tagName];
117265117279 if (exactTag) return exactTag;
@@ -117292,8 +117306,9 @@ function constructScalar(state, event) {
117292117306 const collectionTagDef = lookupTag(state.schema.exact.mapping, state.schema.prefix.mapping, tagName) ?? lookupTag(state.schema.exact.sequence, state.schema.prefix.sequence, tagName);
117293117307 if (collectionTagDef) {
117294117308 if (source !== "") throwError$1(state, `cannot resolve a node with !<${tagName}> explicit tag`);
117309+ const carrier = collectionTagDef.create(tagName);
117295117310 return {
117296- value: collectionTagDef.create(tagName ),
117311+ value: collectionTagDef.carrierIsResult ? carrier : finalizeCollection(state, state.position, collectionTagDef, carrier ),
117297117312 tag: collectionTagDef
117298117313 };
117299117314 }
@@ -117379,11 +117394,17 @@ function addValue(state, value, tag) {
117379117394 frame.hasKey = true;
117380117395 }
117381117396}
117382- function storeAnchor(state, event, value, tag) {
117383- if (event.anchorStart !== NO_RANGE$2) state.anchors.set(state.source.slice(event.anchorStart, event.anchorEnd), {
117384- value,
117385- tag
117386- });
117397+ function storeAnchor(state, event, value, tag, isValueFinal) {
117398+ if (event.anchorStart !== NO_RANGE$2) {
117399+ const anchor = {
117400+ value,
117401+ tag,
117402+ isValueFinal
117403+ };
117404+ state.anchors.set(state.source.slice(event.anchorStart, event.anchorEnd), anchor);
117405+ return anchor;
117406+ }
117407+ return null;
117387117408}
117388117409function constructFromEvents(events, options) {
117389117410 const state = {
@@ -117414,21 +117435,22 @@ function constructFromEvents(events, options) {
117414117435 break;
117415117436 case 4: {
117416117437 const { value, tag } = constructScalar(state, event);
117417- storeAnchor(state, event, value, tag);
117438+ storeAnchor(state, event, value, tag, true );
117418117439 addValue(state, value, tag);
117419117440 break;
117420117441 }
117421117442 case 2: {
117422117443 const definition = collectionTag(state, event, state.schema.exact.sequence, state.schema.prefix.sequence, "tag:yaml.org,2002:seq", "sequence");
117423117444 const value = definition.tag.create(definition.tagName);
117424- storeAnchor(state, event, value, definition.tag);
117445+ const anchor = storeAnchor(state, event, value, definition.tag, definition.tag.carrierIsResult );
117425117446 const parent = state.frames[state.frames.length - 1];
117426117447 const merge = parent !== void 0 && parent.kind === "mapping" && parent.hasKey && parent.key === MERGE_KEY;
117427117448 state.frames.push({
117428117449 kind: "sequence",
117429117450 position: state.position,
117430117451 value,
117431117452 tag: definition.tag,
117453+ anchor,
117432117454 index: 0,
117433117455 merge
117434117456 });
@@ -117437,12 +117459,13 @@ function constructFromEvents(events, options) {
117437117459 case 3: {
117438117460 const definition = collectionTag(state, event, state.schema.exact.mapping, state.schema.prefix.mapping, "tag:yaml.org,2002:map", "mapping");
117439117461 const value = definition.tag.create(definition.tagName);
117440- storeAnchor(state, event, value, definition.tag);
117462+ const anchor = storeAnchor(state, event, value, definition.tag, definition.tag.carrierIsResult );
117441117463 state.frames.push({
117442117464 kind: "mapping",
117443117465 position: state.position,
117444117466 value,
117445117467 tag: definition.tag,
117468+ anchor,
117446117469 key: void 0,
117447117470 keyPosition: state.position,
117448117471 hasKey: false,
@@ -117454,13 +117477,21 @@ function constructFromEvents(events, options) {
117454117477 const name = state.source.slice(event.anchorStart, event.anchorEnd);
117455117478 const anchor = state.anchors.get(name);
117456117479 if (!anchor) throwError$1(state, `unidentified alias "${name}"`);
117480+ if (!anchor.isValueFinal) throwError$1(state, `recursive alias "${name}" is not supported for tag ${anchor.tag.tagName} because it uses finalize()`);
117457117481 addValue(state, anchor.value, anchor.tag);
117458117482 break;
117459117483 }
117460117484 case 6: {
117461117485 const frame = state.frames.pop();
117462117486 if (frame.kind === "document") state.documents.push(frame.value);
117463- else addValue(state, frame.value, frame.tag);
117487+ else {
117488+ const value = frame.tag.carrierIsResult ? frame.value : finalizeCollection(state, frame.position, frame.tag, frame.value);
117489+ if (frame.anchor) {
117490+ frame.anchor.value = value;
117491+ frame.anchor.isValueFinal = true;
117492+ }
117493+ addValue(state, value, frame.tag);
117494+ }
117464117495 break;
117465117496 }
117466117497 }
@@ -118551,7 +118582,8 @@ var DEFAULT_PRESENTER_OPTIONS = {
118551118582 flowSkipCommaSpace: false,
118552118583 flowSkipColonSpace: false,
118553118584 quoteFlowKeys: false,
118554- quoteStyle: "auto",
118585+ quoteStyle: "single",
118586+ forceQuotes: false,
118555118587 tagBeforeAnchor: false
118556118588};
118557118589function nodeTagShort(node) {
@@ -118665,9 +118697,8 @@ var STYLE_SINGLE = 2;
118665118697var STYLE_LITERAL = 3;
118666118698var STYLE_FOLDED = 4;
118667118699var STYLE_DOUBLE = 5;
118668- function chooseScalarStyle(state, string, layout, singleLineOnly, inblock) {
118700+ function chooseScalarStyle(state, string, layout, singleLineOnly, forceQuote, inblock) {
118669118701 const { blockIndent, lineWidth } = layout;
118670- const forceQuote = state.quoteStyle !== "auto";
118671118702 let i;
118672118703 let char = 0;
118673118704 let prevChar = -1;
@@ -118724,11 +118755,11 @@ function resolveScalarStyle(state, node, layout, iskey, inblock) {
118724118755 }
118725118756 const string = node.value;
118726118757 if (string.length === 0) {
118727- if (state.quoteStyle === "auto" && ( node.style.tagged || resolveImplicitTag(state, string) === node.tag) ) return STYLE_PLAIN;
118758+ if (node.style.tagged || resolveImplicitTag(state, string) === node.tag) return STYLE_PLAIN;
118728118759 return state.quoteStyle === "double" ? STYLE_DOUBLE : STYLE_SINGLE;
118729118760 }
118730- const style = chooseScalarStyle(state, string, layout, singleLineOnly, inblock);
118731- if (style === STYLE_PLAIN && !node.style.tagged && resolveImplicitTag(state, string) !== node.tag) return STYLE_SINGLE;
118761+ const style = chooseScalarStyle(state, string, layout, singleLineOnly, state.forceQuotes && !iskey, inblock);
118762+ if (style === STYLE_PLAIN && !node.style.tagged && resolveImplicitTag(state, string) !== node.tag) return state.quoteStyle === "double" ? STYLE_DOUBLE : STYLE_SINGLE;
118732118763 return style;
118733118764}
118734118765function blockHeader(string, indentPerLevel) {
@@ -118845,7 +118876,7 @@ function writeFlowMapping(state, level, node) {
118845118876 for (const { key, value } of items) {
118846118877 let pairBuffer = "";
118847118878 if (result !== "") pairBuffer += `,${!state.flowSkipCommaSpace ? " " : ""}`;
118848- const keyText = writeNode(state, level, key, {});
118879+ const keyText = writeNode(state, level, key, { iskey: true });
118849118880 const explicitPair = keyText.length > 1024;
118850118881 if (explicitPair) pairBuffer += "? ";
118851118882 else if (state.quoteFlowKeys) pairBuffer += "\"";
0 commit comments