@rotorsoft/act-diagram 1.0.0 → 1.0.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.
Files changed (58) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/@types/cli/colors.d.ts +1 -1
  3. package/dist/@types/cli/colors.d.ts.map +1 -1
  4. package/dist/@types/cli/contract-index.d.ts +6 -6
  5. package/dist/@types/cli/contract-index.d.ts.map +1 -1
  6. package/dist/@types/cli/format.d.ts +9 -9
  7. package/dist/@types/cli/format.d.ts.map +1 -1
  8. package/dist/@types/cli/index.d.ts +9 -9
  9. package/dist/@types/cli/index.d.ts.map +1 -1
  10. package/dist/@types/cli/json-schema.d.ts +1 -1
  11. package/dist/@types/cli/json-schema.d.ts.map +1 -1
  12. package/dist/@types/cli/load-project.d.ts +3 -3
  13. package/dist/@types/cli/load-project.d.ts.map +1 -1
  14. package/dist/@types/cli/markdown.d.ts +1 -1
  15. package/dist/@types/cli/markdown.d.ts.map +1 -1
  16. package/dist/@types/cli/open-editor.d.ts +4 -4
  17. package/dist/@types/cli/open-editor.d.ts.map +1 -1
  18. package/dist/@types/cli/repl.d.ts +1 -1
  19. package/dist/@types/cli/repl.d.ts.map +1 -1
  20. package/dist/@types/cli/vim-keys.d.ts +1 -1
  21. package/dist/@types/cli/vim-keys.d.ts.map +1 -1
  22. package/dist/@types/client/components/ActDiagram.d.ts +1 -1
  23. package/dist/@types/client/components/ActDiagram.d.ts.map +1 -1
  24. package/dist/@types/client/components/AiBar.d.ts +1 -1
  25. package/dist/@types/client/components/AiBar.d.ts.map +1 -1
  26. package/dist/@types/client/components/CodePreview.d.ts +2 -2
  27. package/dist/@types/client/components/CodePreview.d.ts.map +1 -1
  28. package/dist/@types/client/components/Diagram.d.ts +1 -1
  29. package/dist/@types/client/components/Diagram.d.ts.map +1 -1
  30. package/dist/@types/client/components/Logo.d.ts +1 -1
  31. package/dist/@types/client/components/Logo.d.ts.map +1 -1
  32. package/dist/@types/client/components/Tooltip.d.ts +1 -1
  33. package/dist/@types/client/components/Tooltip.d.ts.map +1 -1
  34. package/dist/@types/client/lib/build-model.d.ts +2 -2
  35. package/dist/@types/client/lib/build-model.d.ts.map +1 -1
  36. package/dist/@types/client/lib/evaluate.d.ts +2 -2
  37. package/dist/@types/client/lib/evaluate.d.ts.map +1 -1
  38. package/dist/@types/client/lib/layout.d.ts +1 -1
  39. package/dist/@types/client/lib/layout.d.ts.map +1 -1
  40. package/dist/@types/client/lib/mock-builders.d.ts +6 -6
  41. package/dist/@types/client/lib/mock-builders.d.ts.map +1 -1
  42. package/dist/@types/client/lib/navigate.d.ts +1 -1
  43. package/dist/@types/client/lib/navigate.d.ts.map +1 -1
  44. package/dist/@types/client/lib/schema-extract.d.ts +4 -4
  45. package/dist/@types/client/lib/schema-extract.d.ts.map +1 -1
  46. package/dist/@types/client/lib/sort.d.ts +1 -1
  47. package/dist/@types/client/lib/sort.d.ts.map +1 -1
  48. package/dist/@types/client/lib/strip-fences.d.ts +3 -3
  49. package/dist/@types/client/lib/strip-fences.d.ts.map +1 -1
  50. package/dist/@types/index.d.ts +0 -6
  51. package/dist/@types/index.d.ts.map +1 -1
  52. package/dist/cli/act.js +1515 -1310
  53. package/dist/cli/act.js.map +1 -1
  54. package/dist/index.cjs +640 -704
  55. package/dist/index.cjs.map +1 -1
  56. package/dist/index.js +640 -696
  57. package/dist/index.js.map +1 -1
  58. package/package.json +13 -13
package/dist/index.cjs CHANGED
@@ -25,15 +25,7 @@ __export(index_exports, {
25
25
  Diagram: () => Diagram,
26
26
  Logo: () => Logo,
27
27
  Tooltip: () => Tooltip,
28
- buildModel: () => buildModel,
29
- computeLayout: () => computeLayout,
30
- deriveProjectName: () => deriveProjectName,
31
28
  emptyModel: () => emptyModel2,
32
- extractModel: () => extractModel,
33
- navigateToCode: () => navigateToCode,
34
- parseMultiFileResponse: () => parseMultiFileResponse,
35
- stripFences: () => stripFences,
36
- topoSort: () => topoSort,
37
29
  validate: () => validate
38
30
  });
39
31
  module.exports = __toCommonJS(index_exports);
@@ -45,13 +37,13 @@ var import_react3 = require("react");
45
37
  var import_sucrase = require("sucrase");
46
38
 
47
39
  // src/client/lib/schema-extract.ts
48
- var isWS = (c) => c === " " || c === " " || c === "\n" || c === "\r";
49
- var isIdent = (c) => !!c && /[\w$]/.test(c);
50
- function skipTrivia(src, from) {
40
+ var is_w_s = (c) => c === " " || c === " " || c === "\n" || c === "\r";
41
+ var is_ident = (c) => !!c && /[\w$]/.test(c);
42
+ function skip_trivia(src, from) {
51
43
  let i = from;
52
44
  while (i < src.length) {
53
45
  const c = src[i];
54
- if (isWS(c)) {
46
+ if (is_w_s(c)) {
55
47
  i++;
56
48
  continue;
57
49
  }
@@ -69,7 +61,7 @@ function skipTrivia(src, from) {
69
61
  }
70
62
  return i;
71
63
  }
72
- function readValue(src, start) {
64
+ function read_value(src, start) {
73
65
  let i = start;
74
66
  let depth = 0;
75
67
  while (i < src.length) {
@@ -141,19 +133,19 @@ function readValue(src, start) {
141
133
  }
142
134
  return i;
143
135
  }
144
- function parseObjectLiteral(src, startBrace) {
136
+ function parse_object_literal(src, start_brace) {
145
137
  const entries = [];
146
- let i = startBrace + 1;
138
+ let i = start_brace + 1;
147
139
  while (i < src.length) {
148
- i = skipTrivia(src, i);
149
- if (src[i] === "}") return { entries, endBrace: i };
140
+ i = skip_trivia(src, i);
141
+ if (src[i] === "}") return { entries, end_brace: i };
150
142
  let key = "";
151
- let keyStart = i;
152
- let keyEnd = i;
153
- let keyWasIdentifier = false;
143
+ let key_start = i;
144
+ let key_end = i;
145
+ let key_was_identifier = false;
154
146
  if (src[i] === '"' || src[i] === "'") {
155
147
  const q = src[i];
156
- keyStart = ++i;
148
+ key_start = ++i;
157
149
  while (i < src.length && src[i] !== q) {
158
150
  if (src[i] === "\\") {
159
151
  i += 2;
@@ -161,38 +153,38 @@ function parseObjectLiteral(src, startBrace) {
161
153
  }
162
154
  i++;
163
155
  }
164
- key = src.slice(keyStart, i);
165
- keyEnd = i;
156
+ key = src.slice(key_start, i);
157
+ key_end = i;
166
158
  i++;
167
- } else if (isIdent(src[i])) {
168
- keyStart = i;
169
- while (isIdent(src[i])) i++;
170
- key = src.slice(keyStart, i);
171
- keyEnd = i;
172
- keyWasIdentifier = true;
159
+ } else if (is_ident(src[i])) {
160
+ key_start = i;
161
+ while (is_ident(src[i])) i++;
162
+ key = src.slice(key_start, i);
163
+ key_end = i;
164
+ key_was_identifier = true;
173
165
  } else {
174
166
  return null;
175
167
  }
176
- i = skipTrivia(src, i);
168
+ i = skip_trivia(src, i);
177
169
  if (src[i] !== ":") {
178
- if (keyWasIdentifier) {
179
- entries.push({ key, valueStart: keyStart, valueEnd: keyEnd });
170
+ if (key_was_identifier) {
171
+ entries.push({ key, value_start: key_start, value_end: key_end });
180
172
  }
181
173
  while (i < src.length && src[i] !== "," && src[i] !== "}") i++;
182
174
  if (src[i] === ",") i++;
183
175
  continue;
184
176
  }
185
177
  i++;
186
- i = skipTrivia(src, i);
187
- const valueStart = i;
188
- const valueEnd = readValue(src, i);
189
- entries.push({ key, valueStart, valueEnd });
190
- i = valueEnd;
178
+ i = skip_trivia(src, i);
179
+ const value_start = i;
180
+ const value_end = read_value(src, i);
181
+ entries.push({ key, value_start, value_end });
182
+ i = value_end;
191
183
  if (src[i] === ",") i++;
192
184
  }
193
185
  return null;
194
186
  }
195
- function readTopLevelExpression(src, start) {
187
+ function read_top_level_expression(src, start) {
196
188
  let i = start;
197
189
  let depth = 0;
198
190
  while (i < src.length) {
@@ -258,7 +250,7 @@ function readTopLevelExpression(src, start) {
258
250
  }
259
251
  return i;
260
252
  }
261
- function extractIdentifierAssignments(src) {
253
+ function extract_identifier_assignments(src) {
262
254
  const out = /* @__PURE__ */ new Map();
263
255
  const re = /(?:^|[^\w$])(?:export\s+)?(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*(?::[^=\n;]{1,256})?=\s*/gm;
264
256
  let m;
@@ -268,14 +260,14 @@ function extractIdentifierAssignments(src) {
268
260
  continue;
269
261
  }
270
262
  const start = m.index + m[0].length;
271
- const end = readTopLevelExpression(src, start);
263
+ const end = read_top_level_expression(src, start);
272
264
  const text = src.slice(start, end).trim();
273
265
  if (text) out.set(ident, text);
274
266
  re.lastIndex = end;
275
267
  }
276
268
  return out;
277
269
  }
278
- function findIdentifierObjectLiteral(src, ident) {
270
+ function find_identifier_object_literal(src, ident) {
279
271
  const re = new RegExp(
280
272
  `(?:^|[^\\w$])(?:const|let|var)\\s+${ident}\\b\\s*(?::[^=\\n;]+)?=\\s*`,
281
273
  "m"
@@ -283,112 +275,112 @@ function findIdentifierObjectLiteral(src, ident) {
283
275
  const m = re.exec(src);
284
276
  if (!m) return -1;
285
277
  const after = m.index + m[0].length;
286
- const skipped = skipTrivia(src, after);
278
+ const skipped = skip_trivia(src, after);
287
279
  return src[skipped] === "{" ? skipped : -1;
288
280
  }
289
281
  var BARE_IDENT_RE = /^[A-Za-z_$][\w$]*$/;
290
- function extractSchemasFromSource(src, eventNames, external) {
282
+ function extract_schemas_from_source(src, event_names, external) {
291
283
  const out = /* @__PURE__ */ new Map();
292
- if (!src || eventNames.size === 0) return out;
293
- const localIdents = extractIdentifierAssignments(src);
294
- const deref = (text) => BARE_IDENT_RE.test(text) ? localIdents.get(text) ?? external?.get(text) ?? text : text;
295
- const emitsRe = /\.emits\s*\(/g;
284
+ if (!src || event_names.size === 0) return out;
285
+ const local_idents = extract_identifier_assignments(src);
286
+ const deref = (text) => BARE_IDENT_RE.test(text) ? local_idents.get(text) ?? external?.get(text) ?? text : text;
287
+ const emits_re = /\.emits\s*\(/g;
296
288
  let m;
297
- while ((m = emitsRe.exec(src)) !== null) {
298
- let i = skipTrivia(src, emitsRe.lastIndex);
299
- if (isIdent(src[i])) {
289
+ while ((m = emits_re.exec(src)) !== null) {
290
+ let i = skip_trivia(src, emits_re.lastIndex);
291
+ if (is_ident(src[i])) {
300
292
  const start = i;
301
- while (isIdent(src[i])) i++;
293
+ while (is_ident(src[i])) i++;
302
294
  const ident = src.slice(start, i);
303
- const objStart = findIdentifierObjectLiteral(src, ident);
304
- if (objStart < 0) continue;
305
- i = objStart;
295
+ const obj_start = find_identifier_object_literal(src, ident);
296
+ if (obj_start < 0) continue;
297
+ i = obj_start;
306
298
  }
307
299
  if (src[i] !== "{") continue;
308
- const parsed = parseObjectLiteral(src, i);
300
+ const parsed = parse_object_literal(src, i);
309
301
  if (!parsed) continue;
310
302
  for (const e of parsed.entries) {
311
- if (!eventNames.has(e.key)) continue;
312
- const raw = src.slice(e.valueStart, e.valueEnd).trim();
303
+ if (!event_names.has(e.key)) continue;
304
+ const raw = src.slice(e.value_start, e.value_end).trim();
313
305
  const text = deref(raw);
314
306
  if (text) out.set(e.key, text);
315
307
  }
316
- emitsRe.lastIndex = Math.max(emitsRe.lastIndex, parsed.endBrace + 1);
308
+ emits_re.lastIndex = Math.max(emits_re.lastIndex, parsed.end_brace + 1);
317
309
  }
318
310
  return out;
319
311
  }
320
312
 
321
313
  // src/client/lib/build-model.ts
322
314
  var _stateIdx = 0;
323
- function buildState(model, st) {
315
+ function build_state(model, st) {
324
316
  const events = st.events ?? {};
325
317
  for (const [name, schema] of Object.entries(events)) {
326
318
  if (schema === void 0)
327
319
  return { error: `Event "${name}" has undefined schema` };
328
320
  }
329
- const rawActions = st.actions ?? {};
330
- for (const [name, schema] of Object.entries(rawActions)) {
321
+ const raw_actions = st.actions ?? {};
322
+ for (const [name, schema] of Object.entries(raw_actions)) {
331
323
  if (name.startsWith("__emits_")) continue;
332
324
  if (schema === void 0)
333
325
  return { error: `Action "${name}" has undefined schema` };
334
326
  }
335
- const domainName = st.name;
336
- const uniqueKey = `${domainName}:${_stateIdx++}`;
337
- const eventNodes = [];
338
- for (const eventName of Object.keys(events)) {
339
- eventNodes.push({
340
- name: eventName,
341
- hasCustomPatch: st.patches?.has(eventName) ?? false,
327
+ const domain_name = st.name;
328
+ const unique_key = `${domain_name}:${_stateIdx++}`;
329
+ const event_nodes = [];
330
+ for (const event_name of Object.keys(events)) {
331
+ event_nodes.push({
332
+ name: event_name,
333
+ hasCustomPatch: st.patches?.has(event_name) ?? false,
342
334
  // Stash the runtime Zod schema so the JSON Schema exporter can
343
335
  // call `z.toJSONSchema(zod)` later without re-running the parser.
344
- zod: events[eventName]
336
+ zod: events[event_name]
345
337
  });
346
338
  }
347
- const actionNodes = [];
348
- for (const actionName of Object.keys(rawActions)) {
349
- if (actionName.startsWith("__emits_")) continue;
350
- const emits = rawActions[`__emits_${actionName}`] ?? [];
351
- const invariants = (st.given?.[actionName] ?? []).map(
339
+ const action_nodes = [];
340
+ for (const action_name of Object.keys(raw_actions)) {
341
+ if (action_name.startsWith("__emits_")) continue;
342
+ const emits = raw_actions[`__emits_${action_name}`] ?? [];
343
+ const invariants = (st.given?.[action_name] ?? []).map(
352
344
  (inv) => inv.description ?? ""
353
345
  );
354
- actionNodes.push({ name: actionName, emits, invariants });
346
+ action_nodes.push({ name: action_name, emits, invariants });
355
347
  }
356
348
  const node = {
357
- name: domainName,
358
- varName: uniqueKey,
359
- events: eventNodes,
360
- actions: actionNodes,
349
+ name: domain_name,
350
+ varName: unique_key,
351
+ events: event_nodes,
352
+ actions: action_nodes,
361
353
  file: st._sourceFile
362
354
  };
363
355
  model.states.push(node);
364
- st._modelKey = uniqueKey;
365
- return { key: uniqueKey, node };
356
+ st._modelKey = unique_key;
357
+ return { key: unique_key, node };
366
358
  }
367
- function fixupReactions(reactions, files, sourceFile) {
359
+ function fixup_reactions(reactions, files, source_file) {
368
360
  const fallbacks = reactions.filter((r) => r.handlerName.startsWith("on "));
369
361
  if (fallbacks.length === 0) return;
370
- const src = sourceFile ? files.find((f) => f.path === sourceFile)?.content : files.map((f) => f.content).join("\n");
362
+ const src = source_file ? files.find((f) => f.path === source_file)?.content : files.map((f) => f.content).join("\n");
371
363
  if (!src) return;
372
- const doRe = /\.on\(\s*["'`](\w+)["'`]\s*\)\s*\.do\(\s*(?:async\s+)?(?:function\s+(\w+)|(?:\w+\.)?(\w+))?/g;
364
+ const do_re = /\.on\(\s*["'`](\w+)["'`]\s*\)\s*\.do\(\s*(?:async\s+)?(?:function\s+(\w+)|(?:\w+\.)?(\w+))?/g;
373
365
  let dm;
374
- while ((dm = doRe.exec(src)) !== null) {
375
- const eventName = dm[1];
366
+ while ((dm = do_re.exec(src)) !== null) {
367
+ const event_name = dm[1];
376
368
  const handlerName = dm[2] || dm[3];
377
369
  if (!handlerName) continue;
378
370
  const r = fallbacks.find(
379
- (r2) => r2.event === eventName && r2.handlerName === `on ${eventName}`
371
+ (r2) => r2.event === event_name && r2.handlerName === `on ${event_name}`
380
372
  );
381
373
  if (r) r.handlerName = handlerName;
382
374
  }
383
375
  }
384
- function buildModel(result, files, expectedSlices) {
385
- const rawStates = result.states.filter((s) => s && s._tag === "State");
386
- const rawSlices = result.slices.filter((s) => s && s._tag === "Slice");
387
- const rawProjections = result.projections.filter(
376
+ function build_model(result, files, expected_slices) {
377
+ const raw_states = result.states.filter((s) => s && s._tag === "State");
378
+ const raw_slices = result.slices.filter((s) => s && s._tag === "Slice");
379
+ const raw_projections = result.projections.filter(
388
380
  (p) => p && p._tag === "Projection"
389
381
  );
390
- const rawActs = result.acts.filter((a) => a && a._tag === "Act");
391
- const stateByRef = /* @__PURE__ */ new Map();
382
+ const raw_acts = result.acts.filter((a) => a && a._tag === "Act");
383
+ const state_by_ref = /* @__PURE__ */ new Map();
392
384
  const model = {
393
385
  entries: [],
394
386
  states: [],
@@ -396,89 +388,89 @@ function buildModel(result, files, expectedSlices) {
396
388
  projections: [],
397
389
  reactions: []
398
390
  };
399
- for (const st of rawStates) {
400
- if (stateByRef.has(st)) continue;
391
+ for (const st of raw_states) {
392
+ if (state_by_ref.has(st)) continue;
401
393
  try {
402
- stateByRef.set(st, buildState(model, st));
394
+ state_by_ref.set(st, build_state(model, st));
403
395
  } catch (e) {
404
- stateByRef.set(st, {
396
+ state_by_ref.set(st, {
405
397
  error: e instanceof Error ? e.message : String(e)
406
398
  });
407
399
  }
408
400
  }
409
- for (const a of rawActs) {
401
+ for (const a of raw_acts) {
410
402
  for (const st of a.states ?? []) {
411
- if (!st || st._tag !== "State" || stateByRef.has(st)) continue;
403
+ if (!st || st._tag !== "State" || state_by_ref.has(st)) continue;
412
404
  try {
413
- stateByRef.set(st, buildState(model, st));
405
+ state_by_ref.set(st, build_state(model, st));
414
406
  } catch (e) {
415
- stateByRef.set(st, {
407
+ state_by_ref.set(st, {
416
408
  error: e instanceof Error ? e.message : String(e)
417
409
  });
418
410
  }
419
411
  }
420
412
  }
421
- const builtSliceNames = /* @__PURE__ */ new Set();
422
- for (const s of rawSlices) {
423
- const sliceName = s._varName ?? "slice";
424
- builtSliceNames.add(sliceName);
413
+ const built_slice_names = /* @__PURE__ */ new Set();
414
+ for (const s of raw_slices) {
415
+ const slice_name = s._varName ?? "slice";
416
+ built_slice_names.add(slice_name);
425
417
  try {
426
418
  try {
427
- fixupReactions(s.reactions, files);
419
+ fixup_reactions(s.reactions, files);
428
420
  } catch {
429
421
  }
430
- const sliceStateKeys = [];
422
+ const slice_state_keys = [];
431
423
  const errors = [];
432
424
  for (const st of s.states ?? []) {
433
425
  if (!st || typeof st !== "object") {
434
- const fileErr = [...result.fileErrors.values()][0];
426
+ const fileErr = [...result.file_errors.values()][0];
435
427
  errors.push(fileErr ?? "Missing state (broken import)");
436
428
  continue;
437
429
  }
438
- const built = stateByRef.get(st);
430
+ const built = state_by_ref.get(st);
439
431
  if (built) {
440
432
  if ("error" in built) {
441
433
  errors.push(built.error);
442
434
  } else {
443
- sliceStateKeys.push(built.key);
435
+ slice_state_keys.push(built.key);
444
436
  }
445
437
  } else {
446
438
  try {
447
- const result2 = buildState(model, st);
448
- stateByRef.set(st, result2);
439
+ const result2 = build_state(model, st);
440
+ state_by_ref.set(st, result2);
449
441
  if ("error" in result2) {
450
442
  errors.push(result2.error);
451
443
  } else {
452
- sliceStateKeys.push(result2.key);
444
+ slice_state_keys.push(result2.key);
453
445
  }
454
446
  } catch (e) {
455
447
  const msg = e instanceof Error ? e.message : String(e);
456
- stateByRef.set(st, { error: msg });
448
+ state_by_ref.set(st, { error: msg });
457
449
  errors.push(msg);
458
450
  }
459
451
  }
460
452
  }
461
- const projNames = [];
453
+ const proj_names = [];
462
454
  for (const p of s.projections ?? []) {
463
- if (p && p._tag === "Projection") projNames.push(p.target);
455
+ if (p && p._tag === "Projection") proj_names.push(p.target);
464
456
  }
465
- const sliceFile = s._sourceFile;
457
+ const slice_file = s._sourceFile;
466
458
  model.slices.push({
467
- name: sliceName,
468
- states: sliceStateKeys,
469
- stateVars: sliceStateKeys,
470
- projections: projNames,
459
+ name: slice_name,
460
+ states: slice_state_keys,
461
+ stateVars: slice_state_keys,
462
+ projections: proj_names,
471
463
  reactions: (s.reactions ?? []).map((r) => ({
472
464
  ...r,
473
- file: r.file ?? sliceFile
465
+ file: r.file ?? slice_file
474
466
  })),
475
- file: sliceFile,
467
+ file: slice_file,
476
468
  error: errors.length > 0 ? errors.join("; ") : void 0
477
469
  });
478
470
  } catch (e) {
479
471
  const msg = e instanceof Error ? e.message : String(e);
480
472
  model.slices.push({
481
- name: sliceName,
473
+ name: slice_name,
482
474
  states: [],
483
475
  stateVars: [],
484
476
  projections: [],
@@ -488,38 +480,38 @@ function buildModel(result, files, expectedSlices) {
488
480
  });
489
481
  }
490
482
  }
491
- for (const [name, filePath] of expectedSlices) {
492
- if (!builtSliceNames.has(name)) {
483
+ for (const [name, file_path] of expected_slices) {
484
+ if (!built_slice_names.has(name)) {
493
485
  model.slices.push({
494
486
  name,
495
487
  states: [],
496
488
  stateVars: [],
497
489
  projections: [],
498
490
  reactions: [],
499
- error: result.fileErrors.get(filePath) ?? result.error ?? "Failed to build slice",
500
- file: filePath
491
+ error: result.file_errors.get(file_path) ?? result.error ?? "Failed to build slice",
492
+ file: file_path
501
493
  });
502
494
  }
503
495
  }
504
- const sourceByPath = /* @__PURE__ */ new Map();
505
- const externalIdents = /* @__PURE__ */ new Map();
496
+ const source_by_path = /* @__PURE__ */ new Map();
497
+ const external_idents = /* @__PURE__ */ new Map();
506
498
  for (const f of files) {
507
- sourceByPath.set(f.path, f.content);
508
- for (const [ident, expr] of extractIdentifierAssignments(f.content)) {
509
- if (!externalIdents.has(ident)) externalIdents.set(ident, expr);
499
+ source_by_path.set(f.path, f.content);
500
+ for (const [ident, expr] of extract_identifier_assignments(f.content)) {
501
+ if (!external_idents.has(ident)) external_idents.set(ident, expr);
510
502
  }
511
503
  }
512
- for (const stNode of model.states) {
513
- if (!stNode.file) continue;
514
- const src = sourceByPath.get(stNode.file);
515
- const names = new Set(stNode.events.map((e) => e.name));
504
+ for (const st_node of model.states) {
505
+ if (!st_node.file) continue;
506
+ const src = source_by_path.get(st_node.file);
507
+ const names = new Set(st_node.events.map((e) => e.name));
516
508
  if (names.size === 0) continue;
517
- const schemas = extractSchemasFromSource(src, names, externalIdents);
518
- for (const ev of stNode.events) {
509
+ const schemas = extract_schemas_from_source(src, names, external_idents);
510
+ for (const ev of st_node.events) {
519
511
  ev.schema = schemas.get(ev.name);
520
512
  }
521
513
  }
522
- for (const p of rawProjections) {
514
+ for (const p of raw_projections) {
523
515
  model.projections.push({
524
516
  name: p.target,
525
517
  varName: p.target,
@@ -527,11 +519,11 @@ function buildModel(result, files, expectedSlices) {
527
519
  file: p._sourceFile
528
520
  });
529
521
  }
530
- const statesInSlices = new Set(model.slices.flatMap((s) => s.states));
531
- const globalStateKeys = model.states.filter((s) => !statesInSlices.has(s.varName)).map((s) => s.varName);
532
- for (const a of rawActs) {
522
+ const states_in_slices = new Set(model.slices.flatMap((s) => s.states));
523
+ const global_state_keys = model.states.filter((s) => !states_in_slices.has(s.varName)).map((s) => s.varName);
524
+ for (const a of raw_acts) {
533
525
  try {
534
- fixupReactions(
526
+ fixup_reactions(
535
527
  a.reactions ?? [],
536
528
  files,
537
529
  a._sourceFile
@@ -543,53 +535,55 @@ function buildModel(result, files, expectedSlices) {
543
535
  projections: model.projections.map((p) => p.name),
544
536
  states: model.states.map((s) => s.name)
545
537
  };
546
- const actFile = a._sourceFile;
538
+ const act_file = a._sourceFile;
547
539
  for (const r of a.reactions ?? []) {
548
- model.reactions.push({ ...r, file: r.file ?? actFile });
540
+ model.reactions.push({ ...r, file: r.file ?? act_file });
549
541
  }
550
- const entryPath = a._sourceFile ?? "app.ts";
551
- const actSliceNames = new Set(
542
+ const entry_path = a._sourceFile ?? "app.ts";
543
+ const act_slice_names = new Set(
552
544
  (a.slices ?? []).filter((s) => s != null).map((s) => s._varName ?? "").filter(Boolean)
553
545
  );
554
546
  for (const sl of model.slices) {
555
- if (sl.error && !actSliceNames.has(sl.name)) {
556
- const actSrc = files.find((f) => f.path === entryPath)?.content ?? "";
557
- if (actSrc.includes(sl.name)) {
558
- actSliceNames.add(sl.name);
547
+ if (sl.error && !act_slice_names.has(sl.name)) {
548
+ const act_src = files.find((f) => f.path === entry_path)?.content ?? "";
549
+ if (act_src.includes(sl.name)) {
550
+ act_slice_names.add(sl.name);
559
551
  }
560
552
  }
561
553
  }
562
- const entrySlices = model.slices.filter((s) => actSliceNames.has(s.name));
563
- const sliceStateKeys = new Set(entrySlices.flatMap((s) => s.states));
564
- const actStateKeys = /* @__PURE__ */ new Set();
554
+ const entry_slices = model.slices.filter(
555
+ (s) => act_slice_names.has(s.name)
556
+ );
557
+ const slice_state_keys = new Set(entry_slices.flatMap((s) => s.states));
558
+ const act_state_keys = /* @__PURE__ */ new Set();
565
559
  for (const s of a.states ?? []) {
566
560
  try {
567
561
  if (s && s._tag === "State") {
568
- actStateKeys.add(s._modelKey ?? s.name);
562
+ act_state_keys.add(s._modelKey ?? s.name);
569
563
  }
570
564
  } catch {
571
565
  }
572
566
  }
573
- const allStateKeys = /* @__PURE__ */ new Set([...actStateKeys, ...sliceStateKeys]);
574
- const actProjNames = new Set(
567
+ const all_state_keys = /* @__PURE__ */ new Set([...act_state_keys, ...slice_state_keys]);
568
+ const act_proj_names = new Set(
575
569
  (a.projections ?? []).filter((p) => p && p._tag === "Projection").map((p) => p.target)
576
570
  );
577
- for (const sl of entrySlices) {
578
- for (const pn of sl.projections) actProjNames.add(pn);
571
+ for (const sl of entry_slices) {
572
+ for (const pn of sl.projections) act_proj_names.add(pn);
579
573
  }
580
574
  model.entries.push({
581
- path: entryPath,
582
- states: model.states.filter((s) => allStateKeys.has(s.varName)),
583
- slices: entrySlices,
584
- projections: model.projections.filter((p) => actProjNames.has(p.name)),
575
+ path: entry_path,
576
+ states: model.states.filter((s) => all_state_keys.has(s.varName)),
577
+ slices: entry_slices,
578
+ projections: model.projections.filter((p) => act_proj_names.has(p.name)),
585
579
  reactions: a.reactions ?? []
586
580
  });
587
581
  }
588
- if (globalStateKeys.length > 0 || model.reactions.length > 0) {
582
+ if (global_state_keys.length > 0 || model.reactions.length > 0) {
589
583
  model.slices.push({
590
584
  name: "global",
591
- states: globalStateKeys,
592
- stateVars: globalStateKeys,
585
+ states: global_state_keys,
586
+ stateVars: global_state_keys,
593
587
  projections: model.projections.map((p) => p.name),
594
588
  reactions: model.reactions
595
589
  });
@@ -611,42 +605,42 @@ function buildModel(result, files, expectedSlices) {
611
605
 
612
606
  // src/client/lib/mock-builders.ts
613
607
  var import_zod = require("zod");
614
- function proxyTarget() {
608
+ function proxy_target() {
615
609
  }
616
- function attachEmit(info, actionName, handler) {
610
+ function attach_emit(info, action_name, handler) {
617
611
  const emits = [];
618
612
  if (typeof handler === "string") {
619
613
  emits.push(handler);
620
614
  } else if (typeof handler === "function") {
621
615
  const src = String(handler);
622
- for (const eventName of Object.keys(info.events)) {
623
- if (src.includes(`"${eventName}"`) || src.includes(`'${eventName}'`) || src.includes(`\`${eventName}\``)) {
624
- emits.push(eventName);
616
+ for (const event_name of Object.keys(info.events)) {
617
+ if (src.includes(`"${event_name}"`) || src.includes(`'${event_name}'`) || src.includes(`\`${event_name}\``)) {
618
+ emits.push(event_name);
625
619
  }
626
620
  }
627
621
  if (emits.length === 0) {
628
622
  try {
629
- const deepProxy = new Proxy(
623
+ const deep_proxy = new Proxy(
630
624
  {},
631
625
  {
632
- get: () => deepProxy,
626
+ get: () => deep_proxy,
633
627
  has: () => true
634
628
  }
635
629
  );
636
- const proxyFn = new Proxy(proxyTarget, {
637
- get: () => deepProxy,
638
- apply: () => deepProxy
630
+ const proxy_fn = new Proxy(proxy_target, {
631
+ get: () => deep_proxy,
632
+ apply: () => deep_proxy
639
633
  });
640
- const dummyArg = new Proxy(
634
+ const dummy_arg = new Proxy(
641
635
  {},
642
636
  {
643
637
  get: (_t, prop) => {
644
- if (typeof prop === "string") return proxyFn;
638
+ if (typeof prop === "string") return proxy_fn;
645
639
  return void 0;
646
640
  }
647
641
  }
648
642
  );
649
- const result = handler(dummyArg, dummyArg, dummyArg);
643
+ const result = handler(dummy_arg, dummy_arg, dummy_arg);
650
644
  if (Array.isArray(result) && typeof result[0] === "string") {
651
645
  emits.push(result[0]);
652
646
  }
@@ -654,9 +648,9 @@ function attachEmit(info, actionName, handler) {
654
648
  }
655
649
  }
656
650
  }
657
- info.actions[`__emits_${actionName}`] = emits;
651
+ info.actions[`__emits_${action_name}`] = emits;
658
652
  }
659
- function mockState(entry, onBuild) {
653
+ function mock_state(entry, on_build) {
660
654
  const name = Object.keys(entry)[0];
661
655
  const info = {
662
656
  name,
@@ -666,29 +660,29 @@ function mockState(entry, onBuild) {
666
660
  patches: /* @__PURE__ */ new Set(),
667
661
  _tag: "State"
668
662
  };
669
- const actionBuilder = (_currentAction) => ({
670
- on(actionEntry) {
671
- const actionName = Object.keys(actionEntry)[0];
672
- info.actions[actionName] = actionEntry[actionName];
663
+ const action_builder = (_currentAction) => ({
664
+ on(action_entry) {
665
+ const action_name = Object.keys(action_entry)[0];
666
+ info.actions[action_name] = action_entry[action_name];
673
667
  return {
674
668
  given(rules) {
675
- if (rules) info.given[actionName] = rules;
669
+ if (rules) info.given[action_name] = rules;
676
670
  return {
677
671
  emit(handler) {
678
- attachEmit(info, actionName, handler);
679
- return actionBuilder(actionName);
672
+ attach_emit(info, action_name, handler);
673
+ return action_builder(action_name);
680
674
  }
681
675
  };
682
676
  },
683
677
  emit(handler) {
684
- attachEmit(info, actionName, handler);
685
- return actionBuilder(actionName);
678
+ attach_emit(info, action_name, handler);
679
+ return action_builder(action_name);
686
680
  }
687
681
  };
688
682
  },
689
- snap: () => actionBuilder(_currentAction),
683
+ snap: () => action_builder(_currentAction),
690
684
  build: () => {
691
- onBuild?.(info);
685
+ on_build?.(info);
692
686
  return info;
693
687
  }
694
688
  });
@@ -698,36 +692,36 @@ function mockState(entry, onBuild) {
698
692
  emits(events) {
699
693
  info.events = events ?? {};
700
694
  return {
701
- ...actionBuilder(),
695
+ ...action_builder(),
702
696
  patch(patches) {
703
697
  if (patches)
704
698
  for (const k of Object.keys(patches)) info.patches.add(k);
705
- return actionBuilder();
699
+ return action_builder();
706
700
  }
707
701
  };
708
702
  }
709
703
  })
710
704
  };
711
705
  }
712
- function captureDispatches(handler) {
706
+ function capture_dispatches(handler) {
713
707
  const dispatches = [];
714
708
  if (typeof handler !== "function") return dispatches;
715
709
  try {
716
- const safeProxy = () => new Proxy({}, { get: () => "" });
717
- const mockApp = {
718
- do: (actionName) => {
719
- if (typeof actionName === "string" && !dispatches.includes(actionName))
720
- dispatches.push(actionName);
710
+ const safe_proxy = () => new Proxy({}, { get: () => "" });
711
+ const mock_app = {
712
+ do: (action_name) => {
713
+ if (typeof action_name === "string" && !dispatches.includes(action_name))
714
+ dispatches.push(action_name);
721
715
  return Promise.resolve([]);
722
716
  },
723
- load: () => Promise.resolve({ state: safeProxy(), version: 0 }),
717
+ load: () => Promise.resolve({ state: safe_proxy(), version: 0 }),
724
718
  query: () => Promise.resolve({ count: 0 }),
725
719
  query_array: () => Promise.resolve([])
726
720
  };
727
- const mockEvent = new Proxy({}, {
721
+ const mock_event = new Proxy({}, {
728
722
  get: (_, prop) => prop === "stream" ? "mock" : prop === "data" ? new Proxy({}, { get: () => "" }) : ""
729
723
  });
730
- const result = handler(mockEvent, "mock", mockApp);
724
+ const result = handler(mock_event, "mock", mock_app);
731
725
  if (result && typeof result.catch === "function") {
732
726
  result.catch(() => {
733
727
  });
@@ -744,7 +738,7 @@ function captureDispatches(handler) {
744
738
  }
745
739
  return dispatches;
746
740
  }
747
- function mockSlice(onBuild) {
741
+ function mock_slice(on_build) {
748
742
  const info = {
749
743
  _tag: "Slice",
750
744
  states: [],
@@ -760,13 +754,13 @@ function mockSlice(onBuild) {
760
754
  if (p) info.projections.push(p);
761
755
  return builder;
762
756
  },
763
- on(eventName) {
757
+ on(event_name) {
764
758
  return {
765
759
  do(handler) {
766
- const dispatches = captureDispatches(handler);
760
+ const dispatches = capture_dispatches(handler);
767
761
  const reaction = {
768
- event: eventName,
769
- handlerName: typeof handler?.name === "string" && handler.name || `on ${eventName}`,
762
+ event: event_name,
763
+ handlerName: typeof handler?.name === "string" && handler.name || `on ${event_name}`,
770
764
  dispatches
771
765
  };
772
766
  info.reactions.push(reaction);
@@ -780,22 +774,22 @@ function mockSlice(onBuild) {
780
774
  };
781
775
  },
782
776
  build: () => {
783
- onBuild?.(info);
777
+ on_build?.(info);
784
778
  return info;
785
779
  }
786
780
  };
787
781
  return builder;
788
782
  }
789
- function mockProjection(target, onBuild) {
783
+ function mock_projection(target, on_build) {
790
784
  const info = {
791
785
  _tag: "Projection",
792
786
  target: target || "projection",
793
787
  handles: []
794
788
  };
795
789
  const builder = {
796
- on(eventEntry) {
797
- const eventName = Object.keys(eventEntry)[0];
798
- info.handles.push(eventName);
790
+ on(event_entry) {
791
+ const event_name = Object.keys(event_entry)[0];
792
+ info.handles.push(event_name);
799
793
  return {
800
794
  do() {
801
795
  return {
@@ -809,13 +803,13 @@ function mockProjection(target, onBuild) {
809
803
  };
810
804
  },
811
805
  build: () => {
812
- onBuild?.(info);
806
+ on_build?.(info);
813
807
  return info;
814
808
  }
815
809
  };
816
810
  return builder;
817
811
  }
818
- function mockAct(onBuild) {
812
+ function mock_act(on_build) {
819
813
  const info = {
820
814
  _tag: "Act",
821
815
  states: [],
@@ -837,13 +831,13 @@ function mockAct(onBuild) {
837
831
  return builder;
838
832
  },
839
833
  withActor: () => builder,
840
- on(eventName) {
834
+ on(event_name) {
841
835
  return {
842
836
  do(handler) {
843
- const dispatches = captureDispatches(handler);
837
+ const dispatches = capture_dispatches(handler);
844
838
  const reaction = {
845
- event: eventName,
846
- handlerName: typeof handler?.name === "string" && handler.name || `on ${eventName}`,
839
+ event: event_name,
840
+ handlerName: typeof handler?.name === "string" && handler.name || `on ${event_name}`,
847
841
  dispatches
848
842
  };
849
843
  info.reactions.push(reaction);
@@ -857,10 +851,10 @@ function mockAct(onBuild) {
857
851
  };
858
852
  },
859
853
  build: () => {
860
- const noop = () => actStub;
861
- const actStub = {
854
+ const noop = () => act_stub;
855
+ const act_stub = {
862
856
  ...info,
863
- on: () => actStub,
857
+ on: () => act_stub,
864
858
  do: () => Promise.resolve([]),
865
859
  load: () => Promise.resolve({}),
866
860
  drain: () => Promise.resolve(),
@@ -869,8 +863,8 @@ function mockAct(onBuild) {
869
863
  start_correlations: noop,
870
864
  query_array: () => Promise.resolve([])
871
865
  };
872
- onBuild?.(actStub);
873
- return actStub;
866
+ on_build?.(act_stub);
867
+ return act_stub;
874
868
  }
875
869
  };
876
870
  return builder;
@@ -881,13 +875,13 @@ var InvariantError = class extends Error {
881
875
  this.name = "InvariantError";
882
876
  }
883
877
  };
884
- var cryptoMock = { randomUUID: () => "mock-uuid" };
878
+ var crypto_mock = { randomUUID: () => "mock-uuid" };
885
879
  var MODULES = {
886
880
  "@rotorsoft/act": {
887
- state: mockState,
888
- slice: mockSlice,
889
- projection: mockProjection,
890
- act: mockAct,
881
+ state: mock_state,
882
+ slice: mock_slice,
883
+ projection: mock_projection,
884
+ act: mock_act,
891
885
  store: () => ({
892
886
  seed: () => Promise.resolve(),
893
887
  drop: () => Promise.resolve(),
@@ -900,10 +894,10 @@ var MODULES = {
900
894
  InvariantError
901
895
  },
902
896
  zod: { z: import_zod.z, ...import_zod.z },
903
- crypto: cryptoMock,
904
- "node:crypto": cryptoMock
897
+ crypto: crypto_mock,
898
+ "node:crypto": crypto_mock
905
899
  };
906
- function unknownModuleProxy() {
900
+ function unknown_module_proxy() {
907
901
  const handler = {
908
902
  get(_target, prop) {
909
903
  if (prop === Symbol.toPrimitive) return () => "";
@@ -920,62 +914,62 @@ function unknownModuleProxy() {
920
914
  return true;
921
915
  }
922
916
  };
923
- const proxy = new Proxy(proxyTarget, handler);
917
+ const proxy = new Proxy(proxy_target, handler);
924
918
  return proxy;
925
919
  }
926
920
 
927
921
  // src/client/lib/sort.ts
928
- function topoSort(tsFiles) {
929
- if (tsFiles.length <= 1) return tsFiles;
922
+ function topo_sort(ts_files) {
923
+ if (ts_files.length <= 1) return ts_files;
930
924
  const strip = (p) => p.replace(/\.tsx?$/, "");
931
- const byKey = /* @__PURE__ */ new Map();
932
- for (const f of tsFiles) {
933
- byKey.set(strip(f.path), f);
925
+ const by_key = /* @__PURE__ */ new Map();
926
+ for (const f of ts_files) {
927
+ by_key.set(strip(f.path), f);
934
928
  }
935
929
  const deps = /* @__PURE__ */ new Map();
936
- for (const f of tsFiles) {
930
+ for (const f of ts_files) {
937
931
  const key = strip(f.path);
938
- const fileDeps = /* @__PURE__ */ new Set();
939
- deps.set(key, fileDeps);
940
- const fromRe = /from\s+["']([^"']+)["']/g;
932
+ const file_deps = /* @__PURE__ */ new Set();
933
+ deps.set(key, file_deps);
934
+ const from_re = /from\s+["']([^"']+)["']/g;
941
935
  let m;
942
- while ((m = fromRe.exec(f.content)) !== null) {
936
+ while ((m = from_re.exec(f.content)) !== null) {
943
937
  const imp = m[1];
944
- const resolved = resolve(imp, key, byKey);
945
- if (resolved && byKey.has(resolved)) fileDeps.add(resolved);
938
+ const resolved = resolve(imp, key, by_key);
939
+ if (resolved && by_key.has(resolved)) file_deps.add(resolved);
946
940
  }
947
941
  }
948
- const inDegree = /* @__PURE__ */ new Map();
949
- for (const f of tsFiles) inDegree.set(strip(f.path), 0);
950
- for (const [, fileDeps] of deps) {
951
- for (const dep of fileDeps) {
952
- inDegree.set(dep, inDegree.get(dep) + 1);
942
+ const in_degree = /* @__PURE__ */ new Map();
943
+ for (const f of ts_files) in_degree.set(strip(f.path), 0);
944
+ for (const [, file_deps] of deps) {
945
+ for (const dep of file_deps) {
946
+ in_degree.set(dep, in_degree.get(dep) + 1);
953
947
  }
954
948
  }
955
949
  const queue = [];
956
- for (const [key, _deg] of inDegree) {
950
+ for (const [key, _deg] of in_degree) {
957
951
  if (deps.get(key)?.size === 0) queue.push(key);
958
952
  }
959
953
  const order = [];
960
954
  while (queue.length > 0) {
961
955
  const key = queue.shift();
962
956
  order.push(key);
963
- for (const [other, fileDeps] of deps) {
964
- if (fileDeps.has(key)) {
965
- fileDeps.delete(key);
966
- if (fileDeps.size === 0) queue.push(other);
957
+ for (const [other, file_deps] of deps) {
958
+ if (file_deps.has(key)) {
959
+ file_deps.delete(key);
960
+ if (file_deps.size === 0) queue.push(other);
967
961
  }
968
962
  }
969
963
  }
970
- for (const f of tsFiles) {
964
+ for (const f of ts_files) {
971
965
  const key = strip(f.path);
972
966
  if (!order.includes(key)) order.push(key);
973
967
  }
974
- return order.map((k) => byKey.get(k)).filter(Boolean);
968
+ return order.map((k) => by_key.get(k)).filter(Boolean);
975
969
  }
976
- function resolve(imp, fromPath, byKey) {
970
+ function resolve(imp, from_path, by_key) {
977
971
  if (imp.startsWith(".")) {
978
- const dir = fromPath.includes("/") ? fromPath.slice(0, fromPath.lastIndexOf("/")) : "";
972
+ const dir = from_path.includes("/") ? from_path.slice(0, from_path.lastIndexOf("/")) : "";
979
973
  const parts = (dir ? dir + "/" + imp : imp).split("/");
980
974
  const resolved = [];
981
975
  for (const p of parts) {
@@ -986,23 +980,23 @@ function resolve(imp, fromPath, byKey) {
986
980
  return resolved.join("/").replace(/\.js$/, "").replace(/\.ts$/, "");
987
981
  }
988
982
  if (imp.startsWith("@") && !imp.startsWith("@rotorsoft/")) {
989
- const pkgName = imp.split("/")[1];
990
- if (pkgName) {
983
+ const pkg_name = imp.split("/")[1];
984
+ if (pkg_name) {
991
985
  for (const candidate of [
992
- `packages/${pkgName}/src/index`,
993
- `${pkgName}/src/index`,
994
- `${pkgName}/index`
986
+ `packages/${pkg_name}/src/index`,
987
+ `${pkg_name}/src/index`,
988
+ `${pkg_name}/index`
995
989
  ]) {
996
- if (byKey?.has(candidate)) return candidate;
990
+ if (by_key?.has(candidate)) return candidate;
997
991
  }
998
- return `packages/${pkgName}/src/index`;
992
+ return `packages/${pkg_name}/src/index`;
999
993
  }
1000
994
  }
1001
995
  return void 0;
1002
996
  }
1003
997
 
1004
998
  // src/client/lib/evaluate.ts
1005
- var stripNonCode = (src, level = "full") => {
999
+ var strip_non_code = (src, level = "full") => {
1006
1000
  const blank = (m) => m.replace(/[^\n]/g, " ");
1007
1001
  let result = src.replace(/\/\/[^\n]*/g, blank).replace(/\/\*[\s\S]*?\*\//g, blank).replace(/`(?:\\[\s\S]|[^`\\])*`/g, blank);
1008
1002
  if (level === "full") {
@@ -1010,7 +1004,7 @@ var stripNonCode = (src, level = "full") => {
1010
1004
  }
1011
1005
  return result;
1012
1006
  };
1013
- var isSourceFile = (f) => f.path.endsWith(".ts") && !f.path.endsWith(".d.ts") && !f.path.endsWith(".tsx") && !f.path.endsWith(".spec.ts") && !f.path.endsWith(".test.ts") && !f.path.includes("node_modules/") && !f.path.includes("__tests__/") && !f.path.includes("/test/") && !f.path.startsWith("test/");
1007
+ var is_source_file = (f) => f.path.endsWith(".ts") && !f.path.endsWith(".d.ts") && !f.path.endsWith(".tsx") && !f.path.endsWith(".spec.ts") && !f.path.endsWith(".test.ts") && !f.path.includes("node_modules/") && !f.path.includes("__tests__/") && !f.path.includes("/test/") && !f.path.startsWith("test/");
1014
1008
  function transpile(code) {
1015
1009
  try {
1016
1010
  const safe = code.replace(/\bimport\.meta\.\w+/g, "'__import_meta__'");
@@ -1032,8 +1026,8 @@ function execute(files) {
1032
1026
  projections: [],
1033
1027
  acts: [],
1034
1028
  error: void 0,
1035
- fileErrors: /* @__PURE__ */ new Map(),
1036
- expectedSlices: /* @__PURE__ */ new Map()
1029
+ file_errors: /* @__PURE__ */ new Map(),
1030
+ expected_slices: /* @__PURE__ */ new Map()
1037
1031
  };
1038
1032
  try {
1039
1033
  const __built__ = {
@@ -1047,24 +1041,24 @@ function execute(files) {
1047
1041
  info._sourceFile = _currentFile;
1048
1042
  __built__[type + "s"].push(info);
1049
1043
  };
1050
- const actModule = { ...MODULES["@rotorsoft/act"] };
1051
- actModule.state = (entry) => MODULES["@rotorsoft/act"].state(entry, capture("state"));
1052
- actModule.slice = () => MODULES["@rotorsoft/act"].slice(capture("slice"));
1053
- actModule.projection = (target) => MODULES["@rotorsoft/act"].projection(
1044
+ const act_module = { ...MODULES["@rotorsoft/act"] };
1045
+ act_module.state = (entry) => MODULES["@rotorsoft/act"].state(entry, capture("state"));
1046
+ act_module.slice = () => MODULES["@rotorsoft/act"].slice(capture("slice"));
1047
+ act_module.projection = (target) => MODULES["@rotorsoft/act"].projection(
1054
1048
  target,
1055
1049
  capture("projection")
1056
1050
  );
1057
- actModule.act = () => MODULES["@rotorsoft/act"].act(capture("act"));
1058
- const pkgModules = {
1051
+ act_module.act = () => MODULES["@rotorsoft/act"].act(capture("act"));
1052
+ const pkg_modules = {
1059
1053
  ...MODULES,
1060
- "@rotorsoft/act": actModule
1054
+ "@rotorsoft/act": act_module
1061
1055
  };
1062
- const fileExports = /* @__PURE__ */ new Map();
1056
+ const file_exports = /* @__PURE__ */ new Map();
1063
1057
  const strip = (p) => p.replace(/\.tsx?$/, "");
1064
- const resolveModule = (mod, fromPath) => {
1065
- if (pkgModules[mod]) return pkgModules[mod];
1058
+ const resolve_module = (mod, from_path) => {
1059
+ if (pkg_modules[mod]) return pkg_modules[mod];
1066
1060
  if (mod.startsWith(".")) {
1067
- const dir = fromPath.includes("/") ? fromPath.slice(0, fromPath.lastIndexOf("/")) : "";
1061
+ const dir = from_path.includes("/") ? from_path.slice(0, from_path.lastIndexOf("/")) : "";
1068
1062
  const parts = (dir ? dir + "/" + mod : mod).split("/");
1069
1063
  const resolved = [];
1070
1064
  for (const p of parts) {
@@ -1073,43 +1067,44 @@ function execute(files) {
1073
1067
  else resolved.push(p);
1074
1068
  }
1075
1069
  const rp = resolved.join("/").replace(/\.js$/, "").replace(/\.ts$/, "");
1076
- return fileExports.get(rp) ?? fileExports.get(rp + "/index") ?? {};
1070
+ return file_exports.get(rp) ?? file_exports.get(rp + "/index") ?? {};
1077
1071
  }
1078
1072
  if (mod.startsWith("@") && !mod.startsWith("@rotorsoft/")) {
1079
- const pkgName = mod.split("/")[1];
1080
- const subPath = mod.split("/").slice(2).join("/");
1081
- if (pkgName) {
1082
- const suffix = subPath ? `/${subPath.replace(/\.js$/, "")}` : "/src/index";
1083
- return fileExports.get(`packages/${pkgName}${suffix}`) ?? fileExports.get(`${pkgName}${suffix}`) ?? fileExports.get(`packages/${pkgName}/src/index`) ?? fileExports.get(`${pkgName}/src/index`) ?? fileExports.get(`${pkgName}/index`) ?? fileExports.get(pkgName) ?? unknownModuleProxy();
1073
+ const pkg_name = mod.split("/")[1];
1074
+ const sub_path = mod.split("/").slice(2).join("/");
1075
+ if (pkg_name) {
1076
+ const suffix = sub_path ? `/${sub_path.replace(/\.js$/, "")}` : "/src/index";
1077
+ return file_exports.get(`packages/${pkg_name}${suffix}`) ?? file_exports.get(`${pkg_name}${suffix}`) ?? file_exports.get(`packages/${pkg_name}/src/index`) ?? file_exports.get(`${pkg_name}/src/index`) ?? file_exports.get(`${pkg_name}/index`) ?? file_exports.get(pkg_name) ?? unknown_module_proxy();
1084
1078
  }
1085
1079
  }
1086
- return unknownModuleProxy();
1080
+ return unknown_module_proxy();
1087
1081
  };
1088
- const sorted = topoSort(files.filter(isSourceFile));
1082
+ const sorted = topo_sort(files.filter(is_source_file));
1089
1083
  for (const file of sorted) {
1090
1084
  _currentFile = file.path;
1091
1085
  const js = transpile(file.content);
1092
1086
  const key = strip(file.path);
1093
1087
  const fileExp = {};
1094
- fileExports.set(key, fileExp);
1095
- const sliceNamesInAct = [];
1096
- const wsRe = /\.withSlice\(\s*(?:\w+\.)*(\w+)\s*\)/g;
1088
+ file_exports.set(key, fileExp);
1089
+ const slice_names_in_act = [];
1090
+ const ws_re = /\.withSlice\(\s*(?:\w+\.)*(\w+)\s*\)/g;
1097
1091
  let wsm;
1098
- const codeOnly = stripNonCode(js);
1099
- while ((wsm = wsRe.exec(codeOnly)) !== null) {
1100
- if (!sliceNamesInAct.includes(wsm[1])) sliceNamesInAct.push(wsm[1]);
1092
+ const code_only = strip_non_code(js);
1093
+ while ((wsm = ws_re.exec(code_only)) !== null) {
1094
+ if (!slice_names_in_act.includes(wsm[1]))
1095
+ slice_names_in_act.push(wsm[1]);
1101
1096
  }
1102
- for (const m of codeOnly.matchAll(
1097
+ for (const m of code_only.matchAll(
1103
1098
  /(?:exports\.)?(\w+)\s*=\s*(?:\w+\.)?slice(?:\s*\(\s*\)|\.call\(void 0,\s*\))/g
1104
1099
  )) {
1105
- result.expectedSlices.set(m[1], file.path);
1100
+ result.expected_slices.set(m[1], file.path);
1106
1101
  }
1107
- const fileRequire = Object.assign(
1108
- (mod) => resolveModule(mod, key),
1102
+ const file_require = Object.assign(
1103
+ (mod) => resolve_module(mod, key),
1109
1104
  { resolve: (mod) => mod, cache: {}, main: void 0 }
1110
1105
  );
1111
1106
  try {
1112
- const cleanJs = js.replace(/\bconst\s+__dirname\b/g, "var __dirname").replace(/\bconst\s+__filename\b/g, "var __filename");
1107
+ const clean_js = js.replace(/\bconst\s+__dirname\b/g, "var __dirname").replace(/\bconst\s+__filename\b/g, "var __filename");
1113
1108
  const fn = new Function(
1114
1109
  // lgtm[js/code-injection]
1115
1110
  "require",
@@ -1122,21 +1117,21 @@ function execute(files) {
1122
1117
  var process = { env: {}, cwd: function() { return "/"; }, exit: function() {}, on: function() {}, off: function() {} };
1123
1118
  var Buffer = { from: function() { return ""; } };
1124
1119
  var console = { log: function() {}, error: function() {}, warn: function() {}, info: function() {}, debug: function() {} };
1125
- ${cleanJs}
1120
+ ${clean_js}
1126
1121
  `
1127
1122
  );
1128
- fn(fileRequire, fileExp, { exports: fileExp });
1123
+ fn(file_require, fileExp, { exports: fileExp });
1129
1124
  } catch (evalErr) {
1130
1125
  const errMsg = evalErr instanceof Error ? evalErr.message : String(evalErr);
1131
- result.fileErrors.set(file.path, errMsg);
1132
- }
1133
- if (sliceNamesInAct.length > 0) {
1134
- for (const actObj of __built__.acts) {
1135
- if (actObj._sourceFile !== file.path) continue;
1136
- const actSlices = actObj.slices;
1137
- for (let ai = 0; ai < Math.min(sliceNamesInAct.length, actSlices.length); ai++) {
1138
- if (actSlices[ai]) {
1139
- actSlices[ai]._varName = sliceNamesInAct[ai];
1126
+ result.file_errors.set(file.path, errMsg);
1127
+ }
1128
+ if (slice_names_in_act.length > 0) {
1129
+ for (const act_obj of __built__.acts) {
1130
+ if (act_obj._sourceFile !== file.path) continue;
1131
+ const act_slices = act_obj.slices;
1132
+ for (let ai = 0; ai < Math.min(slice_names_in_act.length, act_slices.length); ai++) {
1133
+ if (act_slices[ai]) {
1134
+ act_slices[ai]._varName = slice_names_in_act[ai];
1140
1135
  }
1141
1136
  }
1142
1137
  }
@@ -1151,29 +1146,29 @@ function execute(files) {
1151
1146
  }
1152
1147
  return result;
1153
1148
  }
1154
- function extractModel(files) {
1149
+ function extract_model(files) {
1155
1150
  const result = execute(files);
1156
- return buildModel(result, files, result.expectedSlices);
1151
+ return build_model(result, files, result.expected_slices);
1157
1152
  }
1158
1153
 
1159
1154
  // src/client/lib/navigate.ts
1160
- function positionAt(content, index) {
1155
+ function position_at(content, index) {
1161
1156
  const before = content.slice(0, index);
1162
1157
  const line = before.split("\n").length;
1163
- const lastNl = before.lastIndexOf("\n");
1164
- const col = index - (lastNl >= 0 ? lastNl : 0);
1158
+ const last_nl = before.lastIndexOf("\n");
1159
+ const col = index - (last_nl >= 0 ? last_nl : 0);
1165
1160
  return { line, col };
1166
1161
  }
1167
- function buildPatterns(esc, type) {
1168
- const statePatterns = [new RegExp(`state\\(\\s*\\{\\s*(${esc})\\s*[}:,]`)];
1169
- const actionPatterns = [new RegExp(`\\.on\\(\\s*\\{\\s*(${esc})\\s*[},:]`)];
1170
- const eventPatterns = [
1162
+ function build_patterns(esc, type) {
1163
+ const state_patterns = [new RegExp(`state\\(\\s*\\{\\s*(${esc})\\s*[}:,]`)];
1164
+ const action_patterns = [new RegExp(`\\.on\\(\\s*\\{\\s*(${esc})\\s*[},:]`)];
1165
+ const event_patterns = [
1171
1166
  // Match event name inside .emits({ EventName: ... }) — inline declaration
1172
1167
  new RegExp(`\\.emits\\([\\s\\S]*?(${esc})\\s*:`),
1173
1168
  // Match event name as key in a schema object: EventName: z.object(...)
1174
1169
  new RegExp(`(${esc})\\s*:\\s*z\\.object\\(`)
1175
1170
  ];
1176
- const reactionPatterns = [
1171
+ const reaction_patterns = [
1177
1172
  // .do(handlerName) or .do(module.handlerName) — handler declaration in builder
1178
1173
  new RegExp(`\\.do\\(\\s*(?:\\w+\\.)?(${esc})\\b`),
1179
1174
  // inline function in .do()
@@ -1183,11 +1178,11 @@ function buildPatterns(esc, type) {
1183
1178
  // Fallback: function definition
1184
1179
  new RegExp(`(?:export\\s+)?async\\s+function\\s+(${esc})\\s*\\(`)
1185
1180
  ];
1186
- const projectionPatterns = [
1181
+ const projection_patterns = [
1187
1182
  new RegExp(`(?:const|let|var)\\s+(${esc})\\s*=\\s*projection\\s*\\(`),
1188
1183
  new RegExp(`projection\\(\\s*["'\`](${esc})["'\`]`)
1189
1184
  ];
1190
- const guardPatterns = [
1185
+ const guard_patterns = [
1191
1186
  // Guard definition — prefer jumping to the declaration
1192
1187
  new RegExp(`(?:const|let|var)\\s+(${esc})\\s*(?::\\s*Invariant)?\\s*=`),
1193
1188
  new RegExp(`rule\\(\\s*["'\`](${esc})["'\`]`),
@@ -1195,7 +1190,7 @@ function buildPatterns(esc, type) {
1195
1190
  // .given() usage in the state builder — last resort
1196
1191
  new RegExp(`\\.given\\([\\s\\S]*?(${esc})`)
1197
1192
  ];
1198
- const slicePatterns = [
1193
+ const slice_patterns = [
1199
1194
  new RegExp(`(?:const|let|var)\\s+(${esc})\\s*=\\s*slice\\s*\\(`)
1200
1195
  ];
1201
1196
  const generic = [
@@ -1207,36 +1202,36 @@ function buildPatterns(esc, type) {
1207
1202
  ];
1208
1203
  switch (type) {
1209
1204
  case "state":
1210
- return [...statePatterns, ...generic];
1205
+ return [...state_patterns, ...generic];
1211
1206
  case "action":
1212
- return [...actionPatterns, ...generic];
1207
+ return [...action_patterns, ...generic];
1213
1208
  case "event":
1214
- return [...eventPatterns, ...generic];
1209
+ return [...event_patterns, ...generic];
1215
1210
  case "reaction":
1216
- return [...reactionPatterns, ...generic];
1211
+ return [...reaction_patterns, ...generic];
1217
1212
  case "projection":
1218
- return [...projectionPatterns, ...generic];
1213
+ return [...projection_patterns, ...generic];
1219
1214
  case "guard":
1220
- return [...guardPatterns, ...generic];
1215
+ return [...guard_patterns, ...generic];
1221
1216
  default:
1222
1217
  return [
1223
- ...slicePatterns,
1224
- ...statePatterns,
1225
- ...actionPatterns,
1226
- ...eventPatterns,
1227
- ...reactionPatterns,
1228
- ...projectionPatterns,
1229
- ...guardPatterns,
1218
+ ...slice_patterns,
1219
+ ...state_patterns,
1220
+ ...action_patterns,
1221
+ ...event_patterns,
1222
+ ...reaction_patterns,
1223
+ ...projection_patterns,
1224
+ ...guard_patterns,
1230
1225
  ...generic
1231
1226
  ];
1232
1227
  }
1233
1228
  }
1234
- function navigateToCode(files, name, type, targetFile) {
1229
+ function navigate_to_code(files, name, type, target_file) {
1235
1230
  const stripped = /* @__PURE__ */ new Map();
1236
1231
  const code = (f) => {
1237
1232
  let c = stripped.get(f.path);
1238
1233
  if (c === void 0) {
1239
- c = stripNonCode(f.content, "nav");
1234
+ c = strip_non_code(f.content, "nav");
1240
1235
  stripped.set(f.path, c);
1241
1236
  }
1242
1237
  return c;
@@ -1244,122 +1239,122 @@ function navigateToCode(files, name, type, targetFile) {
1244
1239
  if (type === "file") {
1245
1240
  const file = files.find((f) => f.path === name || f.path.endsWith(name));
1246
1241
  if (file) {
1247
- const actMatch = /\bact\s*\(\s*\)/.exec(code(file));
1248
- if (actMatch) {
1249
- const { line, col } = positionAt(file.content, actMatch.index);
1242
+ const act_match = /\bact\s*\(\s*\)/.exec(code(file));
1243
+ if (act_match) {
1244
+ const { line, col } = position_at(file.content, act_match.index);
1250
1245
  return { file: file.path, line, col };
1251
1246
  }
1252
1247
  return { file: file.path, line: 1, col: 1 };
1253
1248
  }
1254
1249
  return void 0;
1255
1250
  }
1256
- if (targetFile) {
1257
- const file = files.find((f) => f.path === targetFile);
1251
+ if (target_file) {
1252
+ const file = files.find((f) => f.path === target_file);
1258
1253
  if (file) {
1259
1254
  const c = code(file);
1260
1255
  const esc2 = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1261
1256
  if (type === "event") {
1262
- const emitsBlockRe = new RegExp(
1257
+ const emits_block_re = new RegExp(
1263
1258
  `\\.emits\\([\\s\\S]*?(${esc2})\\s*[,:}]`
1264
1259
  );
1265
- const blockMatch = emitsBlockRe.exec(c);
1266
- if (blockMatch) {
1267
- const nameIdx = blockMatch.index + blockMatch[0].lastIndexOf(name);
1268
- const { line, col } = positionAt(file.content, nameIdx);
1260
+ const block_match = emits_block_re.exec(c);
1261
+ if (block_match) {
1262
+ const name_idx = block_match.index + block_match[0].lastIndexOf(name);
1263
+ const { line, col } = position_at(file.content, name_idx);
1269
1264
  return { file: file.path, line, col };
1270
1265
  }
1271
- const nameRe2 = new RegExp(`\\b${esc2}\\b`, "g");
1272
- if (nameRe2.exec(c)) {
1273
- const emitsMatch = /\.emits\s*\(/.exec(c);
1274
- if (emitsMatch) {
1275
- const { line, col } = positionAt(
1266
+ const name_re2 = new RegExp(`\\b${esc2}\\b`, "g");
1267
+ if (name_re2.exec(c)) {
1268
+ const emits_match = /\.emits\s*\(/.exec(c);
1269
+ if (emits_match) {
1270
+ const { line, col } = position_at(
1276
1271
  file.content,
1277
- emitsMatch.index + 1
1272
+ emits_match.index + 1
1278
1273
  );
1279
1274
  return { file: file.path, line, col };
1280
1275
  }
1281
1276
  }
1282
1277
  }
1283
1278
  if (type === "guard") {
1284
- const descRe = new RegExp(`description:\\s*["'\`]${esc2}["'\`]`);
1285
- const descMatch = descRe.exec(c);
1286
- if (descMatch) {
1287
- const before = c.slice(0, descMatch.index);
1288
- const declRe = /(?:export\s+)?(?:const|let|var)\s+(\w+)\s*(?::\s*Invariant[^=]*)?\s*=/g;
1289
- let lastDecl = null;
1279
+ const desc_re = new RegExp(`description:\\s*["'\`]${esc2}["'\`]`);
1280
+ const desc_match = desc_re.exec(c);
1281
+ if (desc_match) {
1282
+ const before = c.slice(0, desc_match.index);
1283
+ const decl_re = /(?:export\s+)?(?:const|let|var)\s+(\w+)\s*(?::\s*Invariant[^=]*)?\s*=/g;
1284
+ let last_decl = null;
1290
1285
  let m;
1291
- while ((m = declRe.exec(before)) !== null) {
1292
- lastDecl = m;
1286
+ while ((m = decl_re.exec(before)) !== null) {
1287
+ last_decl = m;
1293
1288
  }
1294
- if (lastDecl) {
1295
- const nameIdx = lastDecl.index + lastDecl[0].indexOf(lastDecl[1]);
1296
- const { line: line2, col: col2 } = positionAt(file.content, nameIdx);
1289
+ if (last_decl) {
1290
+ const name_idx = last_decl.index + last_decl[0].indexOf(last_decl[1]);
1291
+ const { line: line2, col: col2 } = position_at(file.content, name_idx);
1297
1292
  return { file: file.path, line: line2, col: col2 };
1298
1293
  }
1299
- const { line, col } = positionAt(file.content, descMatch.index);
1294
+ const { line, col } = position_at(file.content, desc_match.index);
1300
1295
  return { file: file.path, line, col };
1301
1296
  }
1302
1297
  }
1303
1298
  if (type === "action") {
1304
- const nameRe2 = new RegExp(`\\b${esc2}\\b`, "g");
1305
- const blockStart = c.indexOf(".on(");
1306
- if (blockStart >= 0) {
1307
- nameRe2.lastIndex = blockStart;
1308
- const match2 = nameRe2.exec(c);
1299
+ const name_re2 = new RegExp(`\\b${esc2}\\b`, "g");
1300
+ const block_start = c.indexOf(".on(");
1301
+ if (block_start >= 0) {
1302
+ name_re2.lastIndex = block_start;
1303
+ const match2 = name_re2.exec(c);
1309
1304
  if (match2) {
1310
- const { line, col } = positionAt(file.content, match2.index);
1305
+ const { line, col } = position_at(file.content, match2.index);
1311
1306
  return { file: file.path, line, col };
1312
1307
  }
1313
1308
  }
1314
1309
  }
1315
- const nameRe = new RegExp(`\\b${esc2}\\b`);
1316
- const match = nameRe.exec(c);
1310
+ const name_re = new RegExp(`\\b${esc2}\\b`);
1311
+ const match = name_re.exec(c);
1317
1312
  if (match) {
1318
- const { line, col } = positionAt(file.content, match.index);
1313
+ const { line, col } = position_at(file.content, match.index);
1319
1314
  return { file: file.path, line, col };
1320
1315
  }
1321
1316
  }
1322
1317
  return void 0;
1323
1318
  }
1324
1319
  const esc = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1325
- const isTestFile = (p) => /(?:\.spec\.|\.test\.|__tests__)/.test(p) || /\/test\//.test(p);
1326
- const sortedFiles = [...files].sort(
1327
- (a, b) => (isTestFile(a.path) ? 1 : 0) - (isTestFile(b.path) ? 1 : 0)
1320
+ const is_test_file = (p) => /(?:\.spec\.|\.test\.|__tests__)/.test(p) || /\/test\//.test(p);
1321
+ const sorted_files = [...files].sort(
1322
+ (a, b) => (is_test_file(a.path) ? 1 : 0) - (is_test_file(b.path) ? 1 : 0)
1328
1323
  );
1329
1324
  if (type === "guard") {
1330
- const descRe = new RegExp(`description:\\s*["'\`]${esc}["'\`]`);
1331
- for (const f of sortedFiles) {
1325
+ const desc_re = new RegExp(`description:\\s*["'\`]${esc}["'\`]`);
1326
+ for (const f of sorted_files) {
1332
1327
  if (!/\.tsx?$/.test(f.path)) continue;
1333
1328
  const c = code(f);
1334
- const descMatch = descRe.exec(c);
1335
- if (descMatch) {
1336
- const before = c.slice(0, descMatch.index);
1337
- const declRe = /(?:export\s+)?(?:const|let|var)\s+(\w+)\s*(?::\s*Invariant[^=]*)?\s*=/g;
1338
- let lastDecl = null;
1329
+ const desc_match = desc_re.exec(c);
1330
+ if (desc_match) {
1331
+ const before = c.slice(0, desc_match.index);
1332
+ const decl_re = /(?:export\s+)?(?:const|let|var)\s+(\w+)\s*(?::\s*Invariant[^=]*)?\s*=/g;
1333
+ let last_decl = null;
1339
1334
  let m;
1340
- while ((m = declRe.exec(before)) !== null) lastDecl = m;
1341
- if (lastDecl) {
1342
- const nameIdx = lastDecl.index + lastDecl[0].indexOf(lastDecl[1]);
1343
- const { line: line2, col: col2 } = positionAt(f.content, nameIdx);
1335
+ while ((m = decl_re.exec(before)) !== null) last_decl = m;
1336
+ if (last_decl) {
1337
+ const name_idx = last_decl.index + last_decl[0].indexOf(last_decl[1]);
1338
+ const { line: line2, col: col2 } = position_at(f.content, name_idx);
1344
1339
  return { file: f.path, line: line2, col: col2 };
1345
1340
  }
1346
- const { line, col } = positionAt(f.content, descMatch.index);
1341
+ const { line, col } = position_at(f.content, desc_match.index);
1347
1342
  return { file: f.path, line, col };
1348
1343
  }
1349
1344
  }
1350
1345
  }
1351
- const patterns = buildPatterns(esc, type);
1346
+ const patterns = build_patterns(esc, type);
1352
1347
  for (const re of patterns) {
1353
- for (const f of sortedFiles) {
1348
+ for (const f of sorted_files) {
1354
1349
  if (!/\.tsx?$/.test(f.path)) continue;
1355
1350
  const c = code(f);
1356
- const globalRe = new RegExp(re.source, re.flags + "g");
1351
+ const global_re = new RegExp(re.source, re.flags + "g");
1357
1352
  let match;
1358
- while ((match = globalRe.exec(c)) !== null) {
1359
- const matchText = match[0];
1360
- const nameOffsetInMatch = matchText.lastIndexOf(name);
1361
- const nameStart = match.index + Math.max(0, nameOffsetInMatch);
1362
- const { line, col } = positionAt(f.content, nameStart);
1353
+ while ((match = global_re.exec(c)) !== null) {
1354
+ const match_text = match[0];
1355
+ const name_offset_in_match = match_text.lastIndexOf(name);
1356
+ const name_start = match.index + Math.max(0, name_offset_in_match);
1357
+ const { line, col } = position_at(f.content, name_start);
1363
1358
  return { file: f.path, line, col };
1364
1359
  }
1365
1360
  }
@@ -1483,63 +1478,63 @@ var COLORS = {
1483
1478
  reaction: { bg: "#7e22ce", border: "#a855f7", text: "#d8b4fe" },
1484
1479
  projection: { bg: "#15803d", border: "#22c55e", text: "#bbf7d0" }
1485
1480
  };
1486
- function measureChain(rDef, lookup, visited, allStates) {
1481
+ function measure_chain(rDef, lookup, visited, all_states) {
1487
1482
  const rows = [];
1488
- let dispatchBlockH = 0;
1483
+ let dispatch_block_h = 0;
1489
1484
  for (const an of rDef.dispatches) {
1490
- const targetAction = allStates.flatMap((s) => s.actions).find((a) => a.name === an);
1491
- const targetState = allStates.find(
1485
+ const target_action = all_states.flatMap((s) => s.actions).find((a) => a.name === an);
1486
+ const target_state = all_states.find(
1492
1487
  (s) => s.actions.some((a) => a.name === an)
1493
1488
  );
1494
- const emitNames = targetAction?.emits ?? [];
1495
- const emitInfos = [];
1489
+ const emit_names = target_action?.emits ?? [];
1490
+ const emit_infos = [];
1496
1491
  let emitsH = 0;
1497
- for (const en of emitNames) {
1492
+ for (const en of emit_names) {
1498
1493
  const subR = lookup.get(en);
1499
1494
  let eventH = H;
1500
- let subChain;
1495
+ let sub_chain;
1501
1496
  if (subR && !visited.has(subR.handlerName)) {
1502
1497
  visited.add(subR.handlerName);
1503
- subChain = measureChain(subR, lookup, visited, allStates);
1504
- eventH = Math.max(H, subChain.groupH);
1498
+ sub_chain = measure_chain(subR, lookup, visited, all_states);
1499
+ eventH = Math.max(H, sub_chain.groupH);
1505
1500
  }
1506
- emitInfos.push({
1501
+ emit_infos.push({
1507
1502
  name: en,
1508
1503
  h: eventH,
1509
- subChain,
1510
- subReaction: subR && subChain ? subR : void 0
1504
+ sub_chain,
1505
+ sub_reaction: subR && sub_chain ? subR : void 0
1511
1506
  });
1512
1507
  emitsH += eventH;
1513
1508
  }
1514
- const rowH = Math.max(H, targetState ? STATE_H : 0, emitsH || H);
1515
- rows.push({ an, rowH, emitInfos, emitsH, targetState });
1516
- if (dispatchBlockH > 0) dispatchBlockH += GAP / 2;
1517
- dispatchBlockH += rowH;
1509
+ const rowH = Math.max(H, target_state ? STATE_H : 0, emitsH || H);
1510
+ rows.push({ an, rowH, emit_infos, emitsH, target_state });
1511
+ if (dispatch_block_h > 0) dispatch_block_h += GAP / 2;
1512
+ dispatch_block_h += rowH;
1518
1513
  }
1519
- return { groupH: Math.max(H, dispatchBlockH), dispatchBlockH, rows };
1514
+ return { groupH: Math.max(H, dispatch_block_h), dispatch_block_h, rows };
1520
1515
  }
1521
- function placeChain(measure, rDef, reactionY, rX, triggeredFromX, triggeredFromY, ns, es, sliceName, lookup, eventProjections, eventReactions, eventSchemas, sliceRightXRef) {
1522
- const dispatchBaseX = rX + W + GAP;
1516
+ function place_chain(measure, rDef, reactionY, rX, triggered_from_x, triggered_from_y, ns, es, slice_name, lookup, event_projections, event_reactions, event_schemas, slice_right_x_ref) {
1517
+ const dispatch_base_x = rX + W + GAP;
1523
1518
  const rp = { x: rX, y: reactionY };
1524
1519
  ns.push({
1525
- key: `r:${rDef.handlerName}:${sliceName}`,
1520
+ key: `r:${rDef.handlerName}:${slice_name}`,
1526
1521
  pos: rp,
1527
1522
  type: "reaction",
1528
1523
  label: rDef.handlerName
1529
1524
  });
1530
1525
  es.push({
1531
- from: { x: triggeredFromX, y: triggeredFromY },
1526
+ from: { x: triggered_from_x, y: triggered_from_y },
1532
1527
  to: { x: rp.x, y: rp.y + H / 2 },
1533
1528
  color: COLORS.reaction.border,
1534
1529
  dash: true
1535
1530
  });
1536
- const reactionCenterY = reactionY + H / 2;
1537
- let dispatchY = reactionCenterY - measure.dispatchBlockH / 2;
1531
+ const reaction_center_y = reactionY + H / 2;
1532
+ let dispatchY = reaction_center_y - measure.dispatch_block_h / 2;
1538
1533
  for (const row of measure.rows) {
1539
- const rowCenterY = dispatchY + row.rowH / 2;
1540
- let nextX = dispatchBaseX;
1541
- const dap = { x: nextX, y: rowCenterY - H / 2 };
1542
- const dispatchedAction = row.targetState?.actions.find(
1534
+ const row_center_y = dispatchY + row.rowH / 2;
1535
+ let nextX = dispatch_base_x;
1536
+ const dap = { x: nextX, y: row_center_y - H / 2 };
1537
+ const dispatched_action = row.target_state?.actions.find(
1543
1538
  (a) => a.name === row.an
1544
1539
  );
1545
1540
  ns.push({
@@ -1547,10 +1542,10 @@ function placeChain(measure, rDef, reactionY, rX, triggeredFromX, triggeredFromY
1547
1542
  pos: dap,
1548
1543
  type: "action",
1549
1544
  label: row.an,
1550
- sub: dispatchedAction && dispatchedAction.invariants.length > 0 ? "guarded" : void 0,
1551
- guards: dispatchedAction && dispatchedAction.invariants.length > 0 ? dispatchedAction.invariants : void 0,
1552
- file: row.targetState?.file,
1553
- emits: dispatchedAction?.emits
1545
+ sub: dispatched_action && dispatched_action.invariants.length > 0 ? "guarded" : void 0,
1546
+ guards: dispatched_action && dispatched_action.invariants.length > 0 ? dispatched_action.invariants : void 0,
1547
+ file: row.target_state?.file,
1548
+ emits: dispatched_action?.emits
1554
1549
  });
1555
1550
  es.push({
1556
1551
  from: { x: rp.x + W, y: rp.y + H / 2 },
@@ -1559,106 +1554,106 @@ function placeChain(measure, rDef, reactionY, rX, triggeredFromX, triggeredFromY
1559
1554
  dash: true
1560
1555
  });
1561
1556
  nextX += W + GAP;
1562
- if (row.targetState) {
1557
+ if (row.target_state) {
1563
1558
  ns.push({
1564
- key: `s:${row.targetState.name}:dispatched:${rDef.handlerName}:${row.an}`,
1565
- pos: { x: nextX, y: rowCenterY - STATE_H / 2 },
1559
+ key: `s:${row.target_state.name}:dispatched:${rDef.handlerName}:${row.an}`,
1560
+ pos: { x: nextX, y: row_center_y - STATE_H / 2 },
1566
1561
  type: "state",
1567
- label: row.targetState.name,
1568
- file: row.targetState.file
1562
+ label: row.target_state.name,
1563
+ file: row.target_state.file
1569
1564
  });
1570
1565
  nextX += STATE_W + GAP;
1571
1566
  }
1572
1567
  const evtX = nextX;
1573
- const nEvents = row.emitInfos.length;
1574
- const eventsOnlyH = nEvents * H + (nEvents - 1) * (GAP / 2);
1575
- let emitY = rowCenterY - eventsOnlyH / 2;
1576
- for (const emit of row.emitInfos) {
1568
+ const nEvents = row.emit_infos.length;
1569
+ const events_only_h = nEvents * H + (nEvents - 1) * (GAP / 2);
1570
+ let emitY = row_center_y - events_only_h / 2;
1571
+ for (const emit of row.emit_infos) {
1577
1572
  ns.push({
1578
1573
  key: `e:${emit.name}:dispatched:${rDef.handlerName}:${row.an}`,
1579
1574
  pos: { x: evtX, y: emitY },
1580
1575
  type: "event",
1581
1576
  label: emit.name,
1582
- file: row.targetState?.file,
1583
- projections: eventProjections.get(emit.name),
1584
- reactions: eventReactions.get(emit.name),
1585
- schema: eventSchemas.get(emit.name)
1577
+ file: row.target_state?.file,
1578
+ projections: event_projections.get(emit.name),
1579
+ reactions: event_reactions.get(emit.name),
1580
+ schema: event_schemas.get(emit.name)
1586
1581
  });
1587
- if (emit.subChain && emit.subReaction) {
1588
- const subRX = evtX + W + GAP * 3;
1589
- placeChain(
1590
- emit.subChain,
1591
- emit.subReaction,
1582
+ if (emit.sub_chain && emit.sub_reaction) {
1583
+ const sub_r_x = evtX + W + GAP * 3;
1584
+ place_chain(
1585
+ emit.sub_chain,
1586
+ emit.sub_reaction,
1592
1587
  emitY,
1593
1588
  // reaction aligns with emit
1594
- subRX,
1589
+ sub_r_x,
1595
1590
  evtX + W,
1596
1591
  emitY + H / 2,
1597
1592
  ns,
1598
1593
  es,
1599
- sliceName,
1594
+ slice_name,
1600
1595
  lookup,
1601
- eventProjections,
1602
- eventReactions,
1603
- eventSchemas,
1604
- sliceRightXRef
1596
+ event_projections,
1597
+ event_reactions,
1598
+ event_schemas,
1599
+ slice_right_x_ref
1605
1600
  );
1606
1601
  }
1607
1602
  emitY += H + GAP / 2;
1608
1603
  }
1609
- if (row.emitInfos.length > 0) nextX = evtX + W + GAP;
1610
- sliceRightXRef.value = Math.max(sliceRightXRef.value, nextX);
1604
+ if (row.emit_infos.length > 0) nextX = evtX + W + GAP;
1605
+ slice_right_x_ref.value = Math.max(slice_right_x_ref.value, nextX);
1611
1606
  dispatchY += row.rowH + GAP / 2;
1612
1607
  }
1613
1608
  }
1614
- function computeLayout(viewModel) {
1609
+ function compute_layout(view_model) {
1615
1610
  const ns = [];
1616
1611
  const es = [];
1617
1612
  const boxes = [];
1618
1613
  const sv = /* @__PURE__ */ new Map();
1619
- for (const s of viewModel.states) {
1614
+ for (const s of view_model.states) {
1620
1615
  sv.set(s.varName, s);
1621
1616
  sv.set(s.name, s);
1622
1617
  }
1623
- const eventProjections = /* @__PURE__ */ new Map();
1624
- const eventReactions = /* @__PURE__ */ new Map();
1625
- const eventSchemas = /* @__PURE__ */ new Map();
1626
- for (const s of viewModel.states) {
1618
+ const event_projections = /* @__PURE__ */ new Map();
1619
+ const event_reactions = /* @__PURE__ */ new Map();
1620
+ const event_schemas = /* @__PURE__ */ new Map();
1621
+ for (const s of view_model.states) {
1627
1622
  for (const e of s.events) {
1628
- if (e.schema && !eventSchemas.has(e.name)) {
1629
- eventSchemas.set(e.name, e.schema);
1623
+ if (e.schema && !event_schemas.has(e.name)) {
1624
+ event_schemas.set(e.name, e.schema);
1630
1625
  }
1631
1626
  }
1632
1627
  }
1633
- const projectionHandles = /* @__PURE__ */ new Map();
1634
- for (const proj of viewModel.projections) {
1635
- projectionHandles.set(proj.name, proj.handles);
1628
+ const projection_handles = /* @__PURE__ */ new Map();
1629
+ for (const proj of view_model.projections) {
1630
+ projection_handles.set(proj.name, proj.handles);
1636
1631
  }
1637
- for (const slice of viewModel.slices) {
1632
+ for (const slice of view_model.slices) {
1638
1633
  for (const r of slice.reactions) {
1639
- const list = eventReactions.get(r.event) ?? [];
1634
+ const list = event_reactions.get(r.event) ?? [];
1640
1635
  list.push(r.handlerName);
1641
- eventReactions.set(r.event, list);
1636
+ event_reactions.set(r.event, list);
1642
1637
  }
1643
1638
  }
1644
- for (const r of viewModel.reactions) {
1645
- const list = eventReactions.get(r.event) ?? [];
1639
+ for (const r of view_model.reactions) {
1640
+ const list = event_reactions.get(r.event) ?? [];
1646
1641
  list.push(r.handlerName);
1647
- eventReactions.set(r.event, list);
1642
+ event_reactions.set(r.event, list);
1648
1643
  }
1649
- for (const proj of viewModel.projections) {
1644
+ for (const proj of view_model.projections) {
1650
1645
  for (const en of proj.handles) {
1651
- const list = eventProjections.get(en) ?? [];
1646
+ const list = event_projections.get(en) ?? [];
1652
1647
  list.push(proj.name);
1653
- eventProjections.set(en, list);
1648
+ event_projections.set(en, list);
1654
1649
  }
1655
1650
  }
1656
1651
  let cx = PAD;
1657
1652
  let globalY = 0;
1658
- const sortedSlices = [...viewModel.slices].sort(
1653
+ const sorted_slices = [...view_model.slices].sort(
1659
1654
  (a, b) => a.name.localeCompare(b.name)
1660
1655
  );
1661
- for (const slice of sortedSlices) {
1656
+ for (const slice of sorted_slices) {
1662
1657
  if (slice.error && slice.states.length === 0) {
1663
1658
  const sx2 = PAD;
1664
1659
  const errorW = Math.max(300, slice.error.length * 5);
@@ -1678,181 +1673,181 @@ function computeLayout(viewModel) {
1678
1673
  cx = PAD;
1679
1674
  const sx = cx;
1680
1675
  cx += SLICE_PAD + GAP;
1681
- const eventFileMap = /* @__PURE__ */ new Map();
1682
- const actionFileMap = /* @__PURE__ */ new Map();
1683
- const rawParts = slice.stateVars.map((v) => sv.get(v)).filter(Boolean);
1684
- const mergedByName = /* @__PURE__ */ new Map();
1685
- for (const st of rawParts) {
1676
+ const event_file_map = /* @__PURE__ */ new Map();
1677
+ const action_file_map = /* @__PURE__ */ new Map();
1678
+ const raw_parts = slice.stateVars.map((v) => sv.get(v)).filter(Boolean);
1679
+ const merged_by_name = /* @__PURE__ */ new Map();
1680
+ for (const st of raw_parts) {
1686
1681
  for (const e of st.events) {
1687
- if (st.file) eventFileMap.set(e.name, st.file);
1682
+ if (st.file) event_file_map.set(e.name, st.file);
1688
1683
  }
1689
1684
  for (const a of st.actions) {
1690
- if (st.file) actionFileMap.set(a.name, st.file);
1685
+ if (st.file) action_file_map.set(a.name, st.file);
1691
1686
  }
1692
- const existing = mergedByName.get(st.name);
1687
+ const existing = merged_by_name.get(st.name);
1693
1688
  if (existing) {
1694
- const actionNames = new Set(existing.actions.map((a) => a.name));
1689
+ const action_names = new Set(existing.actions.map((a) => a.name));
1695
1690
  for (const a of st.actions) {
1696
- if (!actionNames.has(a.name)) existing.actions.push(a);
1691
+ if (!action_names.has(a.name)) existing.actions.push(a);
1697
1692
  }
1698
- const eventNames = new Set(existing.events.map((e) => e.name));
1693
+ const event_names = new Set(existing.events.map((e) => e.name));
1699
1694
  for (const e of st.events) {
1700
- if (!eventNames.has(e.name)) existing.events.push(e);
1695
+ if (!event_names.has(e.name)) existing.events.push(e);
1701
1696
  }
1702
1697
  } else {
1703
- mergedByName.set(st.name, {
1698
+ merged_by_name.set(st.name, {
1704
1699
  ...st,
1705
1700
  actions: [...st.actions],
1706
1701
  events: [...st.events]
1707
1702
  });
1708
1703
  }
1709
1704
  }
1710
- const parts = [...mergedByName.values()];
1705
+ const parts = [...merged_by_name.values()];
1711
1706
  let y = SLICE_INNER;
1712
- let sliceRightX = cx;
1713
- const sliceNodeStart = ns.length;
1714
- const sliceEdgeStart = es.length;
1715
- const sliceReactionsByEvent = /* @__PURE__ */ new Map();
1707
+ let slice_right_x = cx;
1708
+ const slice_node_start = ns.length;
1709
+ const slice_edge_start = es.length;
1710
+ const slice_reactions_by_event = /* @__PURE__ */ new Map();
1716
1711
  for (const r of slice.reactions) {
1717
- const list = sliceReactionsByEvent.get(r.event) ?? [];
1712
+ const list = slice_reactions_by_event.get(r.event) ?? [];
1718
1713
  list.push(r);
1719
- sliceReactionsByEvent.set(r.event, list);
1714
+ slice_reactions_by_event.set(r.event, list);
1720
1715
  }
1721
- const sliceReactionByEvent = /* @__PURE__ */ new Map();
1722
- for (const [event, reactions] of sliceReactionsByEvent) {
1723
- sliceReactionByEvent.set(event, reactions[0]);
1716
+ const slice_reaction_by_event = /* @__PURE__ */ new Map();
1717
+ for (const [event, reactions] of slice_reactions_by_event) {
1718
+ slice_reaction_by_event.set(event, reactions[0]);
1724
1719
  }
1725
- const visitedEvents = /* @__PURE__ */ new Set();
1726
- const visitedReactions = /* @__PURE__ */ new Set();
1727
- let partIdx = 0;
1720
+ const visited_events = /* @__PURE__ */ new Set();
1721
+ const visited_reactions = /* @__PURE__ */ new Set();
1722
+ let part_idx = 0;
1728
1723
  for (const st of parts) {
1729
- if (partIdx > 0) y += GAP * 2;
1730
- const stateColX = cx + W + GAP;
1731
- const eventColX = stateColX + STATE_W + GAP;
1732
- const eventRows = [];
1733
- const actionEmitted = /* @__PURE__ */ new Set();
1724
+ if (part_idx > 0) y += GAP * 2;
1725
+ const state_col_x = cx + W + GAP;
1726
+ const event_col_x = state_col_x + STATE_W + GAP;
1727
+ const event_rows = [];
1728
+ const action_emitted = /* @__PURE__ */ new Set();
1734
1729
  for (const action of st.actions) {
1735
1730
  for (const en of action.emits) {
1736
- actionEmitted.add(en);
1731
+ action_emitted.add(en);
1737
1732
  }
1738
1733
  }
1739
1734
  for (const ev of st.events) {
1740
- if (!actionEmitted.has(ev.name)) {
1741
- eventRows.push({ eventName: ev.name, actionName: "" });
1735
+ if (!action_emitted.has(ev.name)) {
1736
+ event_rows.push({ event_name: ev.name, action_name: "" });
1742
1737
  }
1743
1738
  }
1744
1739
  for (const action of st.actions) {
1745
1740
  for (const en of action.emits) {
1746
- eventRows.push({ eventName: en, actionName: action.name });
1741
+ event_rows.push({ event_name: en, action_name: action.name });
1747
1742
  }
1748
1743
  }
1749
- const measuredEvents = [];
1750
- let evtBlockH = 0;
1751
- for (const { eventName: en, actionName } of eventRows) {
1744
+ const measured_events = [];
1745
+ let evt_block_h = 0;
1746
+ for (const { event_name: en, action_name } of event_rows) {
1752
1747
  const chains = [];
1753
- if (!visitedEvents.has(en)) {
1754
- const rDefs = sliceReactionsByEvent.get(en) ?? [];
1748
+ if (!visited_events.has(en)) {
1749
+ const rDefs = slice_reactions_by_event.get(en) ?? [];
1755
1750
  for (const rDef of rDefs) {
1756
- if (visitedReactions.has(rDef.handlerName)) continue;
1757
- visitedReactions.add(rDef.handlerName);
1758
- const chain = measureChain(
1751
+ if (visited_reactions.has(rDef.handlerName)) continue;
1752
+ visited_reactions.add(rDef.handlerName);
1753
+ const chain = measure_chain(
1759
1754
  rDef,
1760
- sliceReactionByEvent,
1761
- visitedReactions,
1762
- viewModel.states
1755
+ slice_reaction_by_event,
1756
+ visited_reactions,
1757
+ view_model.states
1763
1758
  );
1764
1759
  chains.push({ chain, reaction: rDef });
1765
1760
  }
1766
- if (rDefs.length > 0) visitedEvents.add(en);
1761
+ if (rDefs.length > 0) visited_events.add(en);
1767
1762
  }
1768
- measuredEvents.push({
1769
- eventName: en,
1770
- actionName,
1763
+ measured_events.push({
1764
+ event_name: en,
1765
+ action_name,
1771
1766
  h: H,
1772
1767
  chains
1773
1768
  });
1774
- if (evtBlockH > 0) evtBlockH += GAP / 2;
1775
- evtBlockH += H;
1769
+ if (evt_block_h > 0) evt_block_h += GAP / 2;
1770
+ evt_block_h += H;
1776
1771
  }
1777
- if (evtBlockH === 0) evtBlockH = H;
1772
+ if (evt_block_h === 0) evt_block_h = H;
1778
1773
  const nActs = st.actions.length;
1779
- const actBlockH = nActs * H + (nActs - 1) * (GAP / 2);
1780
- const primaryBlockH = Math.max(evtBlockH, actBlockH, STATE_H);
1781
- const stCenterY = y + primaryBlockH / 2;
1774
+ const act_block_h = nActs * H + (nActs - 1) * (GAP / 2);
1775
+ const primary_block_h = Math.max(evt_block_h, act_block_h, STATE_H);
1776
+ const st_center_y = y + primary_block_h / 2;
1782
1777
  ns.push({
1783
1778
  key: `s:${st.name}:${slice.name}`,
1784
- pos: { x: stateColX, y: stCenterY - STATE_H / 2 },
1779
+ pos: { x: state_col_x, y: st_center_y - STATE_H / 2 },
1785
1780
  type: "state",
1786
1781
  label: st.name,
1787
1782
  file: st.file
1788
1783
  });
1789
- const sliceRightXRef = { value: sliceRightX };
1790
- let evtY = stCenterY - evtBlockH / 2;
1791
- let chainWatermark = -Infinity;
1792
- const eventYMap = /* @__PURE__ */ new Map();
1793
- for (let ei = 0; ei < measuredEvents.length; ei++) {
1794
- const { eventName: en, actionName, chains } = measuredEvents[ei];
1784
+ const slice_right_x_ref = { value: slice_right_x };
1785
+ let evtY = st_center_y - evt_block_h / 2;
1786
+ let chain_watermark = -Infinity;
1787
+ const event_y_map = /* @__PURE__ */ new Map();
1788
+ for (let ei = 0; ei < measured_events.length; ei++) {
1789
+ const { event_name: en, action_name, chains } = measured_events[ei];
1795
1790
  ns.push({
1796
- key: `e:${en}:${slice.name}:${actionName}`,
1797
- pos: { x: eventColX, y: evtY },
1791
+ key: `e:${en}:${slice.name}:${action_name}`,
1792
+ pos: { x: event_col_x, y: evtY },
1798
1793
  type: "event",
1799
1794
  label: en,
1800
- file: eventFileMap.get(en) ?? st.file,
1801
- projections: eventProjections.get(en),
1802
- reactions: eventReactions.get(en),
1803
- schema: eventSchemas.get(en)
1795
+ file: event_file_map.get(en) ?? st.file,
1796
+ projections: event_projections.get(en),
1797
+ reactions: event_reactions.get(en),
1798
+ schema: event_schemas.get(en)
1804
1799
  });
1805
- eventYMap.set(en, evtY);
1806
- for (const { chain, reaction: chainReaction } of chains) {
1807
- const rX = eventColX + W + GAP * 3;
1808
- const minReactionY = chainWatermark + chain.dispatchBlockH / 2 - H / 2;
1809
- const reactionY = Math.max(evtY, minReactionY);
1810
- const chainStartIdx = ns.length;
1811
- placeChain(
1800
+ event_y_map.set(en, evtY);
1801
+ for (const { chain, reaction: chain_reaction } of chains) {
1802
+ const rX = event_col_x + W + GAP * 3;
1803
+ const min_reaction_y = chain_watermark + chain.dispatch_block_h / 2 - H / 2;
1804
+ const reactionY = Math.max(evtY, min_reaction_y);
1805
+ const chain_start_idx = ns.length;
1806
+ place_chain(
1812
1807
  chain,
1813
- chainReaction,
1808
+ chain_reaction,
1814
1809
  reactionY,
1815
1810
  rX,
1816
- eventColX + W,
1811
+ event_col_x + W,
1817
1812
  evtY + H / 2,
1818
1813
  // arrow always from event center
1819
1814
  ns,
1820
1815
  es,
1821
1816
  slice.name,
1822
- sliceReactionByEvent,
1823
- eventProjections,
1824
- eventReactions,
1825
- eventSchemas,
1826
- sliceRightXRef
1817
+ slice_reaction_by_event,
1818
+ event_projections,
1819
+ event_reactions,
1820
+ event_schemas,
1821
+ slice_right_x_ref
1827
1822
  );
1828
- for (let ni = chainStartIdx; ni < ns.length; ni++) {
1823
+ for (let ni = chain_start_idx; ni < ns.length; ni++) {
1829
1824
  const n = ns[ni];
1830
1825
  const nh = n.type === "state" ? STATE_H : H;
1831
- chainWatermark = Math.max(chainWatermark, n.pos.y + nh + GAP / 2);
1826
+ chain_watermark = Math.max(chain_watermark, n.pos.y + nh + GAP / 2);
1832
1827
  }
1833
1828
  }
1834
1829
  evtY += H + GAP / 2;
1835
1830
  }
1836
- const seenProj = /* @__PURE__ */ new Set();
1837
- for (const me of measuredEvents) {
1838
- const projs = eventProjections.get(me.eventName);
1831
+ const seen_proj = /* @__PURE__ */ new Set();
1832
+ for (const me of measured_events) {
1833
+ const projs = event_projections.get(me.event_name);
1839
1834
  if (!projs) continue;
1840
1835
  for (const pn of projs) {
1841
- if (seenProj.has(pn)) continue;
1842
- seenProj.add(pn);
1836
+ if (seen_proj.has(pn)) continue;
1837
+ seen_proj.add(pn);
1843
1838
  ns.push({
1844
1839
  key: `p:${pn}:${slice.name}`,
1845
- pos: { x: eventColX, y: evtY },
1840
+ pos: { x: event_col_x, y: evtY },
1846
1841
  type: "projection",
1847
1842
  label: pn,
1848
- handles: projectionHandles.get(pn)
1843
+ handles: projection_handles.get(pn)
1849
1844
  });
1850
1845
  evtY += H + GAP / 2;
1851
1846
  }
1852
1847
  }
1853
- sliceRightX = sliceRightXRef.value;
1854
- let actY = stCenterY - actBlockH / 2;
1855
- const actionColors = [
1848
+ slice_right_x = slice_right_x_ref.value;
1849
+ let actY = st_center_y - act_block_h / 2;
1850
+ const action_colors = [
1856
1851
  "#60a5fa",
1857
1852
  "#f97316",
1858
1853
  "#a78bfa",
@@ -1860,9 +1855,9 @@ function computeLayout(viewModel) {
1860
1855
  "#fb7185",
1861
1856
  "#fbbf24"
1862
1857
  ];
1863
- let actionIdx = 0;
1858
+ let action_idx = 0;
1864
1859
  for (const action of st.actions) {
1865
- const color = actionColors[actionIdx % actionColors.length];
1860
+ const color = action_colors[action_idx % action_colors.length];
1866
1861
  ns.push({
1867
1862
  key: `a:${action.name}:${slice.name}`,
1868
1863
  pos: { x: cx, y: actY },
@@ -1870,32 +1865,32 @@ function computeLayout(viewModel) {
1870
1865
  label: action.name,
1871
1866
  sub: action.invariants.length > 0 ? "guarded" : void 0,
1872
1867
  guards: action.invariants.length > 0 ? action.invariants : void 0,
1873
- file: actionFileMap.get(action.name) ?? st.file,
1868
+ file: action_file_map.get(action.name) ?? st.file,
1874
1869
  emits: action.emits
1875
1870
  });
1876
1871
  for (const en of action.emits) {
1877
- const ey = eventYMap.get(en);
1872
+ const ey = event_y_map.get(en);
1878
1873
  es.push({
1879
1874
  from: { x: cx + W, y: actY + H / 2 },
1880
- to: { x: eventColX, y: ey + H / 2 },
1875
+ to: { x: event_col_x, y: ey + H / 2 },
1881
1876
  color,
1882
1877
  dash: false
1883
1878
  });
1884
1879
  }
1885
1880
  actY += H + GAP / 2;
1886
- actionIdx++;
1881
+ action_idx++;
1887
1882
  }
1888
- const contentBottomY = Math.max(
1889
- y + primaryBlockH,
1883
+ const content_bottom_y = Math.max(
1884
+ y + primary_block_h,
1890
1885
  evtY,
1891
- chainWatermark > -Infinity ? chainWatermark : 0
1886
+ chain_watermark > -Infinity ? chain_watermark : 0
1892
1887
  );
1893
- y = contentBottomY + GAP / 2;
1894
- partIdx++;
1888
+ y = content_bottom_y + GAP / 2;
1889
+ part_idx++;
1895
1890
  }
1896
1891
  for (const r of slice.reactions) {
1897
- if (visitedReactions.has(r.handlerName)) continue;
1898
- const rX = sliceRightX + GAP * 2;
1892
+ if (visited_reactions.has(r.handlerName)) continue;
1893
+ const rX = slice_right_x + GAP * 2;
1899
1894
  const rp = { x: rX, y };
1900
1895
  ns.push({
1901
1896
  key: `r:${r.handlerName}:${slice.name}`,
@@ -1903,7 +1898,7 @@ function computeLayout(viewModel) {
1903
1898
  type: "reaction",
1904
1899
  label: r.handlerName
1905
1900
  });
1906
- sliceRightX = Math.max(sliceRightX, rX + W + GAP);
1901
+ slice_right_x = Math.max(slice_right_x, rX + W + GAP);
1907
1902
  y += H + GAP / 2;
1908
1903
  }
1909
1904
  const bbox = {
@@ -1912,7 +1907,7 @@ function computeLayout(viewModel) {
1912
1907
  maxX: -Infinity,
1913
1908
  maxY: -Infinity
1914
1909
  };
1915
- for (let ni = sliceNodeStart; ni < ns.length; ni++) {
1910
+ for (let ni = slice_node_start; ni < ns.length; ni++) {
1916
1911
  const n = ns[ni];
1917
1912
  const nw = n.type === "state" ? STATE_W : W;
1918
1913
  const nh = n.type === "state" ? STATE_H : H;
@@ -1930,10 +1925,10 @@ function computeLayout(viewModel) {
1930
1925
  const contentH = bbox.maxY - bbox.minY;
1931
1926
  const boxH = contentH + SLICE_INNER * 2;
1932
1927
  const dy = globalY - bbox.minY + SLICE_INNER;
1933
- for (let ni = sliceNodeStart; ni < ns.length; ni++) {
1928
+ for (let ni = slice_node_start; ni < ns.length; ni++) {
1934
1929
  ns[ni].pos.y += dy;
1935
1930
  }
1936
- for (let ei = sliceEdgeStart; ei < es.length; ei++) {
1931
+ for (let ei = slice_edge_start; ei < es.length; ei++) {
1937
1932
  es[ei].from.y += dy;
1938
1933
  es[ei].to.y += dy;
1939
1934
  }
@@ -1948,57 +1943,57 @@ function computeLayout(viewModel) {
1948
1943
  globalY += boxH + SLICE_GAP;
1949
1944
  }
1950
1945
  cx = PAD;
1951
- const claimed = new Set(sortedSlices.flatMap((sl) => sl.stateVars));
1952
- const standaloneStates = [...viewModel.states].filter((s) => !claimed.has(s.varName)).sort((a, b) => a.name.localeCompare(b.name));
1953
- for (const st of standaloneStates) {
1954
- const stateColX = cx + W + GAP;
1955
- const eventColX = stateColX + STATE_W + GAP;
1956
- const actionEmittedEvents = new Set(st.actions.flatMap((a) => a.emits));
1957
- const orphanEvents = st.events.map((e) => e.name).filter((en) => !actionEmittedEvents.has(en));
1958
- const nEvents = actionEmittedEvents.size + orphanEvents.length;
1959
- const evtBlockH = Math.max(nEvents, 1) * H + (Math.max(nEvents, 1) - 1) * (GAP / 2);
1946
+ const claimed = new Set(sorted_slices.flatMap((sl) => sl.stateVars));
1947
+ const standalone_states = [...view_model.states].filter((s) => !claimed.has(s.varName)).sort((a, b) => a.name.localeCompare(b.name));
1948
+ for (const st of standalone_states) {
1949
+ const state_col_x = cx + W + GAP;
1950
+ const event_col_x = state_col_x + STATE_W + GAP;
1951
+ const action_emitted_events = new Set(st.actions.flatMap((a) => a.emits));
1952
+ const orphan_events = st.events.map((e) => e.name).filter((en) => !action_emitted_events.has(en));
1953
+ const nEvents = action_emitted_events.size + orphan_events.length;
1954
+ const evt_block_h = Math.max(nEvents, 1) * H + (Math.max(nEvents, 1) - 1) * (GAP / 2);
1960
1955
  const nActs = st.actions.length;
1961
- const actBlockH = nActs * H + (nActs - 1) * (GAP / 2);
1962
- const blockH = Math.max(evtBlockH, actBlockH, STATE_H);
1963
- const stCenterY = globalY + blockH / 2;
1956
+ const act_block_h = nActs * H + (nActs - 1) * (GAP / 2);
1957
+ const blockH = Math.max(evt_block_h, act_block_h, STATE_H);
1958
+ const st_center_y = globalY + blockH / 2;
1964
1959
  ns.push({
1965
1960
  key: `s:${st.name}:standalone`,
1966
- pos: { x: stateColX, y: stCenterY - STATE_H / 2 },
1961
+ pos: { x: state_col_x, y: st_center_y - STATE_H / 2 },
1967
1962
  type: "state",
1968
1963
  label: st.name
1969
1964
  });
1970
- let evtY = stCenterY - evtBlockH / 2;
1971
- const eventYMap = /* @__PURE__ */ new Map();
1965
+ let evtY = st_center_y - evt_block_h / 2;
1966
+ const event_y_map = /* @__PURE__ */ new Map();
1972
1967
  for (const action of st.actions) {
1973
1968
  for (const en of action.emits) {
1974
1969
  ns.push({
1975
1970
  key: `e:${en}:standalone`,
1976
- pos: { x: eventColX, y: evtY },
1971
+ pos: { x: event_col_x, y: evtY },
1977
1972
  type: "event",
1978
1973
  label: en,
1979
- projections: eventProjections.get(en),
1980
- reactions: eventReactions.get(en),
1981
- schema: eventSchemas.get(en)
1974
+ projections: event_projections.get(en),
1975
+ reactions: event_reactions.get(en),
1976
+ schema: event_schemas.get(en)
1982
1977
  });
1983
- eventYMap.set(en, evtY);
1978
+ event_y_map.set(en, evtY);
1984
1979
  evtY += H + GAP / 2;
1985
1980
  }
1986
1981
  }
1987
- for (const en of orphanEvents) {
1982
+ for (const en of orphan_events) {
1988
1983
  ns.push({
1989
1984
  key: `e:${en}:standalone`,
1990
- pos: { x: eventColX, y: evtY },
1985
+ pos: { x: event_col_x, y: evtY },
1991
1986
  type: "event",
1992
1987
  label: en,
1993
- projections: eventProjections.get(en),
1994
- reactions: eventReactions.get(en),
1995
- schema: eventSchemas.get(en)
1988
+ projections: event_projections.get(en),
1989
+ reactions: event_reactions.get(en),
1990
+ schema: event_schemas.get(en)
1996
1991
  });
1997
- eventYMap.set(en, evtY);
1992
+ event_y_map.set(en, evtY);
1998
1993
  evtY += H + GAP / 2;
1999
1994
  }
2000
- let actY = stCenterY - actBlockH / 2;
2001
- const standaloneColors = [
1995
+ let actY = st_center_y - act_block_h / 2;
1996
+ const standalone_colors = [
2002
1997
  "#60a5fa",
2003
1998
  "#f97316",
2004
1999
  "#a78bfa",
@@ -2008,7 +2003,7 @@ function computeLayout(viewModel) {
2008
2003
  ];
2009
2004
  let aIdx = 0;
2010
2005
  for (const action of st.actions) {
2011
- const aColor = standaloneColors[aIdx % standaloneColors.length];
2006
+ const aColor = standalone_colors[aIdx % standalone_colors.length];
2012
2007
  ns.push({
2013
2008
  key: `a:${action.name}:standalone`,
2014
2009
  pos: { x: cx, y: actY },
@@ -2019,10 +2014,10 @@ function computeLayout(viewModel) {
2019
2014
  emits: action.emits
2020
2015
  });
2021
2016
  for (const en of action.emits) {
2022
- const ey = eventYMap.get(en);
2017
+ const ey = event_y_map.get(en);
2023
2018
  es.push({
2024
2019
  from: { x: cx + W, y: actY + H / 2 },
2025
- to: { x: eventColX, y: ey + H / 2 },
2020
+ to: { x: event_col_x, y: ey + H / 2 },
2026
2021
  color: aColor,
2027
2022
  dash: false
2028
2023
  });
@@ -2032,15 +2027,15 @@ function computeLayout(viewModel) {
2032
2027
  }
2033
2028
  globalY += blockH + GAP * 2;
2034
2029
  }
2035
- if (viewModel.reactions.length > 0) {
2036
- const reactionYByEvent = /* @__PURE__ */ new Map();
2037
- for (const r of viewModel.reactions) {
2038
- const trigNode = ns.find(
2030
+ if (view_model.reactions.length > 0) {
2031
+ const reaction_y_by_event = /* @__PURE__ */ new Map();
2032
+ for (const r of view_model.reactions) {
2033
+ const trig_node = ns.find(
2039
2034
  (n) => n.type === "event" && n.label === r.event
2040
2035
  );
2041
- const baseY = trigNode ? trigNode.pos.y : globalY;
2042
- const rY = reactionYByEvent.get(r.event) ?? baseY;
2043
- const rX = trigNode ? trigNode.pos.x + W + GAP * 3 : cx + W * 3 + GAP * 4;
2036
+ const baseY = trig_node ? trig_node.pos.y : globalY;
2037
+ const rY = reaction_y_by_event.get(r.event) ?? baseY;
2038
+ const rX = trig_node ? trig_node.pos.x + W + GAP * 3 : cx + W * 3 + GAP * 4;
2044
2039
  const rp = { x: rX, y: rY };
2045
2040
  ns.push({
2046
2041
  key: `r:${r.handlerName}:standalone`,
@@ -2048,15 +2043,15 @@ function computeLayout(viewModel) {
2048
2043
  type: "reaction",
2049
2044
  label: r.handlerName
2050
2045
  });
2051
- if (trigNode) {
2046
+ if (trig_node) {
2052
2047
  es.push({
2053
- from: { x: trigNode.pos.x + W, y: trigNode.pos.y + H / 2 },
2048
+ from: { x: trig_node.pos.x + W, y: trig_node.pos.y + H / 2 },
2054
2049
  to: { x: rp.x, y: rp.y + H / 2 },
2055
2050
  color: COLORS.reaction.border,
2056
2051
  dash: true
2057
2052
  });
2058
2053
  }
2059
- reactionYByEvent.set(r.event, rY + H + GAP / 2);
2054
+ reaction_y_by_event.set(r.event, rY + H + GAP / 2);
2060
2055
  globalY = Math.max(globalY, rY + H + GAP);
2061
2056
  }
2062
2057
  }
@@ -2120,10 +2115,10 @@ function splitLabel(label, maxChars = 16) {
2120
2115
  function formatModelTree(model) {
2121
2116
  const lines = [];
2122
2117
  for (const entry of model.entries) {
2123
- const sortedSlices = [...entry.slices].sort(
2118
+ const sorted_slices = [...entry.slices].sort(
2124
2119
  (a, b) => a.name.localeCompare(b.name)
2125
2120
  );
2126
- for (const sl of sortedSlices) {
2121
+ for (const sl of sorted_slices) {
2127
2122
  lines.push(`Slice: ${sl.name}`);
2128
2123
  for (const stKey of sl.stateVars) {
2129
2124
  const st = entry.states.find((s) => s.varName === stKey);
@@ -2145,9 +2140,9 @@ function formatModelTree(model) {
2145
2140
  for (const p of entry.projections) {
2146
2141
  lines.push(`Projection: ${p.name} [${p.handles.join(", ")}]`);
2147
2142
  }
2148
- const sliceStateKeys = new Set(entry.slices.flatMap((sl) => sl.stateVars));
2143
+ const slice_state_keys = new Set(entry.slices.flatMap((sl) => sl.stateVars));
2149
2144
  for (const st of entry.states.filter(
2150
- (s) => !sliceStateKeys.has(s.varName)
2145
+ (s) => !slice_state_keys.has(s.varName)
2151
2146
  )) {
2152
2147
  lines.push(`State: ${st.name}`);
2153
2148
  for (const a of st.actions) {
@@ -2193,7 +2188,7 @@ function Diagram({
2193
2188
  const [pan, setPan] = (0, import_react2.useState)({ x: 0, y: 0 });
2194
2189
  const [zoom, setZoom] = (0, import_react2.useState)(1);
2195
2190
  const entry = model.entries[activeTab];
2196
- const viewModel = entry ? {
2191
+ const view_model = entry ? {
2197
2192
  ...model,
2198
2193
  entries: [entry],
2199
2194
  states: entry.states,
@@ -2272,7 +2267,7 @@ function Diagram({
2272
2267
  const { ns, es, boxes, minX, minY, width, height, layoutError } = (0, import_react2.useMemo)(() => {
2273
2268
  try {
2274
2269
  return {
2275
- ...computeLayout(viewModel),
2270
+ ...compute_layout(view_model),
2276
2271
  layoutError: void 0
2277
2272
  };
2278
2273
  } catch (e) {
@@ -2288,7 +2283,7 @@ function Diagram({
2288
2283
  layoutError: msg
2289
2284
  };
2290
2285
  }
2291
- }, [viewModel]);
2286
+ }, [view_model]);
2292
2287
  const fitTransform = (0, import_react2.useCallback)(() => {
2293
2288
  const el = svgContainerRef.current;
2294
2289
  const cw = el?.clientWidth || 800;
@@ -2316,7 +2311,7 @@ function Diagram({
2316
2311
  layoutError
2317
2312
  ] });
2318
2313
  }
2319
- if (viewModel.states.length === 0 && viewModel.projections.length === 0) {
2314
+ if (view_model.states.length === 0 && view_model.projections.length === 0) {
2320
2315
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "flex h-full items-center justify-center text-xs text-zinc-600", children: "Nothing to diagram here" });
2321
2316
  }
2322
2317
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "relative flex h-full flex-col bg-zinc-950", children: [
@@ -2383,7 +2378,7 @@ function Diagram({
2383
2378
  title: "@rotorsoft/act-diagram version",
2384
2379
  children: [
2385
2380
  "v",
2386
- "0.4.0"
2381
+ "1.0.1"
2387
2382
  ]
2388
2383
  }
2389
2384
  )
@@ -2413,7 +2408,7 @@ function Diagram({
2413
2408
  }
2414
2409
  )
2415
2410
  ] }),
2416
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("pre", { className: "flex-1 overflow-auto whitespace-pre px-3 py-2 font-mono text-[10px] leading-relaxed text-zinc-400 select-all", children: formatModelTree(viewModel) })
2411
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("pre", { className: "flex-1 overflow-auto whitespace-pre px-3 py-2 font-mono text-[10px] leading-relaxed text-zinc-400 select-all", children: formatModelTree(view_model) })
2417
2412
  ] }),
2418
2413
  showWarnings && warnings.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex max-h-[30%] flex-col border-b border-zinc-800 bg-zinc-950", children: [
2419
2414
  /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex items-center justify-between border-b border-zinc-800 bg-zinc-900 px-3 py-1", children: [
@@ -2937,7 +2932,7 @@ function useExtractModel(files) {
2937
2932
  return;
2938
2933
  }
2939
2934
  const timer = setTimeout(() => {
2940
- const { model, error } = extractModel(files);
2935
+ const { model, error } = extract_model(files);
2941
2936
  const warnings = validate(model);
2942
2937
  const hasErrors = !!error || model.slices.some((s) => !!s.error);
2943
2938
  if (!hasErrors) {
@@ -2998,7 +2993,7 @@ function ActDiagram({
2998
2993
  const handleClick = (0, import_react3.useCallback)(
2999
2994
  (name, type, file) => {
3000
2995
  if (!onNavigate) return;
3001
- const result = navigateToCode(files, name, type, file);
2996
+ const result = navigate_to_code(files, name, type, file);
3002
2997
  if (result) onNavigate(result.file, result.line, result.col, type);
3003
2998
  },
3004
2999
  [files, onNavigate]
@@ -3185,57 +3180,6 @@ function Tooltip({
3185
3180
  );
3186
3181
  }
3187
3182
 
3188
- // src/client/lib/strip-fences.ts
3189
- function parseMultiFileResponse(raw) {
3190
- const files = [];
3191
- const re = /```(?:typescript|ts):([^\n]+)\n([\s\S]*?)```/g;
3192
- let m;
3193
- while ((m = re.exec(raw)) !== null) {
3194
- const path = m[1].trim();
3195
- const content = m[2].trim();
3196
- if (path && content) {
3197
- files.push({ path, content });
3198
- }
3199
- }
3200
- if (files.length === 0) {
3201
- const code = stripFences(raw);
3202
- if (code.trim()) {
3203
- files.push({ path: "src/app.ts", content: code });
3204
- }
3205
- }
3206
- return files;
3207
- }
3208
- function stripFences(code) {
3209
- let result = code.replace(/```(?:typescript|ts)?\s*\n/g, "");
3210
- result = result.replace(/\n?```\s*$/g, "");
3211
- result = result.replace(
3212
- /^[\s\S]*?(?=\/\*\*|\/\/|import\b|export\b|const\b|let\b|var\b|type\b|interface\b|function\b)/,
3213
- ""
3214
- );
3215
- const lines = result.split("\n");
3216
- let lastCodeLine = lines.length - 1;
3217
- while (lastCodeLine > 0) {
3218
- const trimmed = lines[lastCodeLine].trim();
3219
- if (trimmed && /[;{})\]:]$|^\s*\/\/|^\s*\*\/|^\s*\*|^$/.test(trimmed))
3220
- break;
3221
- lastCodeLine--;
3222
- }
3223
- if (lastCodeLine < lines.length - 1) {
3224
- result = lines.slice(0, lastCodeLine + 1).join("\n");
3225
- }
3226
- return result.trim();
3227
- }
3228
- function deriveProjectName(prompt, code) {
3229
- if (code) {
3230
- const actMatch = code.match(/(?:const|let|var)\s+(\w+)\s*=\s*act\s*\(/);
3231
- if (actMatch) return actMatch[1];
3232
- const stateMatch = code.match(/state\(\s*\{\s*(\w+)/);
3233
- if (stateMatch) return stateMatch[1] + " App";
3234
- }
3235
- const words = prompt.replace(/[^\w\s]/g, "").split(/\s+/).filter((w) => w.length > 2).slice(0, 3);
3236
- return words.length > 0 ? words.map((w) => w[0].toUpperCase() + w.slice(1).toLowerCase()).join(" ") : "Generated App";
3237
- }
3238
-
3239
3183
  // src/client/types/domain-model.ts
3240
3184
  function emptyModel2() {
3241
3185
  return {
@@ -3254,15 +3198,7 @@ function emptyModel2() {
3254
3198
  Diagram,
3255
3199
  Logo,
3256
3200
  Tooltip,
3257
- buildModel,
3258
- computeLayout,
3259
- deriveProjectName,
3260
3201
  emptyModel,
3261
- extractModel,
3262
- navigateToCode,
3263
- parseMultiFileResponse,
3264
- stripFences,
3265
- topoSort,
3266
3202
  validate
3267
3203
  });
3268
3204
  //# sourceMappingURL=index.cjs.map