@assistant-ui/react 0.14.19 → 0.14.21
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/context/react/utils/createContextStoreHook.d.ts.map +1 -1
- package/dist/context/react/utils/createContextStoreHook.js +3 -18
- package/dist/context/react/utils/createContextStoreHook.js.map +1 -1
- package/dist/utils/useToolArgsFieldStatus.d.ts +2 -2
- package/dist/utils/useToolArgsFieldStatus.d.ts.map +1 -1
- package/package.json +9 -9
- package/src/context/react/utils/createContextStoreHook.ts +4 -3
- package/src/legacy-runtime/runtime-cores/assistant-transport/replayBoundaryStream.test.ts +10 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createContextStoreHook.d.ts","names":[],"sources":["../../../../src/context/react/utils/createContextStoreHook.ts"],"mappings":";;;;;AASA;;;;iBAAgB,sBAAA,oBAA0C,CAAA,WACxD,WAAA,GAAc,OAAA;EAAY,QAAA;AAAA,MAAyB,CAAA,SACnD,UAAA,EAAY,CAAA,
|
|
1
|
+
{"version":3,"file":"createContextStoreHook.d.ts","names":[],"sources":["../../../../src/context/react/utils/createContextStoreHook.ts"],"mappings":";;;;;AASA;;;;iBAAgB,sBAAA,oBAA0C,CAAA,WACxD,WAAA,GAAc,OAAA;EAAY,QAAA;AAAA,MAAyB,CAAA,SACnD,UAAA,EAAY,CAAA,WA2DJ,CAAA;EAAA,0CAxDgD,CAAA;EAAA,YAiBzB,QAAA,GAClB,KAAA,EAAK,CAAA,CAAA,CAAA,UAAA,aAAA,YAlBsC,CAAA,aAkBtB,SAAA,GAC/B,SAAA;EAAA;IAC8B,QAAA;EAAA,KAAmB,CAAA,CAAA,CAAA,UAAA,aAAA,YApBI,CAAA;EAAA,YAqBzB,OAAA;IAC7B,QAAA;IACA,QAAA,IAAY,KAAA,EAAK,CAAA,CAAA,CAAA,UAAA,aAAA,YAvBqC,CAAA,aAuBrB,SAAA;EAAA,IAC/B,SAAA;AAAA,iBAkCO,CAAA;EAAA,IAvDmB,aAAA,CAAa,CAAA,CAAA,CAAA,UAAA,aAAA,YAHa,CAAA;EAAA;IAKtD,QAAA;EAAA,IACE,aAAA,CAAa,CAAA,CAAA,CAAA,UAAA,aAAA,YANuC,CAAA;AAAA"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
2
1
|
//#region src/context/react/utils/createContextStoreHook.ts
|
|
3
2
|
/**
|
|
4
3
|
* Creates hooks for accessing a store within a context.
|
|
@@ -13,7 +12,6 @@ function createContextStoreHook(contextHook, contextKey) {
|
|
|
13
12
|
return context[contextKey];
|
|
14
13
|
}
|
|
15
14
|
function useStoreHook(param) {
|
|
16
|
-
const $ = c(5);
|
|
17
15
|
let optional = false;
|
|
18
16
|
let selector;
|
|
19
17
|
if (typeof param === "function") selector = param;
|
|
@@ -21,22 +19,9 @@ function createContextStoreHook(contextHook, contextKey) {
|
|
|
21
19
|
optional = !!param.optional;
|
|
22
20
|
selector = param.selector;
|
|
23
21
|
}
|
|
24
|
-
|
|
25
|
-
if (
|
|
26
|
-
|
|
27
|
-
$[0] = optional;
|
|
28
|
-
$[1] = t0;
|
|
29
|
-
} else t0 = $[1];
|
|
30
|
-
const store = useStoreStoreHook(t0);
|
|
31
|
-
if (!store) return null;
|
|
32
|
-
let t1;
|
|
33
|
-
if ($[2] !== selector || $[3] !== store) {
|
|
34
|
-
t1 = selector ? store(selector) : store();
|
|
35
|
-
$[2] = selector;
|
|
36
|
-
$[3] = store;
|
|
37
|
-
$[4] = t1;
|
|
38
|
-
} else t1 = $[4];
|
|
39
|
-
return t1;
|
|
22
|
+
const useStore = useStoreStoreHook({ optional });
|
|
23
|
+
if (!useStore) return null;
|
|
24
|
+
return selector ? useStore(selector) : useStore();
|
|
40
25
|
}
|
|
41
26
|
return {
|
|
42
27
|
[contextKey]: useStoreHook,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createContextStoreHook.js","names":["UseBoundStore","ReadonlyStore","createContextStoreHook","T","contextHook","options","optional","contextKey","K","StoreType","StateType","S","useStoreStoreHook","context","useStoreHook","selector","state","TSelected","param","
|
|
1
|
+
{"version":3,"file":"createContextStoreHook.js","names":["UseBoundStore","ReadonlyStore","createContextStoreHook","T","contextHook","options","optional","contextKey","K","StoreType","StateType","S","useStoreStoreHook","context","useStoreHook","selector","state","TSelected","param","useStore"],"sources":["../../../../src/context/react/utils/createContextStoreHook.ts"],"sourcesContent":["import type { UseBoundStore } from \"zustand\";\nimport type { ReadonlyStore } from \"../../ReadonlyStore\";\n\n/**\n * Creates hooks for accessing a store within a context.\n * @param contextHook - The hook to access the context.\n * @param contextKey - The key of the store in the context.\n * @returns An object containing the hooks: `use...` and `use...Store`.\n */\nexport function createContextStoreHook<T, K extends keyof T & string>(\n contextHook: (options?: { optional?: boolean }) => T | null,\n contextKey: K,\n) {\n type StoreType = T[K];\n type StateType = StoreType extends ReadonlyStore<infer S> ? S : never;\n\n // Define useStoreStoreHook with overloads\n function useStoreStoreHook(): ReadonlyStore<StateType>;\n function useStoreStoreHook(options: {\n optional: true;\n }): ReadonlyStore<StateType> | null;\n function useStoreStoreHook(options?: {\n optional?: boolean;\n }): ReadonlyStore<StateType> | null {\n const context = contextHook(options);\n if (!context) return null;\n return context[contextKey] as ReadonlyStore<StateType>;\n }\n\n // Define useStoreHook with overloads\n function useStoreHook(): StateType;\n function useStoreHook<TSelected>(\n selector: (state: StateType) => TSelected,\n ): TSelected;\n function useStoreHook(options: { optional: true }): StateType | null;\n function useStoreHook<TSelected>(options: {\n optional: true;\n selector?: (state: StateType) => TSelected;\n }): TSelected | null;\n function useStoreHook<TSelected>(\n param?:\n | ((state: StateType) => TSelected)\n | {\n optional?: boolean;\n selector?: (state: StateType) => TSelected;\n },\n ): TSelected | StateType | null {\n let optional = false;\n let selector: ((state: StateType) => TSelected) | undefined;\n\n if (typeof param === \"function\") {\n selector = param;\n } else if (param && typeof param === \"object\") {\n optional = !!param.optional;\n selector = param.selector;\n }\n\n const useStore = useStoreStoreHook({\n optional,\n } as any) as UseBoundStore<ReadonlyStore<StateType>>;\n if (!useStore) return null;\n // oxlint-disable-next-line react-hooks/rules-of-hooks -- optional context returns before calling the dynamic Zustand hook\n return selector ? useStore(selector) : useStore();\n }\n\n // Return an object with keys based on contextKey\n return {\n [contextKey]: useStoreHook,\n [`${contextKey}Store`]: useStoreStoreHook,\n } as {\n [P in K]: typeof useStoreHook;\n } & {\n [P in `${K}Store`]: typeof useStoreStoreHook;\n };\n}\n"],"mappings":";;;;;;;AASA,SAAgBE,uBACdE,aACAG,YACA;CASA,SAASK,kBAAkBP,SAES;EAClC,MAAMQ,UAAUT,YAAYC,OAAO;EACnC,IAAI,CAACQ,SAAS,OAAO;EACrB,OAAOA,QAAQN;CACjB;CAYA,SAASO,aACPI,OAM8B;EAC9B,IAAIZ,WAAW;EACf,IAAIS;EAEJ,IAAI,OAAOG,UAAU,YACnBH,WAAWG;OACN,IAAIA,SAAS,OAAOA,UAAU,UAAU;GAC7CZ,WAAW,CAAC,CAACY,MAAMZ;GACnBS,WAAWG,MAAMH;EACnB;EAEA,MAAMI,WAAWP,kBAAkB,EACjCN,SACF,CAAQ;EACR,IAAI,CAACa,UAAU,OAAO;EAEtB,OAAOJ,WAAWI,SAASJ,QAAQ,IAAII,SAAS;CAClD;CAGA,OAAO;GACJZ,aAAaO;GACb,GAAGP,WAAU,SAAUK;CAC1B;AAKF"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
//#region src/utils/useToolArgsFieldStatus.d.ts
|
|
2
2
|
declare const useToolArgsFieldStatus: (fieldPath: (string | number)[]) => {
|
|
3
|
-
type: string;
|
|
4
|
-
} | {
|
|
5
3
|
readonly type: "running";
|
|
6
4
|
} | {
|
|
7
5
|
readonly type: "complete";
|
|
@@ -9,6 +7,8 @@ declare const useToolArgsFieldStatus: (fieldPath: (string | number)[]) => {
|
|
|
9
7
|
readonly type: "incomplete";
|
|
10
8
|
readonly reason: "cancelled" | "length" | "content-filter" | "other" | "error";
|
|
11
9
|
readonly error?: unknown;
|
|
10
|
+
} | {
|
|
11
|
+
type: string;
|
|
12
12
|
};
|
|
13
13
|
//#endregion
|
|
14
14
|
export { useToolArgsFieldStatus };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useToolArgsFieldStatus.d.ts","names":[],"sources":["../../src/utils/useToolArgsFieldStatus.ts"],"mappings":";cAKa,sBAAA,GAA0B,SAAA"}
|
|
1
|
+
{"version":3,"file":"useToolArgsFieldStatus.d.ts","names":[],"sources":["../../src/utils/useToolArgsFieldStatus.ts"],"mappings":";cAKa,sBAAA,GAA0B,SAAA;EAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@assistant-ui/react",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.21",
|
|
4
4
|
"description": "Open-source TypeScript/React library for building production-grade AI chat experiences",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -55,17 +55,17 @@
|
|
|
55
55
|
],
|
|
56
56
|
"sideEffects": false,
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@assistant-ui/core": "^0.2.
|
|
59
|
-
"@assistant-ui/store": "^0.2.
|
|
60
|
-
"@assistant-ui/tap": "^0.
|
|
58
|
+
"@assistant-ui/core": "^0.2.16",
|
|
59
|
+
"@assistant-ui/store": "^0.2.18",
|
|
60
|
+
"@assistant-ui/tap": "^0.9.2",
|
|
61
61
|
"@radix-ui/primitive": "^1.1.4",
|
|
62
62
|
"@radix-ui/react-compose-refs": "^1.1.3",
|
|
63
63
|
"@radix-ui/react-context": "^1.1.4",
|
|
64
64
|
"@radix-ui/react-primitive": "^2.1.5",
|
|
65
65
|
"@radix-ui/react-use-callback-ref": "^1.1.2",
|
|
66
66
|
"@radix-ui/react-use-escape-keydown": "^1.1.2",
|
|
67
|
-
"assistant-cloud": "^0.1.
|
|
68
|
-
"assistant-stream": "^0.3.
|
|
67
|
+
"assistant-cloud": "^0.1.33",
|
|
68
|
+
"assistant-stream": "^0.3.23",
|
|
69
69
|
"nanoid": "^5.1.11",
|
|
70
70
|
"radix-ui": "^1.5.0",
|
|
71
71
|
"react-textarea-autosize": "^8.5.9",
|
|
@@ -90,15 +90,15 @@
|
|
|
90
90
|
"devDependencies": {
|
|
91
91
|
"@testing-library/react": "^16.3.2",
|
|
92
92
|
"@types/json-schema": "^7.0.15",
|
|
93
|
-
"@types/node": "^25.9.
|
|
93
|
+
"@types/node": "^25.9.3",
|
|
94
94
|
"@types/react": "^19.2.17",
|
|
95
95
|
"@types/react-dom": "^19.2.3",
|
|
96
96
|
"jsdom": "^29.1.1",
|
|
97
97
|
"react": "^19.2.7",
|
|
98
98
|
"react-dom": "^19.2.7",
|
|
99
99
|
"vitest": "^4.1.8",
|
|
100
|
-
"@assistant-ui/vite": "0.0.
|
|
101
|
-
"@assistant-ui/x-buildutils": "0.0.
|
|
100
|
+
"@assistant-ui/vite": "0.0.5",
|
|
101
|
+
"@assistant-ui/x-buildutils": "0.0.15"
|
|
102
102
|
},
|
|
103
103
|
"publishConfig": {
|
|
104
104
|
"access": "public",
|
|
@@ -55,11 +55,12 @@ export function createContextStoreHook<T, K extends keyof T & string>(
|
|
|
55
55
|
selector = param.selector;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
const
|
|
58
|
+
const useStore = useStoreStoreHook({
|
|
59
59
|
optional,
|
|
60
60
|
} as any) as UseBoundStore<ReadonlyStore<StateType>>;
|
|
61
|
-
if (!
|
|
62
|
-
|
|
61
|
+
if (!useStore) return null;
|
|
62
|
+
// oxlint-disable-next-line react-hooks/rules-of-hooks -- optional context returns before calling the dynamic Zustand hook
|
|
63
|
+
return selector ? useStore(selector) : useStore();
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
// Return an object with keys based on contextKey
|
|
@@ -29,12 +29,16 @@ const createResponse = (
|
|
|
29
29
|
chunks: readonly string[],
|
|
30
30
|
replayContentLength?: number | string,
|
|
31
31
|
) =>
|
|
32
|
-
new Response(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
new Response(
|
|
33
|
+
createBody(chunks),
|
|
34
|
+
replayContentLength === undefined
|
|
35
|
+
? undefined
|
|
36
|
+
: {
|
|
37
|
+
headers: {
|
|
38
|
+
[REPLAY_CONTENT_LENGTH_HEADER]: String(replayContentLength),
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
);
|
|
38
42
|
|
|
39
43
|
const createRenderWait = () => {
|
|
40
44
|
const pending: Array<() => void> = [];
|