@uipath/apollo-react 7.15.0 → 7.15.2

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 (39) hide show
  1. package/README.md +3 -2
  2. package/dist/canvas/styles/tailwind.canvas.css +1 -1
  3. package/dist/chat/headless/markdown/citation-parser.cjs +57 -9
  4. package/dist/chat/headless/markdown/citation-parser.d.ts.map +1 -1
  5. package/dist/chat/headless/markdown/citation-parser.js +57 -9
  6. package/dist/chat/styles/tailwind.chat.css +1 -1
  7. package/dist/decision-table/DecisionTable.cjs +82 -36
  8. package/dist/decision-table/DecisionTable.d.ts +28 -2
  9. package/dist/decision-table/DecisionTable.d.ts.map +1 -1
  10. package/dist/decision-table/DecisionTable.js +76 -36
  11. package/dist/decision-table/GridCell.cjs +1 -1
  12. package/dist/decision-table/GridCell.d.ts.map +1 -1
  13. package/dist/decision-table/GridCell.js +2 -2
  14. package/dist/decision-table/GridMenu.cjs +2 -2
  15. package/dist/decision-table/GridMenu.d.ts +1 -0
  16. package/dist/decision-table/GridMenu.d.ts.map +1 -1
  17. package/dist/decision-table/GridMenu.js +2 -2
  18. package/dist/decision-table/constants.cjs +1 -1
  19. package/dist/decision-table/constants.d.ts +1 -1
  20. package/dist/decision-table/constants.js +1 -1
  21. package/dist/decision-table/gridEvents.cjs +1 -1
  22. package/dist/decision-table/gridEvents.d.ts.map +1 -1
  23. package/dist/decision-table/gridEvents.js +1 -1
  24. package/dist/decision-table/gridStyles.cjs +59 -29
  25. package/dist/decision-table/gridStyles.d.ts +15 -9
  26. package/dist/decision-table/gridStyles.d.ts.map +1 -1
  27. package/dist/decision-table/gridStyles.js +26 -11
  28. package/dist/decision-table/gridTypes.d.ts +9 -6
  29. package/dist/decision-table/gridTypes.d.ts.map +1 -1
  30. package/dist/decision-table/index.cjs +37 -21
  31. package/dist/decision-table/index.d.ts +1 -1
  32. package/dist/decision-table/index.d.ts.map +1 -1
  33. package/dist/decision-table/index.js +2 -2
  34. package/dist/decision-table/styles/tailwind.decision-table.css +1 -1
  35. package/dist/decision-table/useGridLayout.cjs +6 -15
  36. package/dist/decision-table/useGridLayout.d.ts +1 -2
  37. package/dist/decision-table/useGridLayout.d.ts.map +1 -1
  38. package/dist/decision-table/useGridLayout.js +6 -15
  39. package/package.json +3 -3
@@ -29,25 +29,27 @@ __webpack_require__.d(__webpack_exports__, {
29
29
  });
30
30
  const external_unist_util_visit_namespaceObject = require("unist-util-visit");
31
31
  const index_cjs_namespaceObject = require("../../service/index.cjs");
32
+ const SEPARATOR = '\t';
32
33
  function citationPlugin() {
33
34
  const citationStack = [];
34
35
  return (tree)=>{
35
36
  (0, external_unist_util_visit_namespaceObject.visit)(tree, 'text', (node, _index, parent)=>{
36
37
  if (!node?.value || !parent) return;
37
38
  const text = String(node.value);
38
- const pattern = /\[\[cite-start:([^\]]+)\]\]|\[\[cite-end\]\]/g;
39
+ const pattern = /\[\[cite-start(\+?):([^\]]+)\]\]|\[\[cite-end(\+?)\]\]/g;
39
40
  const newChildren = [];
40
41
  let lastIndex = 0;
41
42
  let match;
42
43
  while(null !== (match = pattern.exec(text))){
43
- const before = text.slice(lastIndex, match.index);
44
+ let before = text.slice(lastIndex, match.index);
45
+ if ((match[1] || match[3]) && before.endsWith(SEPARATOR)) before = before.slice(0, -SEPARATOR.length);
44
46
  if (before) newChildren.push({
45
47
  type: 'text',
46
48
  value: before
47
49
  });
48
50
  const token = match[0];
49
- if (token.startsWith('[[cite-start:')) try {
50
- const raw = atob(match[1]);
51
+ if (token.startsWith('[[cite-start')) try {
52
+ const raw = atob(match[2]);
51
53
  const decoded = raw.startsWith('%5B') ? decodeURIComponent(raw) : raw;
52
54
  const citationsData = JSON.parse(decoded);
53
55
  citationStack.push({
@@ -102,8 +104,49 @@ function citationPlugin() {
102
104
  });
103
105
  };
104
106
  }
107
+ const URL_START = /https?:\/\/|www\./i;
108
+ const URL_START_OVERLAP = 7;
109
+ function lastWhitespaceIndex(text) {
110
+ let index = text.length - 1;
111
+ while(index >= 0 && !/\s/.test(text[index]))index--;
112
+ return index;
113
+ }
114
+ function endsWithUrl(text) {
115
+ return URL_START.test(text.slice(lastWhitespaceIndex(text) + 1));
116
+ }
117
+ function canSeparateAfter(text, truncated = false) {
118
+ const last = text[text.length - 1];
119
+ if ('*' !== last && '_' !== last && '~' !== last && '\\' !== last) return true;
120
+ let start = text.length - 1;
121
+ while(start > 0 && text[start - 1] === last)start--;
122
+ if (0 === start && truncated) return false;
123
+ if ('\\' === last) return (text.length - start) % 2 === 0;
124
+ return start > 0 && /[\p{L}\p{N}]/u.test(text[start - 1]);
125
+ }
126
+ function needsUrlSeparator(text) {
127
+ return endsWithUrl(text) && canSeparateAfter(text);
128
+ }
129
+ const TAIL_LENGTH = 64;
105
130
  function contentPartsToMarkdown(messageId, contentParts) {
106
- const markdown = contentParts.map((part, _index)=>{
131
+ let markdown = '';
132
+ let lastWordHasUrl = false;
133
+ let lastWordEnd = '';
134
+ let tail = '';
135
+ const append = (chunk)=>{
136
+ const whitespace = lastWhitespaceIndex(chunk);
137
+ if (whitespace >= 0) {
138
+ const word = chunk.slice(whitespace + 1);
139
+ lastWordHasUrl = URL_START.test(word);
140
+ lastWordEnd = word.slice(-URL_START_OVERLAP);
141
+ } else {
142
+ const joined = lastWordEnd + chunk;
143
+ lastWordHasUrl = lastWordHasUrl || URL_START.test(joined);
144
+ lastWordEnd = joined.slice(-URL_START_OVERLAP);
145
+ }
146
+ tail = chunk.length >= TAIL_LENGTH ? chunk.slice(-TAIL_LENGTH) : (tail + chunk).slice(-TAIL_LENGTH);
147
+ markdown += chunk;
148
+ };
149
+ for (const part of contentParts){
107
150
  let text = part.text ?? '';
108
151
  if (part.citations && part.citations.length > 0) {
109
152
  const citationsData = part.citations.map((citation)=>({
@@ -115,11 +158,16 @@ function contentPartsToMarkdown(messageId, contentParts) {
115
158
  messageId
116
159
  }));
117
160
  const encodedData = btoa(encodeURIComponent(JSON.stringify(citationsData)));
118
- const endsWithUrl = /https?:\/\/\S+$/.test(text);
119
- text = `[[cite-start:${encodedData}]]${text}${endsWithUrl ? ' ' : ''}[[cite-end]]`;
161
+ const startGap = lastWordHasUrl && canSeparateAfter(tail, markdown.length > tail.length) ? SEPARATOR : '';
162
+ let endGap = '';
163
+ if (/https?:\/\/\S+$/.test(text)) endGap = ' ';
164
+ else if (needsUrlSeparator(text)) endGap = SEPARATOR;
165
+ const startFlag = startGap ? '+' : '';
166
+ const endFlag = endGap === SEPARATOR ? '+' : '';
167
+ text = `${startGap}[[cite-start${startFlag}:${encodedData}]]${text}${endGap}[[cite-end${endFlag}]]`;
120
168
  }
121
- return text;
122
- }).join('');
169
+ append(text);
170
+ }
123
171
  return markdown;
124
172
  }
125
173
  exports.citationPlugin = __webpack_exports__.citationPlugin;
@@ -1 +1 @@
1
- {"version":3,"file":"citation-parser.d.ts","sourceRoot":"","sources":["../../../../src/chat/headless/markdown/citation-parser.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAuB,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAKtE,wBAAgB,cAAc,KAIpB,MAAM,GAAG,UAuFlB;AAsCD,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,GAAG,MAAM,CA4B7F"}
1
+ {"version":3,"file":"citation-parser.d.ts","sourceRoot":"","sources":["../../../../src/chat/headless/markdown/citation-parser.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAuB,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAUtE,wBAAgB,cAAc,KAIpB,MAAM,GAAG,UA4FlB;AAgGD,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,GAAG,MAAM,CA6D7F"}
@@ -1,24 +1,26 @@
1
1
  import { visit } from "unist-util-visit";
2
2
  import { CHAT_CITATION_START } from "../../service/index.js";
3
+ const SEPARATOR = '\t';
3
4
  function citationPlugin() {
4
5
  const citationStack = [];
5
6
  return (tree)=>{
6
7
  visit(tree, 'text', (node, _index, parent)=>{
7
8
  if (!node?.value || !parent) return;
8
9
  const text = String(node.value);
9
- const pattern = /\[\[cite-start:([^\]]+)\]\]|\[\[cite-end\]\]/g;
10
+ const pattern = /\[\[cite-start(\+?):([^\]]+)\]\]|\[\[cite-end(\+?)\]\]/g;
10
11
  const newChildren = [];
11
12
  let lastIndex = 0;
12
13
  let match;
13
14
  while(null !== (match = pattern.exec(text))){
14
- const before = text.slice(lastIndex, match.index);
15
+ let before = text.slice(lastIndex, match.index);
16
+ if ((match[1] || match[3]) && before.endsWith(SEPARATOR)) before = before.slice(0, -SEPARATOR.length);
15
17
  if (before) newChildren.push({
16
18
  type: 'text',
17
19
  value: before
18
20
  });
19
21
  const token = match[0];
20
- if (token.startsWith('[[cite-start:')) try {
21
- const raw = atob(match[1]);
22
+ if (token.startsWith('[[cite-start')) try {
23
+ const raw = atob(match[2]);
22
24
  const decoded = raw.startsWith('%5B') ? decodeURIComponent(raw) : raw;
23
25
  const citationsData = JSON.parse(decoded);
24
26
  citationStack.push({
@@ -73,8 +75,49 @@ function citationPlugin() {
73
75
  });
74
76
  };
75
77
  }
78
+ const URL_START = /https?:\/\/|www\./i;
79
+ const URL_START_OVERLAP = 7;
80
+ function lastWhitespaceIndex(text) {
81
+ let index = text.length - 1;
82
+ while(index >= 0 && !/\s/.test(text[index]))index--;
83
+ return index;
84
+ }
85
+ function endsWithUrl(text) {
86
+ return URL_START.test(text.slice(lastWhitespaceIndex(text) + 1));
87
+ }
88
+ function canSeparateAfter(text, truncated = false) {
89
+ const last = text[text.length - 1];
90
+ if ('*' !== last && '_' !== last && '~' !== last && '\\' !== last) return true;
91
+ let start = text.length - 1;
92
+ while(start > 0 && text[start - 1] === last)start--;
93
+ if (0 === start && truncated) return false;
94
+ if ('\\' === last) return (text.length - start) % 2 === 0;
95
+ return start > 0 && /[\p{L}\p{N}]/u.test(text[start - 1]);
96
+ }
97
+ function needsUrlSeparator(text) {
98
+ return endsWithUrl(text) && canSeparateAfter(text);
99
+ }
100
+ const TAIL_LENGTH = 64;
76
101
  function contentPartsToMarkdown(messageId, contentParts) {
77
- const markdown = contentParts.map((part, _index)=>{
102
+ let markdown = '';
103
+ let lastWordHasUrl = false;
104
+ let lastWordEnd = '';
105
+ let tail = '';
106
+ const append = (chunk)=>{
107
+ const whitespace = lastWhitespaceIndex(chunk);
108
+ if (whitespace >= 0) {
109
+ const word = chunk.slice(whitespace + 1);
110
+ lastWordHasUrl = URL_START.test(word);
111
+ lastWordEnd = word.slice(-URL_START_OVERLAP);
112
+ } else {
113
+ const joined = lastWordEnd + chunk;
114
+ lastWordHasUrl = lastWordHasUrl || URL_START.test(joined);
115
+ lastWordEnd = joined.slice(-URL_START_OVERLAP);
116
+ }
117
+ tail = chunk.length >= TAIL_LENGTH ? chunk.slice(-TAIL_LENGTH) : (tail + chunk).slice(-TAIL_LENGTH);
118
+ markdown += chunk;
119
+ };
120
+ for (const part of contentParts){
78
121
  let text = part.text ?? '';
79
122
  if (part.citations && part.citations.length > 0) {
80
123
  const citationsData = part.citations.map((citation)=>({
@@ -86,11 +129,16 @@ function contentPartsToMarkdown(messageId, contentParts) {
86
129
  messageId
87
130
  }));
88
131
  const encodedData = btoa(encodeURIComponent(JSON.stringify(citationsData)));
89
- const endsWithUrl = /https?:\/\/\S+$/.test(text);
90
- text = `[[cite-start:${encodedData}]]${text}${endsWithUrl ? ' ' : ''}[[cite-end]]`;
132
+ const startGap = lastWordHasUrl && canSeparateAfter(tail, markdown.length > tail.length) ? SEPARATOR : '';
133
+ let endGap = '';
134
+ if (/https?:\/\/\S+$/.test(text)) endGap = ' ';
135
+ else if (needsUrlSeparator(text)) endGap = SEPARATOR;
136
+ const startFlag = startGap ? '+' : '';
137
+ const endFlag = endGap === SEPARATOR ? '+' : '';
138
+ text = `${startGap}[[cite-start${startFlag}:${encodedData}]]${text}${endGap}[[cite-end${endFlag}]]`;
91
139
  }
92
- return text;
93
- }).join('');
140
+ append(text);
141
+ }
94
142
  return markdown;
95
143
  }
96
144
  export { citationPlugin, contentPartsToMarkdown };