@limaformat/lima 0.1.0 → 0.1.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 +11 -1
- package/README.md +2 -0
- package/dist/block.js +6 -6
- package/dist/core.d.ts +2 -2
- package/dist/core.js +8 -8
- package/dist/flow.js +5 -5
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/normalize.js +3 -3
- package/dist/references.d.ts +1 -1
- package/dist/references.js +13 -13
- package/dist/scalars.js +7 -7
- package/dist/value.js +4 -4
- package/package.json +21 -19
package/CHANGELOG.md
CHANGED
|
@@ -10,7 +10,17 @@ and [Lima References
|
|
|
10
10
|
1.0](https://github.com/limaformat/lima/blob/main/docs/lima-references-1.0-spec.md)
|
|
11
11
|
are both frozen regardless of what this file shows.
|
|
12
12
|
|
|
13
|
-
## [
|
|
13
|
+
## [Unreleased]
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
|
|
17
|
+
- Error message prefix `LIMA:` → `Lima:` throughout (e.g. `LIMA: duplicate
|
|
18
|
+
key "a" at line 3` → `Lima: duplicate key "a" at line 3`), plus internal
|
|
19
|
+
code comments — naming-consistency fix, no functional change. `.code`
|
|
20
|
+
(the stable, documented field for programmatic error handling) is
|
|
21
|
+
unaffected; message text was never a documented stable API surface.
|
|
22
|
+
|
|
23
|
+
## [0.1.0] — 2026-08-05
|
|
14
24
|
|
|
15
25
|
Initial release.
|
|
16
26
|
|
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# @limaformat/lima
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/@limaformat/lima)
|
|
4
|
+
|
|
3
5
|
**LIMA Is Metadata Annotation** — a small, predictable frontmatter format.
|
|
4
6
|
A deliberate, focused subset of YAML: the part frontmatter actually needs,
|
|
5
7
|
with well-defined types, no surprises, and zero runtime dependencies.
|
package/dist/block.js
CHANGED
|
@@ -108,14 +108,14 @@ const parseCursorBlock = (cursor, baseIndent, ctx, baseLine, builder) => {
|
|
|
108
108
|
else {
|
|
109
109
|
if (ctx.strict)
|
|
110
110
|
throw new LimaError({ code: 'INVALID_INDENTATION', line,
|
|
111
|
-
message: `
|
|
111
|
+
message: `Lima: unexpected syntax in array item continuation at line ${line}: "${trimmed}"` });
|
|
112
112
|
cursor.next();
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
else {
|
|
116
116
|
if (ctx.strict)
|
|
117
117
|
throw new LimaError({ code: 'INVALID_INDENTATION', line,
|
|
118
|
-
message: `
|
|
118
|
+
message: `Lima: unexpected indentation at line ${line}: "${trimmed}"` });
|
|
119
119
|
cursor.next();
|
|
120
120
|
}
|
|
121
121
|
continue;
|
|
@@ -130,7 +130,7 @@ const parseCursorBlock = (cursor, baseIndent, ctx, baseLine, builder) => {
|
|
|
130
130
|
if (entries !== null) {
|
|
131
131
|
if (ctx.strict)
|
|
132
132
|
throw new LimaError({ code: 'INVALID_INDENTATION', line,
|
|
133
|
-
message: `
|
|
133
|
+
message: `Lima: mixed array and map entries for the same key at line ${line}` });
|
|
134
134
|
cursor.next();
|
|
135
135
|
continue;
|
|
136
136
|
}
|
|
@@ -153,7 +153,7 @@ const parseCursorBlock = (cursor, baseIndent, ctx, baseLine, builder) => {
|
|
|
153
153
|
else if (afterDash === '-' || DASH_PREFIX_RE.test(afterDash)) {
|
|
154
154
|
if (ctx.strict)
|
|
155
155
|
throw new LimaError({ code: 'INVALID_INDENTATION', line,
|
|
156
|
-
message: `
|
|
156
|
+
message: `Lima: nested block sequence at line ${line}: "${cursorContent(cursor)}"` });
|
|
157
157
|
items.push(builder.null(line));
|
|
158
158
|
cursor.next();
|
|
159
159
|
while (cursor.valid) {
|
|
@@ -237,7 +237,7 @@ const parseCursorBlock = (cursor, baseIndent, ctx, baseLine, builder) => {
|
|
|
237
237
|
if (items !== null) {
|
|
238
238
|
if (ctx.strict)
|
|
239
239
|
throw new LimaError({ code: 'INVALID_INDENTATION', line,
|
|
240
|
-
message: `
|
|
240
|
+
message: `Lima: mixed map and array entries for the same key at line ${line}` });
|
|
241
241
|
cursor.next();
|
|
242
242
|
continue;
|
|
243
243
|
}
|
|
@@ -275,7 +275,7 @@ const parseCursorBlock = (cursor, baseIndent, ctx, baseLine, builder) => {
|
|
|
275
275
|
else {
|
|
276
276
|
if (ctx.strict)
|
|
277
277
|
throw new LimaError({ code: 'INVALID_INDENTATION', line,
|
|
278
|
-
message: `
|
|
278
|
+
message: `Lima: indented freetext without a block scalar marker at line ${line}: "${trimmed}"` });
|
|
279
279
|
cursor.next();
|
|
280
280
|
}
|
|
281
281
|
}
|
package/dist/core.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Lima Core 1.0 parser — reference-unaware by construction (Appendix B:
|
|
3
3
|
* reference resolution is exclusively the concern of the optional
|
|
4
4
|
* References extension). `($key)`/`(%key)`-shaped text is never
|
|
5
5
|
* recognised or coerced here; it simply falls through as an ordinary
|
|
@@ -33,7 +33,7 @@ export type CoreOptions = {
|
|
|
33
33
|
onWarning?: (diagnostic: Diagnostic) => void;
|
|
34
34
|
};
|
|
35
35
|
/**
|
|
36
|
-
* Parses
|
|
36
|
+
* Parses Lima Core 1.0 syntax into the internal annotated value tree —
|
|
37
37
|
* every node carrying its source line, string leaves additionally carrying
|
|
38
38
|
* whether they came from quoted syntax. `($key)`/`(%key)` text is left
|
|
39
39
|
* exactly as written; nothing here ever inspects or resolves it. The
|
package/dist/core.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Lima Core 1.0 parser — reference-unaware by construction (Appendix B:
|
|
3
3
|
* reference resolution is exclusively the concern of the optional
|
|
4
4
|
* References extension). `($key)`/`(%key)`-shaped text is never
|
|
5
5
|
* recognised or coerced here; it simply falls through as an ordinary
|
|
@@ -89,7 +89,7 @@ const lineAt = (s, pos) => {
|
|
|
89
89
|
return n;
|
|
90
90
|
};
|
|
91
91
|
/**
|
|
92
|
-
* Parses
|
|
92
|
+
* Parses Lima Core 1.0 syntax, generic over the output representation
|
|
93
93
|
* (`builder` — see `builder.ts`): References needs the annotated
|
|
94
94
|
* `PositionedValue` tree (`parseCoreWithPositions` below fixes `V` to
|
|
95
95
|
* that), while `parseCore` fixes `V` to the public native shape directly,
|
|
@@ -111,7 +111,7 @@ const parseCoreGeneric = (frontMatter, ctx, builder, computeDepth) => {
|
|
|
111
111
|
byteLength(frontMatter) > DOCUMENT_SIZE_LIMIT) {
|
|
112
112
|
throw new LimaError({
|
|
113
113
|
code: 'RESOURCE_LIMIT', line: 1,
|
|
114
|
-
message: `
|
|
114
|
+
message: `Lima: document exceeds maximum size of ${DOCUMENT_SIZE_LIMIT} bytes at line 1`,
|
|
115
115
|
});
|
|
116
116
|
}
|
|
117
117
|
const root = builder.createMapping();
|
|
@@ -154,7 +154,7 @@ const parseCoreGeneric = (frontMatter, ctx, builder, computeDepth) => {
|
|
|
154
154
|
if (SPACE_BEFORE_COLON_RE.test(line)) {
|
|
155
155
|
throw new LimaError({
|
|
156
156
|
code: 'INVALID_QUOTE', line: lineAt(frontMatter, searchFrom),
|
|
157
|
-
message: `
|
|
157
|
+
message: `Lima: space between closing quote and colon at line ${lineAt(frontMatter, searchFrom)}`,
|
|
158
158
|
});
|
|
159
159
|
}
|
|
160
160
|
if (lineEnd === -1)
|
|
@@ -167,7 +167,7 @@ const parseCoreGeneric = (frontMatter, ctx, builder, computeDepth) => {
|
|
|
167
167
|
if ((strict || ctx.onWarning !== undefined) && builder.hasMappingKey(root, key)) {
|
|
168
168
|
const diagnostic = {
|
|
169
169
|
code: 'DUPLICATE_KEY', line, key,
|
|
170
|
-
message: `
|
|
170
|
+
message: `Lima: duplicate key "${key}" at line ${line} — last value wins`,
|
|
171
171
|
};
|
|
172
172
|
if (strict)
|
|
173
173
|
throw new LimaError(diagnostic);
|
|
@@ -309,7 +309,7 @@ const parseCoreGeneric = (frontMatter, ctx, builder, computeDepth) => {
|
|
|
309
309
|
if (keyCount > TOP_LEVEL_KEY_LIMIT) {
|
|
310
310
|
throw new LimaError({
|
|
311
311
|
code: 'RESOURCE_LIMIT', line: 1,
|
|
312
|
-
message: `
|
|
312
|
+
message: `Lima: too many top-level key entries (max ${TOP_LEVEL_KEY_LIMIT}) at line 1`,
|
|
313
313
|
});
|
|
314
314
|
}
|
|
315
315
|
for (let i = 0; i < keyCount; i++) {
|
|
@@ -327,13 +327,13 @@ const parseCoreGeneric = (frontMatter, ctx, builder, computeDepth) => {
|
|
|
327
327
|
if (blockDepthRisk.mayExceed && builder.mappingMaxDepth(root, computeDepth) > NESTING_DEPTH_LIMIT) {
|
|
328
328
|
throw new LimaError({
|
|
329
329
|
code: 'RESOURCE_LIMIT', line: 1,
|
|
330
|
-
message: `
|
|
330
|
+
message: `Lima: nesting depth exceeds maximum of ${NESTING_DEPTH_LIMIT} at line 1`,
|
|
331
331
|
});
|
|
332
332
|
}
|
|
333
333
|
return root;
|
|
334
334
|
};
|
|
335
335
|
/**
|
|
336
|
-
* Parses
|
|
336
|
+
* Parses Lima Core 1.0 syntax into the internal annotated value tree —
|
|
337
337
|
* every node carrying its source line, string leaves additionally carrying
|
|
338
338
|
* whether they came from quoted syntax. `($key)`/`(%key)` text is left
|
|
339
339
|
* exactly as written; nothing here ever inspects or resolves it. The
|
package/dist/flow.js
CHANGED
|
@@ -79,14 +79,14 @@ export const parseFlowSequence = (val, ctx, line, builder) => {
|
|
|
79
79
|
const item = val.slice(start, end);
|
|
80
80
|
if (!item) {
|
|
81
81
|
if (ctx.strict)
|
|
82
|
-
throw new LimaError({ code: 'INVALID_FLOW_SYNTAX', line, message: `
|
|
82
|
+
throw new LimaError({ code: 'INVALID_FLOW_SYNTAX', line, message: `Lima: empty element in flow sequence at line ${line}` });
|
|
83
83
|
items.push(builder.null(line));
|
|
84
84
|
continue;
|
|
85
85
|
}
|
|
86
86
|
if (item.charCodeAt(0) === 91 && item.charCodeAt(item.length - 1) === 93) {
|
|
87
87
|
throw new LimaError({
|
|
88
88
|
code: 'INVALID_FLOW_SYNTAX', line,
|
|
89
|
-
message: `
|
|
89
|
+
message: `Lima: nested flow sequence not permitted at line ${line}: "${item}"`,
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
92
|
if (item.charCodeAt(0) === 123 && item.charCodeAt(item.length - 1) === 125) {
|
|
@@ -114,7 +114,7 @@ export const parseFlowMapping = (val, ctx, line, builder) => {
|
|
|
114
114
|
const item = val.slice(itemStart, itemEnd);
|
|
115
115
|
if (!item) {
|
|
116
116
|
if (ctx.strict)
|
|
117
|
-
throw new LimaError({ code: 'INVALID_FLOW_SYNTAX', line, message: `
|
|
117
|
+
throw new LimaError({ code: 'INVALID_FLOW_SYNTAX', line, message: `Lima: empty element in flow mapping at line ${line}` });
|
|
118
118
|
continue;
|
|
119
119
|
}
|
|
120
120
|
const colonPos = val.indexOf(': ', itemStart);
|
|
@@ -122,7 +122,7 @@ export const parseFlowMapping = (val, ctx, line, builder) => {
|
|
|
122
122
|
if (ctx.strict)
|
|
123
123
|
throw new LimaError({
|
|
124
124
|
code: 'INVALID_FLOW_SYNTAX', line,
|
|
125
|
-
message: `
|
|
125
|
+
message: `Lima: invalid flow mapping item (missing ": ") at line ${line}: "${item}"`,
|
|
126
126
|
});
|
|
127
127
|
return null;
|
|
128
128
|
}
|
|
@@ -137,7 +137,7 @@ export const parseFlowMapping = (val, ctx, line, builder) => {
|
|
|
137
137
|
const valueEnd = trimEnd(val, valueStart, itemEnd);
|
|
138
138
|
const rawVal = val.slice(valueStart, valueEnd);
|
|
139
139
|
if (isNestedFlowConstruct(rawVal)) {
|
|
140
|
-
throw new LimaError({ code: 'INVALID_FLOW_SYNTAX', line, message: `
|
|
140
|
+
throw new LimaError({ code: 'INVALID_FLOW_SYNTAX', line, message: `Lima: invalid flow nesting at line ${line}: "${rawVal}"` });
|
|
141
141
|
}
|
|
142
142
|
builder.setMapping(entries, key, parseQuotedOrTyped(rawVal, ctx, line, false, builder));
|
|
143
143
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Lima Parser — LIMA Is Metadata Annotation
|
|
3
3
|
*
|
|
4
4
|
* Public entry point. The implementation is split per Appendix B's own
|
|
5
5
|
* layering:
|
|
6
|
-
* - `core.ts` —
|
|
6
|
+
* - `core.ts` — Lima Core 1.0, reference-unaware by construction.
|
|
7
7
|
* - `references.ts` — the optional References 1.0 extension, layered on
|
|
8
8
|
* top of Core's internal annotated value tree.
|
|
9
9
|
* - `value.ts` — the shared Lima Value Model both build on.
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Lima Parser — LIMA Is Metadata Annotation
|
|
3
3
|
*
|
|
4
4
|
* Public entry point. The implementation is split per Appendix B's own
|
|
5
5
|
* layering:
|
|
6
|
-
* - `core.ts` —
|
|
6
|
+
* - `core.ts` — Lima Core 1.0, reference-unaware by construction.
|
|
7
7
|
* - `references.ts` — the optional References 1.0 extension, layered on
|
|
8
8
|
* top of Core's internal annotated value tree.
|
|
9
9
|
* - `value.ts` — the shared Lima Value Model both build on.
|
package/dist/normalize.js
CHANGED
|
@@ -20,7 +20,7 @@ export const checkStringLimit = (value, line) => {
|
|
|
20
20
|
if (value.length > SCALAR_LENGTH_LIMIT && codepointLength(value) > SCALAR_LENGTH_LIMIT) {
|
|
21
21
|
throw new LimaError({
|
|
22
22
|
code: 'RESOURCE_LIMIT', line,
|
|
23
|
-
message: `
|
|
23
|
+
message: `Lima: scalar exceeds maximum length of ${SCALAR_LENGTH_LIMIT} code points at line ${line}`,
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
};
|
|
@@ -41,7 +41,7 @@ export const checkKeyLength = (key, line) => {
|
|
|
41
41
|
const l = line();
|
|
42
42
|
throw new LimaError({
|
|
43
43
|
code: 'RESOURCE_LIMIT', line: l,
|
|
44
|
-
message: `
|
|
44
|
+
message: `Lima: key "${key}" exceeds maximum length of ${KEY_LENGTH_LIMIT} code points at line ${l}`,
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
47
|
};
|
|
@@ -50,7 +50,7 @@ export const checkDuplicateKey = (exists, key, line, ctx) => {
|
|
|
50
50
|
return;
|
|
51
51
|
const diagnostic = {
|
|
52
52
|
code: 'DUPLICATE_KEY', line, key,
|
|
53
|
-
message: `
|
|
53
|
+
message: `Lima: duplicate key "${key}" at line ${line} — last value wins`,
|
|
54
54
|
};
|
|
55
55
|
if (ctx.strict)
|
|
56
56
|
throw new LimaError(diagnostic);
|
package/dist/references.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Lima References 1.0 — layered strictly on top of `core.ts` (Appendix B:
|
|
3
3
|
* reference resolution is exclusively this extension's concern; Core never
|
|
4
4
|
* sees it). Reads the annotated `PositionedValue` tree Core produces and
|
|
5
5
|
* performs the two-phase resolution the spec describes (§4), keeping every
|
package/dist/references.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Lima References 1.0 — layered strictly on top of `core.ts` (Appendix B:
|
|
3
3
|
* reference resolution is exclusively this extension's concern; Core never
|
|
4
4
|
* sees it). Reads the annotated `PositionedValue` tree Core produces and
|
|
5
5
|
* performs the two-phase resolution the spec describes (§4), keeping every
|
|
@@ -216,7 +216,7 @@ const resolveTree = (node, lookup, partials, ctx) => {
|
|
|
216
216
|
if (target.kind === 'mapping') {
|
|
217
217
|
reportDiagnostic(ctx, {
|
|
218
218
|
code: 'INVALID_INTERPOLATION', line: node.line, token: match,
|
|
219
|
-
message: `
|
|
219
|
+
message: `Lima: invalid interpolation of "${match}" at line ${node.line}: mapping cannot be interpolated into a string`,
|
|
220
220
|
});
|
|
221
221
|
return match;
|
|
222
222
|
}
|
|
@@ -224,7 +224,7 @@ const resolveTree = (node, lookup, partials, ctx) => {
|
|
|
224
224
|
if (target.items.some((item) => item.kind === 'array' || item.kind === 'mapping')) {
|
|
225
225
|
reportDiagnostic(ctx, {
|
|
226
226
|
code: 'INVALID_INTERPOLATION', line: node.line, token: match,
|
|
227
|
-
message: `
|
|
227
|
+
message: `Lima: invalid interpolation of "${match}" at line ${node.line}: array contains a nested array or mapping`,
|
|
228
228
|
});
|
|
229
229
|
return match;
|
|
230
230
|
}
|
|
@@ -240,7 +240,7 @@ const resolveTree = (node, lookup, partials, ctx) => {
|
|
|
240
240
|
if (codepointLength(replaced) > SCALAR_LENGTH_LIMIT) {
|
|
241
241
|
throw new LimaError({
|
|
242
242
|
code: 'RESOURCE_LIMIT', line: node.line,
|
|
243
|
-
message: `
|
|
243
|
+
message: `Lima: scalar exceeds maximum length of ${SCALAR_LENGTH_LIMIT} code points at line ${node.line}`,
|
|
244
244
|
});
|
|
245
245
|
}
|
|
246
246
|
return { kind: 'string', value: replaced, line: node.line, quoted: false };
|
|
@@ -266,7 +266,7 @@ const resolveTree = (node, lookup, partials, ctx) => {
|
|
|
266
266
|
// throws in BOTH modes (R-036/R-143).
|
|
267
267
|
reportDiagnostic(ctx, {
|
|
268
268
|
code: 'INVALID_REFERENCE_SHAPE', line: item.line, token: item.value,
|
|
269
|
-
message: `
|
|
269
|
+
message: `Lima: reference "${item.value}" resolves to an array, which cannot be inserted as a sequence item at line ${item.line}`,
|
|
270
270
|
});
|
|
271
271
|
return item;
|
|
272
272
|
}
|
|
@@ -356,13 +356,13 @@ export const parseReferences = (frontMatter, options) => {
|
|
|
356
356
|
// diagnostics collected below.
|
|
357
357
|
const partialNames = Object.keys(rawPartials);
|
|
358
358
|
if (partialNames.length > PARTIAL_COUNT_LIMIT) {
|
|
359
|
-
throw new LimaError({ code: 'INVALID_PARTIAL', message: `
|
|
359
|
+
throw new LimaError({ code: 'INVALID_PARTIAL', message: `Lima: too many partials (max ${PARTIAL_COUNT_LIMIT})` });
|
|
360
360
|
}
|
|
361
361
|
for (const name of partialNames) {
|
|
362
362
|
if (codepointLength(name) > PARTIAL_NAME_LENGTH_LIMIT) {
|
|
363
363
|
throw new LimaError({
|
|
364
364
|
code: 'INVALID_PARTIAL', partial: name, path: name,
|
|
365
|
-
message: `
|
|
365
|
+
message: `Lima: invalid partial "${name}" at path "${name}": name exceeds maximum length of ${PARTIAL_NAME_LENGTH_LIMIT} code points`,
|
|
366
366
|
});
|
|
367
367
|
}
|
|
368
368
|
}
|
|
@@ -376,7 +376,7 @@ export const parseReferences = (frontMatter, options) => {
|
|
|
376
376
|
if (totalPartialNodes > PARTIAL_NODE_LIMIT) {
|
|
377
377
|
throw new LimaError({
|
|
378
378
|
code: 'INVALID_PARTIAL',
|
|
379
|
-
message: `
|
|
379
|
+
message: `Lima: partials exceed the combined maximum of ${PARTIAL_NODE_LIMIT} value nodes`,
|
|
380
380
|
});
|
|
381
381
|
}
|
|
382
382
|
// Converted to the annotated representation once per partial, not once
|
|
@@ -446,7 +446,7 @@ export const parseReferences = (frontMatter, options) => {
|
|
|
446
446
|
if (m) {
|
|
447
447
|
reportDiagnostic(ctx, {
|
|
448
448
|
code: 'UNRESOLVED_REFERENCE', line: v.line, token: `(${m[1]}${m[2]})`,
|
|
449
|
-
message: `
|
|
449
|
+
message: `Lima: unresolved reference "(${m[1]}${m[2]})" at line ${v.line}`,
|
|
450
450
|
});
|
|
451
451
|
}
|
|
452
452
|
}
|
|
@@ -491,8 +491,8 @@ export const parseReferences = (frontMatter, options) => {
|
|
|
491
491
|
throw new LimaError({
|
|
492
492
|
code: 'RESOURCE_LIMIT', line: winner?.line ?? 1, token: winner?.token,
|
|
493
493
|
message: winner
|
|
494
|
-
? `
|
|
495
|
-
: `
|
|
494
|
+
? `Lima: nesting depth exceeds maximum of ${NESTING_DEPTH_LIMIT} at line ${winner.line}: "${winner.token}"`
|
|
495
|
+
: `Lima: nesting depth exceeds maximum of ${NESTING_DEPTH_LIMIT} at line 1`,
|
|
496
496
|
});
|
|
497
497
|
}
|
|
498
498
|
// §6.2: total node count of the final result tree, both modes. Same
|
|
@@ -509,8 +509,8 @@ export const parseReferences = (frontMatter, options) => {
|
|
|
509
509
|
throw new LimaError({
|
|
510
510
|
code: 'RESOURCE_LIMIT', line: winner?.line ?? 1, token: winner?.token,
|
|
511
511
|
message: winner
|
|
512
|
-
? `
|
|
513
|
-
: `
|
|
512
|
+
? `Lima: result exceeds maximum size of ${RESULT_NODE_LIMIT} total nodes at line ${winner.line}: "${winner.token}"`
|
|
513
|
+
: `Lima: result exceeds maximum size of ${RESULT_NODE_LIMIT} total nodes at line 1`,
|
|
514
514
|
});
|
|
515
515
|
}
|
|
516
516
|
const out = emptyMapping();
|
package/dist/scalars.js
CHANGED
|
@@ -87,7 +87,7 @@ const parseExactIsoSpan = (source, start, end, strict, line) => {
|
|
|
87
87
|
hour > 23 || minute > 59 || second > 59) {
|
|
88
88
|
if (strict) {
|
|
89
89
|
const raw = source.slice(start, end);
|
|
90
|
-
throw new LimaError({ code: 'INVALID_DATE', line, message: `
|
|
90
|
+
throw new LimaError({ code: 'INVALID_DATE', line, message: `Lima: invalid date "${raw}" at line ${line}` });
|
|
91
91
|
}
|
|
92
92
|
return null;
|
|
93
93
|
}
|
|
@@ -102,7 +102,7 @@ const parseExactIsoSpan = (source, start, end, strict, line) => {
|
|
|
102
102
|
const parseDateUTC = (str, strict = false, line = 0) => {
|
|
103
103
|
const invalid = () => {
|
|
104
104
|
if (strict)
|
|
105
|
-
throw new LimaError({ code: 'INVALID_DATE', line, message: `
|
|
105
|
+
throw new LimaError({ code: 'INVALID_DATE', line, message: `Lima: invalid date "${str}" at line ${line}` });
|
|
106
106
|
return null;
|
|
107
107
|
};
|
|
108
108
|
const exact = parseExactIsoSpan(str, 0, str.length, strict, line);
|
|
@@ -258,14 +258,14 @@ const buildTyped = (str, strict, line, builder) => {
|
|
|
258
258
|
if (strict)
|
|
259
259
|
throw new LimaError({
|
|
260
260
|
code: 'INVALID_NUMBER', line,
|
|
261
|
-
message: `
|
|
261
|
+
message: `Lima: float value overflows to a non-finite value at line ${line}: "${str}"`,
|
|
262
262
|
});
|
|
263
263
|
}
|
|
264
264
|
else if (n === 0 && !isZeroLiteral(str)) {
|
|
265
265
|
if (strict)
|
|
266
266
|
throw new LimaError({
|
|
267
267
|
code: 'INVALID_NUMBER', line,
|
|
268
|
-
message: `
|
|
268
|
+
message: `Lima: non-zero float value underflows to zero at line ${line}: "${str}"`,
|
|
269
269
|
});
|
|
270
270
|
}
|
|
271
271
|
else {
|
|
@@ -312,7 +312,7 @@ export const unescapeDQ = (s, strict = false, line = 0) => {
|
|
|
312
312
|
if (strict) {
|
|
313
313
|
for (const m of s.matchAll(ANY_ESCAPE_RE)) {
|
|
314
314
|
if (!isValidEscape(m[0].slice(1))) {
|
|
315
|
-
throw new LimaError({ code: 'INVALID_ESCAPE', line, message: `
|
|
315
|
+
throw new LimaError({ code: 'INVALID_ESCAPE', line, message: `Lima: unknown escape sequence "${m[0]}" at line ${line}` });
|
|
316
316
|
}
|
|
317
317
|
}
|
|
318
318
|
}
|
|
@@ -385,7 +385,7 @@ export const parseQuotedOrTyped = (raw, ctx, line, topLevel, builder) => {
|
|
|
385
385
|
return builder.string(value, line, true);
|
|
386
386
|
}
|
|
387
387
|
if (topLevel && ctx.strict) {
|
|
388
|
-
throw new LimaError({ code: 'INVALID_QUOTE', line, message: `
|
|
388
|
+
throw new LimaError({ code: 'INVALID_QUOTE', line, message: `Lima: non-whitespace content after closing quote at line ${line}` });
|
|
389
389
|
}
|
|
390
390
|
}
|
|
391
391
|
if (raw !== '' && raw !== 'null' && raw !== '~' && raw !== 'true' && raw !== 'false' &&
|
|
@@ -400,7 +400,7 @@ export const parseScalarValue = (raw, ctx, line, builder) => {
|
|
|
400
400
|
if (ctx.strict && (first === 91 || first === 123)) {
|
|
401
401
|
throw new LimaError({
|
|
402
402
|
code: 'INVALID_FLOW_SYNTAX', line,
|
|
403
|
-
message: `
|
|
403
|
+
message: `Lima: unclosed flow ${first === 91 ? 'sequence' : 'mapping'} at line ${line}`,
|
|
404
404
|
});
|
|
405
405
|
}
|
|
406
406
|
return parseQuotedOrTyped(raw, ctx, line, true, builder);
|
package/dist/value.js
CHANGED
|
@@ -106,7 +106,7 @@ export const ingestPartialValue = (value, partialName, path, depth = 0, seen = n
|
|
|
106
106
|
const invalid = (reason) => {
|
|
107
107
|
throw new LimaError({
|
|
108
108
|
code: 'INVALID_PARTIAL', partial: partialName, path,
|
|
109
|
-
message: `
|
|
109
|
+
message: `Lima: invalid partial "${partialName}" at path "${path}": ${reason}`,
|
|
110
110
|
});
|
|
111
111
|
};
|
|
112
112
|
if (value === null)
|
|
@@ -147,7 +147,7 @@ export const ingestPartialValue = (value, partialName, path, depth = 0, seen = n
|
|
|
147
147
|
if (Array.isArray(item)) {
|
|
148
148
|
throw new LimaError({
|
|
149
149
|
code: 'INVALID_PARTIAL', partial: partialName, path: `${path}[${i}]`,
|
|
150
|
-
message: `
|
|
150
|
+
message: `Lima: invalid partial "${partialName}" at path "${path}[${i}]": nested arrays are not supported`,
|
|
151
151
|
});
|
|
152
152
|
}
|
|
153
153
|
return ingestPartialValue(item, partialName, `${path}[${i}]`, depth + 1, seen);
|
|
@@ -167,13 +167,13 @@ export const ingestPartialValue = (value, partialName, path, depth = 0, seen = n
|
|
|
167
167
|
if (!descriptor || !('value' in descriptor)) {
|
|
168
168
|
throw new LimaError({
|
|
169
169
|
code: 'INVALID_PARTIAL', partial: partialName, path: `${path}.${key}`,
|
|
170
|
-
message: `
|
|
170
|
+
message: `Lima: invalid partial "${partialName}" at path "${path}.${key}": accessor properties are not supported`,
|
|
171
171
|
});
|
|
172
172
|
}
|
|
173
173
|
if (codepointLength(key) > PARTIAL_KEY_LENGTH_LIMIT) {
|
|
174
174
|
throw new LimaError({
|
|
175
175
|
code: 'INVALID_PARTIAL', partial: partialName, path: `${path}.${key}`,
|
|
176
|
-
message: `
|
|
176
|
+
message: `Lima: invalid partial "${partialName}" at path "${path}.${key}": key exceeds maximum length of ${PARTIAL_KEY_LENGTH_LIMIT} code points`,
|
|
177
177
|
});
|
|
178
178
|
}
|
|
179
179
|
entries.set(key, ingestPartialValue(value[key], partialName, `${path}.${key}`, depth + 1, seen));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@limaformat/lima",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Lima frontmatter parser — LIMA Is Metadata Annotation",
|
|
5
5
|
"keywords": ["frontmatter", "parser", "yaml", "markdown", "metadata"],
|
|
6
6
|
"homepage": "https://limaformat.dev",
|
|
@@ -20,22 +20,24 @@
|
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
"files": ["dist", "README.md", "LICENSE", "CHANGELOG.md"],
|
|
23
|
-
"engines": {
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=18"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "tsc -p tsconfig.build.json",
|
|
28
|
+
"pretest": "bun run build",
|
|
29
|
+
"test": "bun test",
|
|
30
|
+
"typecheck": "tsc --noEmit",
|
|
31
|
+
"prepublishOnly": "bun run typecheck && bun test",
|
|
32
|
+
"bench": "bun run bench/index.ts",
|
|
33
|
+
"bench:vs-yaml": "bun run bench/vs-yaml.ts",
|
|
34
|
+
"bench:vs-yaml:node": "node bench/vs-yaml-node.mjs",
|
|
35
|
+
"bench:differential": "bun run bench/differential.ts"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/bun": "^1.3.14",
|
|
39
|
+
"@types/js-yaml": "^4.0.9",
|
|
40
|
+
"js-yaml": "^5.2.3",
|
|
41
|
+
"typescript": "^7.0.2"
|
|
42
|
+
}
|
|
41
43
|
}
|