@trops/dash-core 0.1.709 → 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.esm.js +51 -6
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +51 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -79236,6 +79236,41 @@ function renderSafeMarkdown(text) {
|
|
|
79236
79236
|
});
|
|
79237
79237
|
}
|
|
79238
79238
|
|
|
79239
|
+
/**
|
|
79240
|
+
* collapseCodeBlocks — for ChatCore's `hideCodeBlocks` option.
|
|
79241
|
+
*
|
|
79242
|
+
* Replaces each fenced code block (and the `File: path` marker line that
|
|
79243
|
+
* labels it) with a one-line italic note, so a chat whose code is shown
|
|
79244
|
+
* elsewhere (the Widget Builder's Code tab) stays readable. Back-to-back
|
|
79245
|
+
* blocks share one note. A block that is still streaming (no closing
|
|
79246
|
+
* fence yet) becomes "Writing code…". Inline `code` is untouched.
|
|
79247
|
+
*
|
|
79248
|
+
* @param {string} text assistant Markdown
|
|
79249
|
+
* @param {string} note what a hidden block says
|
|
79250
|
+
* @param {{ plain?: boolean }} [opts] plain: no Markdown italics (for the
|
|
79251
|
+
* streaming view, which shows raw text)
|
|
79252
|
+
* @returns {string}
|
|
79253
|
+
*/
|
|
79254
|
+
function collapseCodeBlocks(text, note) {
|
|
79255
|
+
var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
|
79256
|
+
_ref$plain = _ref.plain,
|
|
79257
|
+
plain = _ref$plain === void 0 ? false : _ref$plain;
|
|
79258
|
+
if (!text || typeof text !== "string" || !text.includes("```")) return text;
|
|
79259
|
+
var wrap = function wrap(t) {
|
|
79260
|
+
return plain ? t : "_".concat(t, "_");
|
|
79261
|
+
};
|
|
79262
|
+
var marker = wrap(note);
|
|
79263
|
+
var out = text
|
|
79264
|
+
// Complete blocks, with an optional "File: …" line just above.
|
|
79265
|
+
.replace(/(^|\n)(?:[ \t]*File:[^\n]*\n)?[ \t]*```[^\n]*\n[\s\S]*?\n[ \t]*```[ \t]*(?=\n|$)/g, "$1".concat(marker))
|
|
79266
|
+
// A block still being written: open fence with no close.
|
|
79267
|
+
.replace(/(^|\n)(?:[ \t]*File:[^\n]*\n)?[ \t]*```[^\n]*(?:\n[\s\S]*)?$/, "$1".concat(wrap("Writing code…")));
|
|
79268
|
+
// One note for back-to-back blocks.
|
|
79269
|
+
var escaped = marker.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
79270
|
+
out = out.replace(new RegExp("".concat(escaped, "(\\s*").concat(escaped, ")+"), "g"), marker);
|
|
79271
|
+
return out;
|
|
79272
|
+
}
|
|
79273
|
+
|
|
79239
79274
|
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; }
|
|
79240
79275
|
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; }
|
|
79241
79276
|
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; } } }; }
|
|
@@ -79260,7 +79295,9 @@ var MessageBubble = function MessageBubble(_ref2) {
|
|
|
79260
79295
|
isStreaming = _ref2.isStreaming,
|
|
79261
79296
|
streamingText = _ref2.streamingText,
|
|
79262
79297
|
_ref2$isLast = _ref2.isLast,
|
|
79263
|
-
isLast = _ref2$isLast === void 0 ? false : _ref2$isLast
|
|
79298
|
+
isLast = _ref2$isLast === void 0 ? false : _ref2$isLast,
|
|
79299
|
+
_ref2$codeNote = _ref2.codeNote,
|
|
79300
|
+
codeNote = _ref2$codeNote === void 0 ? null : _ref2$codeNote;
|
|
79264
79301
|
var role = message.role,
|
|
79265
79302
|
content = message.content,
|
|
79266
79303
|
toolCalls = message.toolCalls,
|
|
@@ -79398,11 +79435,13 @@ var MessageBubble = function MessageBubble(_ref2) {
|
|
|
79398
79435
|
className: "text-sm leading-relaxed px-3 py-2 rounded-lg ".concat(bubbleBg, " ").concat(bubbleText),
|
|
79399
79436
|
children: [isStreaming && /*#__PURE__*/jsx("div", {
|
|
79400
79437
|
children: /*#__PURE__*/jsx(StreamingText, {
|
|
79401
|
-
text: streamingText,
|
|
79438
|
+
text: codeNote ? collapseCodeBlocks(streamingText, codeNote, {
|
|
79439
|
+
plain: true
|
|
79440
|
+
}) : streamingText,
|
|
79402
79441
|
isStreaming: true
|
|
79403
79442
|
})
|
|
79404
79443
|
}), !isStreaming && _text && /*#__PURE__*/jsx(AssistantTextContent, {
|
|
79405
|
-
text: _text
|
|
79444
|
+
text: codeNote ? collapseCodeBlocks(_text, codeNote) : _text
|
|
79406
79445
|
}), toolBlocks.map(function (block) {
|
|
79407
79446
|
return /*#__PURE__*/jsx(ToolCallBlock, {
|
|
79408
79447
|
toolName: block.name,
|
|
@@ -79463,7 +79502,9 @@ var ChatMessages = function ChatMessages(_ref) {
|
|
|
79463
79502
|
streamingRequestId = _ref.streamingRequestId,
|
|
79464
79503
|
streamingText = _ref.streamingText,
|
|
79465
79504
|
_ref$isLoading = _ref.isLoading,
|
|
79466
|
-
isLoading = _ref$isLoading === void 0 ? false : _ref$isLoading
|
|
79505
|
+
isLoading = _ref$isLoading === void 0 ? false : _ref$isLoading,
|
|
79506
|
+
_ref$codeNote = _ref.codeNote,
|
|
79507
|
+
codeNote = _ref$codeNote === void 0 ? null : _ref$codeNote;
|
|
79467
79508
|
var scrollRef = useRef(null);
|
|
79468
79509
|
var _ref2 = useContext(ThemeContext) || {},
|
|
79469
79510
|
currentTheme = _ref2.currentTheme;
|
|
@@ -79501,7 +79542,8 @@ var ChatMessages = function ChatMessages(_ref) {
|
|
|
79501
79542
|
message: message,
|
|
79502
79543
|
isStreaming: isStreaming,
|
|
79503
79544
|
streamingText: isStreaming ? streamingText : "",
|
|
79504
|
-
isLast: index === messages.length - 1
|
|
79545
|
+
isLast: index === messages.length - 1,
|
|
79546
|
+
codeNote: codeNote
|
|
79505
79547
|
}, message.id || index);
|
|
79506
79548
|
}), isLoading && !streamingRequestId && ((_messages = messages[messages.length - 1]) === null || _messages === void 0 ? void 0 : _messages.role) === "user" && /*#__PURE__*/jsxs("div", {
|
|
79507
79549
|
className: "mb-4",
|
|
@@ -79956,6 +79998,8 @@ function ChatCore(_ref) {
|
|
|
79956
79998
|
onPublishEvent = _ref$onPublishEvent === void 0 ? null : _ref$onPublishEvent,
|
|
79957
79999
|
_ref$hideToolsBanner = _ref.hideToolsBanner,
|
|
79958
80000
|
hideToolsBanner = _ref$hideToolsBanner === void 0 ? false : _ref$hideToolsBanner,
|
|
80001
|
+
_ref$hideCodeBlocks = _ref.hideCodeBlocks,
|
|
80002
|
+
hideCodeBlocks = _ref$hideCodeBlocks === void 0 ? false : _ref$hideCodeBlocks,
|
|
79959
80003
|
_ref$cwd = _ref.cwd,
|
|
79960
80004
|
cwd = _ref$cwd === void 0 ? null : _ref$cwd,
|
|
79961
80005
|
_ref$initialMessage = _ref.initialMessage,
|
|
@@ -80753,7 +80797,8 @@ function ChatCore(_ref) {
|
|
|
80753
80797
|
messages: messages,
|
|
80754
80798
|
streamingRequestId: isLoading ? activeRequestId.current : null,
|
|
80755
80799
|
streamingText: streamingText,
|
|
80756
|
-
isLoading: isLoading
|
|
80800
|
+
isLoading: isLoading,
|
|
80801
|
+
codeNote: typeof hideCodeBlocks === "string" ? hideCodeBlocks : hideCodeBlocks ? "Code hidden." : null
|
|
80757
80802
|
}), enableLeadRecipients && leadNotice && /*#__PURE__*/jsx("div", {
|
|
80758
80803
|
className: "px-3 pt-2",
|
|
80759
80804
|
children: /*#__PURE__*/jsx(AlertBanner, {
|