@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/dist/umd/index.js CHANGED
@@ -20065,12 +20065,16 @@
20065
20065
  }
20066
20066
  });
20067
20067
  },
20068
- open: () => {
20068
+ open: openingContext => {
20069
20069
  setIdleTimeout();
20070
20070
  set(state => {
20071
20071
  const opened = !state.opened;
20072
+ if (opened) {
20073
+ state.openingContext = openingContext;
20074
+ }
20072
20075
  pushDataLayer({
20073
- event: opened ? 'llm_open' : 'llm_close'
20076
+ event: opened ? state.openingContext ? 'llm_open_context' : 'llm_open' : 'llm_close',
20077
+ ...(state.openingContext || {})
20074
20078
  });
20075
20079
  persistMinimized(false);
20076
20080
  return {
@@ -20085,11 +20089,15 @@
20085
20089
  } = get();
20086
20090
  return opened;
20087
20091
  },
20088
- setOpened: opened => {
20092
+ setOpened: (opened, openingContext) => {
20089
20093
  setIdleTimeout();
20090
20094
  set(state => {
20095
+ if (opened) {
20096
+ state.openingContext = openingContext;
20097
+ }
20091
20098
  pushDataLayer({
20092
- event: opened ? 'llm_open' : 'llm_close'
20099
+ event: opened ? state.openingContext ? 'llm_open_context' : 'llm_open' : 'llm_close',
20100
+ ...(state.openingContext || {})
20093
20101
  });
20094
20102
  return {
20095
20103
  opened
@@ -32785,11 +32793,19 @@ void main(void) {
32785
32793
  });
32786
32794
  };
32787
32795
 
32796
+ const IntroContext = () => {
32797
+ const {
32798
+ Intro
32799
+ } = useLlm(state => state.components);
32800
+ return /*#__PURE__*/jsxRuntimeExports.jsx(Intro, {});
32801
+ };
32802
+
32788
32803
  const Main = () => {
32789
32804
  const {
32790
32805
  Canvas,
32791
32806
  Header,
32792
32807
  Intro,
32808
+ IntroContext,
32793
32809
  Prompt,
32794
32810
  Scroller,
32795
32811
  ScrollProposition,
@@ -32798,6 +32814,7 @@ void main(void) {
32798
32814
  const app = useLlm(state => state.app);
32799
32815
  const theme = useLlm(state => state.theme);
32800
32816
  const messages = useLlm(state => state.messages);
32817
+ const openingContext = useLlmView(state => state.openingContext);
32801
32818
  const introed = useLlmView(state => state.introed);
32802
32819
  const visible = useLlmView(state => state.visible);
32803
32820
  const embedded = useLlmView(state => state.embedded);
@@ -32881,7 +32898,7 @@ void main(void) {
32881
32898
  initial: "hidden",
32882
32899
  animate: "show",
32883
32900
  className: "llm__content",
32884
- children: [/*#__PURE__*/jsxRuntimeExports.jsx(Intro, {}), messages && messages.length > 0 && /*#__PURE__*/jsxRuntimeExports.jsx(Thread, {})]
32901
+ children: [openingContext ? /*#__PURE__*/jsxRuntimeExports.jsx(IntroContext, {}) : /*#__PURE__*/jsxRuntimeExports.jsx(Intro, {}), messages && messages.length > 0 && /*#__PURE__*/jsxRuntimeExports.jsx(Thread, {})]
32885
32902
  })
32886
32903
  }), shouldShowPrompt && /*#__PURE__*/jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, {
32887
32904
  children: [app && !theme.canvas?.enabled && /*#__PURE__*/jsxRuntimeExports.jsx("div", {
@@ -42176,6 +42193,7 @@ void main(void) {
42176
42193
  const Suggestions = () => {
42177
42194
  useWindowSize();
42178
42195
  const app = useLlm(state => state.app);
42196
+ const openingContext = useLlmView(state => state.openingContext);
42179
42197
  const {
42180
42198
  send
42181
42199
  } = useLlmView(state => state.actions);
@@ -42186,6 +42204,9 @@ void main(void) {
42186
42204
  // console.log('Suggestions.onEnd', response);
42187
42205
  });
42188
42206
  };
42207
+ if (openingContext) {
42208
+ return;
42209
+ }
42189
42210
  const sampleInputTexts = app?.contents.sampleInputTexts;
42190
42211
  return /*#__PURE__*/jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {
42191
42212
  children: sampleInputTexts && sampleInputTexts.length > 0 && /*#__PURE__*/jsxRuntimeExports.jsx("section", {
@@ -42380,6 +42401,7 @@ void main(void) {
42380
42401
  Header,
42381
42402
  Hints,
42382
42403
  Intro,
42404
+ IntroContext,
42383
42405
  Main,
42384
42406
  PageActions,
42385
42407
  PageContext,
@@ -46044,17 +46066,17 @@ ${Object.entries(vars).map(_ref2 => {
46044
46066
  const embedded = useLlmView(state => state.embedded);
46045
46067
  const imperative = useLlmView(state => state.imperative);
46046
46068
  const instance = reactExports.useMemo(() => ({
46047
- open: () => {
46048
- open();
46069
+ open: openingContext => {
46070
+ open(openingContext);
46049
46071
  },
46050
46072
  isOpened: () => {
46051
46073
  return isOpened();
46052
46074
  },
46053
- setOpened: opened => {
46054
- setOpened(opened);
46075
+ setOpened: (opened, openingContext) => {
46076
+ setOpened(opened, openingContext);
46055
46077
  },
46056
- send: message => {
46057
- setOpened(true);
46078
+ send: (message, openingContext) => {
46079
+ setOpened(true, openingContext);
46058
46080
  send(message);
46059
46081
  },
46060
46082
  clear: () => {
@@ -46480,7 +46502,7 @@ ${Object.entries(vars).map(_ref2 => {
46480
46502
  const defaultEndpoint = typeof props.test !== 'undefined' ? 'https://bom-sample-basic-web-git-bom-llm-actarian.vercel.app' : 'https://platform.websolute.ai';
46481
46503
  const endpoint = props.endpoint || defaultEndpoint;
46482
46504
  const layout = {
46483
- labels: getLabels(data.locale, defaultLabels, props.labels),
46505
+ labels: getLabels(data.locale, defaultLabels, props.pluginLabels, props.labels),
46484
46506
  locale: data.locale,
46485
46507
  locales: [{
46486
46508
  id: data.locale,
@@ -46551,12 +46573,16 @@ ${Object.entries(vars).map(_ref2 => {
46551
46573
  })
46552
46574
  });
46553
46575
  };
46554
- function getLabels(locale, defaultLabels, extendedLabels) {
46555
- if (extendedLabels === void 0) {
46556
- extendedLabels = [];
46576
+ function getLabels(locale, defaultLabels, pluginLabels, externalLabels) {
46577
+ if (pluginLabels === void 0) {
46578
+ pluginLabels = [];
46579
+ }
46580
+ if (externalLabels === void 0) {
46581
+ externalLabels = [];
46557
46582
  }
46558
- const labels = [...defaultLabels.filter(x => extendedLabels.findIndex(e => e.id === x.id) === -1), ...extendedLabels];
46559
- return labels.map(x => {
46583
+ const labels = [...defaultLabels.filter(x => pluginLabels.findIndex(e => e.id === x.id) === -1), ...pluginLabels];
46584
+ const finalLabels = [...labels.filter(x => externalLabels.findIndex(e => e.id === x.id) === -1), ...externalLabels];
46585
+ return finalLabels.map(x => {
46560
46586
  const localizedItem = localizeItem(x, locale, 'en');
46561
46587
  return {
46562
46588
  id: localizedItem.id,
@@ -46705,7 +46731,7 @@ ${Object.entries(vars).map(_ref2 => {
46705
46731
  return element != null && typeof element[Symbol.iterator] === 'function';
46706
46732
  }
46707
46733
 
46708
- function getInitializer(globalName, plugins) {
46734
+ function getInitializer(globalName, plugins, pluginLabels) {
46709
46735
  if (globalName === void 0) {
46710
46736
  globalName = 'bomLlm';
46711
46737
  }
@@ -46718,23 +46744,24 @@ ${Object.entries(vars).map(_ref2 => {
46718
46744
  return;
46719
46745
  }
46720
46746
  props.plugins = [...(props.plugins || []), ...(plugins || [])];
46747
+ props.pluginLabels = pluginLabels;
46721
46748
  const id = toKebabCase(globalName);
46722
46749
  const node = document.createElement('div');
46723
46750
  node.setAttribute('id', id);
46724
46751
  body.appendChild(node);
46725
46752
  const initError = 'llm plugin is not initialized';
46726
46753
  const llmInstance = {
46727
- open: () => {
46754
+ open: openingContext => {
46728
46755
  console.log(initError);
46729
46756
  },
46730
- setOpened: opened => {
46757
+ setOpened: (opened, openingContext) => {
46731
46758
  console.log(initError);
46732
46759
  },
46733
46760
  isOpened: () => {
46734
46761
  console.log(initError);
46735
46762
  return false;
46736
46763
  },
46737
- send: message => {
46764
+ send: (message, openingContext) => {
46738
46765
  console.log(initError);
46739
46766
  },
46740
46767
  clear: () => {