@trops/dash-core 0.1.708 → 0.1.710

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.js CHANGED
@@ -51968,12 +51968,20 @@ function ListenersTab(_ref1) {
51968
51968
  return m;
51969
51969
  }, [receivers]);
51970
51970
  if (receivers.length === 0) {
51971
+ // Bots are emitters too (component `bot:<ref>`) — count them apart.
51972
+ var botCount = emitters.filter(function (e) {
51973
+ return String(e.component || "").startsWith("bot:");
51974
+ }).length;
51975
+ var widgetCount = emitters.length - botCount;
51976
+ var senders = [widgetCount > 0 && "".concat(widgetCount, " widget").concat(widgetCount === 1 ? "" : "s"), botCount > 0 && "".concat(botCount, " bot").concat(botCount === 1 ? "" : "s")].filter(Boolean);
51971
51977
  return /*#__PURE__*/jsxRuntime.jsx("div", {
51972
51978
  className: "flex items-center justify-center h-full text-sm opacity-60 text-center",
51973
51979
  children: /*#__PURE__*/jsxRuntime.jsxs("div", {
51974
- children: ["No widgets in this dashboard declare event handlers.", emitters.length > 0 && /*#__PURE__*/jsxRuntime.jsxs("div", {
51980
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
51981
+ children: "No widget on this dashboard can listen for events yet."
51982
+ }), senders.length > 0 && /*#__PURE__*/jsxRuntime.jsx("div", {
51975
51983
  className: "mt-2",
51976
- children: ["(", emitters.length, " widget", emitters.length === 1 ? "" : "s", " emit events but nothing is set up to receive.)"]
51984
+ children: "".concat(senders.join(" and "), " ").concat(emitters.length === 1 ? "sends" : "send", " events. Add a widget that listens to use them.")
51977
51985
  })]
51978
51986
  })
51979
51987
  });
@@ -79246,6 +79254,41 @@ function renderSafeMarkdown(text) {
79246
79254
  });
79247
79255
  }
79248
79256
 
79257
+ /**
79258
+ * collapseCodeBlocks — for ChatCore's `hideCodeBlocks` option.
79259
+ *
79260
+ * Replaces each fenced code block (and the `File: path` marker line that
79261
+ * labels it) with a one-line italic note, so a chat whose code is shown
79262
+ * elsewhere (the Widget Builder's Code tab) stays readable. Back-to-back
79263
+ * blocks share one note. A block that is still streaming (no closing
79264
+ * fence yet) becomes "Writing code…". Inline `code` is untouched.
79265
+ *
79266
+ * @param {string} text assistant Markdown
79267
+ * @param {string} note what a hidden block says
79268
+ * @param {{ plain?: boolean }} [opts] plain: no Markdown italics (for the
79269
+ * streaming view, which shows raw text)
79270
+ * @returns {string}
79271
+ */
79272
+ function collapseCodeBlocks(text, note) {
79273
+ var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
79274
+ _ref$plain = _ref.plain,
79275
+ plain = _ref$plain === void 0 ? false : _ref$plain;
79276
+ if (!text || typeof text !== "string" || !text.includes("```")) return text;
79277
+ var wrap = function wrap(t) {
79278
+ return plain ? t : "_".concat(t, "_");
79279
+ };
79280
+ var marker = wrap(note);
79281
+ var out = text
79282
+ // Complete blocks, with an optional "File: …" line just above.
79283
+ .replace(/(^|\n)(?:[ \t]*File:[^\n]*\n)?[ \t]*```[^\n]*\n[\s\S]*?\n[ \t]*```[ \t]*(?=\n|$)/g, "$1".concat(marker))
79284
+ // A block still being written: open fence with no close.
79285
+ .replace(/(^|\n)(?:[ \t]*File:[^\n]*\n)?[ \t]*```[^\n]*(?:\n[\s\S]*)?$/, "$1".concat(wrap("Writing code…")));
79286
+ // One note for back-to-back blocks.
79287
+ var escaped = marker.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
79288
+ out = out.replace(new RegExp("".concat(escaped, "(\\s*").concat(escaped, ")+"), "g"), marker);
79289
+ return out;
79290
+ }
79291
+
79249
79292
  function ownKeys$6(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
79250
79293
  function _objectSpread$6(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$6(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$6(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
79251
79294
  function _createForOfIteratorHelper$5(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$5(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
@@ -79270,7 +79313,9 @@ var MessageBubble = function MessageBubble(_ref2) {
79270
79313
  isStreaming = _ref2.isStreaming,
79271
79314
  streamingText = _ref2.streamingText,
79272
79315
  _ref2$isLast = _ref2.isLast,
79273
- isLast = _ref2$isLast === void 0 ? false : _ref2$isLast;
79316
+ isLast = _ref2$isLast === void 0 ? false : _ref2$isLast,
79317
+ _ref2$codeNote = _ref2.codeNote,
79318
+ codeNote = _ref2$codeNote === void 0 ? null : _ref2$codeNote;
79274
79319
  var role = message.role,
79275
79320
  content = message.content,
79276
79321
  toolCalls = message.toolCalls,
@@ -79408,11 +79453,13 @@ var MessageBubble = function MessageBubble(_ref2) {
79408
79453
  className: "text-sm leading-relaxed px-3 py-2 rounded-lg ".concat(bubbleBg, " ").concat(bubbleText),
79409
79454
  children: [isStreaming && /*#__PURE__*/jsxRuntime.jsx("div", {
79410
79455
  children: /*#__PURE__*/jsxRuntime.jsx(StreamingText, {
79411
- text: streamingText,
79456
+ text: codeNote ? collapseCodeBlocks(streamingText, codeNote, {
79457
+ plain: true
79458
+ }) : streamingText,
79412
79459
  isStreaming: true
79413
79460
  })
79414
79461
  }), !isStreaming && _text && /*#__PURE__*/jsxRuntime.jsx(AssistantTextContent, {
79415
- text: _text
79462
+ text: codeNote ? collapseCodeBlocks(_text, codeNote) : _text
79416
79463
  }), toolBlocks.map(function (block) {
79417
79464
  return /*#__PURE__*/jsxRuntime.jsx(ToolCallBlock, {
79418
79465
  toolName: block.name,
@@ -79473,7 +79520,9 @@ var ChatMessages = function ChatMessages(_ref) {
79473
79520
  streamingRequestId = _ref.streamingRequestId,
79474
79521
  streamingText = _ref.streamingText,
79475
79522
  _ref$isLoading = _ref.isLoading,
79476
- isLoading = _ref$isLoading === void 0 ? false : _ref$isLoading;
79523
+ isLoading = _ref$isLoading === void 0 ? false : _ref$isLoading,
79524
+ _ref$codeNote = _ref.codeNote,
79525
+ codeNote = _ref$codeNote === void 0 ? null : _ref$codeNote;
79477
79526
  var scrollRef = React.useRef(null);
79478
79527
  var _ref2 = React.useContext(DashReact.ThemeContext) || {},
79479
79528
  currentTheme = _ref2.currentTheme;
@@ -79511,7 +79560,8 @@ var ChatMessages = function ChatMessages(_ref) {
79511
79560
  message: message,
79512
79561
  isStreaming: isStreaming,
79513
79562
  streamingText: isStreaming ? streamingText : "",
79514
- isLast: index === messages.length - 1
79563
+ isLast: index === messages.length - 1,
79564
+ codeNote: codeNote
79515
79565
  }, message.id || index);
79516
79566
  }), isLoading && !streamingRequestId && ((_messages = messages[messages.length - 1]) === null || _messages === void 0 ? void 0 : _messages.role) === "user" && /*#__PURE__*/jsxRuntime.jsxs("div", {
79517
79567
  className: "mb-4",
@@ -79966,6 +80016,8 @@ function ChatCore(_ref) {
79966
80016
  onPublishEvent = _ref$onPublishEvent === void 0 ? null : _ref$onPublishEvent,
79967
80017
  _ref$hideToolsBanner = _ref.hideToolsBanner,
79968
80018
  hideToolsBanner = _ref$hideToolsBanner === void 0 ? false : _ref$hideToolsBanner,
80019
+ _ref$hideCodeBlocks = _ref.hideCodeBlocks,
80020
+ hideCodeBlocks = _ref$hideCodeBlocks === void 0 ? false : _ref$hideCodeBlocks,
79969
80021
  _ref$cwd = _ref.cwd,
79970
80022
  cwd = _ref$cwd === void 0 ? null : _ref$cwd,
79971
80023
  _ref$initialMessage = _ref.initialMessage,
@@ -80763,7 +80815,8 @@ function ChatCore(_ref) {
80763
80815
  messages: messages,
80764
80816
  streamingRequestId: isLoading ? activeRequestId.current : null,
80765
80817
  streamingText: streamingText,
80766
- isLoading: isLoading
80818
+ isLoading: isLoading,
80819
+ codeNote: typeof hideCodeBlocks === "string" ? hideCodeBlocks : hideCodeBlocks ? "Code hidden." : null
80767
80820
  }), enableLeadRecipients && leadNotice && /*#__PURE__*/jsxRuntime.jsx("div", {
80768
80821
  className: "px-3 pt-2",
80769
80822
  children: /*#__PURE__*/jsxRuntime.jsx(DashReact.AlertBanner, {