@rotorsoft/act-diagram 0.3.10 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +27 -1
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/@types/cli/colors.d.ts +19 -0
  4. package/dist/@types/cli/colors.d.ts.map +1 -0
  5. package/dist/@types/cli/contract-index.d.ts +57 -0
  6. package/dist/@types/cli/contract-index.d.ts.map +1 -0
  7. package/dist/@types/cli/format.d.ts +22 -0
  8. package/dist/@types/cli/format.d.ts.map +1 -0
  9. package/dist/@types/cli/index.d.ts +32 -0
  10. package/dist/@types/cli/index.d.ts.map +1 -0
  11. package/dist/@types/cli/json-schema.d.ts +13 -0
  12. package/dist/@types/cli/json-schema.d.ts.map +1 -0
  13. package/dist/@types/cli/load-project.d.ts +15 -0
  14. package/dist/@types/cli/load-project.d.ts.map +1 -0
  15. package/dist/@types/cli/markdown.d.ts +3 -0
  16. package/dist/@types/cli/markdown.d.ts.map +1 -0
  17. package/dist/@types/cli/open-editor.d.ts +23 -0
  18. package/dist/@types/cli/open-editor.d.ts.map +1 -0
  19. package/dist/@types/cli/repl.d.ts +3 -0
  20. package/dist/@types/cli/repl.d.ts.map +1 -0
  21. package/dist/@types/cli/vim-keys.d.ts +34 -0
  22. package/dist/@types/cli/vim-keys.d.ts.map +1 -0
  23. package/dist/@types/client/components/Diagram.d.ts.map +1 -1
  24. package/dist/@types/client/lib/build-model.d.ts.map +1 -1
  25. package/dist/@types/client/lib/layout.d.ts +6 -0
  26. package/dist/@types/client/lib/layout.d.ts.map +1 -1
  27. package/dist/@types/client/lib/schema-extract.d.ts +37 -0
  28. package/dist/@types/client/lib/schema-extract.d.ts.map +1 -0
  29. package/dist/@types/client/types/domain-model.d.ts +15 -0
  30. package/dist/@types/client/types/domain-model.d.ts.map +1 -1
  31. package/dist/cli/act.js +3324 -0
  32. package/dist/cli/act.js.map +1 -0
  33. package/dist/index.cjs +413 -39
  34. package/dist/index.cjs.map +1 -1
  35. package/dist/index.js +413 -39
  36. package/dist/index.js.map +1 -1
  37. package/dist/styles.css +2 -2
  38. package/package.json +13 -7
package/dist/index.cjs CHANGED
@@ -44,6 +44,280 @@ var import_react3 = require("react");
44
44
  // src/client/lib/evaluate.ts
45
45
  var import_sucrase = require("sucrase");
46
46
 
47
+ // 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) {
51
+ let i = from;
52
+ while (i < src.length) {
53
+ const c = src[i];
54
+ if (isWS(c)) {
55
+ i++;
56
+ continue;
57
+ }
58
+ if (c === "/" && src[i + 1] === "/") {
59
+ while (i < src.length && src[i] !== "\n") i++;
60
+ continue;
61
+ }
62
+ if (c === "/" && src[i + 1] === "*") {
63
+ i += 2;
64
+ while (i < src.length && !(src[i - 1] === "*" && src[i] === "/")) i++;
65
+ i++;
66
+ continue;
67
+ }
68
+ break;
69
+ }
70
+ return i;
71
+ }
72
+ function readValue(src, start) {
73
+ let i = start;
74
+ let depth = 0;
75
+ while (i < src.length) {
76
+ const c = src[i];
77
+ if (c === '"' || c === "'") {
78
+ const q = c;
79
+ i++;
80
+ while (i < src.length && src[i] !== q) {
81
+ if (src[i] === "\\") {
82
+ i += 2;
83
+ continue;
84
+ }
85
+ i++;
86
+ }
87
+ i++;
88
+ continue;
89
+ }
90
+ if (c === "`") {
91
+ i++;
92
+ while (i < src.length && src[i] !== "`") {
93
+ if (src[i] === "\\") {
94
+ i += 2;
95
+ continue;
96
+ }
97
+ if (src[i] === "$" && src[i + 1] === "{") {
98
+ let td = 1;
99
+ i += 2;
100
+ while (i < src.length && td > 0) {
101
+ if (src[i] === "{") td++;
102
+ else if (src[i] === "}") td--;
103
+ if (td > 0) i++;
104
+ }
105
+ i++;
106
+ continue;
107
+ }
108
+ i++;
109
+ }
110
+ i++;
111
+ continue;
112
+ }
113
+ if (c === "/" && src[i + 1] === "/") {
114
+ while (i < src.length && src[i] !== "\n") i++;
115
+ continue;
116
+ }
117
+ if (c === "/" && src[i + 1] === "*") {
118
+ i += 2;
119
+ while (i < src.length && !(src[i - 1] === "*" && src[i] === "/")) i++;
120
+ i++;
121
+ continue;
122
+ }
123
+ if (c === "(" || c === "{" || c === "[") {
124
+ depth++;
125
+ i++;
126
+ continue;
127
+ }
128
+ if (c === ")" || c === "]") {
129
+ depth--;
130
+ i++;
131
+ continue;
132
+ }
133
+ if (c === "}") {
134
+ if (depth === 0) return i;
135
+ depth--;
136
+ i++;
137
+ continue;
138
+ }
139
+ if (c === "," && depth === 0) return i;
140
+ i++;
141
+ }
142
+ return i;
143
+ }
144
+ function parseObjectLiteral(src, startBrace) {
145
+ const entries = [];
146
+ let i = startBrace + 1;
147
+ while (i < src.length) {
148
+ i = skipTrivia(src, i);
149
+ if (src[i] === "}") return { entries, endBrace: i };
150
+ let key = "";
151
+ let keyStart = i;
152
+ let keyEnd = i;
153
+ let keyWasIdentifier = false;
154
+ if (src[i] === '"' || src[i] === "'") {
155
+ const q = src[i];
156
+ keyStart = ++i;
157
+ while (i < src.length && src[i] !== q) {
158
+ if (src[i] === "\\") {
159
+ i += 2;
160
+ continue;
161
+ }
162
+ i++;
163
+ }
164
+ key = src.slice(keyStart, i);
165
+ keyEnd = i;
166
+ 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;
173
+ } else {
174
+ return null;
175
+ }
176
+ i = skipTrivia(src, i);
177
+ if (src[i] !== ":") {
178
+ if (keyWasIdentifier) {
179
+ entries.push({ key, valueStart: keyStart, valueEnd: keyEnd });
180
+ }
181
+ while (i < src.length && src[i] !== "," && src[i] !== "}") i++;
182
+ if (src[i] === ",") i++;
183
+ continue;
184
+ }
185
+ 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;
191
+ if (src[i] === ",") i++;
192
+ }
193
+ return null;
194
+ }
195
+ function readTopLevelExpression(src, start) {
196
+ let i = start;
197
+ let depth = 0;
198
+ while (i < src.length) {
199
+ const c = src[i];
200
+ if (c === '"' || c === "'") {
201
+ const q = c;
202
+ i++;
203
+ while (i < src.length && src[i] !== q) {
204
+ if (src[i] === "\\") {
205
+ i += 2;
206
+ continue;
207
+ }
208
+ i++;
209
+ }
210
+ i++;
211
+ continue;
212
+ }
213
+ if (c === "`") {
214
+ i++;
215
+ while (i < src.length && src[i] !== "`") {
216
+ if (src[i] === "\\") {
217
+ i += 2;
218
+ continue;
219
+ }
220
+ if (src[i] === "$" && src[i + 1] === "{") {
221
+ let td = 1;
222
+ i += 2;
223
+ while (i < src.length && td > 0) {
224
+ if (src[i] === "{") td++;
225
+ else if (src[i] === "}") td--;
226
+ if (td > 0) i++;
227
+ }
228
+ i++;
229
+ continue;
230
+ }
231
+ i++;
232
+ }
233
+ i++;
234
+ continue;
235
+ }
236
+ if (c === "/" && src[i + 1] === "/") {
237
+ while (i < src.length && src[i] !== "\n") i++;
238
+ continue;
239
+ }
240
+ if (c === "/" && src[i + 1] === "*") {
241
+ i += 2;
242
+ while (i < src.length && !(src[i - 1] === "*" && src[i] === "/")) i++;
243
+ i++;
244
+ continue;
245
+ }
246
+ if (c === "(" || c === "{" || c === "[") {
247
+ depth++;
248
+ i++;
249
+ continue;
250
+ }
251
+ if (c === ")" || c === "}" || c === "]") {
252
+ depth--;
253
+ i++;
254
+ continue;
255
+ }
256
+ if (c === ";" && depth === 0) return i;
257
+ i++;
258
+ }
259
+ return i;
260
+ }
261
+ function extractIdentifierAssignments(src) {
262
+ const out = /* @__PURE__ */ new Map();
263
+ const re = /(?:^|[^\w$])(?:export\s+)?(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*(?::[^=\n;]{1,256})?=\s*/gm;
264
+ let m;
265
+ while ((m = re.exec(src)) !== null) {
266
+ const ident = m[1];
267
+ if (out.has(ident)) {
268
+ continue;
269
+ }
270
+ const start = m.index + m[0].length;
271
+ const end = readTopLevelExpression(src, start);
272
+ const text = src.slice(start, end).trim();
273
+ if (text) out.set(ident, text);
274
+ re.lastIndex = end;
275
+ }
276
+ return out;
277
+ }
278
+ function findIdentifierObjectLiteral(src, ident) {
279
+ const re = new RegExp(
280
+ `(?:^|[^\\w$])(?:const|let|var)\\s+${ident}\\b\\s*(?::[^=\\n;]+)?=\\s*`,
281
+ "m"
282
+ );
283
+ const m = re.exec(src);
284
+ if (!m) return -1;
285
+ const after = m.index + m[0].length;
286
+ const skipped = skipTrivia(src, after);
287
+ return src[skipped] === "{" ? skipped : -1;
288
+ }
289
+ var BARE_IDENT_RE = /^[A-Za-z_$][\w$]*$/;
290
+ function extractSchemasFromSource(src, eventNames, external) {
291
+ 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;
296
+ let m;
297
+ while ((m = emitsRe.exec(src)) !== null) {
298
+ let i = skipTrivia(src, emitsRe.lastIndex);
299
+ if (isIdent(src[i])) {
300
+ const start = i;
301
+ while (isIdent(src[i])) i++;
302
+ const ident = src.slice(start, i);
303
+ const objStart = findIdentifierObjectLiteral(src, ident);
304
+ if (objStart < 0) continue;
305
+ i = objStart;
306
+ }
307
+ if (src[i] !== "{") continue;
308
+ const parsed = parseObjectLiteral(src, i);
309
+ if (!parsed) continue;
310
+ for (const e of parsed.entries) {
311
+ if (!eventNames.has(e.key)) continue;
312
+ const raw = src.slice(e.valueStart, e.valueEnd).trim();
313
+ const text = deref(raw);
314
+ if (text) out.set(e.key, text);
315
+ }
316
+ emitsRe.lastIndex = Math.max(emitsRe.lastIndex, parsed.endBrace + 1);
317
+ }
318
+ return out;
319
+ }
320
+
47
321
  // src/client/lib/build-model.ts
48
322
  var _stateIdx = 0;
49
323
  function buildState(model, st) {
@@ -64,7 +338,10 @@ function buildState(model, st) {
64
338
  for (const eventName of Object.keys(events)) {
65
339
  eventNodes.push({
66
340
  name: eventName,
67
- hasCustomPatch: st.patches?.has(eventName) ?? false
341
+ hasCustomPatch: st.patches?.has(eventName) ?? false,
342
+ // Stash the runtime Zod schema so the JSON Schema exporter can
343
+ // call `z.toJSONSchema(zod)` later without re-running the parser.
344
+ zod: events[eventName]
68
345
  });
69
346
  }
70
347
  const actionNodes = [];
@@ -185,13 +462,17 @@ function buildModel(result, files, expectedSlices) {
185
462
  for (const p of s.projections ?? []) {
186
463
  if (p && p._tag === "Projection") projNames.push(p.target);
187
464
  }
465
+ const sliceFile = s._sourceFile;
188
466
  model.slices.push({
189
467
  name: sliceName,
190
468
  states: sliceStateKeys,
191
469
  stateVars: sliceStateKeys,
192
470
  projections: projNames,
193
- reactions: s.reactions ?? [],
194
- file: s._sourceFile,
471
+ reactions: (s.reactions ?? []).map((r) => ({
472
+ ...r,
473
+ file: r.file ?? sliceFile
474
+ })),
475
+ file: sliceFile,
195
476
  error: errors.length > 0 ? errors.join("; ") : void 0
196
477
  });
197
478
  } catch (e) {
@@ -220,11 +501,30 @@ function buildModel(result, files, expectedSlices) {
220
501
  });
221
502
  }
222
503
  }
504
+ const sourceByPath = /* @__PURE__ */ new Map();
505
+ const externalIdents = /* @__PURE__ */ new Map();
506
+ 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);
510
+ }
511
+ }
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));
516
+ if (names.size === 0) continue;
517
+ const schemas = extractSchemasFromSource(src, names, externalIdents);
518
+ for (const ev of stNode.events) {
519
+ ev.schema = schemas.get(ev.name);
520
+ }
521
+ }
223
522
  for (const p of rawProjections) {
224
523
  model.projections.push({
225
524
  name: p.target,
226
525
  varName: p.target,
227
- handles: p.handles
526
+ handles: p.handles,
527
+ file: p._sourceFile
228
528
  });
229
529
  }
230
530
  const statesInSlices = new Set(model.slices.flatMap((s) => s.states));
@@ -243,8 +543,9 @@ function buildModel(result, files, expectedSlices) {
243
543
  projections: model.projections.map((p) => p.name),
244
544
  states: model.states.map((s) => s.name)
245
545
  };
546
+ const actFile = a._sourceFile;
246
547
  for (const r of a.reactions ?? []) {
247
- model.reactions.push(r);
548
+ model.reactions.push({ ...r, file: r.file ?? actFile });
248
549
  }
249
550
  const entryPath = a._sourceFile ?? "app.ts";
250
551
  const actSliceNames = new Set(
@@ -1217,7 +1518,7 @@ function measureChain(rDef, lookup, visited, allStates) {
1217
1518
  }
1218
1519
  return { groupH: Math.max(H, dispatchBlockH), dispatchBlockH, rows };
1219
1520
  }
1220
- function placeChain(measure, rDef, reactionY, rX, triggeredFromX, triggeredFromY, ns, es, sliceName, lookup, eventProjections, eventReactions, sliceRightXRef) {
1521
+ function placeChain(measure, rDef, reactionY, rX, triggeredFromX, triggeredFromY, ns, es, sliceName, lookup, eventProjections, eventReactions, eventSchemas, sliceRightXRef) {
1221
1522
  const dispatchBaseX = rX + W + GAP;
1222
1523
  const rp = { x: rX, y: reactionY };
1223
1524
  ns.push({
@@ -1248,7 +1549,8 @@ function placeChain(measure, rDef, reactionY, rX, triggeredFromX, triggeredFromY
1248
1549
  label: row.an,
1249
1550
  sub: dispatchedAction && dispatchedAction.invariants.length > 0 ? "guarded" : void 0,
1250
1551
  guards: dispatchedAction && dispatchedAction.invariants.length > 0 ? dispatchedAction.invariants : void 0,
1251
- file: row.targetState?.file
1552
+ file: row.targetState?.file,
1553
+ emits: dispatchedAction?.emits
1252
1554
  });
1253
1555
  es.push({
1254
1556
  from: { x: rp.x + W, y: rp.y + H / 2 },
@@ -1279,7 +1581,8 @@ function placeChain(measure, rDef, reactionY, rX, triggeredFromX, triggeredFromY
1279
1581
  label: emit.name,
1280
1582
  file: row.targetState?.file,
1281
1583
  projections: eventProjections.get(emit.name),
1282
- reactions: eventReactions.get(emit.name)
1584
+ reactions: eventReactions.get(emit.name),
1585
+ schema: eventSchemas.get(emit.name)
1283
1586
  });
1284
1587
  if (emit.subChain && emit.subReaction) {
1285
1588
  const subRX = evtX + W + GAP * 3;
@@ -1297,6 +1600,7 @@ function placeChain(measure, rDef, reactionY, rX, triggeredFromX, triggeredFromY
1297
1600
  lookup,
1298
1601
  eventProjections,
1299
1602
  eventReactions,
1603
+ eventSchemas,
1300
1604
  sliceRightXRef
1301
1605
  );
1302
1606
  }
@@ -1318,6 +1622,18 @@ function computeLayout(viewModel) {
1318
1622
  }
1319
1623
  const eventProjections = /* @__PURE__ */ new Map();
1320
1624
  const eventReactions = /* @__PURE__ */ new Map();
1625
+ const eventSchemas = /* @__PURE__ */ new Map();
1626
+ for (const s of viewModel.states) {
1627
+ for (const e of s.events) {
1628
+ if (e.schema && !eventSchemas.has(e.name)) {
1629
+ eventSchemas.set(e.name, e.schema);
1630
+ }
1631
+ }
1632
+ }
1633
+ const projectionHandles = /* @__PURE__ */ new Map();
1634
+ for (const proj of viewModel.projections) {
1635
+ projectionHandles.set(proj.name, proj.handles);
1636
+ }
1321
1637
  for (const slice of viewModel.slices) {
1322
1638
  for (const r of slice.reactions) {
1323
1639
  const list = eventReactions.get(r.event) ?? [];
@@ -1483,7 +1799,8 @@ function computeLayout(viewModel) {
1483
1799
  label: en,
1484
1800
  file: eventFileMap.get(en) ?? st.file,
1485
1801
  projections: eventProjections.get(en),
1486
- reactions: eventReactions.get(en)
1802
+ reactions: eventReactions.get(en),
1803
+ schema: eventSchemas.get(en)
1487
1804
  });
1488
1805
  eventYMap.set(en, evtY);
1489
1806
  for (const { chain, reaction: chainReaction } of chains) {
@@ -1505,6 +1822,7 @@ function computeLayout(viewModel) {
1505
1822
  sliceReactionByEvent,
1506
1823
  eventProjections,
1507
1824
  eventReactions,
1825
+ eventSchemas,
1508
1826
  sliceRightXRef
1509
1827
  );
1510
1828
  for (let ni = chainStartIdx; ni < ns.length; ni++) {
@@ -1526,7 +1844,8 @@ function computeLayout(viewModel) {
1526
1844
  key: `p:${pn}:${slice.name}`,
1527
1845
  pos: { x: eventColX, y: evtY },
1528
1846
  type: "projection",
1529
- label: pn
1847
+ label: pn,
1848
+ handles: projectionHandles.get(pn)
1530
1849
  });
1531
1850
  evtY += H + GAP / 2;
1532
1851
  }
@@ -1551,7 +1870,8 @@ function computeLayout(viewModel) {
1551
1870
  label: action.name,
1552
1871
  sub: action.invariants.length > 0 ? "guarded" : void 0,
1553
1872
  guards: action.invariants.length > 0 ? action.invariants : void 0,
1554
- file: actionFileMap.get(action.name) ?? st.file
1873
+ file: actionFileMap.get(action.name) ?? st.file,
1874
+ emits: action.emits
1555
1875
  });
1556
1876
  for (const en of action.emits) {
1557
1877
  const ey = eventYMap.get(en);
@@ -1657,7 +1977,8 @@ function computeLayout(viewModel) {
1657
1977
  type: "event",
1658
1978
  label: en,
1659
1979
  projections: eventProjections.get(en),
1660
- reactions: eventReactions.get(en)
1980
+ reactions: eventReactions.get(en),
1981
+ schema: eventSchemas.get(en)
1661
1982
  });
1662
1983
  eventYMap.set(en, evtY);
1663
1984
  evtY += H + GAP / 2;
@@ -1670,7 +1991,8 @@ function computeLayout(viewModel) {
1670
1991
  type: "event",
1671
1992
  label: en,
1672
1993
  projections: eventProjections.get(en),
1673
- reactions: eventReactions.get(en)
1994
+ reactions: eventReactions.get(en),
1995
+ schema: eventSchemas.get(en)
1674
1996
  });
1675
1997
  eventYMap.set(en, evtY);
1676
1998
  evtY += H + GAP / 2;
@@ -1693,7 +2015,8 @@ function computeLayout(viewModel) {
1693
2015
  type: "action",
1694
2016
  label: action.name,
1695
2017
  sub: action.invariants.length > 0 ? "guarded" : void 0,
1696
- guards: action.invariants.length > 0 ? action.invariants : void 0
2018
+ guards: action.invariants.length > 0 ? action.invariants : void 0,
2019
+ emits: action.emits
1697
2020
  });
1698
2021
  for (const en of action.emits) {
1699
2022
  const ey = eventYMap.get(en);
@@ -1854,9 +2177,15 @@ function Diagram({
1854
2177
  onFixWithAi,
1855
2178
  toolbarExtra
1856
2179
  }) {
1857
- const [tip, setTip] = (0, import_react2.useState)(
1858
- null
1859
- );
2180
+ const [tip, setTip] = (0, import_react2.useState)(null);
2181
+ const KIND_TEXT = {
2182
+ event: "text-orange-300",
2183
+ action: "text-blue-300",
2184
+ state: "text-yellow-300",
2185
+ projection: "text-emerald-300",
2186
+ reaction: "text-fuchsia-300",
2187
+ error: "text-red-300"
2188
+ };
1860
2189
  const [activeTab, setActiveTab] = (0, import_react2.useState)(0);
1861
2190
  const [showTree, setShowTree] = (0, import_react2.useState)(false);
1862
2191
  const [showWarnings, setShowWarnings] = (0, import_react2.useState)(false);
@@ -2046,7 +2375,18 @@ function Diagram({
2046
2375
  ]
2047
2376
  }
2048
2377
  ),
2049
- toolbarExtra
2378
+ toolbarExtra,
2379
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2380
+ "span",
2381
+ {
2382
+ className: "select-none font-mono text-[9px] text-zinc-600",
2383
+ title: "@rotorsoft/act-diagram version",
2384
+ children: [
2385
+ "v",
2386
+ "0.3.10"
2387
+ ]
2388
+ }
2389
+ )
2050
2390
  ] })
2051
2391
  ] }),
2052
2392
  model.entries.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "flex gap-px border-b border-zinc-800 bg-zinc-900", children: model.entries.map((e, i) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
@@ -2290,17 +2630,28 @@ ${prompt}`);
2290
2630
  className: "cursor-pointer",
2291
2631
  onClick: () => onClickElement?.(n.label, n.type, n.file),
2292
2632
  onMouseEnter: (ev) => {
2293
- const parts = [n.label];
2633
+ const sections = [];
2634
+ if (n.emits?.length)
2635
+ sections.push({ label: "Emits", items: n.emits });
2636
+ if (n.handles?.length)
2637
+ sections.push({ label: "Handles", items: n.handles });
2294
2638
  if (n.guards?.length)
2295
- parts.push(`Guards: ${n.guards.join(", ")}`);
2639
+ sections.push({ label: "Guards", items: n.guards });
2296
2640
  if (n.reactions?.length)
2297
- parts.push(`Reactions: ${n.reactions.join(", ")}`);
2641
+ sections.push({ label: "Reactions", items: n.reactions });
2298
2642
  if (n.projections?.length)
2299
- parts.push(`Projections: ${n.projections.join(", ")}`);
2643
+ sections.push({
2644
+ label: "Projections",
2645
+ items: n.projections
2646
+ });
2300
2647
  setTip({
2301
2648
  x: ev.clientX,
2302
2649
  y: ev.clientY,
2303
- t: parts.join("\n")
2650
+ kind: n.type,
2651
+ title: n.label,
2652
+ schema: n.schema,
2653
+ sections,
2654
+ file: n.file
2304
2655
  });
2305
2656
  },
2306
2657
  onMouseLeave: () => setTip(null),
@@ -2520,25 +2871,48 @@ ${prompt}`);
2520
2871
  ] }) })
2521
2872
  }
2522
2873
  ),
2523
- tip && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2874
+ tip && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2524
2875
  "div",
2525
2876
  {
2526
- className: "pointer-events-none fixed z-50 max-w-xs rounded-lg border border-zinc-700 bg-zinc-900 px-3 py-2 shadow-2xl",
2877
+ className: "pointer-events-none fixed z-50 max-w-sm rounded-lg border border-zinc-700 bg-zinc-900 px-3 py-2 shadow-2xl",
2527
2878
  style: { left: tip.x + 14, top: tip.y - 12 },
2528
- children: tip.t.split("\n").map((line, i) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2529
- "div",
2530
- {
2531
- className: i === 0 ? "text-[11px] font-medium text-zinc-200" : "mt-0.5 text-[9px] text-zinc-400",
2532
- children: i > 0 && line.includes(":") ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
2533
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "text-zinc-500", children: [
2534
- line.split(":")[0],
2535
- ":"
2536
- ] }),
2537
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "text-zinc-300", children: line.slice(line.indexOf(":") + 1) })
2538
- ] }) : line
2539
- },
2540
- i
2541
- ))
2879
+ children: [
2880
+ tip.t && tip.t.split("\n").map((line, i) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2881
+ "div",
2882
+ {
2883
+ className: i === 0 ? "text-[11px] font-medium text-zinc-200" : "mt-0.5 text-[9px] text-zinc-400",
2884
+ children: i > 0 && line.includes(":") ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
2885
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "text-zinc-500", children: [
2886
+ line.split(":")[0],
2887
+ ":"
2888
+ ] }),
2889
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "text-zinc-300", children: line.slice(line.indexOf(":") + 1) })
2890
+ ] }) : line
2891
+ },
2892
+ i
2893
+ )),
2894
+ tip.title && tip.kind && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
2895
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex items-baseline gap-1.5", children: [
2896
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2897
+ "span",
2898
+ {
2899
+ className: `text-[9px] font-medium uppercase tracking-wide ${KIND_TEXT[tip.kind]}`,
2900
+ children: tip.kind
2901
+ }
2902
+ ),
2903
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "text-[12px] font-semibold text-zinc-100", children: tip.title })
2904
+ ] }),
2905
+ tip.schema && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "mt-1.5", children: [
2906
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "text-[9px] uppercase tracking-wide text-zinc-500", children: "Schema" }),
2907
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("pre", { className: "mt-0.5 max-h-48 overflow-auto rounded border border-zinc-800 bg-zinc-950 px-2 py-1 font-mono text-[10px] leading-snug text-zinc-300 whitespace-pre", children: tip.schema })
2908
+ ] }),
2909
+ tip.sections && tip.sections.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("table", { className: "mt-1.5 w-full text-[10px] leading-snug", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("tbody", { children: tip.sections.map((s) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("tr", { children: [
2910
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { className: "w-[68px] shrink-0 pr-2 align-top text-zinc-500", children: s.label }),
2911
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { className: "align-top text-zinc-300", children: s.items.join(", ") })
2912
+ ] }, s.label)) }) }),
2913
+ tip.file && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "mt-1.5 border-t border-zinc-800 pt-1 text-[9px] text-zinc-500", children: tip.file })
2914
+ ] })
2915
+ ]
2542
2916
  }
2543
2917
  )
2544
2918
  ] });