@speclynx/apidom-core 2.10.3 → 2.12.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 +10 -0
- package/README.md +31 -0
- package/dist/apidom-core.browser.js +553 -46
- package/dist/apidom-core.browser.min.js +1 -1
- package/package.json +5 -5
- package/src/fields/fixed-fields.cjs +4 -0
- package/src/fields/fixed-fields.mjs +4 -0
- package/src/refractor/toolbox.cjs +1 -0
- package/src/refractor/toolbox.mjs +2 -1
- package/src/specification.cjs +13 -1
- package/src/specification.mjs +13 -1
- package/src/transformers/serializers/json.cjs +65 -1
- package/src/transformers/serializers/json.mjs +66 -2
- package/src/transformers/serializers/yaml-1-2.cjs +111 -0
- package/src/transformers/serializers/yaml-1-2.mjs +113 -1
- package/types/apidom-core.d.ts +25 -8
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
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
|
+
# [2.12.0](https://github.com/speclynx/apidom/compare/v2.11.0...v2.12.0) (2026-02-18)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- add support for lossless JSON/YAML roundtrips ([#97](https://github.com/speclynx/apidom/issues/97)) ([dc17c9a](https://github.com/speclynx/apidom/commit/dc17c9a78fbc7df07a91e8f35b12be6409117d91))
|
|
11
|
+
|
|
12
|
+
# [2.11.0](https://github.com/speclynx/apidom/compare/v2.10.3...v2.11.0) (2026-02-12)
|
|
13
|
+
|
|
14
|
+
**Note:** Version bump only for package @speclynx/apidom-core
|
|
15
|
+
|
|
6
16
|
## [2.10.3](https://github.com/speclynx/apidom/compare/v2.10.2...v2.10.3) (2026-02-10)
|
|
7
17
|
|
|
8
18
|
**Note:** Version bump only for package @speclynx/apidom-core
|
package/README.md
CHANGED
|
@@ -587,6 +587,21 @@ const objElement = new ObjectElement({ a: 'b' });
|
|
|
587
587
|
toJSON(objElement); // => '{"a":"b"}'
|
|
588
588
|
```
|
|
589
589
|
|
|
590
|
+
`toJSON` also accepts an options object as the second argument. When `preserveStyle` is `true`,
|
|
591
|
+
the serializer uses style information from `element.style.json` (captured during parsing with `style: true`)
|
|
592
|
+
to preserve original formatting such as indentation and raw number representation.
|
|
593
|
+
|
|
594
|
+
```js
|
|
595
|
+
import { toJSON } from '@speclynx/apidom-core';
|
|
596
|
+
import { parse } from '@speclynx/apidom-parser-adapter-json';
|
|
597
|
+
|
|
598
|
+
const parseResult = await parse(jsonString, { style: true });
|
|
599
|
+
// ... modify elements ...
|
|
600
|
+
toJSON(parseResult.result, { preserveStyle: true });
|
|
601
|
+
```
|
|
602
|
+
|
|
603
|
+
`toJSON` also supports the positional signature `toJSON(element, replacer?, space?)` matching [JSON.stringify](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify).
|
|
604
|
+
|
|
590
605
|
### toYAML
|
|
591
606
|
|
|
592
607
|
Transforms the ApiDOM into YAML string.
|
|
@@ -606,6 +621,22 @@ toYAML(objElement);
|
|
|
606
621
|
*/
|
|
607
622
|
```
|
|
608
623
|
|
|
624
|
+
`toYAML` accepts an optional second argument with serialization options. When `preserveStyle` is `true`,
|
|
625
|
+
the serializer uses style information from `element.style.yaml` (captured during parsing with `style: true`)
|
|
626
|
+
to preserve original formatting such as quoting styles, flow/block collections, comments, and indentation.
|
|
627
|
+
Number format categories (exponential, hex, octal, fractional digits) are also preserved, though the
|
|
628
|
+
underlying yaml library may normalize the exact representation (e.g., `1.0e10` becomes `1e+10`,
|
|
629
|
+
`0x1A` becomes `0x1a`).
|
|
630
|
+
|
|
631
|
+
```js
|
|
632
|
+
import { toYAML } from '@speclynx/apidom-core';
|
|
633
|
+
import { parse } from '@speclynx/apidom-parser-adapter-yaml-1-2';
|
|
634
|
+
|
|
635
|
+
const parseResult = await parse(yamlString, { style: true });
|
|
636
|
+
// ... modify elements ...
|
|
637
|
+
toYAML(parseResult.result, { preserveStyle: true });
|
|
638
|
+
```
|
|
639
|
+
|
|
609
640
|
### dehydrate
|
|
610
641
|
|
|
611
642
|
Creates a [refract representation](https://github.com/refractproject/refract-spec) of an Element.
|