@zhin.js/core 1.1.56 → 1.1.57

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 (45) hide show
  1. package/lib/built/generic-segment-mapper.js +2 -0
  2. package/lib/built/html-to-text.js +2 -2
  3. package/lib/built/rich-segments/markdown-to-text.js +19 -0
  4. package/lib/built/segment-contract/validate.d.ts +1442 -300
  5. package/lib/built/user-interaction.js +3 -1
  6. package/lib/index.d.ts +1 -0
  7. package/lib/index.js +2 -0
  8. package/lib/plugin-runtime/im/conversation-runtime.d.ts +2 -2
  9. package/lib/plugin-runtime/im/conversation-runtime.js +6 -4
  10. package/lib/plugin-runtime/im/inbound-dedup.d.ts +1 -0
  11. package/lib/plugin-runtime/im/inbound-dedup.js +1 -0
  12. package/lib/plugin-runtime/im/inbound-origin.d.ts +27 -0
  13. package/lib/plugin-runtime/im/inbound-runtime.js +78 -2
  14. package/lib/plugin-runtime/im/index.d.ts +1 -0
  15. package/lib/plugin-runtime/im/index.js +1 -0
  16. package/lib/plugin-runtime/im/interaction-runtime.d.ts +7 -6
  17. package/lib/plugin-runtime/im/interaction-runtime.js +85 -24
  18. package/lib/plugin-runtime/im/interactive-router.d.ts +28 -8
  19. package/lib/plugin-runtime/im/interactive-router.js +112 -35
  20. package/lib/plugin-runtime/im/jsx-button-registry.d.ts +16 -2
  21. package/lib/plugin-runtime/im/jsx-button-registry.js +56 -19
  22. package/lib/plugin-runtime/im/message-dispatcher.js +57 -5
  23. package/lib/plugin-runtime/im/outbound-delivery-runtime.d.ts +5 -4
  24. package/lib/plugin-runtime/im/outbound-delivery-runtime.js +71 -21
  25. package/lib/runtime.d.ts +2 -0
  26. package/lib/runtime.js +2 -0
  27. package/lib/venue/contracts.d.ts +21 -0
  28. package/lib/venue/contracts.js +3 -0
  29. package/lib/venue/floor-controller.d.ts +11 -0
  30. package/lib/venue/floor-controller.js +63 -0
  31. package/lib/venue/index.d.ts +13 -0
  32. package/lib/venue/index.js +11 -0
  33. package/lib/venue/membership-port.d.ts +23 -0
  34. package/lib/venue/membership-port.js +141 -0
  35. package/lib/venue/projector.d.ts +38 -0
  36. package/lib/venue/projector.js +45 -0
  37. package/lib/venue/registry.d.ts +16 -0
  38. package/lib/venue/registry.js +63 -0
  39. package/lib/venue/router.d.ts +19 -0
  40. package/lib/venue/router.js +101 -0
  41. package/lib/venue/send-limiter.d.ts +17 -0
  42. package/lib/venue/send-limiter.js +73 -0
  43. package/lib/venue/validator.d.ts +6 -0
  44. package/lib/venue/validator.js +160 -0
  45. package/package.json +16 -16
@@ -162,6 +162,8 @@ function normalizeMarkdown(seg) {
162
162
  function normalizeSegment(seg) {
163
163
  if (seg.type === 'at' || seg.type === 'mention')
164
164
  return normalizeMention(seg);
165
+ if (seg.type === 'record' || seg.type === 'voice')
166
+ return normalizeMedia({ ...seg, type: 'audio' });
165
167
  if (MEDIA_SEGMENT_TYPES.has(seg.type))
166
168
  return normalizeMedia(seg);
167
169
  if (seg.type === 'reply')
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import { readableLinkTarget, decodeReadableEntities as decodeCommonEntities } from './readable-link.js';
5
5
  const DEFAULT_MAX_INPUT = 2 * 1024 * 1024;
6
- const BLOCK_TAGS = ['script', 'style', 'svg', 'nav', 'footer', 'header', 'form'];
6
+ const BLOCK_TAGS = ['script', 'style', 'svg', 'nav', 'form'];
7
7
  function findTagClose(html, from) {
8
8
  const gt = html.indexOf('>', from);
9
9
  return gt === -1 ? -1 : gt + 1;
@@ -213,7 +213,7 @@ export function htmlToFallbackText(html, options) {
213
213
  out.push('\n');
214
214
  else if (/^h[1-6]$/u.test(tag))
215
215
  out.push(closing ? '\n\n' : `\n${'#'.repeat(Number(tag[1]))} `);
216
- else if (['p', 'div', 'section', 'article', 'table', 'blockquote'].includes(tag)) {
216
+ else if (['p', 'div', 'section', 'article', 'table', 'blockquote', 'header', 'footer'].includes(tag)) {
217
217
  if (closing)
218
218
  out.push(tag === 'p' ? '\n\n' : '\n');
219
219
  }
@@ -113,6 +113,7 @@ export function markdownToPlainText(md) {
113
113
  if (fence)
114
114
  text += `${text ? '\n' : ''}${stash(fence.code.join('\n'))}`;
115
115
  text = readableLinks(decodeReadableEntities(text), stash);
116
+ text = formatMarkdownTables(text);
116
117
  text = text.replace(/^#{1,6}\s+/gm, '');
117
118
  text = text.replace(/^[ \t]*>[ \t]?/gm, '');
118
119
  text = text.replace(/^([ \t]*)[-*+][ \t]+/gm, '$1• ');
@@ -137,3 +138,21 @@ export function markdownToHtmlForRender(md) {
137
138
  .replace(/>/g, '>');
138
139
  return `<pre style="white-space:pre-wrap;font-family:sans-serif;font-size:14px;line-height:1.5;padding:16px;">${escaped}</pre>`;
139
140
  }
141
+ function formatMarkdownTables(text) {
142
+ if (!text.includes('|'))
143
+ return text;
144
+ const out = [];
145
+ for (const line of text.split('\n')) {
146
+ const trimmed = line.trim();
147
+ if (trimmed.length > 1 && trimmed.startsWith('|') && trimmed.endsWith('|')) {
148
+ const cells = trimmed.slice(1, -1).split('|').map(cell => cell.trim());
149
+ if (cells.length > 0 && cells.every(cell => /^:?-{2,}:?$/u.test(cell))) {
150
+ continue;
151
+ }
152
+ out.push(cells.join(' | '));
153
+ continue;
154
+ }
155
+ out.push(line);
156
+ }
157
+ return out.join('\n');
158
+ }