@speclynx/apidom-parser-adapter-openapi-yaml-2 5.0.2 → 5.1.0

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/CHANGELOG.md CHANGED
@@ -3,6 +3,10 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [5.1.0](https://github.com/speclynx/apidom/compare/v5.0.2...v5.1.0) (2026-08-09)
7
+
8
+ **Note:** Version bump only for package @speclynx/apidom-parser-adapter-openapi-yaml-2
9
+
6
10
  ## [5.0.2](https://github.com/speclynx/apidom/compare/v5.0.1...v5.0.2) (2026-08-04)
7
11
 
8
12
  **Note:** Version bump only for package @speclynx/apidom-parser-adapter-openapi-yaml-2
@@ -1122,7 +1122,7 @@ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object
1122
1122
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
1123
1123
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
1124
1124
  function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
1125
-
1125
+ ;
1126
1126
 
1127
1127
  var _CompositeEvaluationRealm_brand = /*#__PURE__*/new WeakSet();
1128
1128
  class CompositeEvaluationRealm extends _EvaluationRealm_mjs__WEBPACK_IMPORTED_MODULE_0__["default"] {
@@ -10067,7 +10067,7 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
10067
10067
  function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
10068
10068
  function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
10069
10069
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
10070
-
10070
+ ;
10071
10071
 
10072
10072
  /**
10073
10073
  * Can be used as a way to compose multiple invokers together to form polymorphic functions,
@@ -30749,7 +30749,7 @@ __webpack_require__.r(__webpack_exports__);
30749
30749
  * @public
30750
30750
  */
30751
30751
  const emptyElement = element => {
30752
- const meta = !element.isMetaEmpty ? element.meta.cloneDeep() : undefined;
30752
+ const meta = !element.isMetaEmpty ? (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_1__.cloneDeep)(element.meta) : undefined;
30753
30753
  const attributes = !element.isAttributesEmpty ? (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_1__.cloneDeep)(element.attributes) : undefined;
30754
30754
 
30755
30755
  // @ts-ignore
@@ -30765,7 +30765,7 @@ const getMergeFunction = (keyElement, options) => {
30765
30765
  };
30766
30766
  const getMetaMergeFunction = options => {
30767
30767
  if (typeof options.customMetaMerge !== 'function') {
30768
- return targetMeta => targetMeta.cloneDeep();
30768
+ return targetMeta => (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_1__.cloneDeep)(targetMeta);
30769
30769
  }
30770
30770
  return options.customMetaMerge;
30771
30771
  };
@@ -30840,9 +30840,9 @@ const deepmerge = (targetElement, sourceElement, options) => {
30840
30840
  if (!targetElement.isMetaEmpty && !sourceElement.isMetaEmpty) {
30841
30841
  mergedElement.meta = getMetaMergeFunction(mergedOptions)(targetElement.meta, sourceElement.meta);
30842
30842
  } else if (!targetElement.isMetaEmpty) {
30843
- mergedElement.meta = targetElement.meta.cloneDeep();
30843
+ mergedElement.meta = (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_1__.cloneDeep)(targetElement.meta);
30844
30844
  } else if (!sourceElement.isMetaEmpty) {
30845
- mergedElement.meta = sourceElement.meta.cloneDeep();
30845
+ mergedElement.meta = (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_1__.cloneDeep)(sourceElement.meta);
30846
30846
  }
30847
30847
  if (!targetElement.isAttributesEmpty && !sourceElement.isAttributesEmpty) {
30848
30848
  mergedElement.attributes = getAttributesMergeFunction(mergedOptions)(targetElement.attributes, sourceElement.attributes);
@@ -31820,19 +31820,21 @@ class ShallowCloneError extends _CloneError_mjs__WEBPACK_IMPORTED_MODULE_0__["de
31820
31820
  "use strict";
31821
31821
  __webpack_require__.r(__webpack_exports__);
31822
31822
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
31823
- /* harmony export */ CloneError: () => (/* reexport safe */ _errors_CloneError_mjs__WEBPACK_IMPORTED_MODULE_8__["default"]),
31824
- /* harmony export */ DeepCloneError: () => (/* reexport safe */ _errors_DeepCloneError_mjs__WEBPACK_IMPORTED_MODULE_6__["default"]),
31825
- /* harmony export */ ShallowCloneError: () => (/* reexport safe */ _errors_ShallowCloneError_mjs__WEBPACK_IMPORTED_MODULE_7__["default"])
31823
+ /* harmony export */ CloneError: () => (/* reexport safe */ _errors_CloneError_mjs__WEBPACK_IMPORTED_MODULE_9__["default"]),
31824
+ /* harmony export */ DeepCloneError: () => (/* reexport safe */ _errors_DeepCloneError_mjs__WEBPACK_IMPORTED_MODULE_7__["default"]),
31825
+ /* harmony export */ ShallowCloneError: () => (/* reexport safe */ _errors_ShallowCloneError_mjs__WEBPACK_IMPORTED_MODULE_8__["default"])
31826
31826
  /* harmony export */ });
31827
31827
  /* harmony import */ var ramda__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8138);
31828
31828
  /* harmony import */ var _ObjectSlice_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(38504);
31829
31829
  /* harmony import */ var _KeyValuePair_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(36663);
31830
- /* harmony import */ var _predicates_index_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(18252);
31831
- /* harmony import */ var _predicates_index_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(25162);
31832
- /* harmony import */ var _elements_SourceMap_mjs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(25810);
31833
- /* harmony import */ var _errors_DeepCloneError_mjs__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(95018);
31834
- /* harmony import */ var _errors_ShallowCloneError_mjs__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(3686);
31835
- /* harmony import */ var _errors_CloneError_mjs__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(3772);
31830
+ /* harmony import */ var _Metadata_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(51844);
31831
+ /* harmony import */ var _predicates_index_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(18252);
31832
+ /* harmony import */ var _predicates_index_mjs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(25162);
31833
+ /* harmony import */ var _elements_SourceMap_mjs__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(25810);
31834
+ /* harmony import */ var _errors_DeepCloneError_mjs__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(95018);
31835
+ /* harmony import */ var _errors_ShallowCloneError_mjs__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(3686);
31836
+ /* harmony import */ var _errors_CloneError_mjs__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(3772);
31837
+
31836
31838
 
31837
31839
 
31838
31840
 
@@ -31866,7 +31868,7 @@ const cloneDeepElement = (element, options) => {
31866
31868
  } = element;
31867
31869
  if (Array.isArray(content)) {
31868
31870
  copy.content = content.map(el => cloneDeepElement(el, passThroughOptions));
31869
- } else if ((0,_predicates_index_mjs__WEBPACK_IMPORTED_MODULE_4__.isElement)(content)) {
31871
+ } else if ((0,_predicates_index_mjs__WEBPACK_IMPORTED_MODULE_5__.isElement)(content)) {
31870
31872
  copy.content = cloneDeepElement(content, passThroughOptions);
31871
31873
  } else if (content instanceof _KeyValuePair_mjs__WEBPACK_IMPORTED_MODULE_2__["default"]) {
31872
31874
  copy.content = cloneDeepKeyValuePair(content, passThroughOptions);
@@ -31914,7 +31916,7 @@ const cloneDeepObjectSlice = (slice, options) => {
31914
31916
  };
31915
31917
 
31916
31918
  /**
31917
- * Creates a deep clone of an ApiDOM Element, KeyValuePair, or ObjectSlice.
31919
+ * Creates a deep clone of an ApiDOM Element, KeyValuePair, ObjectSlice, or Metadata.
31918
31920
  * Handles cycles by memoizing visited objects.
31919
31921
  * @public
31920
31922
  */
@@ -31925,10 +31927,13 @@ const cloneDeep = (value, options = {}) => {
31925
31927
  if (value instanceof _ObjectSlice_mjs__WEBPACK_IMPORTED_MODULE_1__["default"]) {
31926
31928
  return cloneDeepObjectSlice(value, options);
31927
31929
  }
31928
- if ((0,_predicates_index_mjs__WEBPACK_IMPORTED_MODULE_4__.isElement)(value)) {
31930
+ if (value instanceof _Metadata_mjs__WEBPACK_IMPORTED_MODULE_3__["default"]) {
31931
+ return value.cloneDeep();
31932
+ }
31933
+ if ((0,_predicates_index_mjs__WEBPACK_IMPORTED_MODULE_5__.isElement)(value)) {
31929
31934
  return cloneDeepElement(value, options);
31930
31935
  }
31931
- throw new _errors_DeepCloneError_mjs__WEBPACK_IMPORTED_MODULE_6__["default"]("Value provided to cloneDeep function couldn't be cloned", {
31936
+ throw new _errors_DeepCloneError_mjs__WEBPACK_IMPORTED_MODULE_7__["default"]("Value provided to cloneDeep function couldn't be cloned", {
31932
31937
  value
31933
31938
  });
31934
31939
  };
@@ -31955,21 +31960,21 @@ const cloneShallowElement = element => {
31955
31960
  const copy = new Ctor();
31956
31961
  copy.element = element.element;
31957
31962
  if (!element.isMetaEmpty) {
31958
- copy.meta = element.meta.cloneDeep();
31963
+ copy.meta = cloneDeep(element.meta);
31959
31964
  }
31960
31965
  if (!element.isAttributesEmpty) {
31961
31966
  copy.attributes = cloneDeep(element.attributes);
31962
31967
  }
31963
- if ((0,_predicates_index_mjs__WEBPACK_IMPORTED_MODULE_3__.hasElementSourceMap)(element)) {
31964
- _elements_SourceMap_mjs__WEBPACK_IMPORTED_MODULE_5__["default"].transfer(element, copy);
31968
+ if ((0,_predicates_index_mjs__WEBPACK_IMPORTED_MODULE_4__.hasElementSourceMap)(element)) {
31969
+ _elements_SourceMap_mjs__WEBPACK_IMPORTED_MODULE_6__["default"].transfer(element, copy);
31965
31970
  }
31966
- if ((0,_predicates_index_mjs__WEBPACK_IMPORTED_MODULE_3__.hasElementStyle)(element)) {
31971
+ if ((0,_predicates_index_mjs__WEBPACK_IMPORTED_MODULE_4__.hasElementStyle)(element)) {
31967
31972
  copy.style = (0,ramda__WEBPACK_IMPORTED_MODULE_0__["default"])(element.style);
31968
31973
  }
31969
31974
  const {
31970
31975
  content
31971
31976
  } = element;
31972
- if ((0,_predicates_index_mjs__WEBPACK_IMPORTED_MODULE_4__.isElement)(content)) {
31977
+ if ((0,_predicates_index_mjs__WEBPACK_IMPORTED_MODULE_5__.isElement)(content)) {
31973
31978
  copy.content = cloneShallowElement(content);
31974
31979
  } else if (Array.isArray(content)) {
31975
31980
  copy.content = [...content];
@@ -31982,7 +31987,7 @@ const cloneShallowElement = element => {
31982
31987
  };
31983
31988
 
31984
31989
  /**
31985
- * Creates a shallow clone of an ApiDOM Element, KeyValuePair, or ObjectSlice.
31990
+ * Creates a shallow clone of an ApiDOM Element, KeyValuePair, ObjectSlice, or Metadata.
31986
31991
  * The element itself is cloned, but content references are shared.
31987
31992
  * Meta and attributes are deep cloned to preserve semantic information.
31988
31993
  * @public
@@ -31994,10 +31999,13 @@ const cloneShallow = value => {
31994
31999
  if (value instanceof _ObjectSlice_mjs__WEBPACK_IMPORTED_MODULE_1__["default"]) {
31995
32000
  return cloneShallowObjectSlice(value);
31996
32001
  }
31997
- if ((0,_predicates_index_mjs__WEBPACK_IMPORTED_MODULE_4__.isElement)(value)) {
32002
+ if (value instanceof _Metadata_mjs__WEBPACK_IMPORTED_MODULE_3__["default"]) {
32003
+ return value.cloneShallow();
32004
+ }
32005
+ if ((0,_predicates_index_mjs__WEBPACK_IMPORTED_MODULE_5__.isElement)(value)) {
31998
32006
  return cloneShallowElement(value);
31999
32007
  }
32000
- throw new _errors_ShallowCloneError_mjs__WEBPACK_IMPORTED_MODULE_7__["default"]("Value provided to cloneShallow function couldn't be cloned", {
32008
+ throw new _errors_ShallowCloneError_mjs__WEBPACK_IMPORTED_MODULE_8__["default"]("Value provided to cloneShallow function couldn't be cloned", {
32001
32009
  value
32002
32010
  });
32003
32011
  };
@@ -35422,7 +35430,7 @@ class SpecificationVisitor extends _Visitor_mjs__WEBPACK_IMPORTED_MODULE_6__["de
35422
35430
  if (visitor instanceof _FallbackVisitor_mjs__WEBPACK_IMPORTED_MODULE_7__["default"] && visitor?.constructor === _FallbackVisitor_mjs__WEBPACK_IMPORTED_MODULE_7__["default"]) {
35423
35431
  return this.consume ? element : (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_4__.cloneDeep)(element);
35424
35432
  }
35425
- (0,_speclynx_apidom_traverse__WEBPACK_IMPORTED_MODULE_5__.traverse)(element, visitor, options);
35433
+ ;(0,_speclynx_apidom_traverse__WEBPACK_IMPORTED_MODULE_5__.traverse)(element, visitor, options);
35426
35434
  return visitor.element;
35427
35435
  }
35428
35436
  }
@@ -35464,7 +35472,7 @@ class Visitor {
35464
35472
  if (!from.isMetaEmpty && !to.isMetaEmpty) {
35465
35473
  to.meta = to.meta.merge(from.meta);
35466
35474
  } else if (!from.isMetaEmpty) {
35467
- to.meta = from.meta.cloneDeep();
35475
+ to.meta = (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_1__.cloneDeep)(from.meta);
35468
35476
  }
35469
35477
  if (!from.isAttributesEmpty && !to.isAttributesEmpty) {
35470
35478
  to.attributes = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_0__["default"])(to.attributes, from.attributes);
@@ -40067,7 +40075,7 @@ class SpecificationVisitor extends _Visitor_mjs__WEBPACK_IMPORTED_MODULE_6__["de
40067
40075
  if (visitor instanceof _FallbackVisitor_mjs__WEBPACK_IMPORTED_MODULE_7__["default"] && visitor?.constructor === _FallbackVisitor_mjs__WEBPACK_IMPORTED_MODULE_7__["default"]) {
40068
40076
  return this.consume ? element : (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_4__.cloneDeep)(element);
40069
40077
  }
40070
- (0,_speclynx_apidom_traverse__WEBPACK_IMPORTED_MODULE_5__.traverse)(element, visitor);
40078
+ ;(0,_speclynx_apidom_traverse__WEBPACK_IMPORTED_MODULE_5__.traverse)(element, visitor);
40071
40079
  return visitor.element;
40072
40080
  }
40073
40081
  }
@@ -40109,7 +40117,7 @@ class Visitor {
40109
40117
  if (!from.isMetaEmpty && !to.isMetaEmpty) {
40110
40118
  to.meta = to.meta.merge(from.meta);
40111
40119
  } else if (!from.isMetaEmpty) {
40112
- to.meta = from.meta.cloneDeep();
40120
+ to.meta = (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_1__.cloneDeep)(from.meta);
40113
40121
  }
40114
40122
  if (!from.isAttributesEmpty && !to.isAttributesEmpty) {
40115
40123
  to.attributes = (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_0__["default"])(to.attributes, from.attributes);
@@ -40502,6 +40510,7 @@ class ConsumesVisitor extends _FallbackVisitor_mjs__WEBPACK_IMPORTED_MODULE_2__[
40502
40510
  ArrayElement(path) {
40503
40511
  const arrayElement = path.node;
40504
40512
  this.element = this.element.concat((0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_0__.cloneDeep)(arrayElement));
40513
+ this.copyMetaAndAttributes(arrayElement, this.element);
40505
40514
  path.stop();
40506
40515
  }
40507
40516
  }
@@ -40559,6 +40568,7 @@ class ProducesVisitor extends _FallbackVisitor_mjs__WEBPACK_IMPORTED_MODULE_2__[
40559
40568
  ArrayElement(path) {
40560
40569
  const arrayElement = path.node;
40561
40570
  this.element = this.element.concat((0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_0__.cloneDeep)(arrayElement));
40571
+ this.copyMetaAndAttributes(arrayElement, this.element);
40562
40572
  path.stop();
40563
40573
  }
40564
40574
  }
@@ -40592,6 +40602,7 @@ class SchemesVisitor extends _FallbackVisitor_mjs__WEBPACK_IMPORTED_MODULE_2__["
40592
40602
  ArrayElement(path) {
40593
40603
  const arrayElement = path.node;
40594
40604
  this.element = this.element.concat((0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_0__.cloneDeep)(arrayElement));
40605
+ this.copyMetaAndAttributes(arrayElement, this.element);
40595
40606
  path.stop();
40596
40607
  }
40597
40608
  }
@@ -41160,6 +41171,7 @@ class ConsumesVisitor extends _FallbackVisitor_mjs__WEBPACK_IMPORTED_MODULE_2__[
41160
41171
  ArrayElement(path) {
41161
41172
  const arrayElement = path.node;
41162
41173
  this.element = this.element.concat((0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_0__.cloneDeep)(arrayElement));
41174
+ this.copyMetaAndAttributes(arrayElement, this.element);
41163
41175
  path.stop();
41164
41176
  }
41165
41177
  }
@@ -41236,6 +41248,7 @@ class ProducesVisitor extends _FallbackVisitor_mjs__WEBPACK_IMPORTED_MODULE_2__[
41236
41248
  ArrayElement(path) {
41237
41249
  const arrayElement = path.node;
41238
41250
  this.element = this.element.concat((0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_0__.cloneDeep)(arrayElement));
41251
+ this.copyMetaAndAttributes(arrayElement, this.element);
41239
41252
  path.stop();
41240
41253
  }
41241
41254
  }
@@ -41269,6 +41282,7 @@ class SchemesVisitor extends _FallbackVisitor_mjs__WEBPACK_IMPORTED_MODULE_2__["
41269
41282
  ArrayElement(path) {
41270
41283
  const arrayElement = path.node;
41271
41284
  this.element = this.element.concat((0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_0__.cloneDeep)(arrayElement));
41285
+ this.copyMetaAndAttributes(arrayElement, this.element);
41272
41286
  path.stop();
41273
41287
  }
41274
41288
  }
@@ -41338,6 +41352,7 @@ class TagsVisitor extends _FallbackVisitor_mjs__WEBPACK_IMPORTED_MODULE_2__["def
41338
41352
  ArrayElement(path) {
41339
41353
  const arrayElement = path.node;
41340
41354
  this.element = this.element.concat((0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_0__.cloneDeep)(arrayElement));
41355
+ this.copyMetaAndAttributes(arrayElement, this.element);
41341
41356
  path.stop();
41342
41357
  }
41343
41358
  }
@@ -42494,8 +42509,11 @@ const processChildren = (cursor, ctx, transformerMap) => {
42494
42509
  return results;
42495
42510
  };
42496
42511
 
42497
- // strip leading '# ' (or bare '#') from comment text, keeping only the content
42498
- const stripCommentHash = text => text.split('\n').map(line => line.replace(/^#\s?/, '')).join('\n');
42512
+ // strip leading '#' from each line of comment text; the text after '#' is kept
42513
+ // verbatim (including leading whitespace) so serializers can round-trip it exactly;
42514
+ // a bare '#' becomes a single space — the yaml library's encoding for an empty
42515
+ // comment, which its stringifier turns back into '#' (plain '' would be dropped)
42516
+ const stripCommentHash = text => text.split('\n').map(line => line === '#' ? ' ' : line.replace(/^#/, '')).join('\n');
42499
42517
 
42500
42518
  // find the first YamlNode in a TransformResult (which may be an array from block_node)
42501
42519
  const findYamlNode = result => {
@@ -42538,7 +42556,10 @@ const processKeyValuePairChildren = (cursor, ctx, transformerMap) => {
42538
42556
  if (seenValue) {
42539
42557
  commentsAfterValue.push(commentText);
42540
42558
  } else if (seenKey) {
42541
- commentsBetweenKeyValue.push(commentText);
42559
+ commentsBetweenKeyValue.push({
42560
+ text: commentText,
42561
+ startLine: info.startPosition.row
42562
+ });
42542
42563
  }
42543
42564
  continue;
42544
42565
  }
@@ -42567,6 +42588,35 @@ const processKeyValuePairChildren = (cursor, ctx, transformerMap) => {
42567
42588
  commentsAfterValue
42568
42589
  };
42569
42590
  };
42591
+
42592
+ // attach comments collected inside a pair: comments on the key's own line belong
42593
+ // after the key (`key: # comment`), the rest before the value node; comments
42594
+ // found after the value become the value's trailing comment
42595
+ const attachPairComments = ({
42596
+ key,
42597
+ value,
42598
+ commentsBetweenKeyValue,
42599
+ commentsAfterValue
42600
+ }) => {
42601
+ if (commentsBetweenKeyValue.length > 0) {
42602
+ const keyNode = findYamlNode(key);
42603
+ const valueNode = findYamlNode(value);
42604
+ const onKeyLine = commentsBetweenKeyValue.filter(comment => keyNode !== null && comment.startLine === keyNode.endLine);
42605
+ const onOwnLine = commentsBetweenKeyValue.filter(comment => !onKeyLine.includes(comment));
42606
+ if (onKeyLine.length > 0 && keyNode) {
42607
+ keyNode.comment = onKeyLine.map(comment => comment.text).join('\n');
42608
+ }
42609
+ if (onOwnLine.length > 0 && valueNode) {
42610
+ valueNode.commentBefore = onOwnLine.map(comment => comment.text).join('\n');
42611
+ }
42612
+ }
42613
+ if (commentsAfterValue.length > 0) {
42614
+ const valueNode = findYamlNode(value);
42615
+ if (valueNode) {
42616
+ valueNode.comment = commentsAfterValue.join('\n');
42617
+ }
42618
+ }
42619
+ };
42570
42620
  const transform = (cursor, ctx, transformerMap, siblings = {}) => {
42571
42621
  const info = getCursorInfo(cursor);
42572
42622
 
@@ -42738,13 +42788,12 @@ const createTransformers = transformerMap => ({
42738
42788
  },
42739
42789
  block_mapping_pair(cursor, ctx) {
42740
42790
  const info = getCursorInfo(cursor);
42791
+ const pairResult = processKeyValuePairChildren(cursor, ctx, transformerMap);
42741
42792
  const {
42742
42793
  key,
42743
42794
  value,
42744
- errors,
42745
- commentsBetweenKeyValue,
42746
- commentsAfterValue
42747
- } = processKeyValuePairChildren(cursor, ctx, transformerMap);
42795
+ errors
42796
+ } = pairResult;
42748
42797
  const children = [];
42749
42798
 
42750
42799
  // Handle empty key
@@ -42790,21 +42839,7 @@ const createTransformers = transformerMap => ({
42790
42839
  } else {
42791
42840
  children.push(value);
42792
42841
  }
42793
-
42794
- // attach comments found between key and value to the value node
42795
- if (commentsBetweenKeyValue.length > 0) {
42796
- const valueNode = findYamlNode(value);
42797
- if (valueNode) {
42798
- valueNode.commentBefore = commentsBetweenKeyValue.join('\n');
42799
- }
42800
- }
42801
- // attach comments found after value to the value node
42802
- if (commentsAfterValue.length > 0) {
42803
- const valueNode = findYamlNode(value);
42804
- if (valueNode) {
42805
- valueNode.comment = commentsAfterValue.join('\n');
42806
- }
42807
- }
42842
+ attachPairComments(pairResult);
42808
42843
  children.push(...errors);
42809
42844
  return new _ast_nodes_YamlKeyValuePair_mjs__WEBPACK_IMPORTED_MODULE_9__["default"]({
42810
42845
  children: children.flat().filter(c => c !== null),
@@ -42832,13 +42867,12 @@ const createTransformers = transformerMap => ({
42832
42867
  },
42833
42868
  flow_pair(cursor, ctx) {
42834
42869
  const info = getCursorInfo(cursor);
42870
+ const pairResult = processKeyValuePairChildren(cursor, ctx, transformerMap);
42835
42871
  const {
42836
42872
  key,
42837
42873
  value,
42838
- errors,
42839
- commentsBetweenKeyValue,
42840
- commentsAfterValue
42841
- } = processKeyValuePairChildren(cursor, ctx, transformerMap);
42874
+ errors
42875
+ } = pairResult;
42842
42876
  const children = [];
42843
42877
 
42844
42878
  // Handle empty key
@@ -42884,21 +42918,7 @@ const createTransformers = transformerMap => ({
42884
42918
  } else {
42885
42919
  children.push(value);
42886
42920
  }
42887
-
42888
- // attach comments found between key and value to the value node
42889
- if (commentsBetweenKeyValue.length > 0) {
42890
- const valueNode = findYamlNode(value);
42891
- if (valueNode) {
42892
- valueNode.commentBefore = commentsBetweenKeyValue.join('\n');
42893
- }
42894
- }
42895
- // attach comments found after value to the value node
42896
- if (commentsAfterValue.length > 0) {
42897
- const valueNode = findYamlNode(value);
42898
- if (valueNode) {
42899
- valueNode.comment = commentsAfterValue.join('\n');
42900
- }
42901
- }
42921
+ attachPairComments(pairResult);
42902
42922
  children.push(...errors);
42903
42923
  return new _ast_nodes_YamlKeyValuePair_mjs__WEBPACK_IMPORTED_MODULE_9__["default"]({
42904
42924
  children: children.flat().filter(c => c !== null),
@@ -43109,7 +43129,9 @@ __webpack_require__.r(__webpack_exports__);
43109
43129
  /* harmony import */ var _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(40094);
43110
43130
  /* harmony import */ var _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(4823);
43111
43131
  /* harmony import */ var _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(25810);
43112
- /* harmony import */ var _ast_nodes_YamlStyle_mjs__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(21544);
43132
+ /* harmony import */ var _ast_nodes_predicates_mjs__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(90594);
43133
+ /* harmony import */ var _ast_nodes_YamlStyle_mjs__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(21544);
43134
+
43113
43135
 
43114
43136
  // Transform context passed through transformation
43115
43137
  // Node with type property and flat position properties
@@ -43136,14 +43158,17 @@ const findFirst = (node, path) => {
43136
43158
  // detect indent from first nested block mapping (stream > document > mapping > keyValuePair > mapping)
43137
43159
  const detectIndent = node => {
43138
43160
  const nested = findFirst(node, ['document', 'mapping', 'keyValuePair', 'mapping']);
43139
- if (nested?.styleGroup === _ast_nodes_YamlStyle_mjs__WEBPACK_IMPORTED_MODULE_9__.YamlStyleGroup.Block && typeof nested.startCharacter === 'number' && nested.startCharacter > 0) {
43161
+ if (nested?.styleGroup === _ast_nodes_YamlStyle_mjs__WEBPACK_IMPORTED_MODULE_10__.YamlStyleGroup.Block && typeof nested.startCharacter === 'number' && nested.startCharacter > 0) {
43140
43162
  return nested.startCharacter;
43141
43163
  }
43142
43164
  return 2;
43143
43165
  };
43144
43166
 
43145
- // strip leading '#' from each line of comment text; yaml library adds '#' during stringification
43146
- const stripCommentHash = text => text.split('\n').map(line => line.replace(/^#/, '')).join('\n');
43167
+ // strip leading '#' from each line of comment text; yaml library adds '#' during
43168
+ // stringification; a bare '#' becomes a single space — the yaml library's encoding
43169
+ // for an empty comment, which its stringifier turns back into '#' (plain '' would
43170
+ // be dropped)
43171
+ const stripCommentHash = text => text.split('\n').map(line => line === '#' ? ' ' : line.replace(/^#/, '')).join('\n');
43147
43172
 
43148
43173
  // collect comment texts from raw AST children, indexed by position relative to non-comment siblings
43149
43174
 
@@ -43213,6 +43238,7 @@ const setYamlStyleProp = (element, key, value) => {
43213
43238
  yaml[key] = value;
43214
43239
  element.style.yaml = yaml;
43215
43240
  };
43241
+ const getYamlStyleProp = (element, key) => element.style?.yaml?.[key];
43216
43242
 
43217
43243
  // apply collected comments to transformed ApiDOM elements
43218
43244
  const applyComments = (elements, comments) => {
@@ -43343,6 +43369,17 @@ const transformChildren = (children, ctx) => {
43343
43369
  return results;
43344
43370
  };
43345
43371
 
43372
+ // stream comments that precede the first document, joined; null when there are none
43373
+ // (stream children are in source order, so everything before the document node qualifies)
43374
+ const collectPreDocumentComments = node => {
43375
+ const texts = [];
43376
+ for (const child of node.children) {
43377
+ if ((0,_ast_nodes_predicates_mjs__WEBPACK_IMPORTED_MODULE_9__.isDocument)(child)) break;
43378
+ if ((0,_ast_nodes_predicates_mjs__WEBPACK_IMPORTED_MODULE_9__.isComment)(child)) texts.push(stripCommentHash(child.content));
43379
+ }
43380
+ return texts.length > 0 ? texts.join('\n') : null;
43381
+ };
43382
+
43346
43383
  // Stream: Wraps transformed children in ParseResultElement
43347
43384
  const transformStream = (node, ctx) => {
43348
43385
  // detect indent from the stream structure (only needed for style preservation)
@@ -43364,6 +43401,16 @@ const transformStream = (node, ctx) => {
43364
43401
  if (elements.length > 0) {
43365
43402
  const resultElement = elements[0];
43366
43403
  resultElement.classes.push('result');
43404
+
43405
+ // stream comments before the first document belong above the result element;
43406
+ // capture them as commentBefore so style round-trips can re-emit them
43407
+ if (ctx.style) {
43408
+ const preDocumentComments = collectPreDocumentComments(node);
43409
+ if (preDocumentComments !== null) {
43410
+ const existing = getYamlStyleProp(resultElement, 'commentBefore');
43411
+ setYamlStyleProp(resultElement, 'commentBefore', typeof existing === 'string' ? `${preDocumentComments}\n${existing}` : preDocumentComments);
43412
+ }
43413
+ }
43367
43414
  }
43368
43415
 
43369
43416
  // Add collected annotations
@@ -43399,7 +43446,7 @@ const transformCollection = (element, node, ctx) => {
43399
43446
  const typedNode = node;
43400
43447
  const children = node.children || [];
43401
43448
  if (ctx.style) {
43402
- if (ctx.flowCollectionPadding === null && node.styleGroup === _ast_nodes_YamlStyle_mjs__WEBPACK_IMPORTED_MODULE_9__.YamlStyleGroup.Flow) {
43449
+ if (ctx.flowCollectionPadding === null && node.styleGroup === _ast_nodes_YamlStyle_mjs__WEBPACK_IMPORTED_MODULE_10__.YamlStyleGroup.Flow) {
43403
43450
  ctx.flowCollectionPadding = detectFlowPadding(typedNode);
43404
43451
  }
43405
43452
  const comments = collectComments(children, typedNode.startCharacter);
@@ -43465,7 +43512,7 @@ const transformScalar = (node, ctx) => {
43465
43512
  const element = ctx.namespace.toElement(node.content);
43466
43513
 
43467
43514
  // Translate style information about empty nodes
43468
- if (node.content === '' && node.style === _ast_nodes_YamlStyle_mjs__WEBPACK_IMPORTED_MODULE_9__.YamlStyle.Plain) {
43515
+ if (node.content === '' && node.style === _ast_nodes_YamlStyle_mjs__WEBPACK_IMPORTED_MODULE_10__.YamlStyle.Plain) {
43469
43516
  element.classes.push('yaml-e-node');
43470
43517
  element.classes.push('yaml-e-scalar');
43471
43518
  }
@@ -45681,7 +45728,7 @@ const forEach = (element, options) => {
45681
45728
  callback = options.callback ?? (() => {});
45682
45729
  predicate = options.predicate ?? (() => true);
45683
45730
  }
45684
- (0,_traversal_mjs__WEBPACK_IMPORTED_MODULE_0__.traverse)(element, {
45731
+ ;(0,_traversal_mjs__WEBPACK_IMPORTED_MODULE_0__.traverse)(element, {
45685
45732
  enter(path) {
45686
45733
  if (predicate(path)) {
45687
45734
  callback(path);