@speclynx/apidom-parser-adapter-yaml-1-2 1.12.2 → 2.0.1
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 +20 -0
- package/NOTICE +16 -7
- package/README.md +34 -7
- package/dist/167.apidom-parser-adapter-yaml-1-2.browser.min.js +1 -1
- package/dist/451.apidom-parser-adapter-yaml-1-2.browser.min.js +1 -1
- package/dist/apidom-parser-adapter-yaml-1-2.browser.js +19340 -16731
- package/dist/apidom-parser-adapter-yaml-1-2.browser.min.js +1 -1
- package/package.json +10 -9
- package/src/adapter.cjs +28 -16
- package/src/adapter.mjs +25 -15
- package/src/tree-sitter/index.cjs +44 -0
- package/src/tree-sitter/index.mjs +38 -0
- package/src/{lexical-analysis → tree-sitter/lexical-analysis}/index.cjs +1 -1
- package/src/{lexical-analysis → tree-sitter/lexical-analysis}/index.mjs +1 -1
- package/src/tree-sitter/syntactic-analysis/CstTransformer.cjs +625 -0
- package/src/tree-sitter/syntactic-analysis/CstTransformer.mjs +618 -0
- package/src/tree-sitter/syntactic-analysis/YamlAstTransformer.cjs +271 -0
- package/src/tree-sitter/syntactic-analysis/YamlAstTransformer.mjs +263 -0
- package/src/tree-sitter/syntactic-analysis/ast/Error.cjs +30 -0
- package/src/tree-sitter/syntactic-analysis/ast/Error.mjs +24 -0
- package/src/tree-sitter/syntactic-analysis/ast/Literal.cjs +27 -0
- package/src/tree-sitter/syntactic-analysis/ast/Literal.mjs +21 -0
- package/src/tree-sitter/syntactic-analysis/ast/Node.cjs +60 -0
- package/src/tree-sitter/syntactic-analysis/ast/Node.mjs +56 -0
- package/src/tree-sitter/syntactic-analysis/ast/ParseResult.cjs +17 -0
- package/src/tree-sitter/syntactic-analysis/ast/ParseResult.mjs +12 -0
- package/src/tree-sitter/syntactic-analysis/ast/anchors-aliases/ReferenceManager.cjs +23 -0
- package/src/tree-sitter/syntactic-analysis/ast/anchors-aliases/ReferenceManager.mjs +18 -0
- package/src/tree-sitter/syntactic-analysis/ast/errors/YamlError.cjs +10 -0
- package/src/tree-sitter/syntactic-analysis/ast/errors/YamlError.mjs +7 -0
- package/src/tree-sitter/syntactic-analysis/ast/errors/YamlSchemaError.cjs +11 -0
- package/src/tree-sitter/syntactic-analysis/ast/errors/YamlSchemaError.mjs +6 -0
- package/src/tree-sitter/syntactic-analysis/ast/errors/YamlTagError.cjs +43 -0
- package/src/tree-sitter/syntactic-analysis/ast/errors/YamlTagError.mjs +37 -0
- package/src/tree-sitter/syntactic-analysis/ast/nodes/YamlAlias.cjs +27 -0
- package/src/tree-sitter/syntactic-analysis/ast/nodes/YamlAlias.mjs +21 -0
- package/src/tree-sitter/syntactic-analysis/ast/nodes/YamlAnchor.cjs +27 -0
- package/src/tree-sitter/syntactic-analysis/ast/nodes/YamlAnchor.mjs +21 -0
- package/src/tree-sitter/syntactic-analysis/ast/nodes/YamlCollection.cjs +11 -0
- package/src/tree-sitter/syntactic-analysis/ast/nodes/YamlCollection.mjs +6 -0
- package/src/tree-sitter/syntactic-analysis/ast/nodes/YamlComment.cjs +27 -0
- package/src/tree-sitter/syntactic-analysis/ast/nodes/YamlComment.mjs +21 -0
- package/src/tree-sitter/syntactic-analysis/ast/nodes/YamlDirective.cjs +39 -0
- package/src/tree-sitter/syntactic-analysis/ast/nodes/YamlDirective.mjs +32 -0
- package/src/tree-sitter/syntactic-analysis/ast/nodes/YamlDocument.cjs +13 -0
- package/src/tree-sitter/syntactic-analysis/ast/nodes/YamlDocument.mjs +8 -0
- package/src/tree-sitter/syntactic-analysis/ast/nodes/YamlKeyValuePair.cjs +48 -0
- package/src/tree-sitter/syntactic-analysis/ast/nodes/YamlKeyValuePair.mjs +42 -0
- package/src/tree-sitter/syntactic-analysis/ast/nodes/YamlMapping.cjs +20 -0
- package/src/tree-sitter/syntactic-analysis/ast/nodes/YamlMapping.mjs +15 -0
- package/src/tree-sitter/syntactic-analysis/ast/nodes/YamlNode.cjs +35 -0
- package/src/tree-sitter/syntactic-analysis/ast/nodes/YamlNode.mjs +29 -0
- package/src/tree-sitter/syntactic-analysis/ast/nodes/YamlScalar.cjs +27 -0
- package/src/tree-sitter/syntactic-analysis/ast/nodes/YamlScalar.mjs +21 -0
- package/src/tree-sitter/syntactic-analysis/ast/nodes/YamlSequence.cjs +23 -0
- package/src/tree-sitter/syntactic-analysis/ast/nodes/YamlSequence.mjs +18 -0
- package/src/tree-sitter/syntactic-analysis/ast/nodes/YamlStream.cjs +20 -0
- package/src/tree-sitter/syntactic-analysis/ast/nodes/YamlStream.mjs +15 -0
- package/src/tree-sitter/syntactic-analysis/ast/nodes/YamlStyle.cjs +27 -0
- package/src/tree-sitter/syntactic-analysis/ast/nodes/YamlStyle.mjs +24 -0
- package/src/tree-sitter/syntactic-analysis/ast/nodes/YamlTag.cjs +38 -0
- package/src/tree-sitter/syntactic-analysis/ast/nodes/YamlTag.mjs +35 -0
- package/src/tree-sitter/syntactic-analysis/ast/nodes/predicates.cjs +26 -0
- package/src/tree-sitter/syntactic-analysis/ast/nodes/predicates.mjs +14 -0
- package/src/tree-sitter/syntactic-analysis/ast/schemas/ScalarTag.cjs +33 -0
- package/src/tree-sitter/syntactic-analysis/ast/schemas/ScalarTag.mjs +29 -0
- package/src/tree-sitter/syntactic-analysis/ast/schemas/Tag.cjs +20 -0
- package/src/tree-sitter/syntactic-analysis/ast/schemas/Tag.mjs +16 -0
- package/src/tree-sitter/syntactic-analysis/ast/schemas/canonical-format.cjs +127 -0
- package/src/tree-sitter/syntactic-analysis/ast/schemas/canonical-format.mjs +122 -0
- package/src/tree-sitter/syntactic-analysis/ast/schemas/failsafe/GenericMapping.cjs +14 -0
- package/src/tree-sitter/syntactic-analysis/ast/schemas/failsafe/GenericMapping.mjs +9 -0
- package/src/tree-sitter/syntactic-analysis/ast/schemas/failsafe/GenericSequence.cjs +14 -0
- package/src/tree-sitter/syntactic-analysis/ast/schemas/failsafe/GenericSequence.mjs +9 -0
- package/src/tree-sitter/syntactic-analysis/ast/schemas/failsafe/GenericString.cjs +10 -0
- package/src/tree-sitter/syntactic-analysis/ast/schemas/failsafe/GenericString.mjs +5 -0
- package/src/tree-sitter/syntactic-analysis/ast/schemas/failsafe/index.cjs +116 -0
- package/src/tree-sitter/syntactic-analysis/ast/schemas/failsafe/index.mjs +111 -0
- package/src/tree-sitter/syntactic-analysis/ast/schemas/json/Boolean.cjs +19 -0
- package/src/tree-sitter/syntactic-analysis/ast/schemas/json/Boolean.mjs +14 -0
- package/src/tree-sitter/syntactic-analysis/ast/schemas/json/FloatingPoint.cjs +19 -0
- package/src/tree-sitter/syntactic-analysis/ast/schemas/json/FloatingPoint.mjs +14 -0
- package/src/tree-sitter/syntactic-analysis/ast/schemas/json/Integer.cjs +19 -0
- package/src/tree-sitter/syntactic-analysis/ast/schemas/json/Integer.mjs +14 -0
- package/src/tree-sitter/syntactic-analysis/ast/schemas/json/Null.cjs +18 -0
- package/src/tree-sitter/syntactic-analysis/ast/schemas/json/Null.mjs +13 -0
- package/src/tree-sitter/syntactic-analysis/ast/schemas/json/index.cjs +43 -0
- package/src/tree-sitter/syntactic-analysis/ast/schemas/json/index.mjs +38 -0
- package/src/tree-sitter/syntactic-analysis/index.cjs +39 -0
- package/src/tree-sitter/syntactic-analysis/index.mjs +33 -0
- package/src/yaml/index.cjs +31 -0
- package/src/yaml/index.mjs +26 -0
- package/types/apidom-parser-adapter-yaml-1-2.d.ts +11 -3
- package/src/syntactic-analysis/TreeCursorIterator.cjs +0 -93
- package/src/syntactic-analysis/TreeCursorIterator.mjs +0 -88
- package/src/syntactic-analysis/TreeCursorSyntaxNode.cjs +0 -80
- package/src/syntactic-analysis/TreeCursorSyntaxNode.mjs +0 -76
- package/src/syntactic-analysis/indirect/index.cjs +0 -51
- package/src/syntactic-analysis/indirect/index.mjs +0 -44
- package/src/syntactic-analysis/indirect/visitors/CstVisitor.cjs +0 -553
- package/src/syntactic-analysis/indirect/visitors/CstVisitor.mjs +0 -547
- package/src/syntactic-analysis/indirect/visitors/YamlAstVisitor.cjs +0 -164
- package/src/syntactic-analysis/indirect/visitors/YamlAstVisitor.mjs +0 -158
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.default = void 0;
|
|
6
|
+
var _Node = _interopRequireDefault(require("../Node.cjs"));
|
|
7
|
+
/**
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
class YamlNode extends _Node.default {
|
|
15
|
+
anchor;
|
|
16
|
+
tag;
|
|
17
|
+
style;
|
|
18
|
+
styleGroup;
|
|
19
|
+
constructor({
|
|
20
|
+
anchor,
|
|
21
|
+
tag,
|
|
22
|
+
style,
|
|
23
|
+
styleGroup,
|
|
24
|
+
...rest
|
|
25
|
+
}) {
|
|
26
|
+
super({
|
|
27
|
+
...rest
|
|
28
|
+
});
|
|
29
|
+
this.anchor = anchor;
|
|
30
|
+
this.tag = tag;
|
|
31
|
+
this.style = style;
|
|
32
|
+
this.styleGroup = styleGroup;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
var _default = exports.default = YamlNode;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import Node from "../Node.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* @public
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
class YamlNode extends Node {
|
|
9
|
+
anchor;
|
|
10
|
+
tag;
|
|
11
|
+
style;
|
|
12
|
+
styleGroup;
|
|
13
|
+
constructor({
|
|
14
|
+
anchor,
|
|
15
|
+
tag,
|
|
16
|
+
style,
|
|
17
|
+
styleGroup,
|
|
18
|
+
...rest
|
|
19
|
+
}) {
|
|
20
|
+
super({
|
|
21
|
+
...rest
|
|
22
|
+
});
|
|
23
|
+
this.anchor = anchor;
|
|
24
|
+
this.tag = tag;
|
|
25
|
+
this.style = style;
|
|
26
|
+
this.styleGroup = styleGroup;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export default YamlNode;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.default = void 0;
|
|
6
|
+
var _YamlNode = _interopRequireDefault(require("./YamlNode.cjs"));
|
|
7
|
+
/**
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
class YamlScalar extends _YamlNode.default {
|
|
15
|
+
static type = 'scalar';
|
|
16
|
+
content;
|
|
17
|
+
constructor({
|
|
18
|
+
content,
|
|
19
|
+
...rest
|
|
20
|
+
}) {
|
|
21
|
+
super({
|
|
22
|
+
...rest
|
|
23
|
+
});
|
|
24
|
+
this.content = content;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
var _default = exports.default = YamlScalar;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import YamlNode from "./YamlNode.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* @public
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
class YamlScalar extends YamlNode {
|
|
9
|
+
static type = 'scalar';
|
|
10
|
+
content;
|
|
11
|
+
constructor({
|
|
12
|
+
content,
|
|
13
|
+
...rest
|
|
14
|
+
}) {
|
|
15
|
+
super({
|
|
16
|
+
...rest
|
|
17
|
+
});
|
|
18
|
+
this.content = content;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export default YamlScalar;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.default = void 0;
|
|
6
|
+
var _YamlCollection = _interopRequireDefault(require("./YamlCollection.cjs"));
|
|
7
|
+
var _predicates = require("./predicates.cjs");
|
|
8
|
+
/**
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
class YamlSequence extends _YamlCollection.default {
|
|
12
|
+
static type = 'sequence';
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(YamlSequence.prototype, 'content', {
|
|
15
|
+
get() {
|
|
16
|
+
const {
|
|
17
|
+
children
|
|
18
|
+
} = this;
|
|
19
|
+
return Array.isArray(children) ? children.filter(node => (0, _predicates.isSequence)(node) || (0, _predicates.isMapping)(node) || (0, _predicates.isScalar)(node) || (0, _predicates.isAlias)(node)) : [];
|
|
20
|
+
},
|
|
21
|
+
enumerable: true
|
|
22
|
+
});
|
|
23
|
+
var _default = exports.default = YamlSequence;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import YamlCollection from "./YamlCollection.mjs";
|
|
2
|
+
import { isScalar, isMapping, isSequence, isAlias } from "./predicates.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
class YamlSequence extends YamlCollection {
|
|
7
|
+
static type = 'sequence';
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(YamlSequence.prototype, 'content', {
|
|
10
|
+
get() {
|
|
11
|
+
const {
|
|
12
|
+
children
|
|
13
|
+
} = this;
|
|
14
|
+
return Array.isArray(children) ? children.filter(node => isSequence(node) || isMapping(node) || isScalar(node) || isAlias(node)) : [];
|
|
15
|
+
},
|
|
16
|
+
enumerable: true
|
|
17
|
+
});
|
|
18
|
+
export default YamlSequence;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.default = void 0;
|
|
6
|
+
var _Node = _interopRequireDefault(require("../Node.cjs"));
|
|
7
|
+
var _predicates = require("./predicates.cjs");
|
|
8
|
+
/**
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
class YamlStream extends _Node.default {
|
|
12
|
+
static type = 'stream';
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(YamlStream.prototype, 'content', {
|
|
15
|
+
get() {
|
|
16
|
+
return Array.isArray(this.children) ? this.children.filter(node => (0, _predicates.isDocument)(node) || (0, _predicates.isComment)(node)) : [];
|
|
17
|
+
},
|
|
18
|
+
enumerable: true
|
|
19
|
+
});
|
|
20
|
+
var _default = exports.default = YamlStream;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import Node from "../Node.mjs";
|
|
2
|
+
import { isDocument, isComment } from "./predicates.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
class YamlStream extends Node {
|
|
7
|
+
static type = 'stream';
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(YamlStream.prototype, 'content', {
|
|
10
|
+
get() {
|
|
11
|
+
return Array.isArray(this.children) ? this.children.filter(node => isDocument(node) || isComment(node)) : [];
|
|
12
|
+
},
|
|
13
|
+
enumerable: true
|
|
14
|
+
});
|
|
15
|
+
export default YamlStream;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.YamlStyleGroup = exports.YamlStyle = void 0;
|
|
5
|
+
/**
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
let YamlStyle = exports.YamlStyle = /*#__PURE__*/function (YamlStyle) {
|
|
9
|
+
YamlStyle["Plain"] = "Plain";
|
|
10
|
+
YamlStyle["SingleQuoted"] = "SingleQuoted";
|
|
11
|
+
YamlStyle["DoubleQuoted"] = "DoubleQuoted";
|
|
12
|
+
YamlStyle["Literal"] = "Literal";
|
|
13
|
+
YamlStyle["Folded"] = "Folded";
|
|
14
|
+
YamlStyle["Explicit"] = "Explicit";
|
|
15
|
+
YamlStyle["SinglePair"] = "SinglePair";
|
|
16
|
+
YamlStyle["NextLine"] = "NextLine";
|
|
17
|
+
YamlStyle["InLine"] = "InLine";
|
|
18
|
+
return YamlStyle;
|
|
19
|
+
}({});
|
|
20
|
+
/**
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
let YamlStyleGroup = exports.YamlStyleGroup = /*#__PURE__*/function (YamlStyleGroup) {
|
|
24
|
+
YamlStyleGroup["Flow"] = "Flow";
|
|
25
|
+
YamlStyleGroup["Block"] = "Block";
|
|
26
|
+
return YamlStyleGroup;
|
|
27
|
+
}({});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @public
|
|
3
|
+
*/
|
|
4
|
+
export let YamlStyle = /*#__PURE__*/function (YamlStyle) {
|
|
5
|
+
YamlStyle["Plain"] = "Plain";
|
|
6
|
+
YamlStyle["SingleQuoted"] = "SingleQuoted";
|
|
7
|
+
YamlStyle["DoubleQuoted"] = "DoubleQuoted";
|
|
8
|
+
YamlStyle["Literal"] = "Literal";
|
|
9
|
+
YamlStyle["Folded"] = "Folded";
|
|
10
|
+
YamlStyle["Explicit"] = "Explicit";
|
|
11
|
+
YamlStyle["SinglePair"] = "SinglePair";
|
|
12
|
+
YamlStyle["NextLine"] = "NextLine";
|
|
13
|
+
YamlStyle["InLine"] = "InLine";
|
|
14
|
+
return YamlStyle;
|
|
15
|
+
}({});
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
export let YamlStyleGroup = /*#__PURE__*/function (YamlStyleGroup) {
|
|
21
|
+
YamlStyleGroup["Flow"] = "Flow";
|
|
22
|
+
YamlStyleGroup["Block"] = "Block";
|
|
23
|
+
return YamlStyleGroup;
|
|
24
|
+
}({});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.default = exports.YamlNodeKind = void 0;
|
|
6
|
+
var _Node = _interopRequireDefault(require("../Node.cjs"));
|
|
7
|
+
/**
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
let YamlNodeKind = exports.YamlNodeKind = /*#__PURE__*/function (YamlNodeKind) {
|
|
11
|
+
YamlNodeKind["Scalar"] = "Scalar";
|
|
12
|
+
YamlNodeKind["Sequence"] = "Sequence";
|
|
13
|
+
YamlNodeKind["Mapping"] = "Mapping";
|
|
14
|
+
return YamlNodeKind;
|
|
15
|
+
}({});
|
|
16
|
+
/**
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
class YamlTag extends _Node.default {
|
|
23
|
+
static type = 'tag';
|
|
24
|
+
explicitName;
|
|
25
|
+
kind;
|
|
26
|
+
constructor({
|
|
27
|
+
explicitName,
|
|
28
|
+
kind,
|
|
29
|
+
...rest
|
|
30
|
+
}) {
|
|
31
|
+
super({
|
|
32
|
+
...rest
|
|
33
|
+
});
|
|
34
|
+
this.explicitName = explicitName;
|
|
35
|
+
this.kind = kind;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
var _default = exports.default = YamlTag;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import Node from "../Node.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* @public
|
|
4
|
+
*/
|
|
5
|
+
export let YamlNodeKind = /*#__PURE__*/function (YamlNodeKind) {
|
|
6
|
+
YamlNodeKind["Scalar"] = "Scalar";
|
|
7
|
+
YamlNodeKind["Sequence"] = "Sequence";
|
|
8
|
+
YamlNodeKind["Mapping"] = "Mapping";
|
|
9
|
+
return YamlNodeKind;
|
|
10
|
+
}({});
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
class YamlTag extends Node {
|
|
20
|
+
static type = 'tag';
|
|
21
|
+
explicitName;
|
|
22
|
+
kind;
|
|
23
|
+
constructor({
|
|
24
|
+
explicitName,
|
|
25
|
+
kind,
|
|
26
|
+
...rest
|
|
27
|
+
}) {
|
|
28
|
+
super({
|
|
29
|
+
...rest
|
|
30
|
+
});
|
|
31
|
+
this.explicitName = explicitName;
|
|
32
|
+
this.kind = kind;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export default YamlTag;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.isSequence = exports.isScalar = exports.isMapping = exports.isKeyValuePair = exports.isDocument = exports.isComment = exports.isAlias = void 0;
|
|
6
|
+
var _YamlScalar = _interopRequireDefault(require("./YamlScalar.cjs"));
|
|
7
|
+
var _YamlMapping = _interopRequireDefault(require("./YamlMapping.cjs"));
|
|
8
|
+
var _YamlSequence = _interopRequireDefault(require("./YamlSequence.cjs"));
|
|
9
|
+
var _YamlAlias = _interopRequireDefault(require("./YamlAlias.cjs"));
|
|
10
|
+
var _YamlKeyValuePair = _interopRequireDefault(require("./YamlKeyValuePair.cjs"));
|
|
11
|
+
var _YamlDocument = _interopRequireDefault(require("./YamlDocument.cjs"));
|
|
12
|
+
var _YamlComment = _interopRequireDefault(require("./YamlComment.cjs"));
|
|
13
|
+
const isScalar = node => node instanceof _YamlScalar.default;
|
|
14
|
+
exports.isScalar = isScalar;
|
|
15
|
+
const isMapping = node => node instanceof _YamlMapping.default;
|
|
16
|
+
exports.isMapping = isMapping;
|
|
17
|
+
const isSequence = node => node instanceof _YamlSequence.default;
|
|
18
|
+
exports.isSequence = isSequence;
|
|
19
|
+
const isAlias = node => node instanceof _YamlAlias.default;
|
|
20
|
+
exports.isAlias = isAlias;
|
|
21
|
+
const isKeyValuePair = node => node instanceof _YamlKeyValuePair.default;
|
|
22
|
+
exports.isKeyValuePair = isKeyValuePair;
|
|
23
|
+
const isDocument = node => node instanceof _YamlDocument.default;
|
|
24
|
+
exports.isDocument = isDocument;
|
|
25
|
+
const isComment = node => node instanceof _YamlComment.default;
|
|
26
|
+
exports.isComment = isComment;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import YamlScalar from "./YamlScalar.mjs";
|
|
2
|
+
import YamlMapping from "./YamlMapping.mjs";
|
|
3
|
+
import YamlSequence from "./YamlSequence.mjs";
|
|
4
|
+
import YamlAlias from "./YamlAlias.mjs";
|
|
5
|
+
import YamlKeyValuePair from "./YamlKeyValuePair.mjs";
|
|
6
|
+
import YamlDocument from "./YamlDocument.mjs";
|
|
7
|
+
import YamlComment from "./YamlComment.mjs";
|
|
8
|
+
export const isScalar = node => node instanceof YamlScalar;
|
|
9
|
+
export const isMapping = node => node instanceof YamlMapping;
|
|
10
|
+
export const isSequence = node => node instanceof YamlSequence;
|
|
11
|
+
export const isAlias = node => node instanceof YamlAlias;
|
|
12
|
+
export const isKeyValuePair = node => node instanceof YamlKeyValuePair;
|
|
13
|
+
export const isDocument = node => node instanceof YamlDocument;
|
|
14
|
+
export const isComment = node => node instanceof YamlComment;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
5
|
+
var _canonicalFormat = require("./canonical-format.cjs");
|
|
6
|
+
var _YamlStyle = require("../nodes/YamlStyle.cjs");
|
|
7
|
+
var _YamlTag = require("../nodes/YamlTag.cjs");
|
|
8
|
+
class ScalarTag {
|
|
9
|
+
static test(node) {
|
|
10
|
+
return node.tag.kind === _YamlTag.YamlNodeKind.Scalar && typeof node.content === 'string';
|
|
11
|
+
}
|
|
12
|
+
static canonicalFormat(node) {
|
|
13
|
+
let canonicalForm = node.content;
|
|
14
|
+
const nodeClone = node.clone();
|
|
15
|
+
if (node.style === _YamlStyle.YamlStyle.Plain) {
|
|
16
|
+
canonicalForm = (0, _canonicalFormat.formatFlowPlain)(node.content);
|
|
17
|
+
} else if (node.style === _YamlStyle.YamlStyle.SingleQuoted) {
|
|
18
|
+
canonicalForm = (0, _canonicalFormat.formatFlowSingleQuoted)(node.content);
|
|
19
|
+
} else if (node.style === _YamlStyle.YamlStyle.DoubleQuoted) {
|
|
20
|
+
canonicalForm = (0, _canonicalFormat.formatFlowDoubleQuoted)(node.content);
|
|
21
|
+
} else if (node.style === _YamlStyle.YamlStyle.Literal) {
|
|
22
|
+
canonicalForm = (0, _canonicalFormat.formatBlockLiteral)(node.content);
|
|
23
|
+
} else if (node.style === _YamlStyle.YamlStyle.Folded) {
|
|
24
|
+
canonicalForm = (0, _canonicalFormat.formatBlockFolded)(node.content);
|
|
25
|
+
}
|
|
26
|
+
nodeClone.content = canonicalForm;
|
|
27
|
+
return nodeClone;
|
|
28
|
+
}
|
|
29
|
+
static resolve(node) {
|
|
30
|
+
return node;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
var _default = exports.default = ScalarTag;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { formatFlowPlain, formatFlowSingleQuoted, formatFlowDoubleQuoted, formatBlockLiteral, formatBlockFolded } from "./canonical-format.mjs";
|
|
2
|
+
import { YamlStyle } from "../nodes/YamlStyle.mjs";
|
|
3
|
+
import { YamlNodeKind } from "../nodes/YamlTag.mjs";
|
|
4
|
+
class ScalarTag {
|
|
5
|
+
static test(node) {
|
|
6
|
+
return node.tag.kind === YamlNodeKind.Scalar && typeof node.content === 'string';
|
|
7
|
+
}
|
|
8
|
+
static canonicalFormat(node) {
|
|
9
|
+
let canonicalForm = node.content;
|
|
10
|
+
const nodeClone = node.clone();
|
|
11
|
+
if (node.style === YamlStyle.Plain) {
|
|
12
|
+
canonicalForm = formatFlowPlain(node.content);
|
|
13
|
+
} else if (node.style === YamlStyle.SingleQuoted) {
|
|
14
|
+
canonicalForm = formatFlowSingleQuoted(node.content);
|
|
15
|
+
} else if (node.style === YamlStyle.DoubleQuoted) {
|
|
16
|
+
canonicalForm = formatFlowDoubleQuoted(node.content);
|
|
17
|
+
} else if (node.style === YamlStyle.Literal) {
|
|
18
|
+
canonicalForm = formatBlockLiteral(node.content);
|
|
19
|
+
} else if (node.style === YamlStyle.Folded) {
|
|
20
|
+
canonicalForm = formatBlockFolded(node.content);
|
|
21
|
+
}
|
|
22
|
+
nodeClone.content = canonicalForm;
|
|
23
|
+
return nodeClone;
|
|
24
|
+
}
|
|
25
|
+
static resolve(node) {
|
|
26
|
+
return node;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export default ScalarTag;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
5
|
+
class Tag {
|
|
6
|
+
static uri = '';
|
|
7
|
+
tag = '';
|
|
8
|
+
constructor() {
|
|
9
|
+
this.tag = this.constructor.uri;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
13
|
+
test(node) {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
resolve(node) {
|
|
17
|
+
return node;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
var _default = exports.default = Tag;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
class Tag {
|
|
2
|
+
static uri = '';
|
|
3
|
+
tag = '';
|
|
4
|
+
constructor() {
|
|
5
|
+
this.tag = this.constructor.uri;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
9
|
+
test(node) {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
resolve(node) {
|
|
13
|
+
return node;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export default Tag;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.formatFlowSingleQuoted = exports.formatFlowPlain = exports.formatFlowDoubleQuoted = exports.formatBlockLiteral = exports.formatBlockFolded = void 0;
|
|
5
|
+
var _ramda = require("ramda");
|
|
6
|
+
var _ramdaAdjunct = require("ramda-adjunct");
|
|
7
|
+
var _unraw = require("unraw");
|
|
8
|
+
/**
|
|
9
|
+
* Helpers.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const blockStyleRegExp = /^(?<style>[|>])(?<chomping>[+-]?)(?<indentation>[0-9]*)\s/;
|
|
13
|
+
const getIndentationIndicator = content => {
|
|
14
|
+
const matches = content.match(blockStyleRegExp);
|
|
15
|
+
const indicator = (0, _ramda.pathOr)('', ['groups', 'indentation'], matches);
|
|
16
|
+
return (0, _ramdaAdjunct.isEmptyString)(indicator) ? undefined : parseInt(indicator, 10);
|
|
17
|
+
};
|
|
18
|
+
const getIndentation = content => {
|
|
19
|
+
const explicitIndentationIndicator = getIndentationIndicator(content);
|
|
20
|
+
|
|
21
|
+
// we have explicit indentation indicator
|
|
22
|
+
if ((0, _ramdaAdjunct.isInteger)(explicitIndentationIndicator)) {
|
|
23
|
+
return (0, _ramdaAdjunct.repeatStr)(' ', explicitIndentationIndicator);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// we assume indentation indicator from first line
|
|
27
|
+
const firstLine = (0, _ramda.pathOr)('', [1], content.split('\n'));
|
|
28
|
+
const implicitIndentationIndicator = (0, _ramda.pathOr)(0, ['groups', 'indentation', 'length'], firstLine.match(/^(?<indentation>[ ]*)/));
|
|
29
|
+
return (0, _ramdaAdjunct.repeatStr)(' ', implicitIndentationIndicator);
|
|
30
|
+
};
|
|
31
|
+
const getChompingIndicator = content => {
|
|
32
|
+
const matches = content.match(blockStyleRegExp);
|
|
33
|
+
const indicator = (0, _ramda.pathOr)('', ['groups', 'chomping'], matches);
|
|
34
|
+
return (0, _ramdaAdjunct.isEmptyString)(indicator) ? undefined : indicator;
|
|
35
|
+
};
|
|
36
|
+
const chomp = (indicator, content) => {
|
|
37
|
+
// clip (single newline at end)
|
|
38
|
+
if ((0, _ramdaAdjunct.isUndefined)(indicator)) {
|
|
39
|
+
return `${(0, _ramdaAdjunct.trimEnd)(content)}\n`;
|
|
40
|
+
}
|
|
41
|
+
// strip (no newline at end)
|
|
42
|
+
if (indicator === '-') {
|
|
43
|
+
return (0, _ramdaAdjunct.trimEnd)(content);
|
|
44
|
+
}
|
|
45
|
+
// keep (all newlines from end)
|
|
46
|
+
if (indicator === '+') {
|
|
47
|
+
return content;
|
|
48
|
+
}
|
|
49
|
+
return content;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Normalizes lines breaks.
|
|
54
|
+
* https://yaml.org/spec/1.2/spec.html#line%20break/normalization/
|
|
55
|
+
*/
|
|
56
|
+
// @ts-ignore
|
|
57
|
+
const normalizeLineBreaks = val => val.replace(/\r\n/g, '\n');
|
|
58
|
+
|
|
59
|
+
// prevent escaped line breaks from being converted to a space
|
|
60
|
+
const preventLineBreakCollapseToSpace = val => val.replace(/\\\n\s*/g, '');
|
|
61
|
+
|
|
62
|
+
// collapse line breaks into spaces
|
|
63
|
+
const collapseLineBreakToSpace = val => {
|
|
64
|
+
/**
|
|
65
|
+
* Safari doesn't support negative lookbehind, thus we use mimicking technique:
|
|
66
|
+
*
|
|
67
|
+
* - https://blog.stevenlevithan.com/archives/mimic-lookbehind-javascript
|
|
68
|
+
*
|
|
69
|
+
* Ideally we want to use following replace, but that's not currently possible:
|
|
70
|
+
*
|
|
71
|
+
* .replace(/[^\n]\n([^\n]+)/g, (match: string, p1: string) => ` ${p1.trimLeft()}`)
|
|
72
|
+
*/
|
|
73
|
+
return val.replace(/(\n)?\n([^\n]+)/g, (match, p1, p2) => p1 ? match : ` ${p2.trimStart()}`).replace(/[\n]{2}/g, '\n');
|
|
74
|
+
};
|
|
75
|
+
const removeQuotes = (0, _ramda.curry)((quoteType, val) => val.replace(new RegExp(`^${quoteType}`), '').replace(new RegExp(`${quoteType}$`), ''));
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Formats Flow Scalar Plain style.
|
|
79
|
+
* https://yaml.org/spec/1.2/spec.html#id2788859
|
|
80
|
+
*/
|
|
81
|
+
const formatFlowPlain = exports.formatFlowPlain = (0, _ramda.pipe)(normalizeLineBreaks, _ramda.trim, collapseLineBreakToSpace, (0, _ramda.split)('\n'), (0, _ramda.map)(_ramdaAdjunct.trimStart), (0, _ramda.join)('\n'));
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Formats Flow Scalar Single-Quoted style.
|
|
85
|
+
* https://yaml.org/spec/1.2/spec.html#id2788097
|
|
86
|
+
*/
|
|
87
|
+
|
|
88
|
+
const formatFlowSingleQuoted = exports.formatFlowSingleQuoted = (0, _ramda.pipe)(normalizeLineBreaks, _ramda.trim, collapseLineBreakToSpace, (0, _ramda.split)('\n'), (0, _ramda.map)(_ramdaAdjunct.trimStart), (0, _ramda.join)('\n'), removeQuotes("'"));
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Formats Flow Scalar Double-Quoted style.
|
|
92
|
+
* https://yaml.org/spec/1.2/spec.html#id2787109
|
|
93
|
+
*/
|
|
94
|
+
const formatFlowDoubleQuoted = exports.formatFlowDoubleQuoted = (0, _ramda.pipe)(normalizeLineBreaks, _ramda.trim, preventLineBreakCollapseToSpace, collapseLineBreakToSpace, _unraw.unraw, (0, _ramda.split)('\n'), (0, _ramda.map)(_ramdaAdjunct.trimStart), (0, _ramda.join)('\n'), removeQuotes('"'));
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Formats Block Scalar Literal style.
|
|
98
|
+
* https://yaml.org/spec/1.2/spec.html#id2795688
|
|
99
|
+
*/
|
|
100
|
+
const formatBlockLiteral = content => {
|
|
101
|
+
const indentation = getIndentation(content);
|
|
102
|
+
const chompingIndicator = getChompingIndicator(content);
|
|
103
|
+
const normalized = normalizeLineBreaks(content);
|
|
104
|
+
const lines = (0, _ramda.tail)(normalized.split('\n')); // first line only contains indicators
|
|
105
|
+
const transducer = (0, _ramda.compose)((0, _ramda.map)((0, _ramdaAdjunct.trimCharsStart)(indentation)), (0, _ramda.map)((0, _ramdaAdjunct.concatRight)('\n')));
|
|
106
|
+
// @ts-ignore
|
|
107
|
+
const deindented = (0, _ramda.transduce)(transducer, _ramda.concat, '', lines);
|
|
108
|
+
return chomp(chompingIndicator, deindented);
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Formats BLock Scalar Folded style.
|
|
113
|
+
* https://yaml.org/spec/1.2/spec.html#id2796251
|
|
114
|
+
*/
|
|
115
|
+
exports.formatBlockLiteral = formatBlockLiteral;
|
|
116
|
+
const formatBlockFolded = content => {
|
|
117
|
+
const indentation = getIndentation(content);
|
|
118
|
+
const chompingIndicator = getChompingIndicator(content);
|
|
119
|
+
const normalized = normalizeLineBreaks(content);
|
|
120
|
+
const lines = (0, _ramda.tail)(normalized.split('\n')); // first line only contains indicators
|
|
121
|
+
const transducer = (0, _ramda.compose)((0, _ramda.map)((0, _ramdaAdjunct.trimCharsStart)(indentation)), (0, _ramda.map)((0, _ramdaAdjunct.concatRight)('\n')));
|
|
122
|
+
// @ts-ignore
|
|
123
|
+
const deindented = (0, _ramda.transduce)(transducer, _ramda.concat, '', lines);
|
|
124
|
+
const collapsed = collapseLineBreakToSpace(deindented);
|
|
125
|
+
return chomp(chompingIndicator, collapsed);
|
|
126
|
+
};
|
|
127
|
+
exports.formatBlockFolded = formatBlockFolded;
|