@vertesia/react 1.3.0 → 1.4.0-dev.20260615.051508Z
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/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/useInteractionStreaming.d.ts +3 -3
- package/lib/useInteractionStreaming.d.ts.map +1 -1
- package/lib/useInteractionStreaming.js +8 -5
- package/lib/useInteractionStreaming.js.map +1 -1
- package/package.json +8 -10
- package/src/index.ts +0 -2
- package/src/useInteractionStreaming.ts +28 -22
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC"}
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { InteractionBase } from
|
|
2
|
-
import {
|
|
1
|
+
import type { InteractionBase } from '@vertesia/client';
|
|
2
|
+
import type { InteractionExecutionPayload, InteractionExecutionResult } from '@vertesia/common';
|
|
3
3
|
export declare function useInteractionStreaming<TProps>(interaction: InteractionBase<TProps>): {
|
|
4
4
|
text: string;
|
|
5
5
|
isRunning: boolean;
|
|
6
|
-
execute: (payload?: InteractionExecutionPayload) => Promise<
|
|
6
|
+
execute: (payload?: InteractionExecutionPayload) => Promise<InteractionExecutionResult<TProps>>;
|
|
7
7
|
};
|
|
8
8
|
//# sourceMappingURL=useInteractionStreaming.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInteractionStreaming.d.ts","sourceRoot":"","sources":["../src/useInteractionStreaming.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"useInteractionStreaming.d.ts","sourceRoot":"","sources":["../src/useInteractionStreaming.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EAAE,2BAA2B,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAGhG,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,WAAW,EAAE,eAAe,CAAC,MAAM,CAAC;;;wBAM7D,2BAA2B,KAAG,OAAO,CAAC,0BAA0B,CAAC,MAAM,CAAC,CAAC;EAwB/F"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useMemo, useState } from
|
|
1
|
+
import { useMemo, useState } from 'react';
|
|
2
2
|
export function useInteractionStreaming(interaction) {
|
|
3
3
|
const [isRunning, setRunning] = useState(false);
|
|
4
4
|
const [text, setText] = useState('');
|
|
@@ -8,17 +8,20 @@ export function useInteractionStreaming(interaction) {
|
|
|
8
8
|
}
|
|
9
9
|
setRunning(true);
|
|
10
10
|
let chunks = [];
|
|
11
|
-
return interaction
|
|
11
|
+
return interaction
|
|
12
|
+
.execute(payload, (chunk) => {
|
|
12
13
|
chunks.push(chunk);
|
|
13
14
|
setText(chunks.join(''));
|
|
14
|
-
})
|
|
15
|
+
})
|
|
16
|
+
.then((run) => {
|
|
15
17
|
setText('');
|
|
16
18
|
setRunning(false);
|
|
17
19
|
return run;
|
|
18
|
-
})
|
|
20
|
+
})
|
|
21
|
+
.finally(() => {
|
|
19
22
|
chunks = [];
|
|
20
23
|
});
|
|
21
|
-
}, []);
|
|
24
|
+
}, [interaction.execute, isRunning]);
|
|
22
25
|
return { text, isRunning, execute };
|
|
23
26
|
}
|
|
24
27
|
//# sourceMappingURL=useInteractionStreaming.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInteractionStreaming.js","sourceRoot":"","sources":["../src/useInteractionStreaming.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE1C,MAAM,UAAU,uBAAuB,CAAS,WAAoC;
|
|
1
|
+
{"version":3,"file":"useInteractionStreaming.js","sourceRoot":"","sources":["../src/useInteractionStreaming.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE1C,MAAM,UAAU,uBAAuB,CAAS,WAAoC;IAChF,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAChD,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IAErC,MAAM,OAAO,GAAG,OAAO,CACnB,GAAG,EAAE,CACD,CAAC,OAAqC,EAA+C,EAAE;QACnF,IAAI,SAAS,EAAE,CAAC;YACZ,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC,CAAC;QACnG,CAAC;QACD,UAAU,CAAC,IAAI,CAAC,CAAC;QACjB,IAAI,MAAM,GAAa,EAAE,CAAC;QAC1B,OAAO,WAAW;aACb,OAAO,CAAC,OAAO,EAAE,CAAC,KAAa,EAAE,EAAE;YAChC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACnB,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;QAC7B,CAAC,CAAC;aACD,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;YACV,OAAO,CAAC,EAAE,CAAC,CAAC;YACZ,UAAU,CAAC,KAAK,CAAC,CAAC;YAClB,OAAO,GAAG,CAAC;QACf,CAAC,CAAC;aACD,OAAO,CAAC,GAAG,EAAE;YACV,MAAM,GAAG,EAAE,CAAC;QAChB,CAAC,CAAC,CAAC;IACX,CAAC,EACL,CAAC,WAAW,CAAC,OAAO,EAAE,SAAS,CAAC,CACnC,CAAC;IAEF,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;AACxC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vertesia/react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0-dev.20260615.051508Z",
|
|
4
4
|
"description": "React helpers for Composable AI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -20,18 +20,16 @@
|
|
|
20
20
|
"react"
|
|
21
21
|
],
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"typescript": "^6.0.2",
|
|
27
|
-
"typescript-eslint": "^8.58.1"
|
|
23
|
+
"@types/react": "^19.2.16",
|
|
24
|
+
"typescript": "^6.0.3",
|
|
25
|
+
"@vertesia/tsconfig": "0.1.0"
|
|
28
26
|
},
|
|
29
27
|
"peerDependencies": {
|
|
30
|
-
"react": ">=
|
|
28
|
+
"react": ">=19.2.7"
|
|
31
29
|
},
|
|
32
30
|
"dependencies": {
|
|
33
|
-
"@vertesia/client": "1.
|
|
34
|
-
"@vertesia/common": "1.
|
|
31
|
+
"@vertesia/client": "1.4.0-dev.20260615.051508Z",
|
|
32
|
+
"@vertesia/common": "1.4.0-dev.20260615.051508Z"
|
|
35
33
|
},
|
|
36
34
|
"repository": {
|
|
37
35
|
"type": "git",
|
|
@@ -39,7 +37,7 @@
|
|
|
39
37
|
"directory": "packages/react"
|
|
40
38
|
},
|
|
41
39
|
"scripts": {
|
|
42
|
-
"lint": "
|
|
40
|
+
"lint": "biome lint src",
|
|
43
41
|
"build": "tsc --build",
|
|
44
42
|
"clean": "rm -rf ./lib ./tsconfig.tsbuildinfo && tsc --build"
|
|
45
43
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,29 +1,35 @@
|
|
|
1
|
-
import { InteractionBase } from
|
|
2
|
-
import {
|
|
3
|
-
import { useMemo, useState } from
|
|
1
|
+
import type { InteractionBase } from '@vertesia/client';
|
|
2
|
+
import type { InteractionExecutionPayload, InteractionExecutionResult } from '@vertesia/common';
|
|
3
|
+
import { useMemo, useState } from 'react';
|
|
4
4
|
|
|
5
5
|
export function useInteractionStreaming<TProps>(interaction: InteractionBase<TProps>) {
|
|
6
|
-
|
|
7
6
|
const [isRunning, setRunning] = useState(false);
|
|
8
7
|
const [text, setText] = useState('');
|
|
9
8
|
|
|
10
|
-
const execute = useMemo(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
9
|
+
const execute = useMemo(
|
|
10
|
+
() =>
|
|
11
|
+
(payload?: InteractionExecutionPayload): Promise<InteractionExecutionResult<TProps>> => {
|
|
12
|
+
if (isRunning) {
|
|
13
|
+
return Promise.reject(new Error('Trying to run the interaction while it is already running.'));
|
|
14
|
+
}
|
|
15
|
+
setRunning(true);
|
|
16
|
+
let chunks: string[] = [];
|
|
17
|
+
return interaction
|
|
18
|
+
.execute(payload, (chunk: string) => {
|
|
19
|
+
chunks.push(chunk);
|
|
20
|
+
setText(chunks.join(''));
|
|
21
|
+
})
|
|
22
|
+
.then((run) => {
|
|
23
|
+
setText('');
|
|
24
|
+
setRunning(false);
|
|
25
|
+
return run;
|
|
26
|
+
})
|
|
27
|
+
.finally(() => {
|
|
28
|
+
chunks = [];
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
[interaction.execute, isRunning],
|
|
32
|
+
);
|
|
27
33
|
|
|
28
|
-
return { text, isRunning, execute }
|
|
34
|
+
return { text, isRunning, execute };
|
|
29
35
|
}
|