@haikit/react 0.16.0 → 0.17.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/README.md +2 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -3
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +10 -3
package/README.md
CHANGED
|
@@ -78,7 +78,8 @@ mountChat({ root, registry, notices: { hold_confirmed: reactNotice(HoldConfirmed
|
|
|
78
78
|
|
|
79
79
|
The default transcript mounts a surface **once**, so `useState` survives the
|
|
80
80
|
conversation streaming on around it. The root re-renders when the surface
|
|
81
|
-
freezes
|
|
81
|
+
freezes, when a tool revises it in place (`ctx.update`), with the new props and
|
|
82
|
+
its state kept, or when the conversation goes out of date. It is unmounted when the surface
|
|
82
83
|
goes away, on `chat.reset()` or `chat.close()`, so effects clean up after
|
|
83
84
|
themselves. The first render is synchronous, so the surface already has its
|
|
84
85
|
height when the transcript scrolls to it.
|
package/dist/index.d.ts
CHANGED
|
@@ -42,8 +42,9 @@ export interface SurfaceProps<S extends AnySurface> {
|
|
|
42
42
|
*
|
|
43
43
|
* The first render is synchronous, so the surface has its height when the
|
|
44
44
|
* transcript scrolls to it; later ones are React's. It re-renders when the
|
|
45
|
-
* surface freezes or the conversation goes out of date,
|
|
46
|
-
* unmounted when the surface goes away, so effects clean up
|
|
45
|
+
* surface freezes, is revised in place, or the conversation goes out of date,
|
|
46
|
+
* and its root is unmounted when the surface goes away, so effects clean up
|
|
47
|
+
* after themselves. A revision keeps the component's own state.
|
|
47
48
|
*/
|
|
48
49
|
export declare function reactSurface<S extends AnySurface>(Component: ComponentType<SurfaceProps<S>>): ComponentDef<PropsOf<S>>;
|
|
49
50
|
type AnyNotice = Notice<any, any>;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names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QG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,UAAU,EAAE,SAAS,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAkDtH;AAGD,KAAK,SAAS,GAAG,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAClC,KAAK,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAE/D,8EAA8E;AAC9E,MAAM,WAAW,WAAW,CAAC,CAAC,SAAS,SAAS;IAC9C,iEAAiE;IACjE,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IACtB,+CAA+C;IAC/C,GAAG,EAAE,MAAM,CAAC;IACZ,8CAA8C;IAC9C,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,SAAS,EAAE,SAAS,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAiBlH"}
|
package/dist/index.js
CHANGED
|
@@ -17,13 +17,16 @@ import { flushSync } from "react-dom";
|
|
|
17
17
|
*
|
|
18
18
|
* The first render is synchronous, so the surface has its height when the
|
|
19
19
|
* transcript scrolls to it; later ones are React's. It re-renders when the
|
|
20
|
-
* surface freezes or the conversation goes out of date,
|
|
21
|
-
* unmounted when the surface goes away, so effects clean up
|
|
20
|
+
* surface freezes, is revised in place, or the conversation goes out of date,
|
|
21
|
+
* and its root is unmounted when the surface goes away, so effects clean up
|
|
22
|
+
* after themselves. A revision keeps the component's own state.
|
|
22
23
|
*/
|
|
23
24
|
export function reactSurface(Component) {
|
|
24
25
|
return {
|
|
25
|
-
mount(element,
|
|
26
|
+
mount(element, firstProps, ctx) {
|
|
26
27
|
const root = createRoot(element);
|
|
28
|
+
// a revision brings new props; the component and its state stay
|
|
29
|
+
let props = firstProps;
|
|
27
30
|
let state = ctx.state;
|
|
28
31
|
// set when it is mounted already frozen
|
|
29
32
|
let selection = ctx.selection;
|
|
@@ -59,6 +62,10 @@ export function reactSurface(Component) {
|
|
|
59
62
|
unmount() {
|
|
60
63
|
root.unmount();
|
|
61
64
|
},
|
|
65
|
+
update(next) {
|
|
66
|
+
props = next;
|
|
67
|
+
draw();
|
|
68
|
+
},
|
|
62
69
|
};
|
|
63
70
|
},
|
|
64
71
|
};
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,aAAa,EAAsB,MAAM,OAAO,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AA+BtC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,aAAa,EAAsB,MAAM,OAAO,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AA+BtC;;;;;;;;GAQG;AACH,MAAM,UAAU,YAAY,CAAuB,SAAyC;IAC1F,OAAO;QACL,KAAK,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG;YAC5B,MAAM,IAAI,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;YACjC,gEAAgE;YAChE,IAAI,KAAK,GAAG,UAAU,CAAC;YACvB,IAAI,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC;YACtB,wCAAwC;YACxC,IAAI,SAAS,GAAG,GAAG,CAAC,SAAS,CAAC;YAC9B,IAAI,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AAM,EAAE,CAAC,CAAC,CAAC,CAAC;YACxG,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,IAAI,CAAC,OAAO,EAAE,CAAC;gBACf,MAAM,GAAG,CAAC;YACZ,CAAC;YACD,OAAO;gBACL,OAAO;oBACL,IAAI,CAAC,OAAO,EAAE,CAAC;gBACjB,CAAC;aACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haikit/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "Write haikit surface components in React: typed props and actions from the shared surface contract.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"haikit",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"prepack": "npm --prefix ../.. run build"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@haikit/client": "0.
|
|
32
|
-
"@haikit/core": "0.
|
|
31
|
+
"@haikit/client": "0.17.0",
|
|
32
|
+
"@haikit/core": "0.17.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"react": "^18.0.0 || ^19.0.0",
|
package/src/index.ts
CHANGED
|
@@ -48,13 +48,16 @@ export interface SurfaceProps<S extends AnySurface> {
|
|
|
48
48
|
*
|
|
49
49
|
* The first render is synchronous, so the surface has its height when the
|
|
50
50
|
* transcript scrolls to it; later ones are React's. It re-renders when the
|
|
51
|
-
* surface freezes or the conversation goes out of date,
|
|
52
|
-
* unmounted when the surface goes away, so effects clean up
|
|
51
|
+
* surface freezes, is revised in place, or the conversation goes out of date,
|
|
52
|
+
* and its root is unmounted when the surface goes away, so effects clean up
|
|
53
|
+
* after themselves. A revision keeps the component's own state.
|
|
53
54
|
*/
|
|
54
55
|
export function reactSurface<S extends AnySurface>(Component: ComponentType<SurfaceProps<S>>): ComponentDef<PropsOf<S>> {
|
|
55
56
|
return {
|
|
56
|
-
mount(element,
|
|
57
|
+
mount(element, firstProps, ctx) {
|
|
57
58
|
const root = createRoot(element);
|
|
59
|
+
// a revision brings new props; the component and its state stay
|
|
60
|
+
let props = firstProps;
|
|
58
61
|
let state = ctx.state;
|
|
59
62
|
// set when it is mounted already frozen
|
|
60
63
|
let selection = ctx.selection;
|
|
@@ -92,6 +95,10 @@ export function reactSurface<S extends AnySurface>(Component: ComponentType<Surf
|
|
|
92
95
|
unmount() {
|
|
93
96
|
root.unmount();
|
|
94
97
|
},
|
|
98
|
+
update(next) {
|
|
99
|
+
props = next;
|
|
100
|
+
draw();
|
|
101
|
+
},
|
|
95
102
|
};
|
|
96
103
|
},
|
|
97
104
|
};
|