@walkeros/explorer 2.1.1 → 2.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -5,14 +5,14 @@ import {
5
5
  loadPackageTypes,
6
6
  loadTypeLibraryFromURL,
7
7
  registerWalkerOSTypes
8
- } from "./chunk-4AJX6MFW.mjs";
8
+ } from "./chunk-52ELVFJE.mjs";
9
9
 
10
10
  // src/components/demos/MappingDemo.tsx
11
11
  import { useState as useState6, useCallback as useCallback5, useEffect as useEffect5 } from "react";
12
12
 
13
13
  // src/components/molecules/code-box.tsx
14
14
  import { useState as useState4, useCallback as useCallback3, useRef as useRef4, useEffect as useEffect3 } from "react";
15
- import * as monacoNs from "monaco-editor";
15
+ import { useMonaco } from "@monaco-editor/react";
16
16
 
17
17
  // src/components/atoms/box.tsx
18
18
  import { useState } from "react";
@@ -1114,9 +1114,14 @@ function registerFormatters(monacoInstance) {
1114
1114
  }
1115
1115
 
1116
1116
  // src/utils/monaco-json-schema.ts
1117
- import { json } from "monaco-editor";
1118
1117
  var schemaRegistry = /* @__PURE__ */ new Map();
1119
1118
  var idCounter = 0;
1119
+ var _json;
1120
+ function initMonacoJson(monaco) {
1121
+ if (_json) return;
1122
+ _json = monaco.json;
1123
+ if (schemaRegistry.size > 0) applySchemas();
1124
+ }
1120
1125
  function generateModelPath() {
1121
1126
  return `inmemory://walkeros/json-${++idCounter}.json`;
1122
1127
  }
@@ -1133,7 +1138,8 @@ function unregisterJsonSchema(modelPath) {
1133
1138
  applySchemas();
1134
1139
  }
1135
1140
  function applySchemas() {
1136
- json.jsonDefaults.setDiagnosticsOptions({
1141
+ if (!_json) return;
1142
+ _json.jsonDefaults.setDiagnosticsOptions({
1137
1143
  validate: true,
1138
1144
  schemaValidation: "error",
1139
1145
  schemaRequest: "ignore",
@@ -1182,19 +1188,19 @@ function useMonacoHeight({
1182
1188
  }
1183
1189
  }, [enabled, minHeight, maxHeight, onHeightChange]);
1184
1190
  const setEditor = useCallback(
1185
- (editor2) => {
1191
+ (editor) => {
1186
1192
  if (updateTimeoutRef.current) {
1187
1193
  clearTimeout(updateTimeoutRef.current);
1188
1194
  updateTimeoutRef.current = null;
1189
1195
  }
1190
- editorRef.current = editor2;
1191
- if (!enabled || !editor2) {
1196
+ editorRef.current = editor;
1197
+ if (!enabled || !editor) {
1192
1198
  setHeight(defaultHeight);
1193
1199
  previousHeightRef.current = defaultHeight;
1194
1200
  return;
1195
1201
  }
1196
1202
  setTimeout(() => updateHeight(), 50);
1197
- const disposable = editor2.onDidContentSizeChange(() => {
1203
+ const disposable = editor.onDidContentSizeChange(() => {
1198
1204
  if (updateTimeoutRef.current) {
1199
1205
  clearTimeout(updateTimeoutRef.current);
1200
1206
  }
@@ -1203,7 +1209,7 @@ function useMonacoHeight({
1203
1209
  updateTimeoutRef.current = null;
1204
1210
  }, 150);
1205
1211
  });
1206
- editor2.__heightDisposable = disposable;
1212
+ editor.__heightDisposable = disposable;
1207
1213
  },
1208
1214
  [enabled, defaultHeight, updateHeight]
1209
1215
  );
@@ -1311,12 +1317,12 @@ function Code({
1311
1317
  };
1312
1318
  }, [isMounted, getDataTheme]);
1313
1319
  useEffect2(() => {
1314
- const editor2 = editorRef.current;
1320
+ const editor = editorRef.current;
1315
1321
  const container = containerRef.current;
1316
- if (!editor2 || !container) return;
1322
+ if (!editor || !container) return;
1317
1323
  const resizeObserver = new ResizeObserver(() => {
1318
1324
  requestAnimationFrame(() => {
1319
- editor2.layout();
1325
+ editor.layout();
1320
1326
  });
1321
1327
  });
1322
1328
  resizeObserver.observe(container);
@@ -1360,11 +1366,12 @@ function Code({
1360
1366
  };
1361
1367
  const handleBeforeMount = async (monaco) => {
1362
1368
  monacoRef.current = monaco;
1369
+ initMonacoJson(monaco);
1363
1370
  registerAllThemes(monaco);
1364
1371
  registerFormatters(monaco);
1365
1372
  if (packages && packages.length > 0) {
1366
1373
  registerWalkerOSTypes(monaco);
1367
- const { loadPackageTypes: loadPackageTypes2 } = await import("./monaco-types-KN2DINPW.mjs");
1374
+ const { loadPackageTypes: loadPackageTypes2 } = await import("./monaco-types-ZGWM2633.mjs");
1368
1375
  for (const pkg of packages) {
1369
1376
  if (pkg !== "@walkeros/core") {
1370
1377
  await loadPackageTypes2(monaco, { package: pkg }).catch(() => {
@@ -1423,10 +1430,6 @@ function Code({
1423
1430
  endColumn: issue.endColumn ?? issue.column + 1
1424
1431
  }))
1425
1432
  );
1426
- onMarkerCountsRef.current?.({
1427
- errors: result.errors.length,
1428
- warnings: result.warnings.length
1429
- });
1430
1433
  };
1431
1434
  runValidation();
1432
1435
  const validateDisposable = monacoEditor.onDidChangeModelContent(() => {
@@ -1438,6 +1441,55 @@ function Code({
1438
1441
  validateDisposable.dispose();
1439
1442
  });
1440
1443
  }
1444
+ if (onMarkerCountsRef.current && monacoRef.current) {
1445
+ const monacoInstance = monacoRef.current;
1446
+ const model = monacoEditor.getModel();
1447
+ const hasCustomValidate = !!validateRef.current;
1448
+ if (model) {
1449
+ const reportMarkers = () => {
1450
+ if (hasCustomValidate) {
1451
+ monacoInstance.editor.setModelMarkers(model, "json", []);
1452
+ }
1453
+ const raw = monacoInstance.editor.getModelMarkers({
1454
+ resource: model.uri
1455
+ });
1456
+ let errors = 0;
1457
+ let warnings = 0;
1458
+ const details = [];
1459
+ for (const m of raw) {
1460
+ if (m.severity === 8) {
1461
+ errors++;
1462
+ details.push({
1463
+ message: m.message,
1464
+ severity: "error",
1465
+ line: m.startLineNumber,
1466
+ column: m.startColumn
1467
+ });
1468
+ } else if (m.severity === 4) {
1469
+ warnings++;
1470
+ details.push({
1471
+ message: m.message,
1472
+ severity: "warning",
1473
+ line: m.startLineNumber,
1474
+ column: m.startColumn
1475
+ });
1476
+ }
1477
+ }
1478
+ onMarkerCountsRef.current?.({ errors, warnings, markers: details });
1479
+ };
1480
+ const markerDisposable = monacoInstance.editor.onDidChangeMarkers(
1481
+ (uris) => {
1482
+ if (uris.some((uri) => uri.toString() === model.uri.toString())) {
1483
+ reportMarkers();
1484
+ }
1485
+ }
1486
+ );
1487
+ requestAnimationFrame(reportMarkers);
1488
+ decorationsCleanupRef.current.push(() => {
1489
+ markerDisposable.dispose();
1490
+ });
1491
+ }
1492
+ }
1441
1493
  requestAnimationFrame(() => {
1442
1494
  monacoEditor.layout();
1443
1495
  });
@@ -1565,6 +1617,7 @@ function CodeBox({
1565
1617
  ...codeProps
1566
1618
  }) {
1567
1619
  const { onMount: userOnMount, ...restCodeProps } = codeProps;
1620
+ const monaco = useMonaco();
1568
1621
  const [copied, setCopied] = useState4(false);
1569
1622
  const [showSettingsPanel, setShowSettingsPanel] = useState4(false);
1570
1623
  const [settings, setSettings] = useState4({
@@ -1575,18 +1628,23 @@ function CodeBox({
1575
1628
  });
1576
1629
  const settingsRef = useRef4(null);
1577
1630
  const [markerCounts, setMarkerCounts] = useState4({ errors: 0, warnings: 0 });
1631
+ const [markerDetails, setMarkerDetails] = useState4([]);
1632
+ const [openMarkerMenu, setOpenMarkerMenu] = useState4(null);
1633
+ const markerMenuRef = useRef4(null);
1578
1634
  const editorInstanceRef = useRef4(null);
1579
- const lastJumpIndexRef = useRef4({ errors: -1, warnings: -1 });
1580
1635
  useEffect3(() => {
1581
- if (!showSettingsPanel) return;
1636
+ if (!showSettingsPanel && !openMarkerMenu) return;
1582
1637
  const handleClickOutside = (e) => {
1583
- if (settingsRef.current && !settingsRef.current.contains(e.target)) {
1638
+ if (showSettingsPanel && settingsRef.current && !settingsRef.current.contains(e.target)) {
1584
1639
  setShowSettingsPanel(false);
1585
1640
  }
1641
+ if (openMarkerMenu && markerMenuRef.current && !markerMenuRef.current.contains(e.target)) {
1642
+ setOpenMarkerMenu(null);
1643
+ }
1586
1644
  };
1587
1645
  document.addEventListener("mousedown", handleClickOutside);
1588
1646
  return () => document.removeEventListener("mousedown", handleClickOutside);
1589
- }, [showSettingsPanel]);
1647
+ }, [showSettingsPanel, openMarkerMenu]);
1590
1648
  const [currentTabId, setCurrentTabId] = useState4(
1591
1649
  controlledActiveTab ?? defaultTab ?? tabs?.[0]?.id ?? ""
1592
1650
  );
@@ -1627,33 +1685,20 @@ function CodeBox({
1627
1685
  [userOnMount]
1628
1686
  );
1629
1687
  const handleMarkerCounts = useCallback3(
1630
- (counts) => {
1631
- setMarkerCounts(counts);
1632
- lastJumpIndexRef.current = { errors: -1, warnings: -1 };
1633
- onValidationIssues?.(counts);
1688
+ (info) => {
1689
+ setMarkerCounts({ errors: info.errors, warnings: info.warnings });
1690
+ setMarkerDetails(info.markers);
1691
+ onValidationIssues?.({ errors: info.errors, warnings: info.warnings });
1634
1692
  },
1635
1693
  [onValidationIssues]
1636
1694
  );
1637
- const jumpToMarker = useCallback3((severity) => {
1695
+ const jumpToLine = useCallback3((line, column) => {
1638
1696
  const ed = editorInstanceRef.current;
1639
1697
  if (!ed) return;
1640
- const model = ed.getModel();
1641
- if (!model) return;
1642
- const severityValue = severity === "error" ? 8 : 4;
1643
- const markers = monacoNs.editor.getModelMarkers({ resource: model.uri }).filter((m) => m.severity === severityValue).sort(
1644
- (a, b) => a.startLineNumber - b.startLineNumber || a.startColumn - b.startColumn
1645
- );
1646
- if (markers.length === 0) return;
1647
- const key = severity === "error" ? "errors" : "warnings";
1648
- const nextIndex = (lastJumpIndexRef.current[key] + 1) % markers.length;
1649
- lastJumpIndexRef.current[key] = nextIndex;
1650
- const marker = markers[nextIndex];
1651
- ed.revealLineInCenter(marker.startLineNumber);
1652
- ed.setPosition({
1653
- lineNumber: marker.startLineNumber,
1654
- column: marker.startColumn
1655
- });
1698
+ ed.revealLineInCenter(line);
1699
+ ed.setPosition({ lineNumber: line, column });
1656
1700
  ed.focus();
1701
+ setOpenMarkerMenu(null);
1657
1702
  }, []);
1658
1703
  const settingsProps = {
1659
1704
  lineNumbers: settings.lineNumbers,
@@ -1663,56 +1708,88 @@ function CodeBox({
1663
1708
  };
1664
1709
  const actions = /* @__PURE__ */ jsxs3("div", { style: { display: "flex", gap: "4px", alignItems: "center" }, children: [
1665
1710
  markerCounts.errors > 0 && /* @__PURE__ */ jsxs3(
1666
- "button",
1711
+ "div",
1667
1712
  {
1668
- className: "elb-codebox-marker-badge elb-codebox-marker-badge--error",
1669
- onClick: () => jumpToMarker("error"),
1670
- title: `${markerCounts.errors} error${markerCounts.errors !== 1 ? "s" : ""} \u2014 click to jump`,
1713
+ ref: openMarkerMenu === "error" ? markerMenuRef : void 0,
1714
+ style: { position: "relative" },
1671
1715
  children: [
1672
1716
  /* @__PURE__ */ jsxs3(
1673
- "svg",
1717
+ "button",
1674
1718
  {
1675
- width: "14",
1676
- height: "14",
1677
- viewBox: "0 0 24 24",
1678
- fill: "none",
1679
- stroke: "currentColor",
1680
- strokeWidth: "2",
1719
+ className: "elb-codebox-marker-badge elb-codebox-marker-badge--error",
1720
+ onClick: () => setOpenMarkerMenu(openMarkerMenu === "error" ? null : "error"),
1681
1721
  children: [
1682
- /* @__PURE__ */ jsx4("circle", { cx: "12", cy: "12", r: "10" }),
1683
- /* @__PURE__ */ jsx4("line", { x1: "15", y1: "9", x2: "9", y2: "15" }),
1684
- /* @__PURE__ */ jsx4("line", { x1: "9", y1: "9", x2: "15", y2: "15" })
1722
+ /* @__PURE__ */ jsxs3(
1723
+ "svg",
1724
+ {
1725
+ width: "14",
1726
+ height: "14",
1727
+ viewBox: "0 0 24 24",
1728
+ fill: "none",
1729
+ stroke: "currentColor",
1730
+ strokeWidth: "2",
1731
+ children: [
1732
+ /* @__PURE__ */ jsx4("circle", { cx: "12", cy: "12", r: "10" }),
1733
+ /* @__PURE__ */ jsx4("line", { x1: "15", y1: "9", x2: "9", y2: "15" }),
1734
+ /* @__PURE__ */ jsx4("line", { x1: "9", y1: "9", x2: "15", y2: "15" })
1735
+ ]
1736
+ }
1737
+ ),
1738
+ /* @__PURE__ */ jsx4("span", { children: markerCounts.errors })
1685
1739
  ]
1686
1740
  }
1687
1741
  ),
1688
- /* @__PURE__ */ jsx4("span", { children: markerCounts.errors })
1742
+ openMarkerMenu === "error" && /* @__PURE__ */ jsx4(
1743
+ MarkerMenu,
1744
+ {
1745
+ markers: markerDetails.filter((m) => m.severity === "error"),
1746
+ onJump: jumpToLine
1747
+ }
1748
+ )
1689
1749
  ]
1690
1750
  }
1691
1751
  ),
1692
1752
  markerCounts.warnings > 0 && /* @__PURE__ */ jsxs3(
1693
- "button",
1753
+ "div",
1694
1754
  {
1695
- className: "elb-codebox-marker-badge elb-codebox-marker-badge--warning",
1696
- onClick: () => jumpToMarker("warning"),
1697
- title: `${markerCounts.warnings} warning${markerCounts.warnings !== 1 ? "s" : ""} \u2014 click to jump`,
1755
+ ref: openMarkerMenu === "warning" ? markerMenuRef : void 0,
1756
+ style: { position: "relative" },
1698
1757
  children: [
1699
1758
  /* @__PURE__ */ jsxs3(
1700
- "svg",
1759
+ "button",
1701
1760
  {
1702
- width: "14",
1703
- height: "14",
1704
- viewBox: "0 0 24 24",
1705
- fill: "none",
1706
- stroke: "currentColor",
1707
- strokeWidth: "2",
1761
+ className: "elb-codebox-marker-badge elb-codebox-marker-badge--warning",
1762
+ onClick: () => setOpenMarkerMenu(openMarkerMenu === "warning" ? null : "warning"),
1708
1763
  children: [
1709
- /* @__PURE__ */ jsx4("path", { d: "M12 3L2 21h20L12 3z" }),
1710
- /* @__PURE__ */ jsx4("line", { x1: "12", y1: "9", x2: "12", y2: "13" }),
1711
- /* @__PURE__ */ jsx4("line", { x1: "12", y1: "17", x2: "12.01", y2: "17" })
1764
+ /* @__PURE__ */ jsxs3(
1765
+ "svg",
1766
+ {
1767
+ width: "14",
1768
+ height: "14",
1769
+ viewBox: "0 0 24 24",
1770
+ fill: "none",
1771
+ stroke: "currentColor",
1772
+ strokeWidth: "2",
1773
+ strokeLinecap: "round",
1774
+ strokeLinejoin: "round",
1775
+ children: [
1776
+ /* @__PURE__ */ jsx4("path", { d: "M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z" }),
1777
+ /* @__PURE__ */ jsx4("line", { x1: "12", y1: "9", x2: "12", y2: "13" }),
1778
+ /* @__PURE__ */ jsx4("circle", { cx: "12", cy: "17", r: ".5" })
1779
+ ]
1780
+ }
1781
+ ),
1782
+ /* @__PURE__ */ jsx4("span", { children: markerCounts.warnings })
1712
1783
  ]
1713
1784
  }
1714
1785
  ),
1715
- /* @__PURE__ */ jsx4("span", { children: markerCounts.warnings })
1786
+ openMarkerMenu === "warning" && /* @__PURE__ */ jsx4(
1787
+ MarkerMenu,
1788
+ {
1789
+ markers: markerDetails.filter((m) => m.severity === "warning"),
1790
+ onJump: jumpToLine
1791
+ }
1792
+ )
1716
1793
  ]
1717
1794
  }
1718
1795
  ),
@@ -1907,6 +1984,26 @@ function CodeBox({
1907
1984
  }
1908
1985
  );
1909
1986
  }
1987
+ function MarkerMenu({
1988
+ markers,
1989
+ onJump
1990
+ }) {
1991
+ return /* @__PURE__ */ jsx4("div", { className: "elb-codebox-marker-menu", children: markers.sort((a, b) => a.line - b.line || a.column - b.column).map((m, i) => /* @__PURE__ */ jsxs3(
1992
+ "button",
1993
+ {
1994
+ className: "elb-codebox-marker-menu-item",
1995
+ onClick: () => onJump(m.line, m.column),
1996
+ children: [
1997
+ /* @__PURE__ */ jsxs3("span", { className: "elb-codebox-marker-menu-line", children: [
1998
+ "Ln ",
1999
+ m.line
2000
+ ] }),
2001
+ /* @__PURE__ */ jsx4("span", { className: "elb-codebox-marker-menu-msg", children: m.message })
2002
+ ]
2003
+ },
2004
+ i
2005
+ )) });
2006
+ }
1910
2007
 
1911
2008
  // src/components/atoms/grid.tsx
1912
2009
  import {
@@ -2580,10 +2677,14 @@ function Preview({
2580
2677
  const createNoopLogger = () => ({
2581
2678
  error: () => {
2582
2679
  },
2680
+ warn: () => {
2681
+ },
2583
2682
  info: () => {
2584
2683
  },
2585
2684
  debug: () => {
2586
2685
  },
2686
+ json: () => {
2687
+ },
2587
2688
  throw: (msg) => {
2588
2689
  throw msg instanceof Error ? msg : new Error(msg);
2589
2690
  },
@@ -2620,6 +2721,8 @@ function Preview({
2620
2721
  logger: noopLogger,
2621
2722
  setIngest: async () => {
2622
2723
  },
2724
+ setRespond: () => {
2725
+ },
2623
2726
  config,
2624
2727
  env
2625
2728
  });
@@ -18361,10 +18464,10 @@ function validateWalkerOSReferences(text, context) {
18361
18464
  }
18362
18465
 
18363
18466
  // src/utils/monaco-intellisense-flow-extractor.ts
18364
- function extractFlowIntelliSenseContext(json2) {
18467
+ function extractFlowIntelliSenseContext(json) {
18365
18468
  let parsed;
18366
18469
  try {
18367
- parsed = JSON.parse(json2);
18470
+ parsed = JSON.parse(json);
18368
18471
  } catch {
18369
18472
  return {};
18370
18473
  }