@limaformat/lima 0.8.0 → 0.8.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 +9 -0
- package/dist/block-cursor.d.ts +15 -0
- package/dist/block-cursor.js +46 -0
- package/dist/block.d.ts +10 -2
- package/dist/block.js +294 -283
- package/dist/builder.d.ts +18 -0
- package/dist/flow.d.ts +6 -4
- package/dist/flow.js +19 -7
- package/dist/outline.js +138 -229
- package/dist/scalars.d.ts +2 -0
- package/dist/scalars.js +20 -15
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -12,6 +12,15 @@ carry their own.
|
|
|
12
12
|
|
|
13
13
|
## [Unreleased]
|
|
14
14
|
|
|
15
|
+
## [0.8.1] — 2026-11-06
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- `outline()` takes the positions of keys and comments from the parser's own readers as they read, instead of
|
|
20
|
+
matching the parsed tree to the lines afterwards. It grows linearly with its input (2,048 malformed lines in 15 ms
|
|
21
|
+
instead of 527); `parse` and `parseCore` keep their speed. For a few malformed inputs the result is now right where
|
|
22
|
+
the old matching took a key from another line.
|
|
23
|
+
|
|
15
24
|
## [0.8.0] — 2026-11-05
|
|
16
25
|
|
|
17
26
|
### Added
|
package/dist/block-cursor.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SourcePositions } from './builder.js';
|
|
1
2
|
/**
|
|
2
3
|
* Allocation-free physical-line cursor over one top-level block extent.
|
|
3
4
|
* Positions are UTF-16 code-unit offsets. Indentation is the run of spaces
|
|
@@ -20,6 +21,20 @@ export declare class BlockCursor {
|
|
|
20
21
|
private nextStart;
|
|
21
22
|
constructor(source: string, rangeStart: number, rangeEnd: number);
|
|
22
23
|
next(): boolean;
|
|
24
|
+
/** Consume the physical body of a block scalar, leaving the first dedented line. */
|
|
25
|
+
scalarLines(keyIndent: number): string[];
|
|
26
|
+
protected scalarBody(keyIndent: number): string[];
|
|
23
27
|
get empty(): boolean;
|
|
24
28
|
get firstCode(): number;
|
|
25
29
|
}
|
|
30
|
+
/** Reports comments only as lines are consumed, never inside a scalar body. */
|
|
31
|
+
export declare class SourceBlockCursor extends BlockCursor {
|
|
32
|
+
private readonly positions;
|
|
33
|
+
private commentFrom;
|
|
34
|
+
private scalar;
|
|
35
|
+
constructor(source: string, start: number, end: number, positions: SourcePositions);
|
|
36
|
+
/** Exclude comment markers before this normalized UTF-16 offset on the current line. */
|
|
37
|
+
excludeCommentsBefore(offset: number): void;
|
|
38
|
+
next(): boolean;
|
|
39
|
+
protected scalarBody(keyIndent: number): string[];
|
|
40
|
+
}
|
package/dist/block-cursor.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isTrimWhitespace } from './chars.js';
|
|
2
|
+
import { commentStart } from './scalars.js';
|
|
2
3
|
/**
|
|
3
4
|
* Allocation-free physical-line cursor over one top-level block extent.
|
|
4
5
|
* Positions are UTF-16 code-unit offsets. Indentation is the run of spaces
|
|
@@ -66,6 +67,21 @@ export class BlockCursor {
|
|
|
66
67
|
this.nextStart = newline === -1 || newline >= this.rangeEnd ? this.rangeEnd : newline + 1;
|
|
67
68
|
return true;
|
|
68
69
|
}
|
|
70
|
+
/** Consume the physical body of a block scalar, leaving the first dedented line. */
|
|
71
|
+
scalarLines(keyIndent) {
|
|
72
|
+
this.next();
|
|
73
|
+
return this.scalarBody(keyIndent);
|
|
74
|
+
}
|
|
75
|
+
scalarBody(keyIndent) {
|
|
76
|
+
const lines = [];
|
|
77
|
+
while (this.valid) {
|
|
78
|
+
if (this.lineEnd - this.lineStart > this.asciiIndent && this.asciiIndent <= keyIndent)
|
|
79
|
+
break;
|
|
80
|
+
lines.push(this.source.slice(this.lineStart, this.lineEnd));
|
|
81
|
+
this.next();
|
|
82
|
+
}
|
|
83
|
+
return lines;
|
|
84
|
+
}
|
|
69
85
|
get empty() {
|
|
70
86
|
return this.contentStart === this.lineEnd;
|
|
71
87
|
}
|
|
@@ -73,3 +89,33 @@ export class BlockCursor {
|
|
|
73
89
|
return this.source.charCodeAt(this.contentStart);
|
|
74
90
|
}
|
|
75
91
|
}
|
|
92
|
+
/** Reports comments only as lines are consumed, never inside a scalar body. */
|
|
93
|
+
export class SourceBlockCursor extends BlockCursor {
|
|
94
|
+
positions;
|
|
95
|
+
commentFrom = 0;
|
|
96
|
+
scalar = false;
|
|
97
|
+
constructor(source, start, end, positions) {
|
|
98
|
+
super(source, start, end);
|
|
99
|
+
this.positions = positions;
|
|
100
|
+
}
|
|
101
|
+
/** Exclude comment markers before this normalized UTF-16 offset on the current line. */
|
|
102
|
+
excludeCommentsBefore(offset) {
|
|
103
|
+
this.commentFrom = offset;
|
|
104
|
+
}
|
|
105
|
+
next() {
|
|
106
|
+
if (this.valid && !this.scalar) {
|
|
107
|
+
const hash = commentStart(this.source.slice(this.commentFrom, this.lineEnd));
|
|
108
|
+
if (hash !== -1)
|
|
109
|
+
this.positions.comment(this.commentFrom + hash, this.lineEnd);
|
|
110
|
+
}
|
|
111
|
+
const valid = super.next();
|
|
112
|
+
this.commentFrom = this.contentStart;
|
|
113
|
+
return valid;
|
|
114
|
+
}
|
|
115
|
+
scalarBody(keyIndent) {
|
|
116
|
+
this.scalar = true;
|
|
117
|
+
const lines = super.scalarBody(keyIndent);
|
|
118
|
+
this.scalar = false;
|
|
119
|
+
return lines;
|
|
120
|
+
}
|
|
121
|
+
}
|
package/dist/block.d.ts
CHANGED
|
@@ -9,13 +9,21 @@
|
|
|
9
9
|
* never resolves a reference in the first place).
|
|
10
10
|
*/
|
|
11
11
|
import { type ParseContext } from './normalize.js';
|
|
12
|
+
import { parseFlowOrScalarValue } from './flow.js';
|
|
12
13
|
import type { ValueBuilder } from './builder.js';
|
|
13
14
|
import { BlockCursor } from './block-cursor.js';
|
|
15
|
+
/**
|
|
16
|
+
* An inline value, or a block scalar when `marker`: `|` alone (§6.1.5;
|
|
17
|
+
* `| # c` is the string `|`). Both leave the cursor on the next unread line.
|
|
18
|
+
*/
|
|
19
|
+
export declare const parseInlineValue: <V, M>(raw: string, marker: boolean, keyIndent: number, keyLine: number, valueCol: number, rawUndecoded: string, cursor: BlockCursor, ctx: ParseContext, builder: ValueBuilder<V, M>, readValue: typeof parseFlowOrScalarValue<V, M>) => V;
|
|
14
20
|
export declare const findKeySep: (s: string) => number;
|
|
21
|
+
declare const nativeBlockParser: <V, M>(cursor: BlockCursor, baseIndent: number, ctx: ParseContext, baseLine: number, builder: ValueBuilder<V, M>, compact?: boolean) => V | null;
|
|
15
22
|
/** Shared block grammar consuming one mutable physical-line cursor. */
|
|
16
|
-
export declare const parseCursorBlock:
|
|
23
|
+
export declare const parseCursorBlock: typeof nativeBlockParser;
|
|
17
24
|
/** Complete block grammar over one UTF-16 source range. */
|
|
18
25
|
export type BlockDepthRisk = {
|
|
19
26
|
mayExceed: boolean;
|
|
20
27
|
};
|
|
21
|
-
export declare const parseBlockRange: <V, M>(source: string, start: number, end: number, ctx: ParseContext, baseLine: number, builder: ValueBuilder<V, M>, depthRisk: BlockDepthRisk) => V | null;
|
|
28
|
+
export declare const parseBlockRange: <V, M>(source: string, start: number, end: number, ctx: ParseContext, baseLine: number, builder: ValueBuilder<V, M>, depthRisk: BlockDepthRisk, cursor?: BlockCursor) => V | null;
|
|
29
|
+
export {};
|