@assistant-ui/store 0.2.10 → 0.2.12

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.
Files changed (94) hide show
  1. package/README.md +36 -65
  2. package/dist/AuiIf.d.ts +43 -8
  3. package/dist/AuiIf.d.ts.map +1 -1
  4. package/dist/AuiIf.js +28 -3
  5. package/dist/AuiIf.js.map +1 -1
  6. package/dist/Derived.d.ts +15 -13
  7. package/dist/Derived.d.ts.map +1 -1
  8. package/dist/Derived.js +24 -20
  9. package/dist/Derived.js.map +1 -1
  10. package/dist/RenderChildrenWithAccessor.d.ts +13 -6
  11. package/dist/RenderChildrenWithAccessor.d.ts.map +1 -1
  12. package/dist/RenderChildrenWithAccessor.js +42 -48
  13. package/dist/RenderChildrenWithAccessor.js.map +1 -1
  14. package/dist/attachTransformScopes.d.ts +11 -10
  15. package/dist/attachTransformScopes.d.ts.map +1 -1
  16. package/dist/attachTransformScopes.js +20 -23
  17. package/dist/attachTransformScopes.js.map +1 -1
  18. package/dist/index.d.ts +15 -16
  19. package/dist/index.js +14 -18
  20. package/dist/tapClientList.d.ts +26 -23
  21. package/dist/tapClientList.d.ts.map +1 -1
  22. package/dist/tapClientList.js +66 -63
  23. package/dist/tapClientList.js.map +1 -1
  24. package/dist/tapClientLookup.d.ts +14 -11
  25. package/dist/tapClientLookup.d.ts.map +1 -1
  26. package/dist/tapClientLookup.js +31 -37
  27. package/dist/tapClientLookup.js.map +1 -1
  28. package/dist/tapClientResource.d.ts +12 -9
  29. package/dist/tapClientResource.d.ts.map +1 -1
  30. package/dist/tapClientResource.js +92 -104
  31. package/dist/tapClientResource.js.map +1 -1
  32. package/dist/types/client.d.ts +50 -42
  33. package/dist/types/client.d.ts.map +1 -1
  34. package/dist/types/client.js +0 -2
  35. package/dist/types/events.d.ts +23 -24
  36. package/dist/types/events.d.ts.map +1 -1
  37. package/dist/types/events.js +13 -6
  38. package/dist/types/events.js.map +1 -1
  39. package/dist/useAui.d.ts +76 -15
  40. package/dist/useAui.d.ts.map +1 -1
  41. package/dist/useAui.js +178 -175
  42. package/dist/useAui.js.map +1 -1
  43. package/dist/useAuiEvent.d.ts +47 -2
  44. package/dist/useAuiEvent.d.ts.map +1 -1
  45. package/dist/useAuiEvent.js +60 -7
  46. package/dist/useAuiEvent.js.map +1 -1
  47. package/dist/useAuiState.d.ts +31 -10
  48. package/dist/useAuiState.d.ts.map +1 -1
  49. package/dist/useAuiState.js +44 -25
  50. package/dist/useAuiState.js.map +1 -1
  51. package/dist/utils/BaseProxyHandler.d.ts +19 -16
  52. package/dist/utils/BaseProxyHandler.d.ts.map +1 -1
  53. package/dist/utils/BaseProxyHandler.js +46 -43
  54. package/dist/utils/BaseProxyHandler.js.map +1 -1
  55. package/dist/utils/NotificationManager.d.ts +13 -9
  56. package/dist/utils/NotificationManager.d.ts.map +1 -1
  57. package/dist/utils/NotificationManager.js +69 -82
  58. package/dist/utils/NotificationManager.js.map +1 -1
  59. package/dist/utils/proxied-assistant-state.d.ts +8 -4
  60. package/dist/utils/proxied-assistant-state.d.ts.map +1 -1
  61. package/dist/utils/proxied-assistant-state.js +28 -26
  62. package/dist/utils/proxied-assistant-state.js.map +1 -1
  63. package/dist/utils/react-assistant-context.d.ts +31 -13
  64. package/dist/utils/react-assistant-context.d.ts.map +1 -1
  65. package/dist/utils/react-assistant-context.js +69 -56
  66. package/dist/utils/react-assistant-context.js.map +1 -1
  67. package/dist/utils/splitClients.d.ts +12 -8
  68. package/dist/utils/splitClients.d.ts.map +1 -1
  69. package/dist/utils/splitClients.js +39 -43
  70. package/dist/utils/splitClients.js.map +1 -1
  71. package/dist/utils/tap-assistant-context.d.ts +17 -14
  72. package/dist/utils/tap-assistant-context.d.ts.map +1 -1
  73. package/dist/utils/tap-assistant-context.js +18 -15
  74. package/dist/utils/tap-assistant-context.js.map +1 -1
  75. package/dist/utils/tap-client-stack-context.d.ts +10 -6
  76. package/dist/utils/tap-client-stack-context.d.ts.map +1 -1
  77. package/dist/utils/tap-client-stack-context.js +22 -19
  78. package/dist/utils/tap-client-stack-context.js.map +1 -1
  79. package/dist/wrapperResource.d.ts +6 -2
  80. package/dist/wrapperResource.d.ts.map +1 -1
  81. package/dist/wrapperResource.js +12 -9
  82. package/dist/wrapperResource.js.map +1 -1
  83. package/package.json +7 -7
  84. package/src/AuiIf.ts +35 -1
  85. package/src/Derived.ts +1 -1
  86. package/src/types/client.ts +1 -2
  87. package/src/useAui.ts +101 -32
  88. package/src/useAuiEvent.ts +41 -0
  89. package/src/useAuiState.ts +25 -8
  90. package/src/utils/react-assistant-context.tsx +18 -5
  91. package/src/utils/splitClients.ts +4 -2
  92. package/dist/index.d.ts.map +0 -1
  93. package/dist/index.js.map +0 -1
  94. package/dist/types/client.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"useAui.d.ts","sourceRoot":"","sources":["../src/useAui.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EACV,eAAe,EAEf,WAAW,EACX,aAAa,EAEd,0BAAuB;AACxB,OAAO,KAAK,EAAW,cAAc,EAAE,qBAAkB;AA2QzD;;GAEG;AACH,eAAO,MAAM,uBAAuB;YAKxB,eAAe;aACd,MAAM,CAAC,KAAK;;YADb,eAAe;aACd,MAAM,CAAC,KAAK;EAwDxB,CAAC;AAEF,yBAAiB,MAAM,CAAC;IACtB,KAAY,KAAK,GAAG;SACjB,CAAC,IAAI,WAAW,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC;KAC1D,CAAC;CACH;AAED,wBAAgB,MAAM,IAAI,eAAe,CAAC;AAC1C,wBAAgB,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,GAAG,eAAe,CAAC;AAC/D,wBAAgB,MAAM,CACpB,OAAO,EAAE,MAAM,CAAC,KAAK,EACrB,MAAM,EAAE;IAAE,MAAM,EAAE,IAAI,GAAG,eAAe,CAAA;CAAE,GACzC,eAAe,CAAC"}
1
+ {"version":3,"file":"useAui.d.ts","names":[],"sources":["../src/useAui.ts"],"mappings":";;;;;;AA6SA;cAAa,uBAAA,GAAuB,KAAA;UAKxB,eAAA;WACC,MAAA,CAAO,KAAA;AAAA;UADR,eAAA;WACC,MAAA,CAAO,KAAA;AAAA;AAAA,kBA0DH,MAAA;EAAA,KACH,KAAA,WACJ,WAAA,IAAe,aAAA,CAAc,CAAA,IAAK,cAAA,CAAe,CAAA;AAAA;;;;;;;;;;;;AA5DlC;AA0DzB;;;;;;;;;;;;;;;;;;AAE4D;AAuC5D;;;;iBAAgB,MAAA,CAAA,GAAU,eAAe;AAsBzC;;;;;;;;;AAA8D;AAI9D;;;;;;;;;;;AAJA,iBAAgB,MAAA,CAAO,OAAA,EAAS,MAAA,CAAO,KAAA,GAAQ,eAAe;;;;iBAI9C,MAAA,CACd,OAAA,EAAS,MAAA,CAAO,KAAA,EAChB,MAAA;EAAU,MAAA,SAAe,eAAA;AAAA,IACxB,eAAA"}
package/dist/useAui.js CHANGED
@@ -1,192 +1,195 @@
1
1
  "use client";
2
- import { useResource } from "@assistant-ui/tap/react";
3
- import { resource, tapMemo, tapResources, tapEffectEvent, tapEffect, tapRef, tapResource, withKey, tapResourceRoot, } from "@assistant-ui/tap";
4
- import { useAssistantContextValue, DefaultAssistantClient, createRootAssistantClient, } from "./utils/react-assistant-context.js";
5
- import { tapSplitClients, } from "./utils/splitClients.js";
6
- import { normalizeEventSelector, } from "./types/events.js";
2
+ import { getClientIndex } from "./utils/tap-client-stack-context.js";
3
+ import { tapClientResource } from "./tapClientResource.js";
4
+ import { PROXIED_ASSISTANT_STATE_SYMBOL, createProxiedAssistantState } from "./utils/proxied-assistant-state.js";
5
+ import { DefaultAssistantClient, createRootAssistantClient, useAssistantContextValue } from "./utils/react-assistant-context.js";
6
+ import { tapSplitClients } from "./utils/splitClients.js";
7
+ import { normalizeEventSelector } from "./types/events.js";
7
8
  import { NotificationManager } from "./utils/NotificationManager.js";
8
9
  import { withAssistantTapContextProvider } from "./utils/tap-assistant-context.js";
9
- import { tapClientResource } from "./tapClientResource.js";
10
- import { getClientIndex } from "./utils/tap-client-stack-context.js";
11
- import { PROXIED_ASSISTANT_STATE_SYMBOL, createProxiedAssistantState, } from "./utils/proxied-assistant-state.js";
10
+ import { useResource } from "@assistant-ui/tap/react";
11
+ import { resource, tapEffect, tapMemo, tapRef, tapResource, tapResourceRoot, tapResources, withKey } from "@assistant-ui/tap";
12
+ //#region src/useAui.ts
12
13
  const tapShallowMemoArray = (array) => {
13
- // biome-ignore lint/correctness/useExhaustiveDependencies: shallow memo
14
- return tapMemo(() => array, array);
14
+ return tapMemo(() => array, array);
15
15
  };
16
- const RootClientResource = resource(({ element, emit, clientRef, }) => {
17
- const { methods, state } = withAssistantTapContextProvider({ clientRef, emit }, () => tapClientResource(element));
18
- return tapMemo(() => ({ state, methods }), [methods, state]);
16
+ const RootClientResource = resource(({ element, emit, clientRef }) => {
17
+ const { methods, state } = withAssistantTapContextProvider({
18
+ clientRef,
19
+ emit
20
+ }, () => tapClientResource(element));
21
+ return tapMemo(() => ({
22
+ state,
23
+ methods
24
+ }), [methods, state]);
19
25
  });
20
- const RootClientAccessorResource = resource(({ element, notifications, clientRef, name, }) => {
21
- const store = tapResourceRoot(RootClientResource({ element, emit: notifications.emit, clientRef }));
22
- tapEffect(() => {
23
- return store.subscribe(notifications.notifySubscribers);
24
- }, [store, notifications]);
25
- return tapMemo(() => {
26
- const clientFunction = () => store.getValue().methods;
27
- Object.defineProperties(clientFunction, {
28
- source: {
29
- value: "root",
30
- writable: false,
31
- },
32
- query: {
33
- value: {},
34
- writable: false,
35
- },
36
- name: {
37
- value: name,
38
- configurable: true,
39
- },
40
- });
41
- return clientFunction;
42
- }, [store, name]);
26
+ const RootClientAccessorResource = resource(({ element, notifications, clientRef, name }) => {
27
+ const store = tapResourceRoot(RootClientResource({
28
+ element,
29
+ emit: notifications.emit,
30
+ clientRef
31
+ }));
32
+ tapEffect(() => {
33
+ return store.subscribe(notifications.notifySubscribers);
34
+ }, [store, notifications]);
35
+ return tapMemo(() => {
36
+ const clientFunction = () => store.getValue().methods;
37
+ Object.defineProperties(clientFunction, {
38
+ source: {
39
+ value: "root",
40
+ writable: false
41
+ },
42
+ query: {
43
+ value: {},
44
+ writable: false
45
+ },
46
+ name: {
47
+ value: name,
48
+ configurable: true
49
+ }
50
+ });
51
+ return clientFunction;
52
+ }, [store, name]);
43
53
  });
44
54
  const NoOpRootClientsAccessorsResource = resource(() => {
45
- return tapMemo(() => ({
46
- clients: [],
47
- subscribe: undefined,
48
- on: undefined,
49
- }), []);
55
+ return tapMemo(() => ({
56
+ clients: [],
57
+ subscribe: void 0,
58
+ on: void 0
59
+ }), []);
50
60
  });
51
- const RootClientsAccessorsResource = resource(({ clients: inputClients, clientRef, }) => {
52
- const notifications = tapResource(NotificationManager());
53
- tapEffect(() => clientRef.parent.subscribe(notifications.notifySubscribers), [clientRef, notifications]);
54
- const results = tapShallowMemoArray(tapResources(() => Object.keys(inputClients).map((key) => withKey(key, RootClientAccessorResource({
55
- element: inputClients[key],
56
- notifications,
57
- clientRef,
58
- name: key,
59
- }))), [inputClients, notifications, clientRef]));
60
- return tapMemo(() => {
61
- return {
62
- clients: results,
63
- subscribe: notifications.subscribe,
64
- on: function (selector, callback) {
65
- if (!this) {
66
- throw new Error("const { on } = useAui() is not supported. Use aui.on() instead.");
67
- }
68
- const { scope, event } = normalizeEventSelector(selector);
69
- if (scope !== "*") {
70
- const source = this[scope].source;
71
- if (source === null) {
72
- throw new Error(`Scope "${scope}" is not available. Use { scope: "*", event: "${event}" } to listen globally.`);
73
- }
74
- }
75
- const localUnsub = notifications.on(event, (payload, clientStack) => {
76
- if (scope === "*") {
77
- callback(payload);
78
- return;
79
- }
80
- const scopeClient = this[scope]();
81
- const index = getClientIndex(scopeClient);
82
- if (scopeClient === clientStack[index]) {
83
- callback(payload);
84
- }
85
- });
86
- if (scope !== "*" &&
87
- clientRef.parent[scope].source === null)
88
- return localUnsub;
89
- const parentUnsub = clientRef.parent.on(selector, callback);
90
- return () => {
91
- localUnsub();
92
- parentUnsub();
93
- };
94
- },
95
- };
96
- }, [results, notifications, clientRef]);
61
+ const RootClientsAccessorsResource = resource(({ clients: inputClients, clientRef }) => {
62
+ const notifications = tapResource(NotificationManager());
63
+ tapEffect(() => clientRef.parent.subscribe(notifications.notifySubscribers), [clientRef, notifications]);
64
+ const results = tapShallowMemoArray(tapResources(() => Object.keys(inputClients).map((key) => withKey(key, RootClientAccessorResource({
65
+ element: inputClients[key],
66
+ notifications,
67
+ clientRef,
68
+ name: key
69
+ }))), [
70
+ inputClients,
71
+ notifications,
72
+ clientRef
73
+ ]));
74
+ return tapMemo(() => {
75
+ return {
76
+ clients: results,
77
+ subscribe: notifications.subscribe,
78
+ on: function(selector, callback) {
79
+ if (!this) throw new Error("const { on } = useAui() is not supported. Use aui.on() instead.");
80
+ const { scope, event } = normalizeEventSelector(selector);
81
+ if (scope !== "*") {
82
+ if (this[scope].source === null) throw new Error(`Scope "${scope}" is not available. Use { scope: "*", event: "${event}" } to listen globally.`);
83
+ }
84
+ const localUnsub = notifications.on(event, (payload, clientStack) => {
85
+ if (scope === "*") {
86
+ callback(payload);
87
+ return;
88
+ }
89
+ const scopeClient = this[scope]();
90
+ if (scopeClient === clientStack[getClientIndex(scopeClient)]) callback(payload);
91
+ });
92
+ if (scope !== "*" && clientRef.parent[scope].source === null) return localUnsub;
93
+ const parentUnsub = clientRef.parent.on(selector, callback);
94
+ return () => {
95
+ localUnsub();
96
+ parentUnsub();
97
+ };
98
+ }
99
+ };
100
+ }, [
101
+ results,
102
+ notifications,
103
+ clientRef
104
+ ]);
97
105
  });
98
- const getMeta = (props, clientRef, memo) => {
99
- if ("source" in props && "query" in props)
100
- return props;
101
- if (memo.dep === props)
102
- return memo.meta;
103
- const meta = props.getMeta(clientRef.current);
104
- memo.meta = meta;
105
- memo.dep = props;
106
- return meta;
107
- };
108
- const DerivedClientAccessorResource = resource(({ element, clientRef, name, }) => {
109
- const get = tapEffectEvent(() => element.props);
110
- return tapMemo(() => {
111
- const clientFunction = () => get().get(clientRef.current);
112
- const metaMemo = {};
113
- Object.defineProperties(clientFunction, {
114
- source: {
115
- get: () => getMeta(get(), clientRef, metaMemo).source,
116
- },
117
- query: {
118
- get: () => getMeta(get(), clientRef, metaMemo).query,
119
- },
120
- name: {
121
- value: name,
122
- configurable: true,
123
- },
124
- });
125
- return clientFunction;
126
- }, [clientRef, name]);
106
+ const DerivedClientAccessorResource = resource(({ element, clientRef, name }) => {
107
+ const propsRef = tapRef(element.props);
108
+ propsRef.current = element.props;
109
+ return tapMemo(() => {
110
+ const clientFunction = () => propsRef.current.get(clientRef.current);
111
+ Object.defineProperties(clientFunction, {
112
+ source: { value: propsRef.current.source },
113
+ query: { value: propsRef.current.query },
114
+ name: {
115
+ value: name,
116
+ configurable: true
117
+ }
118
+ });
119
+ return clientFunction;
120
+ }, [clientRef, name]);
127
121
  });
128
- const DerivedClientsAccessorsResource = resource(({ clients, clientRef, }) => {
129
- return tapShallowMemoArray(tapResources(() => Object.keys(clients).map((key) => withKey(key, DerivedClientAccessorResource({
130
- element: clients[key],
131
- clientRef,
132
- name: key,
133
- }))), [clients, clientRef]));
122
+ const serializeMeta = (name, meta) => {
123
+ let queryKey;
124
+ try {
125
+ const sorted = {};
126
+ for (const k of Object.keys(meta.query).sort()) sorted[k] = meta.query[k];
127
+ queryKey = JSON.stringify(sorted);
128
+ } catch {
129
+ queryKey = String(meta.query);
130
+ }
131
+ return `${name}::${meta.source}::${queryKey}`;
132
+ };
133
+ const DerivedClientsAccessorsResource = resource(({ clients, clientRef }) => {
134
+ return tapShallowMemoArray(tapResources(() => Object.keys(clients).map((key) => {
135
+ const name = key;
136
+ const element = clients[name];
137
+ return withKey(serializeMeta(name, element.props), DerivedClientAccessorResource({
138
+ element,
139
+ clientRef,
140
+ name
141
+ }));
142
+ }), [clients, clientRef]));
134
143
  });
135
144
  /**
136
- * Resource that creates an extended AssistantClient.
137
- */
138
- export const AssistantClientResource = resource(({ parent, clients, }) => {
139
- const { rootClients, derivedClients } = tapSplitClients(clients, parent);
140
- const clientRef = tapRef({
141
- parent: parent,
142
- current: null,
143
- }).current;
144
- tapEffect(() => {
145
- // if (clientRef.current && clientRef.current !== client)
146
- // throw new Error("clientRef.current !== client");
147
- clientRef.current = client;
148
- });
149
- const rootFields = tapResource(Object.keys(rootClients).length > 0
150
- ? RootClientsAccessorsResource({ clients: rootClients, clientRef })
151
- : NoOpRootClientsAccessorsResource());
152
- const derivedFields = tapResource(DerivedClientsAccessorsResource({ clients: derivedClients, clientRef }));
153
- const client = tapMemo(() => {
154
- // Swap DefaultAssistantClient -> createRootAssistantClient at root to change error message
155
- const proto = parent === DefaultAssistantClient
156
- ? createRootAssistantClient()
157
- : parent;
158
- const client = Object.create(proto);
159
- Object.assign(client, {
160
- subscribe: rootFields.subscribe ?? parent.subscribe,
161
- on: rootFields.on ?? parent.on,
162
- [PROXIED_ASSISTANT_STATE_SYMBOL]: createProxiedAssistantState(client),
163
- });
164
- for (const field of rootFields.clients) {
165
- client[field.name] = field;
166
- }
167
- for (const field of derivedFields) {
168
- client[field.name] = field;
169
- }
170
- return client;
171
- }, [parent, rootFields, derivedFields]);
172
- if (clientRef.current === null) {
173
- clientRef.current = client;
174
- }
175
- return client;
145
+ * Resource that creates an extended AssistantClient.
146
+ */
147
+ const AssistantClientResource = resource(({ parent, clients }) => {
148
+ const { rootClients, derivedClients } = tapSplitClients(clients, parent);
149
+ const clientRef = tapRef({
150
+ parent,
151
+ current: null
152
+ }).current;
153
+ tapEffect(() => {
154
+ clientRef.current = client;
155
+ });
156
+ const rootFields = tapResource(Object.keys(rootClients).length > 0 ? RootClientsAccessorsResource({
157
+ clients: rootClients,
158
+ clientRef
159
+ }) : NoOpRootClientsAccessorsResource());
160
+ const derivedFields = tapResource(DerivedClientsAccessorsResource({
161
+ clients: derivedClients,
162
+ clientRef
163
+ }));
164
+ const client = tapMemo(() => {
165
+ const proto = parent === DefaultAssistantClient ? createRootAssistantClient() : parent;
166
+ const client = Object.create(proto);
167
+ Object.assign(client, {
168
+ subscribe: rootFields.subscribe ?? parent.subscribe,
169
+ on: rootFields.on ?? parent.on,
170
+ [PROXIED_ASSISTANT_STATE_SYMBOL]: createProxiedAssistantState(client)
171
+ });
172
+ for (const field of rootFields.clients) client[field.name] = field;
173
+ for (const field of derivedFields) client[field.name] = field;
174
+ return client;
175
+ }, [
176
+ parent,
177
+ rootFields,
178
+ derivedFields
179
+ ]);
180
+ if (clientRef.current === null) clientRef.current = client;
181
+ return client;
176
182
  });
177
183
  /** @deprecated This API is highly experimental and may be changed in a minor release */
178
- export function useAui(clients, { parent } = {
179
- parent: useAssistantContextValue(),
180
- }) {
181
- if (clients) {
182
- // biome-ignore lint/correctness/useHookAtTopLevel: intentional conditional/nested hook usage
183
- return useResource(AssistantClientResource({
184
- parent: parent ?? DefaultAssistantClient,
185
- clients,
186
- }));
187
- }
188
- if (parent === null)
189
- throw new Error("received null parent, this usage is not allowed");
190
- return parent;
184
+ function useAui(clients, { parent } = { parent: useAssistantContextValue() }) {
185
+ if (clients) return useResource(AssistantClientResource({
186
+ parent: parent ?? DefaultAssistantClient,
187
+ clients
188
+ }));
189
+ if (parent === null) throw new Error("received null parent, this usage is not allowed");
190
+ return parent;
191
191
  }
192
+ //#endregion
193
+ export { AssistantClientResource, useAui };
194
+
192
195
  //# sourceMappingURL=useAui.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useAui.js","sourceRoot":"","sources":["../src/useAui.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EACL,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,cAAc,EACd,SAAS,EACT,MAAM,EACN,WAAW,EACX,OAAO,EACP,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAS3B,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,yBAAyB,GAC1B,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,KAAK,CAAC;QACtC,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC,CAAC;IAExC,IAAI,SAAS,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;QAC/B,SAAS,CAAC,OAAO,GAAG,MAAM,CAAC;IAC7B,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CACF,CAAC;AAcF,wFAAwF;AACxF,MAAM,UAAU,MAAM,CACpB,OAAsB,EACtB,EAAE,MAAM,KAAyC;IAC/C,MAAM,EAAE,wBAAwB,EAAE;CACnC;IAED,IAAI,OAAO,EAAE,CAAC;QACZ,6FAA6F;QAC7F,OAAO,WAAW,CAChB,uBAAuB,CAAC;YACtB,MAAM,EAAE,MAAM,IAAI,sBAAsB;YACxC,OAAO;SACR,CAAC,CACH,CAAC;IACJ,CAAC;IACD,IAAI,MAAM,KAAK,IAAI;QACjB,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IACrE,OAAO,MAAM,CAAC;AAChB,CAAC"}
1
+ {"version":3,"file":"useAui.js","names":[],"sources":["../src/useAui.ts"],"sourcesContent":["\"use client\";\n\nimport { useResource } from \"@assistant-ui/tap/react\";\nimport {\n resource,\n tapMemo,\n tapResources,\n tapEffect,\n tapRef,\n tapResource,\n withKey,\n tapResourceRoot,\n} from \"@assistant-ui/tap\";\nimport type {\n AssistantClient,\n AssistantClientAccessor,\n ClientNames,\n ClientElement,\n ClientMeta,\n} from \"./types/client\";\nimport type { DerivedElement } from \"./Derived\";\nimport {\n useAssistantContextValue,\n DefaultAssistantClient,\n createRootAssistantClient,\n} from \"./utils/react-assistant-context\";\nimport {\n type DerivedClients,\n type RootClients,\n tapSplitClients,\n} from \"./utils/splitClients\";\nimport {\n normalizeEventSelector,\n type AssistantEventName,\n type AssistantEventCallback,\n type AssistantEventSelector,\n} from \"./types/events\";\nimport { NotificationManager } from \"./utils/NotificationManager\";\nimport { withAssistantTapContextProvider } from \"./utils/tap-assistant-context\";\nimport { tapClientResource } from \"./tapClientResource\";\nimport { getClientIndex } from \"./utils/tap-client-stack-context\";\nimport {\n PROXIED_ASSISTANT_STATE_SYMBOL,\n createProxiedAssistantState,\n} from \"./utils/proxied-assistant-state\";\n\nconst tapShallowMemoArray = <T>(array: readonly T[]) => {\n // biome-ignore lint/correctness/useExhaustiveDependencies: shallow memo\n return tapMemo(() => array, array);\n};\n\nconst RootClientResource = resource(\n <K extends ClientNames>({\n element,\n emit,\n clientRef,\n }: {\n element: ClientElement<K>;\n emit: NotificationManager[\"emit\"];\n clientRef: { parent: AssistantClient; current: AssistantClient | null };\n }) => {\n const { methods, state } = withAssistantTapContextProvider(\n { clientRef, emit },\n () => tapClientResource(element),\n );\n return tapMemo(() => ({ state, methods }), [methods, state]);\n },\n);\n\nconst RootClientAccessorResource = resource(\n <K extends ClientNames>({\n element,\n notifications,\n clientRef,\n name,\n }: {\n element: ClientElement<K>;\n notifications: NotificationManager;\n clientRef: { parent: AssistantClient; current: AssistantClient | null };\n name: K;\n }): AssistantClientAccessor<K> => {\n const store = tapResourceRoot(\n RootClientResource({ element, emit: notifications.emit, clientRef }),\n );\n\n tapEffect(() => {\n return store.subscribe(notifications.notifySubscribers);\n }, [store, notifications]);\n\n return tapMemo(() => {\n const clientFunction = () => store.getValue().methods;\n Object.defineProperties(clientFunction, {\n source: {\n value: \"root\" as const,\n writable: false,\n },\n query: {\n value: {} as Record<string, never>,\n writable: false,\n },\n name: {\n value: name,\n configurable: true,\n },\n });\n return clientFunction as AssistantClientAccessor<K>;\n }, [store, name]);\n },\n);\n\nconst NoOpRootClientsAccessorsResource = resource(() => {\n return tapMemo(\n () => ({\n clients: [] as AssistantClientAccessor<ClientNames>[],\n subscribe: undefined,\n on: undefined,\n }),\n [],\n );\n});\n\nconst RootClientsAccessorsResource = resource(\n ({\n clients: inputClients,\n clientRef,\n }: {\n clients: RootClients;\n clientRef: { parent: AssistantClient; current: AssistantClient | null };\n }) => {\n const notifications = tapResource(NotificationManager());\n\n tapEffect(\n () => clientRef.parent.subscribe(notifications.notifySubscribers),\n [clientRef, notifications],\n );\n\n const results = tapShallowMemoArray(\n tapResources(\n () =>\n Object.keys(inputClients).map((key) =>\n withKey(\n key,\n RootClientAccessorResource({\n element: inputClients[key as keyof typeof inputClients]!,\n notifications,\n clientRef,\n name: key as keyof typeof inputClients,\n }),\n ),\n ),\n [inputClients, notifications, clientRef],\n ),\n );\n\n return tapMemo(() => {\n return {\n clients: results,\n subscribe: notifications.subscribe,\n on: function <TEvent extends AssistantEventName>(\n this: AssistantClient,\n selector: AssistantEventSelector<TEvent>,\n callback: AssistantEventCallback<TEvent>,\n ) {\n if (!this) {\n throw new Error(\n \"const { on } = useAui() is not supported. Use aui.on() instead.\",\n );\n }\n\n const { scope, event } = normalizeEventSelector(selector);\n\n if (scope !== \"*\") {\n const source = this[scope as ClientNames].source;\n if (source === null) {\n throw new Error(\n `Scope \"${scope}\" is not available. Use { scope: \"*\", event: \"${event}\" } to listen globally.`,\n );\n }\n }\n\n const localUnsub = notifications.on(event, (payload, clientStack) => {\n if (scope === \"*\") {\n callback(payload);\n return;\n }\n\n const scopeClient = this[scope as ClientNames]();\n const index = getClientIndex(scopeClient);\n if (scopeClient === clientStack[index]) {\n callback(payload);\n }\n });\n if (\n scope !== \"*\" &&\n clientRef.parent[scope as ClientNames].source === null\n )\n return localUnsub;\n\n const parentUnsub = clientRef.parent.on(selector, callback);\n\n return () => {\n localUnsub();\n parentUnsub();\n };\n },\n };\n }, [results, notifications, clientRef]);\n },\n);\n\nconst DerivedClientAccessorResource = resource(\n <K extends ClientNames>({\n element,\n clientRef,\n name,\n }: {\n element: DerivedElement<K>;\n clientRef: { parent: AssistantClient; current: AssistantClient | null };\n name: K;\n }) => {\n // Track the latest props on a ref updated in render. The fiber is\n // keyed on the scope's meta by DerivedClientsAccessorsResource, so\n // source/query are stable for this fiber's lifetime and the only\n // value that can change between renders for the same fiber is the\n // identity of the `get` closure. Routing reads through the ref\n // avoids the one-commit lag that the previous `tapEffectEvent`\n // path imposed.\n const propsRef = tapRef(element.props);\n propsRef.current = element.props;\n\n return tapMemo(() => {\n const clientFunction = () => propsRef.current.get(clientRef.current!);\n Object.defineProperties(clientFunction, {\n source: {\n value: propsRef.current.source,\n },\n query: {\n value: propsRef.current.query,\n },\n name: {\n value: name,\n configurable: true,\n },\n });\n return clientFunction as AssistantClientAccessor<K>;\n }, [clientRef, name]);\n },\n);\n\nconst serializeMeta = <K extends ClientNames>(\n name: K,\n meta: ClientMeta<K>,\n): string => {\n // Sort top-level keys so {a, b} and {b, a} hash to the same fiber\n // identity, and guard JSON.stringify against unusual values (BigInt,\n // circular refs) so render never throws here.\n let queryKey: string;\n try {\n const sorted: Record<string, unknown> = {};\n for (const k of Object.keys(meta.query as object).sort()) {\n sorted[k] = (meta.query as Record<string, unknown>)[k];\n }\n queryKey = JSON.stringify(sorted);\n } catch {\n queryKey = String(meta.query);\n }\n return `${name}::${meta.source}::${queryKey}`;\n};\n\nconst DerivedClientsAccessorsResource = resource(\n ({\n clients,\n clientRef,\n }: {\n clients: DerivedClients;\n clientRef: { parent: AssistantClient; current: AssistantClient | null };\n }) => {\n return tapShallowMemoArray(\n tapResources(\n () =>\n Object.keys(clients).map((key) => {\n const name = key as keyof typeof clients;\n const element = clients[name]!;\n return withKey(\n serializeMeta(name, element.props),\n DerivedClientAccessorResource({\n element,\n clientRef,\n name,\n }),\n );\n }),\n [clients, clientRef],\n ),\n );\n },\n);\n\n/**\n * Resource that creates an extended AssistantClient.\n */\nexport const AssistantClientResource = resource(\n ({\n parent,\n clients,\n }: {\n parent: AssistantClient;\n clients: useAui.Props;\n }): AssistantClient => {\n const { rootClients, derivedClients } = tapSplitClients(clients, parent);\n\n const clientRef = tapRef({\n parent: parent,\n current: null as AssistantClient | null,\n }).current;\n\n tapEffect(() => {\n // if (clientRef.current && clientRef.current !== client)\n // throw new Error(\"clientRef.current !== client\");\n\n clientRef.current = client;\n });\n\n const rootFields = tapResource(\n Object.keys(rootClients).length > 0\n ? RootClientsAccessorsResource({ clients: rootClients, clientRef })\n : NoOpRootClientsAccessorsResource(),\n );\n\n const derivedFields = tapResource(\n DerivedClientsAccessorsResource({ clients: derivedClients, clientRef }),\n );\n\n const client = tapMemo(() => {\n // Swap DefaultAssistantClient -> createRootAssistantClient at root to change error message\n const proto =\n parent === DefaultAssistantClient\n ? createRootAssistantClient()\n : parent;\n\n const client = Object.create(proto) as AssistantClient;\n Object.assign(client, {\n subscribe: rootFields.subscribe ?? parent.subscribe,\n on: rootFields.on ?? parent.on,\n [PROXIED_ASSISTANT_STATE_SYMBOL]: createProxiedAssistantState(client),\n });\n\n for (const field of rootFields.clients) {\n (client as any)[field.name] = field;\n }\n for (const field of derivedFields) {\n (client as any)[field.name] = field;\n }\n\n return client;\n }, [parent, rootFields, derivedFields]);\n\n if (clientRef.current === null) {\n clientRef.current = client;\n }\n\n return client;\n },\n);\n\nexport namespace useAui {\n export type Props = {\n [K in ClientNames]?: ClientElement<K> | DerivedElement<K>;\n };\n}\n\n/**\n * Returns the current `AssistantClient` from context.\n *\n * Read the client supplied by the nearest {@link AuiProvider} or\n * {@link AssistantRuntimeProvider}, then access a scope on it —\n * `aui.thread()`, `aui.composer()`, `aui.message()`, and so on. Pair\n * with {@link useAuiState} to read reactive state and {@link useAuiEvent}\n * to subscribe to events. The returned client also exposes lower-level\n * methods such as `aui.on(...)` and `aui.subscribe(...)`; prefer\n * `useAuiEvent` for React event subscriptions.\n *\n * Rendered outside a provider, the returned client's scope accessors\n * throw a descriptive error whenever they are called.\n *\n * @example\n * ```tsx\n * const aui = useAui();\n *\n * const onSend = () => aui.composer().send();\n * const onCancel = () => aui.thread().cancelRun();\n * ```\n *\n * @example\n * ```tsx\n * // Combine with useAuiState to drive disabled state.\n * const aui = useAui();\n * const isRunning = useAuiState((s) => s.thread.isRunning);\n *\n * return (\n * <button disabled={isRunning} onClick={() => aui.composer().send()}>\n * Send\n * </button>\n * );\n * ```\n */\nexport function useAui(): AssistantClient;\n/**\n * Extends the parent `AssistantClient` with additional scopes.\n *\n * Advanced overload used when building primitives or providers — for example,\n * when a custom provider needs to register a `message`, `part`, or other scope\n * onto the client visible to its descendants. Application code rarely reaches\n * for this; use {@link useAui} with no arguments to read the existing client.\n *\n * @example\n * ```tsx\n * const aui = useAui({\n * message: Derived({\n * source: \"thread\",\n * query: { index: 0 },\n * get: (aui) => aui.thread().message({ index: 0 }),\n * }),\n * });\n *\n * const role = useAuiState((s) => s.message.role);\n * ```\n */\nexport function useAui(clients: useAui.Props): AssistantClient;\n/**\n * Extends an explicit parent `AssistantClient` with additional scopes.\n */\nexport function useAui(\n clients: useAui.Props,\n config: { parent: null | AssistantClient },\n): AssistantClient;\n/** @deprecated This API is highly experimental and may be changed in a minor release */\nexport function useAui(\n clients?: useAui.Props,\n { parent }: { parent: null | AssistantClient } = {\n parent: useAssistantContextValue(),\n },\n): AssistantClient {\n if (clients) {\n // biome-ignore lint/correctness/useHookAtTopLevel: intentional conditional/nested hook usage\n return useResource(\n AssistantClientResource({\n parent: parent ?? DefaultAssistantClient,\n clients,\n }),\n );\n }\n if (parent === null)\n throw new Error(\"received null parent, this usage is not allowed\");\n return parent;\n}\n"],"mappings":";;;;;;;;;;;;AA8CA,MAAM,uBAA0B,UAAwB;CAEtD,OAAO,cAAc,OAAO,KAAK;AACnC;AAEA,MAAM,qBAAqB,UACD,EACtB,SACA,MACA,gBAKI;CACJ,MAAM,EAAE,SAAS,UAAU,gCACzB;EAAE;EAAW;CAAK,SACZ,kBAAkB,OAAO,CACjC;CACA,OAAO,eAAe;EAAE;EAAO;CAAQ,IAAI,CAAC,SAAS,KAAK,CAAC;AAC7D,CACF;AAEA,MAAM,6BAA6B,UACT,EACtB,SACA,eACA,WACA,WAMgC;CAChC,MAAM,QAAQ,gBACZ,mBAAmB;EAAE;EAAS,MAAM,cAAc;EAAM;CAAU,CAAC,CACrE;CAEA,gBAAgB;EACd,OAAO,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AAC,GACH,CAAC,SAAS,SAAS,CACrB,CACF;AACF,CACF;;;;AAKA,MAAa,0BAA0B,UACpC,EACC,QACA,cAIqB;CACrB,MAAM,EAAE,aAAa,mBAAmB,gBAAgB,SAAS,MAAM;CAEvE,MAAM,YAAY,OAAO;EACf;EACR,SAAS;CACX,CAAC,EAAE;CAEH,gBAAgB;EAId,UAAU,UAAU;CACtB,CAAC;CAED,MAAM,aAAa,YACjB,OAAO,KAAK,WAAW,EAAE,SAAS,IAC9B,6BAA6B;EAAE,SAAS;EAAa;CAAU,CAAC,IAChE,iCAAiC,CACvC;CAEA,MAAM,gBAAgB,YACpB,gCAAgC;EAAE,SAAS;EAAgB;CAAU,CAAC,CACxE;CAEA,MAAM,SAAS,cAAc;EAE3B,MAAM,QACJ,WAAW,yBACP,0BAA0B,IAC1B;EAEN,MAAM,SAAS,OAAO,OAAO,KAAK;EAClC,OAAO,OAAO,QAAQ;GACpB,WAAW,WAAW,aAAa,OAAO;GAC1C,IAAI,WAAW,MAAM,OAAO;IAC3B,iCAAiC,4BAA4B,MAAM;EACtE,CAAC;EAED,KAAK,MAAM,SAAS,WAAW,SAC7B,OAAgB,MAAM,QAAQ;EAEhC,KAAK,MAAM,SAAS,eAClB,OAAgB,MAAM,QAAQ;EAGhC,OAAO;CACT,GAAG;EAAC;EAAQ;EAAY;CAAa,CAAC;CAEtC,IAAI,UAAU,YAAY,MACxB,UAAU,UAAU;CAGtB,OAAO;AACT,CACF;;AA0EA,SAAgB,OACd,SACA,EAAE,WAA+C,EAC/C,QAAQ,yBAAyB,EACnC,GACiB;CACjB,IAAI,SAEF,OAAO,YACL,wBAAwB;EACtB,QAAQ,UAAU;EAClB;CACF,CAAC,CACH;CAEF,IAAI,WAAW,MACb,MAAM,IAAI,MAAM,iDAAiD;CACnE,OAAO;AACT"}
@@ -1,3 +1,48 @@
1
- import type { AssistantEventName, AssistantEventCallback, AssistantEventSelector } from "./types/events.js";
2
- export declare const useAuiEvent: <TEvent extends AssistantEventName>(selector: AssistantEventSelector<TEvent>, callback: AssistantEventCallback<TEvent>) => void;
1
+ import { AssistantEventCallback, AssistantEventName, AssistantEventSelector } from "./types/events.js";
2
+
3
+ //#region src/useAuiEvent.d.ts
4
+ /**
5
+ * Subscribes to an assistant event for the lifetime of the component.
6
+ *
7
+ * The subscription is established on mount and re-established whenever the
8
+ * scope or event name changes. The `callback` is wrapped in an effect-event
9
+ * shim, so the latest closure is invoked on each emission — you do not
10
+ * need to memoize it.
11
+ *
12
+ * @param selector - Either a dotted event name like
13
+ * `"thread.modelContextUpdate"` or an object `{ scope, event }`. Use
14
+ * `scope: "*"` to subscribe at the root client and receive emissions
15
+ * from any descendant scope, regardless of which one is in React
16
+ * context.
17
+ * @param callback - Invoked with the event payload. The most recent
18
+ * reference is always called. Return values are ignored, async callbacks
19
+ * are not awaited, and the callback cannot be called during render.
20
+ *
21
+ * @example
22
+ * ```tsx
23
+ * // React to transient model-context changes.
24
+ * useAuiEvent("thread.modelContextUpdate", ({ threadId }) => {
25
+ * analytics.track("model_context_update", { threadId });
26
+ * });
27
+ * ```
28
+ *
29
+ * @example
30
+ * ```tsx
31
+ * // React to thread switches.
32
+ * useAuiEvent("threadListItem.switchedTo", () => {
33
+ * resetLocalState();
34
+ * });
35
+ * ```
36
+ *
37
+ * @example
38
+ * ```tsx
39
+ * // Listen from the root client rather than the current React context.
40
+ * useAuiEvent({ scope: "*", event: "thread.modelContextUpdate" }, (payload) => {
41
+ * analytics.track("model_context_update", payload);
42
+ * });
43
+ * ```
44
+ */
45
+ declare const useAuiEvent: <TEvent extends AssistantEventName>(selector: AssistantEventSelector<TEvent>, callback: AssistantEventCallback<TEvent>) => void;
46
+ //#endregion
47
+ export { useAuiEvent };
3
48
  //# sourceMappingURL=useAuiEvent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useAuiEvent.d.ts","sourceRoot":"","sources":["../src/useAuiEvent.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACvB,0BAAuB;AAGxB,eAAO,MAAM,WAAW,GAAI,MAAM,SAAS,kBAAkB,EAC3D,UAAU,sBAAsB,CAAC,MAAM,CAAC,EACxC,UAAU,sBAAsB,CAAC,MAAM,CAAC,SAUzC,CAAC"}
1
+ {"version":3,"file":"useAuiEvent.d.ts","names":[],"sources":["../src/useAuiEvent.ts"],"mappings":";;;;;AAmDA;;;;;;;;;;;;;;;;;;;AAE0C;;;;;;;;;;;;;;;;;;;;cAF7B,WAAA,kBAA8B,kBAAA,EACzC,QAAA,EAAU,sBAAA,CAAuB,MAAA,GACjC,QAAA,EAAU,sBAAA,CAAuB,MAAA"}
@@ -1,11 +1,64 @@
1
+ import { normalizeEventSelector } from "./types/events.js";
2
+ import { useAui } from "./useAui.js";
1
3
  import { useEffect } from "react";
2
4
  import { useEffectEvent } from "use-effect-event";
3
- import { useAui } from "./useAui.js";
4
- import { normalizeEventSelector } from "./types/events.js";
5
- export const useAuiEvent = (selector, callback) => {
6
- const aui = useAui();
7
- const callbackRef = useEffectEvent(callback);
8
- const { scope, event } = normalizeEventSelector(selector);
9
- useEffect(() => aui.on({ scope, event }, callbackRef), [aui, scope, event, callbackRef]);
5
+ //#region src/useAuiEvent.ts
6
+ /**
7
+ * Subscribes to an assistant event for the lifetime of the component.
8
+ *
9
+ * The subscription is established on mount and re-established whenever the
10
+ * scope or event name changes. The `callback` is wrapped in an effect-event
11
+ * shim, so the latest closure is invoked on each emission — you do not
12
+ * need to memoize it.
13
+ *
14
+ * @param selector - Either a dotted event name like
15
+ * `"thread.modelContextUpdate"` or an object `{ scope, event }`. Use
16
+ * `scope: "*"` to subscribe at the root client and receive emissions
17
+ * from any descendant scope, regardless of which one is in React
18
+ * context.
19
+ * @param callback - Invoked with the event payload. The most recent
20
+ * reference is always called. Return values are ignored, async callbacks
21
+ * are not awaited, and the callback cannot be called during render.
22
+ *
23
+ * @example
24
+ * ```tsx
25
+ * // React to transient model-context changes.
26
+ * useAuiEvent("thread.modelContextUpdate", ({ threadId }) => {
27
+ * analytics.track("model_context_update", { threadId });
28
+ * });
29
+ * ```
30
+ *
31
+ * @example
32
+ * ```tsx
33
+ * // React to thread switches.
34
+ * useAuiEvent("threadListItem.switchedTo", () => {
35
+ * resetLocalState();
36
+ * });
37
+ * ```
38
+ *
39
+ * @example
40
+ * ```tsx
41
+ * // Listen from the root client rather than the current React context.
42
+ * useAuiEvent({ scope: "*", event: "thread.modelContextUpdate" }, (payload) => {
43
+ * analytics.track("model_context_update", payload);
44
+ * });
45
+ * ```
46
+ */
47
+ const useAuiEvent = (selector, callback) => {
48
+ const aui = useAui();
49
+ const callbackRef = useEffectEvent(callback);
50
+ const { scope, event } = normalizeEventSelector(selector);
51
+ useEffect(() => aui.on({
52
+ scope,
53
+ event
54
+ }, callbackRef), [
55
+ aui,
56
+ scope,
57
+ event,
58
+ callbackRef
59
+ ]);
10
60
  };
61
+ //#endregion
62
+ export { useAuiEvent };
63
+
11
64
  //# sourceMappingURL=useAuiEvent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useAuiEvent.js","sourceRoot":"","sources":["../src/useAuiEvent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,oBAAiB;AAMlC,OAAO,EAAE,sBAAsB,EAAE,0BAAuB;AAExD,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,QAAwC,EACxC,QAAwC,EACxC,EAAE;IACF,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC;IACrB,MAAM,WAAW,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC;IAE7C,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,sBAAsB,CAAC,QAAQ,CAAC,CAAC;IAC1D,SAAS,CACP,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,WAAW,CAAC,EAC3C,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,CAAC,CACjC,CAAC;AACJ,CAAC,CAAC"}
1
+ {"version":3,"file":"useAuiEvent.js","names":[],"sources":["../src/useAuiEvent.ts"],"sourcesContent":["import { useEffect } from \"react\";\nimport { useEffectEvent } from \"use-effect-event\";\nimport { useAui } from \"./useAui\";\nimport type {\n AssistantEventName,\n AssistantEventCallback,\n AssistantEventSelector,\n} from \"./types/events\";\nimport { normalizeEventSelector } from \"./types/events\";\n\n/**\n * Subscribes to an assistant event for the lifetime of the component.\n *\n * The subscription is established on mount and re-established whenever the\n * scope or event name changes. The `callback` is wrapped in an effect-event\n * shim, so the latest closure is invoked on each emission — you do not\n * need to memoize it.\n *\n * @param selector - Either a dotted event name like\n * `\"thread.modelContextUpdate\"` or an object `{ scope, event }`. Use\n * `scope: \"*\"` to subscribe at the root client and receive emissions\n * from any descendant scope, regardless of which one is in React\n * context.\n * @param callback - Invoked with the event payload. The most recent\n * reference is always called. Return values are ignored, async callbacks\n * are not awaited, and the callback cannot be called during render.\n *\n * @example\n * ```tsx\n * // React to transient model-context changes.\n * useAuiEvent(\"thread.modelContextUpdate\", ({ threadId }) => {\n * analytics.track(\"model_context_update\", { threadId });\n * });\n * ```\n *\n * @example\n * ```tsx\n * // React to thread switches.\n * useAuiEvent(\"threadListItem.switchedTo\", () => {\n * resetLocalState();\n * });\n * ```\n *\n * @example\n * ```tsx\n * // Listen from the root client rather than the current React context.\n * useAuiEvent({ scope: \"*\", event: \"thread.modelContextUpdate\" }, (payload) => {\n * analytics.track(\"model_context_update\", payload);\n * });\n * ```\n */\nexport const useAuiEvent = <TEvent extends AssistantEventName>(\n selector: AssistantEventSelector<TEvent>,\n callback: AssistantEventCallback<TEvent>,\n) => {\n const aui = useAui();\n const callbackRef = useEffectEvent(callback);\n\n const { scope, event } = normalizeEventSelector(selector);\n useEffect(\n () => aui.on({ scope, event }, callbackRef),\n [aui, scope, event, callbackRef],\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,MAAa,eACX,UACA,aACG;CACH,MAAM,MAAM,OAAO;CACnB,MAAM,cAAc,eAAe,QAAQ;CAE3C,MAAM,EAAE,OAAO,UAAU,uBAAuB,QAAQ;CACxD,gBACQ,IAAI,GAAG;EAAE;EAAO;CAAM,GAAG,WAAW,GAC1C;EAAC;EAAK;EAAO;EAAO;CAAW,CACjC;AACF"}
@@ -1,18 +1,39 @@
1
- import type { AssistantState } from "./types/client.js";
1
+ import { AssistantState } from "./types/client.js";
2
+
3
+ //#region src/useAuiState.d.ts
2
4
  /**
3
- * Hook to access a slice of the assistant state with automatic subscription
5
+ * Subscribes to a slice of {@link AssistantState} and re-renders the
6
+ * component whenever that slice changes.
4
7
  *
5
- * @param selector - Function to select a slice of the state
6
- * @returns The selected state slice
8
+ * The `selector` is called on every store update; its return value is
9
+ * compared by `Object.is`, and the component re-renders only when the
10
+ * selected slice changes. Returning the entire state object is not
11
+ * supported and throws at runtime — select a specific field instead, or
12
+ * compose multiple `useAuiState` calls. Returning a new object or array
13
+ * literal, including spreading `s.thread` into a new object, causes a
14
+ * re-render on every store update; either select primitives or return a
15
+ * memoized reference.
16
+ *
17
+ * @param selector - Pure function that derives a value from the current
18
+ * assistant state. Should be cheap and referentially stable for equal
19
+ * inputs (plain field reads, primitives, or memoized values).
20
+ * @returns The currently selected slice.
7
21
  *
8
22
  * @example
9
- * ```typescript
10
- * const aui = useAui({
11
- * foo: RootScope({ ... }),
12
- * });
23
+ * ```tsx
24
+ * // Disable a button while a run is in flight.
25
+ * const isRunning = useAuiState((s) => s.thread.isRunning);
26
+ * ```
13
27
  *
14
- * const bar = useAuiState((s) => s.foo.bar);
28
+ * @example
29
+ * ```tsx
30
+ * // Prefer multiple selectors over an inline object literal, which would
31
+ * // create a new reference on every render.
32
+ * const text = useAuiState((s) => s.composer.text);
33
+ * const canSend = useAuiState((s) => s.composer.canSend);
15
34
  * ```
16
35
  */
17
- export declare const useAuiState: <T>(selector: (state: AssistantState) => T) => T;
36
+ declare const useAuiState: <T>(selector: (state: AssistantState) => T) => T;
37
+ //#endregion
38
+ export { useAuiState };
18
39
  //# sourceMappingURL=useAuiState.d.ts.map