@aljazmc/syntax 0.7.1 → 0.7.2
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/bin/index.js +13 -5
- package/bin/types/parser/base.d.ts +1 -0
- package/package.json +1 -1
package/bin/index.js
CHANGED
|
@@ -3727,6 +3727,8 @@ var BaseParser = class {
|
|
|
3727
3727
|
previous = 0;
|
|
3728
3728
|
/** Whether `in` is a binary operator here (not in a for-in head). */
|
|
3729
3729
|
allowIn = true;
|
|
3730
|
+
/** Lines and columns of the source, made by the first error. */
|
|
3731
|
+
#lines;
|
|
3730
3732
|
constructor(source, options) {
|
|
3731
3733
|
this.source = source;
|
|
3732
3734
|
this.options = options;
|
|
@@ -3819,7 +3821,8 @@ var BaseParser = class {
|
|
|
3819
3821
|
);
|
|
3820
3822
|
}
|
|
3821
3823
|
raise(message, position) {
|
|
3822
|
-
|
|
3824
|
+
this.#lines ??= new Lines(this.source);
|
|
3825
|
+
const lines = this.#lines;
|
|
3823
3826
|
throw new ParseError(
|
|
3824
3827
|
`${message} (${lines.line(position)}:${lines.column(position)})`,
|
|
3825
3828
|
position
|
|
@@ -7381,6 +7384,7 @@ var YamlParser = class {
|
|
|
7381
7384
|
};
|
|
7382
7385
|
|
|
7383
7386
|
// shared/syntax/src/walker.ts
|
|
7387
|
+
var compare = /* @__PURE__ */ __name((a, b) => a.start - b.start || b.end - a.end, "compare");
|
|
7384
7388
|
var Walker = class _Walker {
|
|
7385
7389
|
static {
|
|
7386
7390
|
__name(this, "Walker");
|
|
@@ -7391,16 +7395,20 @@ var Walker = class _Walker {
|
|
|
7391
7395
|
/** Child nodes by start, outer nodes before inner ones starting with them. */
|
|
7392
7396
|
static children(node) {
|
|
7393
7397
|
const children = [];
|
|
7394
|
-
|
|
7398
|
+
const shorthand = node.type === "Property" && node.shorthand;
|
|
7399
|
+
for (const key of Object.keys(node)) {
|
|
7395
7400
|
if (key === "comments") continue;
|
|
7396
|
-
if (
|
|
7397
|
-
|
|
7401
|
+
if (shorthand && key === "key") continue;
|
|
7402
|
+
const value = node[key];
|
|
7398
7403
|
if (Array.isArray(value)) {
|
|
7399
7404
|
for (const item of value)
|
|
7400
7405
|
if (_Walker.isNode(item)) children.push(item);
|
|
7401
7406
|
} else if (_Walker.isNode(value)) children.push(value);
|
|
7402
7407
|
}
|
|
7403
|
-
|
|
7408
|
+
for (let index = 1; index < children.length; index++)
|
|
7409
|
+
if (compare(children[index - 1], children[index]) > 0)
|
|
7410
|
+
return children.sort(compare);
|
|
7411
|
+
return children;
|
|
7404
7412
|
}
|
|
7405
7413
|
};
|
|
7406
7414
|
|
|
@@ -11,6 +11,7 @@ interface Snapshot {
|
|
|
11
11
|
}
|
|
12
12
|
type Fields<T extends NodeType> = Omit<NodeOf<T>, "end" | "start" | "type">;
|
|
13
13
|
export default abstract class BaseParser {
|
|
14
|
+
#private;
|
|
14
15
|
protected readonly source: string;
|
|
15
16
|
protected readonly scanner: Scanner;
|
|
16
17
|
protected readonly options: Options;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aljazmc/syntax",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "Shared, dependency-free parser for CSS, HTML, JavaScript, JSON, JSX, Markdown, TypeScript and YAML, bundled into @aljazmc/formatero and @aljazmc/lintero.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"parser",
|