@speclynx/apidom-core 1.12.2 → 2.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.
Files changed (92) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/NOTICE +16 -7
  3. package/README.md +102 -330
  4. package/dist/apidom-core.browser.js +13110 -10559
  5. package/dist/apidom-core.browser.min.js +1 -1
  6. package/package.json +7 -12
  7. package/src/identity/index.cjs +8 -6
  8. package/src/identity/index.mjs +6 -4
  9. package/src/index.cjs +13 -79
  10. package/src/index.mjs +3 -13
  11. package/src/merge/deepmerge.cjs +22 -20
  12. package/src/merge/deepmerge.mjs +9 -7
  13. package/src/merge/merge-right.cjs +2 -2
  14. package/src/merge/merge-right.mjs +1 -1
  15. package/src/namespace.cjs +4 -36
  16. package/src/namespace.mjs +2 -30
  17. package/src/refractor/plugins/dispatcher/index.cjs +5 -12
  18. package/src/refractor/plugins/dispatcher/index.mjs +5 -12
  19. package/src/refractor/plugins/element-identity.cjs +2 -2
  20. package/src/refractor/plugins/element-identity.mjs +2 -2
  21. package/src/refractor/plugins/semantic-element-identity.cjs +5 -10
  22. package/src/refractor/plugins/semantic-element-identity.mjs +5 -9
  23. package/src/refractor/toolbox.cjs +22 -5
  24. package/src/refractor/toolbox.mjs +25 -6
  25. package/src/specification.cjs +51 -0
  26. package/src/specification.mjs +47 -0
  27. package/src/transcluder/Transcluder.cjs +8 -8
  28. package/src/transcluder/Transcluder.mjs +1 -1
  29. package/src/transformers/from.mjs +2 -2
  30. package/src/transformers/serializers/json.cjs +2 -2
  31. package/src/transformers/serializers/json.mjs +1 -1
  32. package/src/transformers/serializers/value.cjs +50 -0
  33. package/src/transformers/serializers/value.mjs +47 -0
  34. package/src/transformers/serializers/yaml-1-2.cjs +22 -18
  35. package/src/transformers/serializers/yaml-1-2.mjs +22 -18
  36. package/src/transformers/sexprs.cjs +20 -23
  37. package/src/transformers/sexprs.mjs +20 -22
  38. package/src/transformers/to-string.mjs +2 -2
  39. package/types/apidom-core.d.ts +67 -519
  40. package/src/clone/errors/CloneError.cjs +0 -22
  41. package/src/clone/errors/CloneError.mjs +0 -19
  42. package/src/clone/errors/DeepCloneError.cjs +0 -11
  43. package/src/clone/errors/DeepCloneError.mjs +0 -6
  44. package/src/clone/errors/ShallowCloneError.cjs +0 -11
  45. package/src/clone/errors/ShallowCloneError.mjs +0 -6
  46. package/src/clone/index.cjs +0 -155
  47. package/src/clone/index.mjs +0 -146
  48. package/src/elements/Annotation.cjs +0 -23
  49. package/src/elements/Annotation.mjs +0 -20
  50. package/src/elements/Comment.cjs +0 -15
  51. package/src/elements/Comment.mjs +0 -12
  52. package/src/elements/ParseResult.cjs +0 -53
  53. package/src/elements/ParseResult.mjs +0 -50
  54. package/src/elements/SourceMap.cjs +0 -39
  55. package/src/elements/SourceMap.mjs +0 -36
  56. package/src/predicates/helpers.cjs +0 -85
  57. package/src/predicates/helpers.mjs +0 -77
  58. package/src/predicates/index.cjs +0 -208
  59. package/src/predicates/index.mjs +0 -198
  60. package/src/refractor/index.cjs +0 -46
  61. package/src/refractor/index.mjs +0 -40
  62. package/src/refractor/registration.cjs +0 -34
  63. package/src/refractor/registration.mjs +0 -19
  64. package/src/transformers/serializers/value/ast/ephemeral-array.cjs +0 -21
  65. package/src/transformers/serializers/value/ast/ephemeral-array.mjs +0 -17
  66. package/src/transformers/serializers/value/ast/ephemeral-object.cjs +0 -20
  67. package/src/transformers/serializers/value/ast/ephemeral-object.mjs +0 -16
  68. package/src/transformers/serializers/value/index.cjs +0 -85
  69. package/src/transformers/serializers/value/index.mjs +0 -80
  70. package/src/transformers/serializers/value/visitor.cjs +0 -52
  71. package/src/transformers/serializers/value/visitor.mjs +0 -47
  72. package/src/traversal/filter.cjs +0 -18
  73. package/src/traversal/filter.mjs +0 -14
  74. package/src/traversal/find.cjs +0 -19
  75. package/src/traversal/find.mjs +0 -15
  76. package/src/traversal/findAtOffset.cjs +0 -65
  77. package/src/traversal/findAtOffset.mjs +0 -60
  78. package/src/traversal/index.cjs +0 -19
  79. package/src/traversal/index.mjs +0 -7
  80. package/src/traversal/parents.cjs +0 -38
  81. package/src/traversal/parents.mjs +0 -34
  82. package/src/traversal/reject.cjs +0 -15
  83. package/src/traversal/reject.mjs +0 -10
  84. package/src/traversal/some.cjs +0 -15
  85. package/src/traversal/some.mjs +0 -10
  86. package/src/traversal/traverse.cjs +0 -60
  87. package/src/traversal/traverse.mjs +0 -53
  88. package/src/traversal/visitor.cjs +0 -123
  89. package/src/traversal/visitor.mjs +0 -115
  90. package/src/util.cjs +0 -28
  91. package/src/util.mjs +0 -24
  92. package/types/minim.d.ts +0 -236
@@ -1,22 +0,0 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- exports.default = void 0;
5
- var _apidomError = require("@speclynx/apidom-error");
6
- /**
7
- * @public
8
- */
9
-
10
- /**
11
- * @public
12
- */
13
- class CloneError extends _apidomError.ApiDOMStructuredError {
14
- value;
15
- constructor(message, structuredOptions) {
16
- super(message, structuredOptions);
17
- if (typeof structuredOptions !== 'undefined') {
18
- this.value = structuredOptions.value;
19
- }
20
- }
21
- }
22
- var _default = exports.default = CloneError;
@@ -1,19 +0,0 @@
1
- import { ApiDOMStructuredError } from '@speclynx/apidom-error';
2
-
3
- /**
4
- * @public
5
- */
6
-
7
- /**
8
- * @public
9
- */
10
- class CloneError extends ApiDOMStructuredError {
11
- value;
12
- constructor(message, structuredOptions) {
13
- super(message, structuredOptions);
14
- if (typeof structuredOptions !== 'undefined') {
15
- this.value = structuredOptions.value;
16
- }
17
- }
18
- }
19
- export default CloneError;
@@ -1,11 +0,0 @@
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 _CloneError = _interopRequireDefault(require("./CloneError.cjs"));
7
- /**
8
- * @public
9
- */
10
- class DeepCloneError extends _CloneError.default {}
11
- var _default = exports.default = DeepCloneError;
@@ -1,6 +0,0 @@
1
- import CloneError from "./CloneError.mjs";
2
- /**
3
- * @public
4
- */
5
- class DeepCloneError extends CloneError {}
6
- export default DeepCloneError;
@@ -1,11 +0,0 @@
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 _CloneError = _interopRequireDefault(require("./CloneError.cjs"));
7
- /**
8
- * @public
9
- */
10
- class ShallowCloneError extends _CloneError.default {}
11
- var _default = exports.default = ShallowCloneError;
@@ -1,6 +0,0 @@
1
- import CloneError from "./CloneError.mjs";
2
- /**
3
- * @public
4
- */
5
- class ShallowCloneError extends CloneError {}
6
- export default ShallowCloneError;
@@ -1,155 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
4
- exports.__esModule = true;
5
- exports.cloneShallow = exports.cloneDeep = void 0;
6
- var _minim = require("minim");
7
- var _index = require("../predicates/index.cjs");
8
- var _DeepCloneError = _interopRequireDefault(require("./errors/DeepCloneError.cjs"));
9
- var _ShallowCloneError = _interopRequireDefault(require("./errors/ShallowCloneError.cjs"));
10
- /**
11
- * @public
12
- */
13
-
14
- /**
15
- * @public
16
- */
17
-
18
- /**
19
- * @public
20
- */
21
- const cloneDeep = (value, options = {}) => {
22
- const {
23
- visited = new WeakMap()
24
- } = options;
25
- const passThroughOptions = {
26
- ...options,
27
- visited
28
- };
29
-
30
- // detect cycle and return memoized value
31
- if (visited.has(value)) {
32
- return visited.get(value);
33
- }
34
- if (value instanceof _minim.KeyValuePair) {
35
- const {
36
- key,
37
- value: val
38
- } = value;
39
- const keyCopy = (0, _index.isElement)(key) ? cloneDeep(key, passThroughOptions) : key;
40
- const valueCopy = (0, _index.isElement)(val) ? cloneDeep(val, passThroughOptions) : val;
41
- const copy = new _minim.KeyValuePair(keyCopy, valueCopy);
42
- visited.set(value, copy);
43
- return copy;
44
- }
45
- if (value instanceof _minim.ObjectSlice) {
46
- const mapper = element => cloneDeep(element, passThroughOptions);
47
- const items = [...value].map(mapper);
48
- const copy = new _minim.ObjectSlice(items);
49
- visited.set(value, copy);
50
- return copy;
51
- }
52
- if (value instanceof _minim.ArraySlice) {
53
- const mapper = element => cloneDeep(element, passThroughOptions);
54
- const items = [...value].map(mapper);
55
- const copy = new _minim.ArraySlice(items);
56
- visited.set(value, copy);
57
- return copy;
58
- }
59
- if ((0, _index.isElement)(value)) {
60
- const copy = cloneShallow(value);
61
- visited.set(value, copy);
62
- if (value.content) {
63
- if ((0, _index.isElement)(value.content)) {
64
- copy.content = cloneDeep(value.content, passThroughOptions);
65
- } else if (value.content instanceof _minim.KeyValuePair) {
66
- copy.content = cloneDeep(value.content, passThroughOptions);
67
- } else if (Array.isArray(value.content)) {
68
- const mapper = element => cloneDeep(element, passThroughOptions);
69
- copy.content = value.content.map(mapper);
70
- } else {
71
- copy.content = value.content;
72
- }
73
- } else {
74
- copy.content = value.content;
75
- }
76
- return copy;
77
- }
78
- throw new _DeepCloneError.default("Value provided to cloneDeep function couldn't be cloned", {
79
- value
80
- });
81
- };
82
- exports.cloneDeep = cloneDeep;
83
- cloneDeep.safe = value => {
84
- try {
85
- return cloneDeep(value);
86
- } catch {
87
- return value;
88
- }
89
- };
90
- const cloneShallowKeyValuePair = keyValuePair => {
91
- const {
92
- key,
93
- value
94
- } = keyValuePair;
95
- return new _minim.KeyValuePair(key, value);
96
- };
97
- const cloneShallowArraySlice = arraySlice => {
98
- const items = [...arraySlice];
99
- return new _minim.ArraySlice(items);
100
- };
101
- const cloneShallowObjectSlice = objectSlice => {
102
- const items = [...objectSlice];
103
- return new _minim.ObjectSlice(items);
104
- };
105
- const cloneShallowElement = element => {
106
- // @ts-ignore
107
- const copy = new element.constructor();
108
- copy.element = element.element;
109
- if (element.meta.length > 0) {
110
- copy._meta = cloneDeep(element.meta);
111
- }
112
- if (element.attributes.length > 0) {
113
- copy._attributes = cloneDeep(element.attributes);
114
- }
115
- if ((0, _index.isElement)(element.content)) {
116
- const content = element.content;
117
- copy.content = cloneShallowElement(content);
118
- } else if (Array.isArray(element.content)) {
119
- copy.content = [...element.content];
120
- } else if (element.content instanceof _minim.KeyValuePair) {
121
- copy.content = cloneShallowKeyValuePair(element.content);
122
- } else {
123
- copy.content = element.content;
124
- }
125
- return copy;
126
- };
127
-
128
- /**
129
- * @public
130
- */
131
- const cloneShallow = value => {
132
- if (value instanceof _minim.KeyValuePair) {
133
- return cloneShallowKeyValuePair(value);
134
- }
135
- if (value instanceof _minim.ObjectSlice) {
136
- return cloneShallowObjectSlice(value);
137
- }
138
- if (value instanceof _minim.ArraySlice) {
139
- return cloneShallowArraySlice(value);
140
- }
141
- if ((0, _index.isElement)(value)) {
142
- return cloneShallowElement(value);
143
- }
144
- throw new _ShallowCloneError.default("Value provided to cloneShallow function couldn't be cloned", {
145
- value
146
- });
147
- };
148
- exports.cloneShallow = cloneShallow;
149
- cloneShallow.safe = value => {
150
- try {
151
- return cloneShallow(value);
152
- } catch {
153
- return value;
154
- }
155
- };
@@ -1,146 +0,0 @@
1
- import { ArraySlice, ObjectSlice, KeyValuePair } from 'minim';
2
- import { isElement } from "../predicates/index.mjs";
3
- import DeepCloneError from "./errors/DeepCloneError.mjs";
4
- import ShallowCloneError from "./errors/ShallowCloneError.mjs";
5
- /**
6
- * @public
7
- */
8
- /**
9
- * @public
10
- */
11
- /**
12
- * @public
13
- */
14
- export const cloneDeep = (value, options = {}) => {
15
- const {
16
- visited = new WeakMap()
17
- } = options;
18
- const passThroughOptions = {
19
- ...options,
20
- visited
21
- };
22
-
23
- // detect cycle and return memoized value
24
- if (visited.has(value)) {
25
- return visited.get(value);
26
- }
27
- if (value instanceof KeyValuePair) {
28
- const {
29
- key,
30
- value: val
31
- } = value;
32
- const keyCopy = isElement(key) ? cloneDeep(key, passThroughOptions) : key;
33
- const valueCopy = isElement(val) ? cloneDeep(val, passThroughOptions) : val;
34
- const copy = new KeyValuePair(keyCopy, valueCopy);
35
- visited.set(value, copy);
36
- return copy;
37
- }
38
- if (value instanceof ObjectSlice) {
39
- const mapper = element => cloneDeep(element, passThroughOptions);
40
- const items = [...value].map(mapper);
41
- const copy = new ObjectSlice(items);
42
- visited.set(value, copy);
43
- return copy;
44
- }
45
- if (value instanceof ArraySlice) {
46
- const mapper = element => cloneDeep(element, passThroughOptions);
47
- const items = [...value].map(mapper);
48
- const copy = new ArraySlice(items);
49
- visited.set(value, copy);
50
- return copy;
51
- }
52
- if (isElement(value)) {
53
- const copy = cloneShallow(value);
54
- visited.set(value, copy);
55
- if (value.content) {
56
- if (isElement(value.content)) {
57
- copy.content = cloneDeep(value.content, passThroughOptions);
58
- } else if (value.content instanceof KeyValuePair) {
59
- copy.content = cloneDeep(value.content, passThroughOptions);
60
- } else if (Array.isArray(value.content)) {
61
- const mapper = element => cloneDeep(element, passThroughOptions);
62
- copy.content = value.content.map(mapper);
63
- } else {
64
- copy.content = value.content;
65
- }
66
- } else {
67
- copy.content = value.content;
68
- }
69
- return copy;
70
- }
71
- throw new DeepCloneError("Value provided to cloneDeep function couldn't be cloned", {
72
- value
73
- });
74
- };
75
- cloneDeep.safe = value => {
76
- try {
77
- return cloneDeep(value);
78
- } catch {
79
- return value;
80
- }
81
- };
82
- const cloneShallowKeyValuePair = keyValuePair => {
83
- const {
84
- key,
85
- value
86
- } = keyValuePair;
87
- return new KeyValuePair(key, value);
88
- };
89
- const cloneShallowArraySlice = arraySlice => {
90
- const items = [...arraySlice];
91
- return new ArraySlice(items);
92
- };
93
- const cloneShallowObjectSlice = objectSlice => {
94
- const items = [...objectSlice];
95
- return new ObjectSlice(items);
96
- };
97
- const cloneShallowElement = element => {
98
- // @ts-ignore
99
- const copy = new element.constructor();
100
- copy.element = element.element;
101
- if (element.meta.length > 0) {
102
- copy._meta = cloneDeep(element.meta);
103
- }
104
- if (element.attributes.length > 0) {
105
- copy._attributes = cloneDeep(element.attributes);
106
- }
107
- if (isElement(element.content)) {
108
- const content = element.content;
109
- copy.content = cloneShallowElement(content);
110
- } else if (Array.isArray(element.content)) {
111
- copy.content = [...element.content];
112
- } else if (element.content instanceof KeyValuePair) {
113
- copy.content = cloneShallowKeyValuePair(element.content);
114
- } else {
115
- copy.content = element.content;
116
- }
117
- return copy;
118
- };
119
-
120
- /**
121
- * @public
122
- */
123
- export const cloneShallow = value => {
124
- if (value instanceof KeyValuePair) {
125
- return cloneShallowKeyValuePair(value);
126
- }
127
- if (value instanceof ObjectSlice) {
128
- return cloneShallowObjectSlice(value);
129
- }
130
- if (value instanceof ArraySlice) {
131
- return cloneShallowArraySlice(value);
132
- }
133
- if (isElement(value)) {
134
- return cloneShallowElement(value);
135
- }
136
- throw new ShallowCloneError("Value provided to cloneShallow function couldn't be cloned", {
137
- value
138
- });
139
- };
140
- cloneShallow.safe = value => {
141
- try {
142
- return cloneShallow(value);
143
- } catch {
144
- return value;
145
- }
146
- };
@@ -1,23 +0,0 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- exports.default = void 0;
5
- var _minim = require("minim");
6
- /**
7
- * @public
8
- */
9
- class Annotation extends _minim.StringElement {
10
- // classes: warning | error
11
-
12
- constructor(content, meta, attributes) {
13
- super(content, meta, attributes);
14
- this.element = 'annotation';
15
- }
16
- get code() {
17
- return this.attributes.get('code');
18
- }
19
- set code(value) {
20
- this.attributes.set('code', value);
21
- }
22
- }
23
- var _default = exports.default = Annotation;
@@ -1,20 +0,0 @@
1
- import { StringElement } from 'minim';
2
-
3
- /**
4
- * @public
5
- */
6
- class Annotation extends StringElement {
7
- // classes: warning | error
8
-
9
- constructor(content, meta, attributes) {
10
- super(content, meta, attributes);
11
- this.element = 'annotation';
12
- }
13
- get code() {
14
- return this.attributes.get('code');
15
- }
16
- set code(value) {
17
- this.attributes.set('code', value);
18
- }
19
- }
20
- export default Annotation;
@@ -1,15 +0,0 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- exports.default = void 0;
5
- var _minim = require("minim");
6
- /**
7
- * @public
8
- */
9
- class Comment extends _minim.StringElement {
10
- constructor(content, meta, attributes) {
11
- super(content, meta, attributes);
12
- this.element = 'comment';
13
- }
14
- }
15
- var _default = exports.default = Comment;
@@ -1,12 +0,0 @@
1
- import { StringElement } from 'minim';
2
-
3
- /**
4
- * @public
5
- */
6
- class Comment extends StringElement {
7
- constructor(content, meta, attributes) {
8
- super(content, meta, attributes);
9
- this.element = 'comment';
10
- }
11
- }
12
- export default Comment;
@@ -1,53 +0,0 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- exports.default = void 0;
5
- var _minim = require("minim");
6
- var _ramdaAdjunct = require("ramda-adjunct");
7
- /**
8
- * @public
9
- */
10
- class ParseResult extends _minim.ArrayElement {
11
- constructor(content, meta, attributes) {
12
- super(content, meta, attributes);
13
- this.element = 'parseResult';
14
- }
15
- get api() {
16
- return this.children.filter(item => item.classes.contains('api')).first;
17
- }
18
- get results() {
19
- return this.children.filter(item => item.classes.contains('result'));
20
- }
21
- get result() {
22
- return this.results.first;
23
- }
24
- get annotations() {
25
- return this.children.filter(item => item.element === 'annotation');
26
- }
27
- get warnings() {
28
- return this.children.filter(item => item.element === 'annotation' && item.classes.contains('warning'));
29
- }
30
- get errors() {
31
- return this.children.filter(item => item.element === 'annotation' && item.classes.contains('error'));
32
- }
33
- get isEmpty() {
34
- return this.children.reject(item => item.element === 'annotation').isEmpty;
35
- }
36
- replaceResult(replacement) {
37
- const {
38
- result
39
- } = this;
40
- if ((0, _ramdaAdjunct.isUndefined)(result)) {
41
- return false;
42
- }
43
-
44
- // @ts-ignore
45
- const searchIndex = this.content.findIndex(e => e === result);
46
- if (searchIndex === -1) {
47
- return false;
48
- }
49
- this.content[searchIndex] = replacement;
50
- return true;
51
- }
52
- }
53
- var _default = exports.default = ParseResult;
@@ -1,50 +0,0 @@
1
- import { ArrayElement } from 'minim';
2
- import { isUndefined } from 'ramda-adjunct';
3
-
4
- /**
5
- * @public
6
- */
7
- class ParseResult extends ArrayElement {
8
- constructor(content, meta, attributes) {
9
- super(content, meta, attributes);
10
- this.element = 'parseResult';
11
- }
12
- get api() {
13
- return this.children.filter(item => item.classes.contains('api')).first;
14
- }
15
- get results() {
16
- return this.children.filter(item => item.classes.contains('result'));
17
- }
18
- get result() {
19
- return this.results.first;
20
- }
21
- get annotations() {
22
- return this.children.filter(item => item.element === 'annotation');
23
- }
24
- get warnings() {
25
- return this.children.filter(item => item.element === 'annotation' && item.classes.contains('warning'));
26
- }
27
- get errors() {
28
- return this.children.filter(item => item.element === 'annotation' && item.classes.contains('error'));
29
- }
30
- get isEmpty() {
31
- return this.children.reject(item => item.element === 'annotation').isEmpty;
32
- }
33
- replaceResult(replacement) {
34
- const {
35
- result
36
- } = this;
37
- if (isUndefined(result)) {
38
- return false;
39
- }
40
-
41
- // @ts-ignore
42
- const searchIndex = this.content.findIndex(e => e === result);
43
- if (searchIndex === -1) {
44
- return false;
45
- }
46
- this.content[searchIndex] = replacement;
47
- return true;
48
- }
49
- }
50
- export default ParseResult;
@@ -1,39 +0,0 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- exports.default = void 0;
5
- var _minim = require("minim");
6
- /**
7
- * @public
8
- */
9
-
10
- /**
11
- * @public
12
- */
13
-
14
- /**
15
- * @public
16
- */
17
- class SourceMap extends _minim.ArrayElement {
18
- constructor(content, meta, attributes) {
19
- super(content, meta, attributes);
20
- this.element = 'sourceMap';
21
- }
22
- get positionStart() {
23
- return this.children.filter(item => item.classes.contains('position')).get(0);
24
- }
25
- get positionEnd() {
26
- return this.children.filter(item => item.classes.contains('position')).get(1);
27
- }
28
- set position(position) {
29
- if (typeof position === 'undefined') {
30
- return;
31
- }
32
- const start = new _minim.ArrayElement([position.start.row, position.start.column, position.start.char]);
33
- const end = new _minim.ArrayElement([position.end.row, position.end.column, position.end.char]);
34
- start.classes.push('position');
35
- end.classes.push('position');
36
- this.push(start).push(end);
37
- }
38
- }
39
- var _default = exports.default = SourceMap;
@@ -1,36 +0,0 @@
1
- import { ArrayElement } from 'minim';
2
-
3
- /**
4
- * @public
5
- */
6
-
7
- /**
8
- * @public
9
- */
10
-
11
- /**
12
- * @public
13
- */
14
- class SourceMap extends ArrayElement {
15
- constructor(content, meta, attributes) {
16
- super(content, meta, attributes);
17
- this.element = 'sourceMap';
18
- }
19
- get positionStart() {
20
- return this.children.filter(item => item.classes.contains('position')).get(0);
21
- }
22
- get positionEnd() {
23
- return this.children.filter(item => item.classes.contains('position')).get(1);
24
- }
25
- set position(position) {
26
- if (typeof position === 'undefined') {
27
- return;
28
- }
29
- const start = new ArrayElement([position.start.row, position.start.column, position.start.char]);
30
- const end = new ArrayElement([position.end.row, position.end.column, position.end.char]);
31
- start.classes.push('position');
32
- end.classes.push('position');
33
- this.push(start).push(end);
34
- }
35
- }
36
- export default SourceMap;