@carbon/ai-chat 1.11.0-rc.0 → 1.11.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.
@@ -26,7 +26,7 @@ import "dayjs/locale/en.js";
26
26
 
27
27
  import "lodash-es/isEqual.js";
28
28
 
29
- import "use-sync-external-store/shim/index.js";
29
+ import "use-sync-external-store/with-selector.js";
30
30
 
31
31
  import "compute-scroll-into-view";
32
32
 
@@ -2,7 +2,7 @@ import isEqual from "lodash-es/isEqual.js";
2
2
 
3
3
  import React, { useMemo, createContext, useContext, useRef, useCallback, useEffect, createElement, useState, useImperativeHandle, forwardRef, PureComponent, Component, Suspense, useLayoutEffect, Fragment } from "react";
4
4
 
5
- import { useSyncExternalStore as useSyncExternalStore$1 } from "use-sync-external-store/shim/index.js";
5
+ import { useSyncExternalStoreWithSelector } from "use-sync-external-store/with-selector.js";
6
6
 
7
7
  import { compute } from "compute-scroll-into-view";
8
8
 
@@ -220,7 +220,7 @@ import Toolbar from "@carbon/ai-chat-components/es/react/toolbar.js";
220
220
 
221
221
  import CarbonChatButtonElement, { CHAT_BUTTON_SIZE as CHAT_BUTTON_SIZE$1, CHAT_BUTTON_KIND as CHAT_BUTTON_KIND$1 } from "@carbon/web-components/es/components/chat-button/chat-button.js";
222
222
 
223
- const VERSION = "1.10.0";
223
+ const VERSION = "1.11.0";
224
224
 
225
225
  function memoizeFunction(fn, isEqual) {
226
226
  let hasResult = false;
@@ -394,26 +394,11 @@ function useStore() {
394
394
  return store;
395
395
  }
396
396
 
397
- const useSyncExternalStore = React.useSyncExternalStore ?? useSyncExternalStore$1;
398
-
399
397
  function useSelector(selector, equalityFn) {
400
398
  const store = useStore();
401
- const lastSelectedRef = useRef(UNINITIALIZED);
402
- const compare = equalityFn ?? Object.is;
403
- const computeSelected = useCallback(() => {
404
- const nextSelected = selector(store.getState());
405
- const lastSelected = lastSelectedRef.current;
406
- if (lastSelected !== UNINITIALIZED && compare(nextSelected, lastSelected)) {
407
- return lastSelected;
408
- }
409
- lastSelectedRef.current = nextSelected;
410
- return nextSelected;
411
- }, [ store, selector, compare ]);
412
- return useSyncExternalStore(store.subscribe, computeSelected, computeSelected);
399
+ return useSyncExternalStoreWithSelector(store.subscribe, store.getState, store.getState, selector, equalityFn);
413
400
  }
414
401
 
415
- const UNINITIALIZED = Symbol("useSelector.uninitialized");
416
-
417
402
  const LanguagePackContext = React.createContext(null);
418
403
 
419
404
  function LanguagePackProvider({children}) {