@websolutespa/bom-llm 2.0.1 → 2.0.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @websolutespa/bom-llm
2
2
 
3
+ ## 2.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Added: openingContext & IntroContext
8
+ - 71f0616: Added: pluginLabels
9
+
3
10
  ## 2.0.1
4
11
 
5
12
  ### Patch Changes
package/dist/esm/index.js CHANGED
@@ -20059,12 +20059,16 @@ const createLlmViewStore = _ref => {
20059
20059
  }
20060
20060
  });
20061
20061
  },
20062
- open: () => {
20062
+ open: openingContext => {
20063
20063
  setIdleTimeout();
20064
20064
  set(state => {
20065
20065
  const opened = !state.opened;
20066
+ if (opened) {
20067
+ state.openingContext = openingContext;
20068
+ }
20066
20069
  pushDataLayer({
20067
- event: opened ? 'llm_open' : 'llm_close'
20070
+ event: opened ? state.openingContext ? 'llm_open_context' : 'llm_open' : 'llm_close',
20071
+ ...(state.openingContext || {})
20068
20072
  });
20069
20073
  persistMinimized(false);
20070
20074
  return {
@@ -20079,11 +20083,15 @@ const createLlmViewStore = _ref => {
20079
20083
  } = get();
20080
20084
  return opened;
20081
20085
  },
20082
- setOpened: opened => {
20086
+ setOpened: (opened, openingContext) => {
20083
20087
  setIdleTimeout();
20084
20088
  set(state => {
20089
+ if (opened) {
20090
+ state.openingContext = openingContext;
20091
+ }
20085
20092
  pushDataLayer({
20086
- event: opened ? 'llm_open' : 'llm_close'
20093
+ event: opened ? state.openingContext ? 'llm_open_context' : 'llm_open' : 'llm_close',
20094
+ ...(state.openingContext || {})
20087
20095
  });
20088
20096
  return {
20089
20097
  opened
@@ -32779,11 +32787,19 @@ const Intro = () => {
32779
32787
  });
32780
32788
  };
32781
32789
 
32790
+ const IntroContext = () => {
32791
+ const {
32792
+ Intro
32793
+ } = useLlm(state => state.components);
32794
+ return /*#__PURE__*/jsxRuntimeExports.jsx(Intro, {});
32795
+ };
32796
+
32782
32797
  const Main = () => {
32783
32798
  const {
32784
32799
  Canvas,
32785
32800
  Header,
32786
32801
  Intro,
32802
+ IntroContext,
32787
32803
  Prompt,
32788
32804
  Scroller,
32789
32805
  ScrollProposition,
@@ -32792,6 +32808,7 @@ const Main = () => {
32792
32808
  const app = useLlm(state => state.app);
32793
32809
  const theme = useLlm(state => state.theme);
32794
32810
  const messages = useLlm(state => state.messages);
32811
+ const openingContext = useLlmView(state => state.openingContext);
32795
32812
  const introed = useLlmView(state => state.introed);
32796
32813
  const visible = useLlmView(state => state.visible);
32797
32814
  const embedded = useLlmView(state => state.embedded);
@@ -32875,7 +32892,7 @@ const Main = () => {
32875
32892
  initial: "hidden",
32876
32893
  animate: "show",
32877
32894
  className: "llm__content",
32878
- children: [/*#__PURE__*/jsxRuntimeExports.jsx(Intro, {}), messages && messages.length > 0 && /*#__PURE__*/jsxRuntimeExports.jsx(Thread, {})]
32895
+ children: [openingContext ? /*#__PURE__*/jsxRuntimeExports.jsx(IntroContext, {}) : /*#__PURE__*/jsxRuntimeExports.jsx(Intro, {}), messages && messages.length > 0 && /*#__PURE__*/jsxRuntimeExports.jsx(Thread, {})]
32879
32896
  })
32880
32897
  }), shouldShowPrompt && /*#__PURE__*/jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, {
32881
32898
  children: [app && !theme.canvas?.enabled && /*#__PURE__*/jsxRuntimeExports.jsx("div", {
@@ -42170,6 +42187,7 @@ const Stream = _ref => {
42170
42187
  const Suggestions = () => {
42171
42188
  useWindowSize();
42172
42189
  const app = useLlm(state => state.app);
42190
+ const openingContext = useLlmView(state => state.openingContext);
42173
42191
  const {
42174
42192
  send
42175
42193
  } = useLlmView(state => state.actions);
@@ -42180,6 +42198,9 @@ const Suggestions = () => {
42180
42198
  // console.log('Suggestions.onEnd', response);
42181
42199
  });
42182
42200
  };
42201
+ if (openingContext) {
42202
+ return;
42203
+ }
42183
42204
  const sampleInputTexts = app?.contents.sampleInputTexts;
42184
42205
  return /*#__PURE__*/jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {
42185
42206
  children: sampleInputTexts && sampleInputTexts.length > 0 && /*#__PURE__*/jsxRuntimeExports.jsx("section", {
@@ -42374,6 +42395,7 @@ const LLM_COMPONENTS = {
42374
42395
  Header,
42375
42396
  Hints,
42376
42397
  Intro,
42398
+ IntroContext,
42377
42399
  Main,
42378
42400
  PageActions,
42379
42401
  PageContext,
@@ -46038,17 +46060,17 @@ const LlmComponent = /*#__PURE__*/reactExports.forwardRef((props, ref) => {
46038
46060
  const embedded = useLlmView(state => state.embedded);
46039
46061
  const imperative = useLlmView(state => state.imperative);
46040
46062
  const instance = reactExports.useMemo(() => ({
46041
- open: () => {
46042
- open();
46063
+ open: openingContext => {
46064
+ open(openingContext);
46043
46065
  },
46044
46066
  isOpened: () => {
46045
46067
  return isOpened();
46046
46068
  },
46047
- setOpened: opened => {
46048
- setOpened(opened);
46069
+ setOpened: (opened, openingContext) => {
46070
+ setOpened(opened, openingContext);
46049
46071
  },
46050
- send: message => {
46051
- setOpened(true);
46072
+ send: (message, openingContext) => {
46073
+ setOpened(true, openingContext);
46052
46074
  send(message);
46053
46075
  },
46054
46076
  clear: () => {
@@ -46474,7 +46496,7 @@ const App = _ref => {
46474
46496
  const defaultEndpoint = typeof props.test !== 'undefined' ? 'https://bom-sample-basic-web-git-bom-llm-actarian.vercel.app' : 'https://platform.websolute.ai';
46475
46497
  const endpoint = props.endpoint || defaultEndpoint;
46476
46498
  const layout = {
46477
- labels: getLabels(data.locale, defaultLabels, props.labels),
46499
+ labels: getLabels(data.locale, defaultLabels, props.pluginLabels, props.labels),
46478
46500
  locale: data.locale,
46479
46501
  locales: [{
46480
46502
  id: data.locale,
@@ -46545,12 +46567,16 @@ const App = _ref => {
46545
46567
  })
46546
46568
  });
46547
46569
  };
46548
- function getLabels(locale, defaultLabels, extendedLabels) {
46549
- if (extendedLabels === void 0) {
46550
- extendedLabels = [];
46570
+ function getLabels(locale, defaultLabels, pluginLabels, externalLabels) {
46571
+ if (pluginLabels === void 0) {
46572
+ pluginLabels = [];
46573
+ }
46574
+ if (externalLabels === void 0) {
46575
+ externalLabels = [];
46551
46576
  }
46552
- const labels = [...defaultLabels.filter(x => extendedLabels.findIndex(e => e.id === x.id) === -1), ...extendedLabels];
46553
- return labels.map(x => {
46577
+ const labels = [...defaultLabels.filter(x => pluginLabels.findIndex(e => e.id === x.id) === -1), ...pluginLabels];
46578
+ const finalLabels = [...labels.filter(x => externalLabels.findIndex(e => e.id === x.id) === -1), ...externalLabels];
46579
+ return finalLabels.map(x => {
46554
46580
  const localizedItem = localizeItem(x, locale, 'en');
46555
46581
  return {
46556
46582
  id: localizedItem.id,
@@ -46699,7 +46725,7 @@ function isIterable(element) {
46699
46725
  return element != null && typeof element[Symbol.iterator] === 'function';
46700
46726
  }
46701
46727
 
46702
- function getInitializer(globalName, plugins) {
46728
+ function getInitializer(globalName, plugins, pluginLabels) {
46703
46729
  if (globalName === void 0) {
46704
46730
  globalName = 'bomLlm';
46705
46731
  }
@@ -46712,23 +46738,24 @@ function getInitializer(globalName, plugins) {
46712
46738
  return;
46713
46739
  }
46714
46740
  props.plugins = [...(props.plugins || []), ...(plugins || [])];
46741
+ props.pluginLabels = pluginLabels;
46715
46742
  const id = toKebabCase(globalName);
46716
46743
  const node = document.createElement('div');
46717
46744
  node.setAttribute('id', id);
46718
46745
  body.appendChild(node);
46719
46746
  const initError = 'llm plugin is not initialized';
46720
46747
  const llmInstance = {
46721
- open: () => {
46748
+ open: openingContext => {
46722
46749
  console.log(initError);
46723
46750
  },
46724
- setOpened: opened => {
46751
+ setOpened: (opened, openingContext) => {
46725
46752
  console.log(initError);
46726
46753
  },
46727
46754
  isOpened: () => {
46728
46755
  console.log(initError);
46729
46756
  return false;
46730
46757
  },
46731
- send: message => {
46758
+ send: (message, openingContext) => {
46732
46759
  console.log(initError);
46733
46760
  },
46734
46761
  clear: () => {