@shapeshift-labs/frontier-lang-parser 0.3.40 → 0.3.41
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/README.md +5 -1
- package/dist/action-body.js +62 -0
- package/dist/index.js +11 -5
- package/dist/source-syntax-children.js +124 -2
- package/dist/source-syntax-report.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -81,6 +81,7 @@ The published Frontier package family is generated from one shared package catal
|
|
|
81
81
|
- [`@shapeshift-labs/frontier-trace`](https://www.npmjs.com/package/@shapeshift-labs/frontier-trace): Serializable traces, spans, events, causal links, W3C trace context helpers, timeline/resource/path queries, critical-path analysis, registry graph output, JSONL/proof helpers, Chrome trace export, and redaction for app-wide feature observability.
|
|
82
82
|
- [`@shapeshift-labs/frontier-manifest`](https://www.npmjs.com/package/@shapeshift-labs/frontier-manifest): Build/static feature manifests for owners, routes, actions, states, migrations, tests, source files, assets, resources, tasks, dependency metadata, registry graph output, feature maps, JSONL export, and impact queries.
|
|
83
83
|
- [`@shapeshift-labs/frontier-view`](https://www.npmjs.com/package/@shapeshift-labs/frontier-view): Renderer-neutral view manifests, type defaults, validation frames, action bindings, visual channels, virtual/LOD hints, and data-to-representation mapping for Frontier apps.
|
|
84
|
+
- [`@shapeshift-labs/frontier-collapse`](https://www.npmjs.com/package/@shapeshift-labs/frontier-collapse): Constraint-collapse and projection admission records for one Frontier program becoming many valid shapes, including identity, behavior, runtime, proof, explicit projection losses, admitted projections, rejected shapes, and target contracts for React, SwiftUI, CLI, worker routes, plugin mounts, native adapters, and local-first views.
|
|
84
85
|
- [`@shapeshift-labs/frontier-icons`](https://www.npmjs.com/package/@shapeshift-labs/frontier-icons): Renderer-neutral icon records, icon sets, lookup aliases, SVG frames, string rendering, and registry evidence for Frontier apps.
|
|
85
86
|
- [`@shapeshift-labs/frontier-design`](https://www.npmjs.com/package/@shapeshift-labs/frontier-design): Renderer-neutral design-system tokens, semantic roles, recipes, target style frames, CSS variable output, and registry graph evidence for Frontier apps.
|
|
86
87
|
- [`@shapeshift-labs/frontier-canvas`](https://www.npmjs.com/package/@shapeshift-labs/frontier-canvas): Renderer-neutral infinite canvas surfaces for Frontier apps, including camera and viewport math, pan/zoom plans, grid materialization, snapping, hit testing, selection handles, extensible tool dispatch, frame records, registry graph output, and impact/proof helpers.
|
|
@@ -88,7 +89,8 @@ The published Frontier package family is generated from one shared package catal
|
|
|
88
89
|
- [`@shapeshift-labs/frontier-dnd`](https://www.npmjs.com/package/@shapeshift-labs/frontier-dnd): Renderer-neutral drag-and-drop sessions, sensor descriptors, collision ranking, drop planning, reorder patches, state partitioning, and registry evidence for Frontier apps.
|
|
89
90
|
- [`@shapeshift-labs/frontier-dom`](https://www.npmjs.com/package/@shapeshift-labs/frontier-dom): Patch-native DOM and host renderer bindings, manifest hydration, JSX runtime/compiler helpers, SSR, devtools, and logging bridges.
|
|
90
91
|
- [`@shapeshift-labs/frontier-playwright`](https://www.npmjs.com/package/@shapeshift-labs/frontier-playwright): Playwright/headless automation probes for Frontier state, DOM, devtools, marks, and timeline queries.
|
|
91
|
-
- [`@shapeshift-labs/frontier-annotations`](https://www.npmjs.com/package/@shapeshift-labs/frontier-annotations): Browser harness DOM annotation overlay, selected-node targeting records, CSS/source-hint capture, AST/source graph context ranking, and Codex/frontier-swarm task planning for AI-operable UI fixes.
|
|
92
|
+
- [`@shapeshift-labs/frontier-annotations`](https://www.npmjs.com/package/@shapeshift-labs/frontier-annotations): Browser harness DOM annotation overlay, selected-node targeting records, click geometry, optional image media refs, CSS/source-hint capture, AST/source graph context ranking, and Codex/frontier-swarm task planning for AI-operable UI fixes.
|
|
93
|
+
- [`@shapeshift-labs/frontier-annotations-harness`](https://www.npmjs.com/package/@shapeshift-labs/frontier-annotations-harness): Node browser annotation harness server and CLI for injecting Frontier annotation threads, capturing selected-element screenshots and canvas click crops, collecting source context, writing Loom/frontier-swarm Codex task artifacts, and optionally starting swarm runs.
|
|
92
94
|
- [`@shapeshift-labs/frontier-test`](https://www.npmjs.com/package/@shapeshift-labs/frontier-test): Serializable test/spec evidence manifests for Frontier apps, including fixtures, commands, expected patches/effects/routes/policies, coverage declarations, run plans, run records, report adapters, replay proofs, fuzzers, benchmarks, registry graph output, and impact queries.
|
|
93
95
|
- [`@shapeshift-labs/frontier-fixtures`](https://www.npmjs.com/package/@shapeshift-labs/frontier-fixtures): Deterministic fixture and scenario generation for Frontier apps, including schema-valid sample state, related entity collections, actor personas, route states, replay-verified patch streams, event records, JSONL bundles, and evidence summaries.
|
|
94
96
|
- [`@shapeshift-labs/frontier-component-preview`](https://www.npmjs.com/package/@shapeshift-labs/frontier-component-preview): Frontier-native component preview books, generated preview manifests, stateful variants, Vite virtual modules, standalone browser preview shells, inspector bridges, and preview harness evidence for Frontier apps.
|
|
@@ -186,6 +188,7 @@ Package source repositories:
|
|
|
186
188
|
- [`siliconjungle/-shapeshift-labs-frontier-trace`](https://github.com/siliconjungle/-shapeshift-labs-frontier-trace)
|
|
187
189
|
- [`siliconjungle/-shapeshift-labs-frontier-manifest`](https://github.com/siliconjungle/-shapeshift-labs-frontier-manifest)
|
|
188
190
|
- [`siliconjungle/-shapeshift-labs-frontier-view`](https://github.com/siliconjungle/-shapeshift-labs-frontier-view)
|
|
191
|
+
- [`siliconjungle/-shapeshift-labs-frontier-collapse`](https://github.com/siliconjungle/-shapeshift-labs-frontier-collapse)
|
|
189
192
|
- [`siliconjungle/-shapeshift-labs-frontier-icons`](https://github.com/siliconjungle/-shapeshift-labs-frontier-icons)
|
|
190
193
|
- [`siliconjungle/-shapeshift-labs-frontier-design`](https://github.com/siliconjungle/-shapeshift-labs-frontier-design)
|
|
191
194
|
- [`siliconjungle/-shapeshift-labs-frontier-canvas`](https://github.com/siliconjungle/-shapeshift-labs-frontier-canvas)
|
|
@@ -194,6 +197,7 @@ Package source repositories:
|
|
|
194
197
|
- [`siliconjungle/-shapeshift-labs-frontier-dom`](https://github.com/siliconjungle/-shapeshift-labs-frontier-dom)
|
|
195
198
|
- [`siliconjungle/-shapeshift-labs-frontier-playwright`](https://github.com/siliconjungle/-shapeshift-labs-frontier-playwright)
|
|
196
199
|
- [`siliconjungle/-shapeshift-labs-frontier-annotations`](https://github.com/siliconjungle/-shapeshift-labs-frontier-annotations)
|
|
200
|
+
- [`siliconjungle/-shapeshift-labs-frontier-annotations-harness`](https://github.com/siliconjungle/-shapeshift-labs-frontier-annotations-harness)
|
|
197
201
|
- [`siliconjungle/-shapeshift-labs-frontier-test`](https://github.com/siliconjungle/-shapeshift-labs-frontier-test)
|
|
198
202
|
- [`siliconjungle/-shapeshift-labs-frontier-fixtures`](https://github.com/siliconjungle/-shapeshift-labs-frontier-fixtures)
|
|
199
203
|
- [`siliconjungle/-shapeshift-labs-frontier-component-preview`](https://github.com/siliconjungle/-shapeshift-labs-frontier-component-preview)
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { readFrontierNestedBlocks } from './source-syntax-report.js';
|
|
2
|
+
|
|
3
|
+
export function readActionBodyRecords(body) {
|
|
4
|
+
const records = [];
|
|
5
|
+
for (const bodyBlock of readFrontierNestedBlocks('body', body)) {
|
|
6
|
+
for (const rawLine of bodyBlock.body.split('\n')) {
|
|
7
|
+
const line = rawLine.trim();
|
|
8
|
+
if (!line || line.startsWith('#')) continue;
|
|
9
|
+
const record = parseActionBodyLine(line, records.length);
|
|
10
|
+
if (record) records.push(record);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return records;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function stripNestedBlocks(kind, source) {
|
|
17
|
+
let text = source;
|
|
18
|
+
for (const block of readFrontierNestedBlocks(kind, source).reverse()) text = text.slice(0, block.start) + text.slice(block.end);
|
|
19
|
+
return text;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function parseActionBodyLine(line, index) {
|
|
23
|
+
const statement = /^([A-Za-z_$][\w$-]*)(?:\s+([A-Za-z_$@./:*+-][\w$./@:*+-]*))?(.*)$/.exec(line);
|
|
24
|
+
if (!statement) return undefined;
|
|
25
|
+
const [, rowKind, rawName, rawRest] = statement;
|
|
26
|
+
const name = rawName && !rawName.startsWith('@') ? rawName : `${rowKind}_${index}`;
|
|
27
|
+
const rest = rawName?.startsWith('@') ? ` ${rawName}${rawRest ?? ''}` : (rawRest ?? '');
|
|
28
|
+
if (rowKind === 'set' || rowKind === 'insert' || rowKind === 'merge') {
|
|
29
|
+
return compactRecord({ kind: 'patch', op: rowKind, id: idFrom(rest, `action_body_${rowKind}_${name}`), name, path: readInlineWord('path', rest), value: readInlineActionValue('value', rest) });
|
|
30
|
+
}
|
|
31
|
+
if (rowKind === 'remove') {
|
|
32
|
+
return compactRecord({ kind: 'patch', op: 'remove', id: idFrom(rest, `action_body_remove_${name}`), name, path: readInlineWord('path', rest) });
|
|
33
|
+
}
|
|
34
|
+
if (rowKind === 'callEffect') {
|
|
35
|
+
return compactRecord({ kind: 'callEffect', id: idFrom(rest, `action_body_callEffect_${name}`), name, capability: readInlineWord('capability', rest) ?? readInlineWord('effect', rest) ?? name, input: readInlineActionValue('input', rest) });
|
|
36
|
+
}
|
|
37
|
+
if (rowKind === 'return') {
|
|
38
|
+
const valueText = rawName?.startsWith('@') ? rest.trim() : `${rawName ?? ''}${rest ?? ''}`.trim();
|
|
39
|
+
return compactRecord({ kind: 'return', id: idFrom(rest, `action_body_return_${index}`), value: valueText ? readActionValue(valueText) : undefined });
|
|
40
|
+
}
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function readInlineActionValue(label, text) {
|
|
45
|
+
const value = new RegExp('(?:^|\\s)' + label + '\\s+(.+?)(?=\\s+[A-Za-z_$][\\w$-]*\\s+|$)').exec(text)?.[1]?.trim();
|
|
46
|
+
return value ? readActionValue(value) : undefined;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function readActionValue(value) {
|
|
50
|
+
const text = value.trim();
|
|
51
|
+
const quoted = /^["']([^"']*)["']$/.exec(text);
|
|
52
|
+
if (quoted) return { value: quoted[1] };
|
|
53
|
+
if (text === 'true') return { value: true };
|
|
54
|
+
if (text === 'false') return { value: false };
|
|
55
|
+
if (text === 'null') return { value: null };
|
|
56
|
+
if (/^-?\d+(?:\.\d+)?$/.test(text)) return { value: Number(text) };
|
|
57
|
+
return { expression: text };
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function idFrom(header, fallback) { return /@id\(\s*["']([^"']+)["']\s*\)/.exec(header)?.[1] ?? fallback; }
|
|
61
|
+
function readInlineWord(label, text) { return new RegExp('(?:^|\\s)' + label + '\\s+([^\\s,]+)').exec(text)?.[1]?.trim(); }
|
|
62
|
+
function compactRecord(record) { return Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined && (!Array.isArray(value) || value.length > 0))); }
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { actionNode, capabilityNode, createDocument, effectNode, entityNode, externNode, latticeNode, migrationNode, stateNode, targetNode, typeNode } from '@shapeshift-labs/frontier-lang-kernel';
|
|
2
|
+
import { readActionBodyRecords, stripNestedBlocks } from './action-body.js';
|
|
2
3
|
import { parseConstraintSpaceBlock } from './constraint-space.js';
|
|
3
4
|
import { parseConversionBlock } from './conversion.js';
|
|
4
5
|
import { parseApplicationSurfaceBlock } from './application-surface.js';
|
|
@@ -117,16 +118,21 @@ function parseState(block) {
|
|
|
117
118
|
}
|
|
118
119
|
function parseAction(block) {
|
|
119
120
|
const name = nameFrom(block.header);
|
|
121
|
+
const topLevelBody = stripNestedBlocks('body', block.body);
|
|
122
|
+
const body = readActionBodyRecords(block.body);
|
|
120
123
|
return actionNode({
|
|
121
124
|
id: idFrom(block.header, `action_${name}`),
|
|
122
125
|
name,
|
|
123
|
-
input: parseOptionalTypeExpression(/input\s*:?\s*([^\n]+)/.exec(
|
|
124
|
-
returns: parseOptionalTypeExpression(/returns\s+([^\n]+)/.exec(
|
|
125
|
-
reads: readList('reads',
|
|
126
|
-
writes: readList('writes',
|
|
127
|
-
uses: readList('uses',
|
|
126
|
+
input: parseOptionalTypeExpression(/input\s*:?\s*([^\n]+)/.exec(topLevelBody)?.[1]),
|
|
127
|
+
returns: parseOptionalTypeExpression(/returns\s+([^\n]+)/.exec(topLevelBody)?.[1]),
|
|
128
|
+
reads: readList('reads', topLevelBody),
|
|
129
|
+
writes: readList('writes', topLevelBody),
|
|
130
|
+
uses: readList('uses', topLevelBody),
|
|
131
|
+
throws: readList('throws', topLevelBody),
|
|
132
|
+
body: body.length ? body : undefined
|
|
128
133
|
});
|
|
129
134
|
}
|
|
135
|
+
|
|
130
136
|
function parseMigration(block) {
|
|
131
137
|
const name = nameFrom(block.header);
|
|
132
138
|
return migrationNode({ id: idFrom(block.header, `migration_${name}`), name, fromVersion: readWord('fromVersion', block.body) ?? readWord('from', block.body) ?? 'unknown', toVersion: readWord('toVersion', block.body) ?? readWord('to', block.body) ?? 'unknown', changes: readChangeRecords(block.body), invariants: readList('invariants', block.body) });
|
|
@@ -4,6 +4,9 @@ const ROW_NAME_PATTERN = '([A-Za-z_$@./:*+-][\\w$./@:*+-]*)';
|
|
|
4
4
|
|
|
5
5
|
export function readSourceSyntaxChildren(source, block, options = {}) {
|
|
6
6
|
if (block.malformed) return [];
|
|
7
|
+
if (block.kind === 'action') {
|
|
8
|
+
return readActionSyntaxChildren(source, block, options);
|
|
9
|
+
}
|
|
7
10
|
if (block.kind === 'conversion' || block.kind === 'universalConversionPlan') {
|
|
8
11
|
return readConversionSyntaxChildren(source, block, options);
|
|
9
12
|
}
|
|
@@ -12,6 +15,48 @@ export function readSourceSyntaxChildren(source, block, options = {}) {
|
|
|
12
15
|
return [];
|
|
13
16
|
}
|
|
14
17
|
|
|
18
|
+
const ACTION_BODY_ROWS = new Set(['set', 'insert', 'remove', 'merge', 'callEffect', 'return']);
|
|
19
|
+
|
|
20
|
+
function readActionSyntaxChildren(source, block, options) {
|
|
21
|
+
const children = [];
|
|
22
|
+
const body = source.slice(block.bodyStartOffset, block.bodyEndOffset);
|
|
23
|
+
const bodyBlocks = readNestedBodyBlocks('body', body);
|
|
24
|
+
let rowIndex = 0;
|
|
25
|
+
for (const bodyBlock of bodyBlocks) {
|
|
26
|
+
const bodyStartOffset = block.bodyStartOffset + bodyBlock.bodyStart;
|
|
27
|
+
const bodyEndOffset = block.bodyStartOffset + bodyBlock.bodyEnd;
|
|
28
|
+
for (const line of readTextLines(source, bodyStartOffset, bodyEndOffset)) {
|
|
29
|
+
if (!line.text || line.text.startsWith('#')) continue;
|
|
30
|
+
const row = /^([A-Za-z_$][\w$-]*)(?:\s+([A-Za-z_$@./:*+-][\w$./@:*+-]*))?(.*)$/.exec(line.text);
|
|
31
|
+
const rowKind = row?.[1] ?? 'unknown';
|
|
32
|
+
const name = row?.[2] && !row[2].startsWith('@') ? row[2] : `${rowKind}_${rowIndex}`;
|
|
33
|
+
const rest = row?.[2]?.startsWith('@') ? ` ${row[2]}${row[3] ?? ''}` : (row?.[3] ?? '');
|
|
34
|
+
const recognized = ACTION_BODY_ROWS.has(rowKind);
|
|
35
|
+
children.push(cleanRecord({
|
|
36
|
+
kind: recognized ? 'actionBodyRow' : 'actionUnknownRow',
|
|
37
|
+
rowKind,
|
|
38
|
+
normalizedRowKind: recognized ? rowKind : 'unknown',
|
|
39
|
+
name,
|
|
40
|
+
id: idFrom(rest, `action_body_${safeId(rowKind)}_${safeId(name)}_${rowIndex}`),
|
|
41
|
+
header: line.text,
|
|
42
|
+
startOffset: line.startOffset,
|
|
43
|
+
endOffset: line.endOffset,
|
|
44
|
+
location: sourcePosition(source, line.startOffset),
|
|
45
|
+
parentKind: block.kind,
|
|
46
|
+
parentId: block.id,
|
|
47
|
+
parentName: block.name,
|
|
48
|
+
moduleId: block.moduleId,
|
|
49
|
+
moduleName: block.moduleName,
|
|
50
|
+
sourceSpan: sourceSpan(source, block, line.startOffset, line.endOffset, options),
|
|
51
|
+
recognized,
|
|
52
|
+
reason: recognized ? undefined : 'unsupported-action-body-row'
|
|
53
|
+
}));
|
|
54
|
+
rowIndex++;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return children;
|
|
58
|
+
}
|
|
59
|
+
|
|
15
60
|
function readConversionSyntaxChildren(source, block, options) {
|
|
16
61
|
const children = [];
|
|
17
62
|
for (const line of readBodyLines(source, block)) {
|
|
@@ -131,10 +176,14 @@ function readGenericRowSyntaxChildren(source, block, options, config) {
|
|
|
131
176
|
}
|
|
132
177
|
|
|
133
178
|
function readBodyLines(source, block) {
|
|
134
|
-
|
|
179
|
+
return readTextLines(source, block.bodyStartOffset, block.bodyEndOffset);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function readTextLines(source, startOffset, endOffset) {
|
|
183
|
+
const body = source.slice(startOffset, endOffset);
|
|
135
184
|
const lines = body.split('\n');
|
|
136
185
|
const records = [];
|
|
137
|
-
let lineStart =
|
|
186
|
+
let lineStart = startOffset;
|
|
138
187
|
for (const rawLine of lines) {
|
|
139
188
|
const rawEnd = lineStart + rawLine.length;
|
|
140
189
|
const leading = /^\s*/.exec(rawLine)?.[0].length ?? 0;
|
|
@@ -147,6 +196,79 @@ function readBodyLines(source, block) {
|
|
|
147
196
|
return records;
|
|
148
197
|
}
|
|
149
198
|
|
|
199
|
+
function readNestedBodyBlocks(kind, source) {
|
|
200
|
+
const blocks = [];
|
|
201
|
+
const header = new RegExp('\\b' + kind.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + '(?:\\s+([^{}\\n]+?))?\\s*\\{', 'g');
|
|
202
|
+
let match;
|
|
203
|
+
while ((match = header.exec(source))) {
|
|
204
|
+
const open = header.lastIndex - 1;
|
|
205
|
+
const close = findMatchingBrace(source, open);
|
|
206
|
+
if (close < 0) continue;
|
|
207
|
+
blocks.push({
|
|
208
|
+
header: (match[1] ?? '').trim(),
|
|
209
|
+
start: match.index,
|
|
210
|
+
bodyStart: open + 1,
|
|
211
|
+
bodyEnd: close,
|
|
212
|
+
end: close + 1
|
|
213
|
+
});
|
|
214
|
+
header.lastIndex = close + 1;
|
|
215
|
+
}
|
|
216
|
+
return blocks;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function findMatchingBrace(source, open) {
|
|
220
|
+
let depth = 0;
|
|
221
|
+
let state = 'code';
|
|
222
|
+
let quote = '';
|
|
223
|
+
for (let index = open; index < source.length; index++) {
|
|
224
|
+
const char = source[index];
|
|
225
|
+
const next = source[index + 1];
|
|
226
|
+
if (state === 'line-comment') {
|
|
227
|
+
if (char === '\n') state = 'code';
|
|
228
|
+
continue;
|
|
229
|
+
}
|
|
230
|
+
if (state === 'block-comment') {
|
|
231
|
+
if (char === '*' && next === '/') {
|
|
232
|
+
index++;
|
|
233
|
+
state = 'code';
|
|
234
|
+
}
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
if (state === 'string') {
|
|
238
|
+
if (char === '\\') {
|
|
239
|
+
index++;
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
if (char === quote) {
|
|
243
|
+
state = 'code';
|
|
244
|
+
quote = '';
|
|
245
|
+
}
|
|
246
|
+
continue;
|
|
247
|
+
}
|
|
248
|
+
if (char === '/' && next === '/') {
|
|
249
|
+
index++;
|
|
250
|
+
state = 'line-comment';
|
|
251
|
+
continue;
|
|
252
|
+
}
|
|
253
|
+
if (char === '/' && next === '*') {
|
|
254
|
+
index++;
|
|
255
|
+
state = 'block-comment';
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
258
|
+
if (char === '"' || char === "'") {
|
|
259
|
+
state = 'string';
|
|
260
|
+
quote = char;
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
if (char === '{') depth++;
|
|
264
|
+
if (char === '}') {
|
|
265
|
+
depth--;
|
|
266
|
+
if (depth === 0) return index;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
return -1;
|
|
270
|
+
}
|
|
271
|
+
|
|
150
272
|
function sourcePosition(source, offset) {
|
|
151
273
|
const lines = source.slice(0, offset).split('\n');
|
|
152
274
|
return { line: lines.length, column: lines[lines.length - 1].length + 1, offset };
|
|
@@ -91,7 +91,7 @@ export function readFrontierSourceBlocks(source, options = {}) {
|
|
|
91
91
|
export function readFrontierNestedBlocks(kind, source) {
|
|
92
92
|
const structure = scanFrontierStructure(source);
|
|
93
93
|
const blocks = [];
|
|
94
|
-
const header = new RegExp('\\b' + escapeRegExp(kind) + '
|
|
94
|
+
const header = new RegExp('\\b' + escapeRegExp(kind) + '(?:\\s+([^{}\\n]+?))?\\s*\\{', 'g');
|
|
95
95
|
let match;
|
|
96
96
|
while ((match = header.exec(source))) {
|
|
97
97
|
const start = match.index;
|
|
@@ -101,7 +101,7 @@ export function readFrontierNestedBlocks(kind, source) {
|
|
|
101
101
|
if (close < 0) continue;
|
|
102
102
|
blocks.push({
|
|
103
103
|
kind,
|
|
104
|
-
header: match[1].trim(),
|
|
104
|
+
header: (match[1] ?? '').trim(),
|
|
105
105
|
body: source.slice(header.lastIndex, close),
|
|
106
106
|
start,
|
|
107
107
|
end: close + 1
|