@gendive/chatllm 0.17.14 → 0.17.16

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.
@@ -1346,6 +1346,7 @@ var useProject = (options) => {
1346
1346
  var generateId2 = () => {
1347
1347
  return Math.random().toString(36).substring(2, 11);
1348
1348
  };
1349
+ var stripInlineMarkdown = (text) => text.replace(/\*\*(.+?)\*\*/g, "$1").replace(/__(.+?)__/g, "$1").replace(/\*(.+?)\*/g, "$1").replace(/_(.+?)_/g, "$1").replace(/`(.+?)`/g, "$1").replace(/~~(.+?)~~/g, "$1");
1349
1350
  var parsePollFromContent = (content) => {
1350
1351
  const pollRegex = /<poll([^>]*)>([\s\S]*?)<\/poll>/gi;
1351
1352
  const polls = [];
@@ -1380,12 +1381,12 @@ var parsePollFromContent = (content) => {
1380
1381
  let optionMatch;
1381
1382
  while ((optionMatch = optionTagRegex.exec(innerContent)) !== null) {
1382
1383
  const optionAttrs = optionMatch[1];
1383
- const optionLabel = optionMatch[2].trim();
1384
+ const optionLabel = stripInlineMarkdown(optionMatch[2].trim());
1384
1385
  const descMatch = optionAttrs.match(/description=["']([^"']+)["']/i);
1385
1386
  options.push({
1386
1387
  id: generateId2(),
1387
1388
  label: optionLabel,
1388
- description: descMatch?.[1]
1389
+ description: descMatch?.[1] ? stripInlineMarkdown(descMatch[1]) : void 0
1389
1390
  });
1390
1391
  }
1391
1392
  if (options.length === 0) {
@@ -1395,8 +1396,8 @@ var parsePollFromContent = (content) => {
1395
1396
  const fullText = listMatch[1].trim();
1396
1397
  const colonIndex = fullText.indexOf(":");
1397
1398
  if (colonIndex > 0) {
1398
- const label = fullText.substring(0, colonIndex).trim();
1399
- const description = fullText.substring(colonIndex + 1).trim();
1399
+ const label = stripInlineMarkdown(fullText.substring(0, colonIndex).trim());
1400
+ const description = stripInlineMarkdown(fullText.substring(colonIndex + 1).trim());
1400
1401
  options.push({
1401
1402
  id: generateId2(),
1402
1403
  label,
@@ -1405,7 +1406,7 @@ var parsePollFromContent = (content) => {
1405
1406
  } else {
1406
1407
  options.push({
1407
1408
  id: generateId2(),
1408
- label: fullText
1409
+ label: stripInlineMarkdown(fullText)
1409
1410
  });
1410
1411
  }
1411
1412
  }
@@ -1416,14 +1417,14 @@ var parsePollFromContent = (content) => {
1416
1417
  while ((numMatch = numberedRegex.exec(innerContent)) !== null) {
1417
1418
  options.push({
1418
1419
  id: generateId2(),
1419
- label: numMatch[1].trim()
1420
+ label: stripInlineMarkdown(numMatch[1].trim())
1420
1421
  });
1421
1422
  }
1422
1423
  }
1423
1424
  if (questionText && options.length >= 2) {
1424
1425
  const pollQuestion = {
1425
1426
  id: generateId2(),
1426
- question: questionText,
1427
+ question: stripInlineMarkdown(questionText),
1427
1428
  options,
1428
1429
  multiSelect,
1429
1430
  allowOther,
@@ -6445,7 +6446,12 @@ var MarkdownRenderer = ({
6445
6446
  processedContent = processedContent.replace(UNCLOSED_THINKING_TAG_REGEX, "");
6446
6447
  }
6447
6448
  processedContent = processedContent.replace(/<poll[^>]*>[\s\S]*?<\/poll>/gi, "");
6449
+ const hasUnfinishedPoll = UNCLOSED_POLL_TAG_REGEX.test(processedContent);
6450
+ UNCLOSED_POLL_TAG_REGEX.lastIndex = 0;
6448
6451
  processedContent = processedContent.replace(UNCLOSED_POLL_TAG_REGEX, "");
6452
+ if (hasUnfinishedPoll) {
6453
+ processedContent += "\n\xA7POLL_LOADING\xA7";
6454
+ }
6449
6455
  processedContent = processedContent.replace(UNCLOSED_SKILL_TAG_REGEX, "");
6450
6456
  const codeBlocks = [];
6451
6457
  processedContent = processedContent.replace(CODE_BLOCK_REGEX, (match, lang, code) => {
@@ -6581,6 +6587,46 @@ var MarkdownRenderer = ({
6581
6587
  );
6582
6588
  return;
6583
6589
  }
6590
+ if (line.trim() === "\xA7POLL_LOADING\xA7") {
6591
+ flushList();
6592
+ flushBlockquote();
6593
+ elements.push(
6594
+ /* @__PURE__ */ jsxs6(
6595
+ "div",
6596
+ {
6597
+ style: {
6598
+ display: "flex",
6599
+ alignItems: "center",
6600
+ gap: "8px",
6601
+ padding: "14px 16px",
6602
+ backgroundColor: "var(--chatllm-bg-secondary, #f9fafb)",
6603
+ borderRadius: "10px",
6604
+ border: "1px solid var(--chatllm-border, #e5e7eb)",
6605
+ marginTop: "12px",
6606
+ animation: "chatllm-pulse 1.5s ease-in-out infinite"
6607
+ },
6608
+ children: [
6609
+ /* @__PURE__ */ jsx7(
6610
+ "div",
6611
+ {
6612
+ style: {
6613
+ width: "18px",
6614
+ height: "18px",
6615
+ borderRadius: "50%",
6616
+ border: "2px solid var(--chatllm-primary, #4A90E2)",
6617
+ borderTopColor: "transparent",
6618
+ animation: "chatllm-spin 0.8s linear infinite"
6619
+ }
6620
+ }
6621
+ ),
6622
+ /* @__PURE__ */ jsx7("span", { style: { fontSize: "13px", color: "var(--chatllm-text-muted, #64748b)" }, children: "\uC120\uD0DD\uC9C0\uB97C \uC900\uBE44\uD558\uACE0 \uC788\uC5B4\uC694..." })
6623
+ ]
6624
+ },
6625
+ `poll-loading-${lineIndex}`
6626
+ )
6627
+ );
6628
+ return;
6629
+ }
6584
6630
  const codeBlockMatch = line.match(/§CODEBLOCK§(\d+)§\/CODEBLOCK§/);
6585
6631
  if (codeBlockMatch) {
6586
6632
  flushList();
@@ -7148,6 +7194,26 @@ var PollCard = ({
7148
7194
  const currentHasSelection = getSelectionCount(currentQuestion.id) > 0;
7149
7195
  const isLastTab = activeTab === questions.length - 1;
7150
7196
  const totalSelected = questions.reduce((sum, q) => sum + getSelectionCount(q.id), 0);
7197
+ const [visibleCount, setVisibleCount] = useState11(0);
7198
+ const [cardVisible, setCardVisible] = useState11(false);
7199
+ useEffect7(() => {
7200
+ const fadeTimer = setTimeout(() => setCardVisible(true), 50);
7201
+ const totalItems = currentQuestion.options.length + 1;
7202
+ const timers = [fadeTimer];
7203
+ for (let i = 1; i <= totalItems; i++) {
7204
+ timers.push(setTimeout(() => setVisibleCount(i), 150 + i * 80));
7205
+ }
7206
+ return () => timers.forEach(clearTimeout);
7207
+ }, [currentQuestion.options.length]);
7208
+ useEffect7(() => {
7209
+ setVisibleCount(0);
7210
+ const totalItems = currentQuestion.options.length + 1;
7211
+ const timers = [];
7212
+ for (let i = 1; i <= totalItems; i++) {
7213
+ timers.push(setTimeout(() => setVisibleCount(i), i * 80));
7214
+ }
7215
+ return () => timers.forEach(clearTimeout);
7216
+ }, [activeTab, currentQuestion.options.length]);
7151
7217
  const handleNext = useCallback6(() => {
7152
7218
  if (!isLastTab) {
7153
7219
  setActiveTab((prev) => prev + 1);
@@ -7164,6 +7230,9 @@ var PollCard = ({
7164
7230
  borderRadius: "12px",
7165
7231
  border: "1px solid var(--chatllm-border, #e5e7eb)",
7166
7232
  overflow: "hidden",
7233
+ opacity: cardVisible ? 1 : 0,
7234
+ transform: cardVisible ? "translateY(0)" : "translateY(8px)",
7235
+ transition: "opacity 0.3s ease, transform 0.3s ease",
7167
7236
  marginTop: "12px"
7168
7237
  },
7169
7238
  children: [
@@ -7245,8 +7314,9 @@ var PollCard = ({
7245
7314
  }
7246
7315
  ),
7247
7316
  /* @__PURE__ */ jsxs8("div", { style: { padding: "8px" }, children: [
7248
- currentQuestion.options.map((option) => {
7317
+ currentQuestion.options.map((option, optIdx) => {
7249
7318
  const isSelected = selections[currentQuestion.id]?.has(option.id) || false;
7319
+ const isVisible = optIdx < visibleCount;
7250
7320
  return /* @__PURE__ */ jsxs8(
7251
7321
  "button",
7252
7322
  {
@@ -7262,8 +7332,10 @@ var PollCard = ({
7262
7332
  borderRadius: "8px",
7263
7333
  cursor: "pointer",
7264
7334
  textAlign: "left",
7265
- transition: "all 0.15s ease",
7266
- marginBottom: "6px"
7335
+ transition: "all 0.2s ease",
7336
+ marginBottom: "6px",
7337
+ opacity: isVisible ? 1 : 0,
7338
+ transform: isVisible ? "translateY(0)" : "translateY(6px)"
7267
7339
  },
7268
7340
  children: [
7269
7341
  /* @__PURE__ */ jsx9(
@@ -7316,68 +7388,73 @@ var PollCard = ({
7316
7388
  option.id
7317
7389
  );
7318
7390
  }),
7319
- currentQuestion.allowOther !== false && /* @__PURE__ */ jsxs8(Fragment5, { children: [
7320
- /* @__PURE__ */ jsxs8(
7321
- "button",
7322
- {
7323
- onClick: () => handleOtherToggle(currentQuestion.id, currentQuestion.multiSelect ?? false),
7324
- style: {
7325
- width: "100%",
7326
- display: "flex",
7327
- alignItems: "center",
7328
- gap: "12px",
7329
- padding: "12px 14px",
7330
- backgroundColor: otherSelected[currentQuestion.id] ? "var(--chatllm-primary-light, rgba(74, 144, 226, 0.08))" : "transparent",
7331
- border: otherSelected[currentQuestion.id] ? "1px solid var(--chatllm-primary, #4A90E2)" : "1px solid var(--chatllm-border, #e5e7eb)",
7332
- borderRadius: "8px",
7333
- cursor: "pointer",
7334
- textAlign: "left",
7335
- transition: "all 0.15s ease"
7336
- },
7337
- children: [
7338
- /* @__PURE__ */ jsx9(
7339
- "div",
7340
- {
7341
- style: {
7342
- width: "20px",
7343
- height: "20px",
7344
- borderRadius: currentQuestion.multiSelect ? "4px" : "50%",
7345
- border: `2px solid ${otherSelected[currentQuestion.id] ? "var(--chatllm-primary, #4A90E2)" : "var(--chatllm-border, #d1d5db)"}`,
7346
- backgroundColor: otherSelected[currentQuestion.id] ? "var(--chatllm-primary, #4A90E2)" : "transparent",
7347
- display: "flex",
7348
- alignItems: "center",
7349
- justifyContent: "center",
7350
- flexShrink: 0,
7351
- transition: "all 0.15s ease"
7352
- },
7353
- children: otherSelected[currentQuestion.id] && /* @__PURE__ */ jsx9(IconSvg, { name: "check-line", size: 14, color: "#fff" })
7354
- }
7355
- ),
7356
- /* @__PURE__ */ jsx9("span", { style: { fontSize: "14px", color: "var(--chatllm-text-muted, #64748b)" }, children: "\uAE30\uD0C0" })
7357
- ]
7358
- }
7359
- ),
7360
- otherSelected[currentQuestion.id] && /* @__PURE__ */ jsx9("div", { style: { padding: "8px 0 4px 32px" }, children: /* @__PURE__ */ jsx9(
7361
- "input",
7362
- {
7363
- type: "text",
7364
- value: otherTexts[currentQuestion.id] || "",
7365
- onChange: (e) => setOtherTexts((prev) => ({ ...prev, [currentQuestion.id]: e.target.value })),
7366
- placeholder: "\uC9C1\uC811 \uC785\uB825...",
7367
- style: {
7368
- width: "100%",
7369
- padding: "10px 12px",
7370
- backgroundColor: "var(--chatllm-bg-secondary, #f9fafb)",
7371
- border: "1px solid var(--chatllm-border, #e5e7eb)",
7372
- borderRadius: "6px",
7373
- color: "var(--chatllm-text, #1e293b)",
7374
- fontSize: "13px",
7375
- outline: "none"
7376
- },
7377
- autoFocus: true
7378
- }
7379
- ) })
7380
- ] })
7391
+ currentQuestion.allowOther !== false && (() => {
7392
+ const otherVisible = currentQuestion.options.length < visibleCount;
7393
+ return /* @__PURE__ */ jsxs8(Fragment5, { children: [
7394
+ /* @__PURE__ */ jsxs8(
7395
+ "button",
7396
+ {
7397
+ onClick: () => handleOtherToggle(currentQuestion.id, currentQuestion.multiSelect ?? false),
7398
+ style: {
7399
+ width: "100%",
7400
+ display: "flex",
7401
+ alignItems: "center",
7402
+ gap: "12px",
7403
+ padding: "12px 14px",
7404
+ backgroundColor: otherSelected[currentQuestion.id] ? "var(--chatllm-primary-light, rgba(74, 144, 226, 0.08))" : "transparent",
7405
+ border: otherSelected[currentQuestion.id] ? "1px solid var(--chatllm-primary, #4A90E2)" : "1px solid var(--chatllm-border, #e5e7eb)",
7406
+ borderRadius: "8px",
7407
+ cursor: "pointer",
7408
+ textAlign: "left",
7409
+ transition: "all 0.2s ease",
7410
+ opacity: otherVisible ? 1 : 0,
7411
+ transform: otherVisible ? "translateY(0)" : "translateY(6px)"
7412
+ },
7413
+ children: [
7414
+ /* @__PURE__ */ jsx9(
7415
+ "div",
7416
+ {
7417
+ style: {
7418
+ width: "20px",
7419
+ height: "20px",
7420
+ borderRadius: currentQuestion.multiSelect ? "4px" : "50%",
7421
+ border: `2px solid ${otherSelected[currentQuestion.id] ? "var(--chatllm-primary, #4A90E2)" : "var(--chatllm-border, #d1d5db)"}`,
7422
+ backgroundColor: otherSelected[currentQuestion.id] ? "var(--chatllm-primary, #4A90E2)" : "transparent",
7423
+ display: "flex",
7424
+ alignItems: "center",
7425
+ justifyContent: "center",
7426
+ flexShrink: 0,
7427
+ transition: "all 0.15s ease"
7428
+ },
7429
+ children: otherSelected[currentQuestion.id] && /* @__PURE__ */ jsx9(IconSvg, { name: "check-line", size: 14, color: "#fff" })
7430
+ }
7431
+ ),
7432
+ /* @__PURE__ */ jsx9("span", { style: { fontSize: "14px", color: "var(--chatllm-text-muted, #64748b)" }, children: "\uAE30\uD0C0" })
7433
+ ]
7434
+ }
7435
+ ),
7436
+ otherSelected[currentQuestion.id] && /* @__PURE__ */ jsx9("div", { style: { padding: "8px 0 4px 32px" }, children: /* @__PURE__ */ jsx9(
7437
+ "input",
7438
+ {
7439
+ type: "text",
7440
+ value: otherTexts[currentQuestion.id] || "",
7441
+ onChange: (e) => setOtherTexts((prev) => ({ ...prev, [currentQuestion.id]: e.target.value })),
7442
+ placeholder: "\uC9C1\uC811 \uC785\uB825...",
7443
+ style: {
7444
+ width: "100%",
7445
+ padding: "10px 12px",
7446
+ backgroundColor: "var(--chatllm-bg-secondary, #f9fafb)",
7447
+ border: "1px solid var(--chatllm-border, #e5e7eb)",
7448
+ borderRadius: "6px",
7449
+ color: "var(--chatllm-text, #1e293b)",
7450
+ fontSize: "13px",
7451
+ outline: "none"
7452
+ },
7453
+ autoFocus: true
7454
+ }
7455
+ ) })
7456
+ ] });
7457
+ })()
7381
7458
  ] }),
7382
7459
  /* @__PURE__ */ jsxs8(
7383
7460
  "div",