@adecore/agents-react 0.71.1 → 0.72.0
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/chat/ui/highlighter.js +14 -6
- package/package.json +9 -9
- package/src/chat/ui/highlighter.ts +39 -19
|
@@ -29,9 +29,19 @@ function createCodeHighlighter(source) {
|
|
|
29
29
|
highlighterLoad ??= source().then(loaded => {
|
|
30
30
|
highlighter = loaded;
|
|
31
31
|
return loaded;
|
|
32
|
+
}, error => {
|
|
33
|
+
// A chunk that failed to load once may load the next time; kept, it would leave code plain until a reload.
|
|
34
|
+
highlighterLoad = null;
|
|
35
|
+
throw error;
|
|
32
36
|
});
|
|
33
37
|
return highlighterLoad;
|
|
34
38
|
};
|
|
39
|
+
// A load that failed is asked again by the next block that needs it.
|
|
40
|
+
const retried = (loads, key, pending) => {
|
|
41
|
+
loads.set(key, pending);
|
|
42
|
+
pending.catch(() => loads.delete(key));
|
|
43
|
+
return pending;
|
|
44
|
+
};
|
|
35
45
|
const ready = (langs, theme) => {
|
|
36
46
|
if (highlighter === null || !themes.has(theme)) {
|
|
37
47
|
return null;
|
|
@@ -48,24 +58,22 @@ function createCodeHighlighter(source) {
|
|
|
48
58
|
loadLanguage(lang) {
|
|
49
59
|
let pending = languageLoads.get(lang);
|
|
50
60
|
if (!pending) {
|
|
51
|
-
pending = load().then(async loaded => {
|
|
61
|
+
pending = retried(languageLoads, lang, load().then(async loaded => {
|
|
52
62
|
languages.set(lang, await grammarOf(loaded, lang));
|
|
53
|
-
});
|
|
54
|
-
languageLoads.set(lang, pending);
|
|
63
|
+
}));
|
|
55
64
|
}
|
|
56
65
|
return pending;
|
|
57
66
|
},
|
|
58
67
|
loadTheme(theme, custom) {
|
|
59
68
|
let pending = themeLoads.get(theme);
|
|
60
69
|
if (!pending) {
|
|
61
|
-
pending = load().then(async loaded => {
|
|
70
|
+
pending = retried(themeLoads, theme, load().then(async loaded => {
|
|
62
71
|
// Loading a theme the highlighter already has replaces it, under whatever else of the host draws with it.
|
|
63
72
|
if (!loaded.getLoadedThemes().includes(theme)) {
|
|
64
73
|
await loaded.loadTheme(shikiThemeOf(theme, custom));
|
|
65
74
|
}
|
|
66
75
|
themes.add(theme);
|
|
67
|
-
});
|
|
68
|
-
themeLoads.set(theme, pending);
|
|
76
|
+
}));
|
|
69
77
|
}
|
|
70
78
|
return pending;
|
|
71
79
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adecore/agents-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.72.0",
|
|
4
4
|
"description": "React agent chat threads, composers, approvals, provider accounts and usage views.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -72,12 +72,12 @@
|
|
|
72
72
|
"test:visuals": "bun --config=integration.bunfig.toml --conditions=source test ./src/chat/visual-viewport.integration.test.ts"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@adecore/agent-contracts": "0.
|
|
76
|
-
"@adecore/editor": "0.
|
|
77
|
-
"@adecore/editor-react": "0.
|
|
78
|
-
"@adecore/intelligent-ui": "0.
|
|
79
|
-
"@adecore/merge": "0.
|
|
80
|
-
"@adecore/utils": "0.
|
|
75
|
+
"@adecore/agent-contracts": "0.72.0",
|
|
76
|
+
"@adecore/editor": "0.72.0",
|
|
77
|
+
"@adecore/editor-react": "0.72.0",
|
|
78
|
+
"@adecore/intelligent-ui": "0.72.0",
|
|
79
|
+
"@adecore/merge": "0.72.0",
|
|
80
|
+
"@adecore/utils": "0.72.0",
|
|
81
81
|
"@codemirror/commands": "^6.11.1",
|
|
82
82
|
"@codemirror/language": "^6.13.1",
|
|
83
83
|
"@codemirror/state": "^6.7.6",
|
|
@@ -101,14 +101,14 @@
|
|
|
101
101
|
"zustand": "^5.1.0"
|
|
102
102
|
},
|
|
103
103
|
"peerDependencies": {
|
|
104
|
-
"@adecore/ui": "^0.
|
|
104
|
+
"@adecore/ui": "^0.72.0",
|
|
105
105
|
"i18next": "^26.4.2 || ^27.0.0",
|
|
106
106
|
"react": "^19.3.0",
|
|
107
107
|
"react-dom": "^19.3.0",
|
|
108
108
|
"react-i18next": "^17.0.15 || ^18.0.0"
|
|
109
109
|
},
|
|
110
110
|
"devDependencies": {
|
|
111
|
-
"@adecore/ui": "0.
|
|
111
|
+
"@adecore/ui": "0.72.0",
|
|
112
112
|
"@types/bun": "^1.4.4",
|
|
113
113
|
"@types/react": "^19.3.0",
|
|
114
114
|
"@types/react-dom": "^19.3.0",
|
|
@@ -50,15 +50,31 @@ function createCodeHighlighter(source: () => Promise<Highlighter>): CodeHighligh
|
|
|
50
50
|
const tokenizers = new Map<string, { tokenize: Tokenize<GrammarState>; fg: string | undefined }>();
|
|
51
51
|
|
|
52
52
|
const load = (): Promise<Highlighter> => {
|
|
53
|
-
highlighterLoad ??= source().then(
|
|
54
|
-
|
|
53
|
+
highlighterLoad ??= source().then(
|
|
54
|
+
(loaded) => {
|
|
55
|
+
highlighter = loaded;
|
|
55
56
|
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
return loaded;
|
|
58
|
+
},
|
|
59
|
+
(error: unknown) => {
|
|
60
|
+
// A chunk that failed to load once may load the next time; kept, it would leave code plain until a reload.
|
|
61
|
+
highlighterLoad = null;
|
|
62
|
+
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
);
|
|
58
66
|
|
|
59
67
|
return highlighterLoad;
|
|
60
68
|
};
|
|
61
69
|
|
|
70
|
+
// A load that failed is asked again by the next block that needs it.
|
|
71
|
+
const retried = (loads: Map<string, Promise<void>>, key: string, pending: Promise<void>): Promise<void> => {
|
|
72
|
+
loads.set(key, pending);
|
|
73
|
+
pending.catch(() => loads.delete(key));
|
|
74
|
+
|
|
75
|
+
return pending;
|
|
76
|
+
};
|
|
77
|
+
|
|
62
78
|
const ready = (langs: Iterable<string>, theme: string): Highlighter | null => {
|
|
63
79
|
if (highlighter === null || !themes.has(theme)) {
|
|
64
80
|
return null;
|
|
@@ -80,11 +96,13 @@ function createCodeHighlighter(source: () => Promise<Highlighter>): CodeHighligh
|
|
|
80
96
|
let pending = languageLoads.get(lang);
|
|
81
97
|
|
|
82
98
|
if (!pending) {
|
|
83
|
-
pending =
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
99
|
+
pending = retried(
|
|
100
|
+
languageLoads,
|
|
101
|
+
lang,
|
|
102
|
+
load().then(async (loaded) => {
|
|
103
|
+
languages.set(lang, await grammarOf(loaded, lang));
|
|
104
|
+
})
|
|
105
|
+
);
|
|
88
106
|
}
|
|
89
107
|
|
|
90
108
|
return pending;
|
|
@@ -93,16 +111,18 @@ function createCodeHighlighter(source: () => Promise<Highlighter>): CodeHighligh
|
|
|
93
111
|
let pending = themeLoads.get(theme);
|
|
94
112
|
|
|
95
113
|
if (!pending) {
|
|
96
|
-
pending =
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
114
|
+
pending = retried(
|
|
115
|
+
themeLoads,
|
|
116
|
+
theme,
|
|
117
|
+
load().then(async (loaded) => {
|
|
118
|
+
// Loading a theme the highlighter already has replaces it, under whatever else of the host draws with it.
|
|
119
|
+
if (!loaded.getLoadedThemes().includes(theme)) {
|
|
120
|
+
await loaded.loadTheme(shikiThemeOf(theme, custom) as BundledTheme | ThemeRegistration);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
themes.add(theme);
|
|
124
|
+
})
|
|
125
|
+
);
|
|
106
126
|
}
|
|
107
127
|
|
|
108
128
|
return pending;
|