@assistant-ui/react 0.14.20 → 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.
@@ -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,WA0DJ,CAAA;EAAA,0CAvDgD,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,iBAiCO,CAAA;EAAA,IAtDmB,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
+ {"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
- let t0;
25
- if ($[0] !== optional) {
26
- t0 = { optional };
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","$","_c","t0","store","t1"],"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 store = useStoreStoreHook({\n optional,\n } as any) as UseBoundStore<ReadonlyStore<StateType>>;\n if (!store) return null;\n return selector ? store(selector) : store();\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,SAAAO,aAAAI,OAAA;EAAA,MAAAC,IAAAC,EAAA,CAAA;EAQE,IAAAd,WAAe;EACXS,IAAAA;EAEJ,IAAI,OAAOG,UAAU,YACnBH,WAAWG;OACN,IAAIA,SAAS,OAAOA,UAAU,UAAQ;GAC3CZ,WAAWA,CAACA,CAACY,MAAKZ;GAClBS,WAAWG,MAAKH;EAAR;EACT,IAAAM;EAAA,IAAAF,EAAA,OAAAb,UAAA;GAE+Be,KAAA,EAAAf,SAEhC;GAACa,EAAA,KAAAb;GAAAa,EAAA,KAAAE;EAAA,OAAAA,KAAAF,EAAA;EAFD,MAAAG,QAAcV,kBAAkBS,EAExB;EACR,IAAI,CAACC,OAAK,OAAS;EAAK,IAAAC;EAAA,IAAAJ,EAAA,OAAAJ,YAAAI,EAAA,OAAAG,OAAA;GACjBC,KAAAR,WAAWO,MAAMP,QAAkB,IAANO,MAAM;GAACH,EAAA,KAAAJ;GAAAI,EAAA,KAAAG;GAAAH,EAAA,KAAAI;EAAA,OAAAA,KAAAJ,EAAA;EAAA,OAApCI;CAAoC;CAI7C,OAAO;GACJhB,aAAaO;GACb,GAAGP,WAAU,SAAUK;CAC1B;AAKF"}
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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@assistant-ui/react",
3
- "version": "0.14.20",
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",
@@ -57,7 +57,7 @@
57
57
  "dependencies": {
58
58
  "@assistant-ui/core": "^0.2.16",
59
59
  "@assistant-ui/store": "^0.2.18",
60
- "@assistant-ui/tap": "^0.9.1",
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",
@@ -98,7 +98,7 @@
98
98
  "react-dom": "^19.2.7",
99
99
  "vitest": "^4.1.8",
100
100
  "@assistant-ui/vite": "0.0.5",
101
- "@assistant-ui/x-buildutils": "0.0.14"
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 store = useStoreStoreHook({
58
+ const useStore = useStoreStoreHook({
59
59
  optional,
60
60
  } as any) as UseBoundStore<ReadonlyStore<StateType>>;
61
- if (!store) return null;
62
- return selector ? store(selector) : store();
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