flashtrace 0.2.0 → 0.3.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.
@@ -218,7 +218,10 @@ function parseMarkdown(file, text, problems, forwards = []) {
218
218
 
219
219
  // src/parse-code.mjs
220
220
  import path2 from "node:path";
221
- var TAG_RE = new RegExp(String.raw`\[(>>)?\s*${ID_SRC}\s*\]`, "g");
221
+ var TAG_RE = new RegExp(
222
+ String.raw`\[(?:\s*${ID_SRC}\s*)?>>\s*${ID_SRC}\s*\]|\[\s*${ID_SRC}\s*\]`,
223
+ "g"
224
+ );
222
225
  var FORWARD_RE = new RegExp(FORWARD_SRC, "g");
223
226
  var BLOCK_CLOSERS = { c: "*/", html: "-->" };
224
227
  function findCommentStart(s, pos, lineMarkers, htmlBlocks) {
@@ -261,10 +264,26 @@ function commentText(s, state, lineMarkers, htmlBlocks) {
261
264
  }
262
265
  function collectTags(comment, file, line, state, items, problems) {
263
266
  for (const m of comment.matchAll(TAG_RE)) {
264
- const id = mkId(m[2], m[3], m[4], m[5]);
265
- if (!m[1]) {
266
- state.last = newItem(id, "code", file, line);
267
- items.push(state.last);
267
+ if (m[9]) {
268
+ const item = newItem(mkId(m[9], m[10], m[11], m[12]), "code", file, line);
269
+ state.last = item;
270
+ state.byId.set(item.id, item);
271
+ items.push(item);
272
+ continue;
273
+ }
274
+ const id = mkId(m[5], m[6], m[7], m[8]);
275
+ if (m[1]) {
276
+ const source = mkId(m[1], m[2], m[3], m[4]);
277
+ const anchor = state.byId.get(source);
278
+ if (anchor) {
279
+ anchor.needs.push(id);
280
+ } else {
281
+ problems.push({
282
+ file,
283
+ line,
284
+ message: `need tag [${source} >> ${id}] has no preceding item tag [${source}] in this file`
285
+ });
286
+ }
268
287
  } else if (state.last) {
269
288
  state.last.needs.push(id);
270
289
  } else {
@@ -282,7 +301,7 @@ function parseCode(file, text, problems, forwards = []) {
282
301
  const items = [];
283
302
  const lineMarkers = ext === ".sql" ? ["--"] : ["//"];
284
303
  const htmlBlocks = ext === ".vue";
285
- const state = { last: null, block: null };
304
+ const state = { last: null, byId: /* @__PURE__ */ new Map(), block: null };
286
305
  for (let i = 0; i < lines.length; i++) {
287
306
  const comment = commentText(lines[i], state, lineMarkers, htmlBlocks);
288
307
  for (const m of comment.matchAll(FORWARD_RE)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flashtrace",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Lightning-fast, reference-based requirement tracing that works anywhere.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {