@uipath/apollo-react 7.15.0 → 7.15.1

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/README.md CHANGED
@@ -9,7 +9,7 @@ React component library with Material UI theming for the Apollo Design System.
9
9
  **✅ Actively Supported - Use for:**
10
10
  - **Canvas/workflow components** - Hierarchical canvas, agent workflows, XYFlow integration (unique to this package)
11
11
  - **ApChat** - AI chat interface component
12
- - **Icons** - React icon components
12
+ - **Icons** - React icon components, re-exported from @uipath/apollo-ui-icons-react
13
13
  - **Core tokens** - Re-exported from @uipath/apollo-core
14
14
 
15
15
  **⚠️ Maintenance Mode - Avoid for New Development:**
@@ -258,7 +258,8 @@ function MyComponent() {
258
258
  }
259
259
  ```
260
260
 
261
- Icons are auto-generated from `@uipath/apollo-core` with React wrappers. Icon names use PascalCase.
261
+ The components are generated from the SVGs in `@uipath/apollo-ui-icons`. Icon names use PascalCase.
262
+ Projects that only need icons can install `@uipath/apollo-ui-icons-react` directly.
262
263
 
263
264
  ## Internationalization (i18n)
264
265
 
@@ -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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/apollo-react",
3
- "version": "7.15.0",
3
+ "version": "7.15.1",
4
4
  "description": "Apollo Design System - React component library with Material UI theming",
5
5
  "repository": {
6
6
  "type": "git",
@@ -253,8 +253,8 @@
253
253
  "zustand": "^5.0.9",
254
254
  "@uipath/apollo-core": "5.15.2",
255
255
  "@uipath/apollo-ui-icons": "1.2.1",
256
- "@uipath/apollo-ui-icons-react": "0.0.0",
257
- "@uipath/apollo-wind": "2.85.0"
256
+ "@uipath/apollo-ui-icons-react": "1.0.0",
257
+ "@uipath/apollo-wind": "2.84.0"
258
258
  },
259
259
  "devDependencies": {
260
260
  "@lingui/cli": "^5.6.1",