@websolutespa/bom-mixer-llm 0.0.10 → 0.0.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 (56) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/index.css +14 -16
  3. package/dist/cjs/index.js +72 -102
  4. package/dist/cjs/index.js.map +1 -1
  5. package/dist/esm/index.css +14 -16
  6. package/dist/esm/llm/components/Card/card.js +1 -1
  7. package/dist/esm/llm/components/Card/card.js.map +1 -1
  8. package/dist/esm/llm/components/Header/header.js +2 -1
  9. package/dist/esm/llm/components/Header/header.js.map +1 -1
  10. package/dist/esm/llm/components/Intro/intro.js +3 -24
  11. package/dist/esm/llm/components/Intro/intro.js.map +1 -1
  12. package/dist/esm/llm/components/Main/main.js +1 -0
  13. package/dist/esm/llm/components/Main/main.js.map +1 -1
  14. package/dist/esm/llm/components/ThronPlayer/thron-player.js +34 -34
  15. package/dist/esm/llm/components/ThronPlayer/thron-player.js.map +1 -1
  16. package/dist/esm/llm/llm.js +0 -34
  17. package/dist/esm/llm/llm.js.map +1 -1
  18. package/dist/esm/llm/theme.js +8 -1
  19. package/dist/esm/llm/theme.js.map +1 -1
  20. package/dist/esm/useLlm/api.service.js +1 -1
  21. package/dist/esm/useLlm/api.service.js.map +1 -1
  22. package/dist/esm/useLlm/useLlm.js +16 -4
  23. package/dist/esm/useLlm/useLlm.js.map +1 -1
  24. package/dist/esm/useLlm/useLlmView.js +6 -2
  25. package/dist/esm/useLlm/useLlmView.js.map +1 -1
  26. package/dist/types/llm/components/Header/header.d.ts.map +1 -1
  27. package/dist/types/llm/components/Intro/intro.d.ts +1 -1
  28. package/dist/types/llm/components/Intro/intro.d.ts.map +1 -1
  29. package/dist/types/llm/components/Main/main.d.ts.map +1 -1
  30. package/dist/types/llm/components/ThronPlayer/thron-player.d.ts +1 -1
  31. package/dist/types/llm/components/ThronPlayer/thron-player.d.ts.map +1 -1
  32. package/dist/types/llm/llm.d.ts.map +1 -1
  33. package/dist/types/llm/theme.d.ts +14 -0
  34. package/dist/types/llm/theme.d.ts.map +1 -1
  35. package/dist/types/useLlm/api.service.d.ts +1 -0
  36. package/dist/types/useLlm/api.service.d.ts.map +1 -1
  37. package/dist/types/useLlm/mock-app.lfo.d.ts.map +1 -1
  38. package/dist/types/useLlm/useLlm.d.ts +1 -2
  39. package/dist/types/useLlm/useLlm.d.ts.map +1 -1
  40. package/dist/types/useLlm/useLlmView.d.ts +6 -1
  41. package/dist/types/useLlm/useLlmView.d.ts.map +1 -1
  42. package/package.json +1 -1
  43. package/src/llm/components/Card/_style.scss +2 -2
  44. package/src/llm/components/Card/card.tsx +1 -1
  45. package/src/llm/components/Header/header.tsx +7 -4
  46. package/src/llm/components/Intro/intro.tsx +11 -31
  47. package/src/llm/components/Main/main.tsx +3 -5
  48. package/src/llm/components/ThronPlayer/_style.scss +3 -2
  49. package/src/llm/components/ThronPlayer/thron-player.tsx +32 -32
  50. package/src/llm/components/Trigger/_style.scss +2 -4
  51. package/src/llm/llm.tsx +0 -35
  52. package/src/llm/theme.ts +7 -0
  53. package/src/useLlm/api.service.ts +2 -1
  54. package/src/useLlm/mock-app.lfo.ts +6 -0
  55. package/src/useLlm/useLlm.tsx +14 -3
  56. package/src/useLlm/useLlmView.tsx +19 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @websolutespa/bom-mixer-llm
2
2
 
3
+ ## 0.0.12
4
+
5
+ ### Patch Changes
6
+
7
+ - Added: flags preview, dismissable, opened, skipCustomIntro
8
+
9
+ ## 0.0.11
10
+
11
+ ### Patch Changes
12
+
13
+ - Modified: theme & cards
14
+
3
15
  ## 0.0.10
4
16
 
5
17
  ### Patch Changes
@@ -888,8 +888,7 @@ llm-embed {
888
888
  position: absolute;
889
889
  padding: clamp(16px, 16px + (100vw - 375px) / 1545 * (8), 24px);
890
890
  width: calc(100vw - 40px);
891
- min-width: 240px;
892
- max-width: 460px;
891
+ max-width: var(--llm-popup-max-width);
893
892
  left: 50%;
894
893
  bottom: calc(100% + 12px);
895
894
  translate: -50% 0%;
@@ -907,8 +906,7 @@ llm-embed {
907
906
  }
908
907
  .llm .llm__trigger-welcome > div + div {
909
908
  width: calc(100vw - 40px);
910
- min-width: 240px;
911
- max-width: 460px;
909
+ max-width: var(--llm-popup-max-width);
912
910
  translate: -50% 10%;
913
911
  opacity: 0;
914
912
  }
@@ -1771,7 +1769,7 @@ llm-embed {
1771
1769
  display: flex;
1772
1770
  justify-content: center;
1773
1771
  align-items: center;
1774
- aspect-ratio: 240/165;
1772
+ aspect-ratio: var(--llm-card-aspect-ratio);
1775
1773
  border-radius: 24px;
1776
1774
  overflow: hidden;
1777
1775
  background: var(--llm-color-neutral-200);
@@ -1796,7 +1794,7 @@ llm-embed {
1796
1794
  }
1797
1795
  .llm .llm__card--video .llm__card-asset {
1798
1796
  border-radius: 0;
1799
- aspect-ratio: 16/9;
1797
+ aspect-ratio: var(--llm-card-video-aspect-ratio);
1800
1798
  }
1801
1799
  .llm .llm__card--full .llm__card-media {
1802
1800
  position: absolute;
@@ -2014,33 +2012,33 @@ llm-embed {
2014
2012
  cursor: pointer;
2015
2013
  }
2016
2014
 
2017
- .llm .llm__thron-player .th-video .th-video-player .th-video-poster {
2015
+ .llm__thron-player .th-video .th-video-player .th-video-poster {
2018
2016
  background-size: cover;
2019
2017
  }
2020
- .llm .llm__thron-player .th-player-external-element.th-std-bars,
2021
- .llm .llm__thron-player .th-player.th-std-bars {
2018
+ .llm__thron-player .th-player-external-element.th-std-bars,
2019
+ .llm__thron-player .th-player.th-std-bars {
2022
2020
  width: 100%;
2023
2021
  height: 100%;
2024
2022
  border-radius: 0;
2025
2023
  margin: 0;
2026
2024
  }
2027
- .llm .llm__thron-player .th-video .th-video-player .th-display-icon-wrapper {
2025
+ .llm__thron-player .th-video .th-video-player .th-display-icon-wrapper {
2028
2026
  display: none;
2029
2027
  }
2030
- .llm .llm__thron-player:not(.-enlarged) .th-control-bar.th-horizontal.th-top {
2028
+ .llm__thron-player:not(.-enlarged) .th-control-bar.th-horizontal.th-top {
2031
2029
  display: none;
2032
2030
  }
2033
- .llm .llm__thron-player:not(.-enlarged) .th-time-info {
2031
+ .llm__thron-player:not(.-enlarged) .th-time-info {
2034
2032
  display: none;
2035
2033
  }
2036
- .llm .llm__thron-player:not(.-enlarged) .th-control-bar.th-horizontal .th-group .th-button,
2037
- .llm .llm__thron-player:not(.-enlarged) .th-control-bar.th-horizontal .th-group .th-toggle-button:not(.th-fullscreen-button) {
2034
+ .llm__thron-player:not(.-enlarged) .th-control-bar.th-horizontal .th-group .th-button,
2035
+ .llm__thron-player:not(.-enlarged) .th-control-bar.th-horizontal .th-group .th-toggle-button:not(.th-fullscreen-button) {
2038
2036
  display: none;
2039
2037
  }
2040
- .llm .llm__thron-player:not(.-enlarged) .th-time-rail {
2038
+ .llm__thron-player:not(.-enlarged) .th-time-rail {
2041
2039
  display: none;
2042
2040
  }
2043
- .llm .llm__thron-player.-enlarged {
2041
+ .llm__thron-player.-enlarged {
2044
2042
  position: fixed;
2045
2043
  width: calc(100vw - 40px);
2046
2044
  height: calc((100vw - 40px) / 16 * 9);
package/dist/cjs/index.js CHANGED
@@ -223,6 +223,9 @@ const defaultTheme = {
223
223
  foreground: 'var(--llm-color-base-100)',
224
224
  boxShadow: '0 0 30px rgba(0, 0, 0, 0.3)'
225
225
  },
226
+ popup: {
227
+ maxWidth: '210px'
228
+ },
226
229
  hint: {
227
230
  fontFamily: 'var(--llm-font-primary)',
228
231
  background: 'linear-gradient(rgba(154, 154, 154, 0.2) 10%, rgba(221, 221, 221, 0.1) 80%)',
@@ -248,7 +251,11 @@ const defaultTheme = {
248
251
  },
249
252
  card: {
250
253
  background: 'var(--llm-color-neutral-100)',
251
- foreground: 'var(--llm-color-neutral-900)'
254
+ foreground: 'var(--llm-color-neutral-900)',
255
+ aspectRatio: '240 / 165'
256
+ },
257
+ cardVideo: {
258
+ aspectRatio: '16 / 9'
252
259
  },
253
260
  markdown: {
254
261
  marginTop: '0.5rem',
@@ -1190,7 +1197,7 @@ class ApiService {
1190
1197
  message: 'Bad Request: html is missing'
1191
1198
  };
1192
1199
  }
1193
- console.log('/llm/summary', payload);
1200
+ // console.log('/llm/summary', payload);
1194
1201
  return {
1195
1202
  code: 'SENT'
1196
1203
  };
@@ -2052,15 +2059,19 @@ function stripEmojis(text) {
2052
2059
  const createLlmViewStore = _ref => {
2053
2060
  let {
2054
2061
  threadId,
2062
+ dismissable = true,
2063
+ skipCustomIntro = false,
2055
2064
  opened,
2056
2065
  embedded,
2057
2066
  send,
2058
2067
  setEmbed
2059
2068
  } = _ref;
2060
2069
  const props = {
2061
- opened: opened != null || embedded != null ? Boolean(opened || embedded) : threadId != null ? true : false,
2070
+ opened: opened != null ? opened : embedded != null || threadId != null ? true : false,
2071
+ dismissable: embedded ? false : dismissable,
2072
+ skipCustomIntro: skipCustomIntro,
2062
2073
  embedded: embedded || false,
2063
- introed: false,
2074
+ introed: skipCustomIntro ? true : false,
2064
2075
  hidden: false,
2065
2076
  fixed: false,
2066
2077
  idle: true,
@@ -2261,11 +2272,12 @@ const createLlmStore = _ref => {
2261
2272
  appKey,
2262
2273
  apiKey,
2263
2274
  threadId,
2264
- customTheme,
2265
2275
  decorateUrl,
2266
2276
  endpoint,
2267
- test,
2268
2277
  storage,
2278
+ test,
2279
+ preview,
2280
+ customTheme,
2269
2281
  label
2270
2282
  } = _ref;
2271
2283
  const theme = getTheme(customTheme);
@@ -2296,7 +2308,8 @@ const createLlmStore = _ref => {
2296
2308
  threadId,
2297
2309
  endpoint,
2298
2310
  locale,
2299
- test
2311
+ test,
2312
+ preview
2300
2313
  });
2301
2314
  return apiService;
2302
2315
  },
@@ -2308,7 +2321,8 @@ const createLlmStore = _ref => {
2308
2321
  threadId,
2309
2322
  endpoint,
2310
2323
  locale,
2311
- test
2324
+ test,
2325
+ preview
2312
2326
  });
2313
2327
  const app = yield apiService.getInfo();
2314
2328
  if (!app) {
@@ -2580,6 +2594,15 @@ function LlmProvider(_a) {
2580
2594
  } = _a,
2581
2595
  props = __rest(_a, ["children"]);
2582
2596
  const label = bomMixerHooks.useLabel();
2597
+ if (props.embedded) {
2598
+ props.dismissable = false;
2599
+ props.opened = true;
2600
+ }
2601
+ if (props.preview) {
2602
+ props.dismissable = false;
2603
+ props.opened = true;
2604
+ props.skipCustomIntro = true;
2605
+ }
2583
2606
  const storeRef = react.useRef();
2584
2607
  if (!storeRef.current) {
2585
2608
  storeRef.current = createSharedLlmStore(Object.assign(Object.assign({}, props), {
@@ -2979,6 +3002,7 @@ const Header = props => {
2979
3002
  } = useLlmView(state => state.actions);
2980
3003
  const hidden = useLlmView(state => state.hidden);
2981
3004
  const fixed = useLlmView(state => state.fixed);
3005
+ const dismissable = useLlmView(state => state.dismissable);
2982
3006
  const label = bomMixerHooks.useLabel();
2983
3007
  const logo = app === null || app === void 0 ? void 0 : app.contents.logo;
2984
3008
  const logoMini = (_a = app === null || app === void 0 ? void 0 : app.contents) === null || _a === void 0 ? void 0 : _a.logoMini;
@@ -3005,7 +3029,7 @@ const Header = props => {
3005
3029
  alt: logoMini.alt
3006
3030
  })
3007
3031
  })]
3008
- }), jsxRuntime.jsxs("button", {
3032
+ }), dismissable && jsxRuntime.jsxs("button", {
3009
3033
  className: "llm__header-back -llm-t-cta-3",
3010
3034
  onClick: () => open(),
3011
3035
  children: [label('llm.back'), jsxRuntime.jsx(bomMixerIcons.IconLlmArrowCornerRightUp, {})]
@@ -3204,13 +3228,11 @@ const Blob = () => {
3204
3228
  const Intro = () => {
3205
3229
  const iframeRef = react.useRef(null);
3206
3230
  const app = useLlm(state => state.app);
3207
- // const introed = useLlmView(state => state.introed);
3208
- const {
3209
- send
3210
- } = useLlmView(state => state.actions);
3211
3231
  const {
3232
+ send,
3212
3233
  setIntroed
3213
3234
  } = useLlmView(state => state.actions);
3235
+ const skipCustomIntro = useLlmView(state => state.skipCustomIntro);
3214
3236
  const motionItem = {
3215
3237
  hidden: {
3216
3238
  y: '40px'
@@ -3281,25 +3303,6 @@ const Intro = () => {
3281
3303
  }
3282
3304
  return () => {};
3283
3305
  }, [setIntroed]);
3284
- /*
3285
- const onIntroed = (newIntroed: boolean) => {
3286
- console.log('onIntroed', 'introed', introed, 'newIntroed', newIntroed);
3287
- if (newIntroed !== introed) {
3288
- setIntroed(newIntroed);
3289
- }
3290
- };
3291
- useEffect(() => {
3292
- const onScroll = () => {
3293
- if (iframeRef.current) {
3294
- const rect = iframeRef.current.getBoundingClientRect();
3295
- console.log('onScroll', rect.bottom < window.innerHeight);
3296
- onIntroed(rect.bottom < window.innerHeight);
3297
- }
3298
- }
3299
- window.addEventListener('scroll', onScroll);
3300
- return () => window.removeEventListener('scroll', onScroll);
3301
- }, [setIntroed]);
3302
- */
3303
3306
  react.useEffect(() => {
3304
3307
  const onLenisScroll = () => {
3305
3308
  if (iframeRef.current) {
@@ -3317,7 +3320,7 @@ const Intro = () => {
3317
3320
  if (!app) {
3318
3321
  return;
3319
3322
  }
3320
- return app.contents.customIntro ? jsxRuntime.jsx("div", {
3323
+ return app.contents.customIntro ? skipCustomIntro ? null : jsxRuntime.jsx("div", {
3321
3324
  className: "llm__customIntro",
3322
3325
  children: jsxRuntime.jsx("iframe", {
3323
3326
  ref: iframeRef,
@@ -3688,6 +3691,40 @@ const Dialog = _a => {
3688
3691
  })) : jsxRuntime.jsx(jsxRuntime.Fragment, {}), portal);
3689
3692
  };
3690
3693
 
3694
+ const StaticNode = _a => {
3695
+ var {
3696
+ outerRef,
3697
+ playing
3698
+ } = _a,
3699
+ props = __rest(_a, ["outerRef", "playing"]);
3700
+ const innerRef = react.useRef(null);
3701
+ react.useEffect(() => {
3702
+ if (innerRef.current && outerRef.current) {
3703
+ outerRef.current.removeAttribute('style');
3704
+ innerRef.current.appendChild(outerRef.current);
3705
+ }
3706
+ }, [innerRef, outerRef]);
3707
+ const onClose = () => {
3708
+ if (typeof props.onClose === 'function') {
3709
+ props.onClose();
3710
+ }
3711
+ };
3712
+ const classNames = bomCore.getClassNames('llm__thron-player', 'llm__video', '-enlarged', {
3713
+ '-playing': playing
3714
+ });
3715
+ return jsxRuntime.jsxs(jsxRuntime.Fragment, {
3716
+ children: [jsxRuntime.jsx("div", {
3717
+ ref: innerRef,
3718
+ className: classNames
3719
+ }), jsxRuntime.jsx("button", {
3720
+ type: "button",
3721
+ className: "llm__video-reduce",
3722
+ onClick: () => onClose(),
3723
+ "aria-label": "Reduce",
3724
+ children: jsxRuntime.jsx(bomMixerIcons.IconLlmMinimize, {})
3725
+ })]
3726
+ });
3727
+ };
3691
3728
  const ThronPlayer = props => {
3692
3729
  const id = react.useMemo(() => {
3693
3730
  return `video-${props.media.xcontentId}-${Math.round(Math.random() * 10000)}`;
@@ -3814,40 +3851,6 @@ const ThronPlayer = props => {
3814
3851
  })]
3815
3852
  });
3816
3853
  };
3817
- const StaticNode = _a => {
3818
- var {
3819
- outerRef,
3820
- playing
3821
- } = _a,
3822
- props = __rest(_a, ["outerRef", "playing"]);
3823
- const innerRef = react.useRef(null);
3824
- react.useEffect(() => {
3825
- if (innerRef.current && outerRef.current) {
3826
- outerRef.current.removeAttribute('style');
3827
- innerRef.current.appendChild(outerRef.current);
3828
- }
3829
- }, [innerRef, outerRef]);
3830
- const onClose = () => {
3831
- if (typeof props.onClose === 'function') {
3832
- props.onClose();
3833
- }
3834
- };
3835
- const classNames = bomCore.getClassNames('llm__thron-player', 'llm__video', '-enlarged', {
3836
- '-playing': playing
3837
- });
3838
- return jsxRuntime.jsxs(jsxRuntime.Fragment, {
3839
- children: [jsxRuntime.jsx("div", {
3840
- ref: innerRef,
3841
- className: classNames
3842
- }), jsxRuntime.jsx("button", {
3843
- type: "button",
3844
- className: "llm__video-reduce",
3845
- onClick: () => onClose(),
3846
- "aria-label": "Reduce",
3847
- children: jsxRuntime.jsx(bomMixerIcons.IconLlmMinimize, {})
3848
- })]
3849
- });
3850
- };
3851
3854
 
3852
3855
  const VideoPlayer = props => {
3853
3856
  const id = react.useId();
@@ -3977,7 +3980,7 @@ const Card = props => {
3977
3980
  dangerouslySetInnerHTML: {
3978
3981
  __html: props.abstract
3979
3982
  }
3980
- }), props.cardType !== 'full' && props.cta.url && jsxRuntime.jsxs("a", {
3983
+ }), props.cta && props.cta.url && jsxRuntime.jsxs("a", {
3981
3984
  className: "llm__card-cta",
3982
3985
  href: props.cta.url,
3983
3986
  target: "_blank",
@@ -4885,6 +4888,7 @@ const Main = () => {
4885
4888
  animate: "show",
4886
4889
  exit: "exit",
4887
4890
  className: classNames,
4891
+ "data-lenis-prevent": true,
4888
4892
  children: [visible && jsxRuntime.jsx(Canvas, {}), !embedded && jsxRuntime.jsx(framerMotion.motion.div, {
4889
4893
  className: "llm__top",
4890
4894
  variants: slideIn(-1),
@@ -5007,40 +5011,6 @@ const LlmComponent = /*#__PURE__*/react.forwardRef((props, ref) => {
5007
5011
  document.documentElement.style.overflow = opened ? 'hidden' : 'auto';
5008
5012
  }
5009
5013
  }, [opened, embedded]);
5010
- /*
5011
- useEffect(() => {
5012
- if (innerRef.current) {
5013
- const observer = new MutationObserver((mutations) => {
5014
- const target = mutations[0].target as HTMLDivElement;
5015
- const mutatedVars: Partial<LlmVars> = {};
5016
- Object.entries(vars).forEach(([k, v]) => {
5017
- const newValue = target.style.getPropertyValue(k);
5018
- if (v !== newValue) {
5019
- mutatedVars[k] = newValue;
5020
- }
5021
- if (
5022
- k === '--llm-color-base-100' ||
5023
- k === '--llm-color-base-200' ||
5024
- k === '--llm-color-base-300' ||
5025
- k === '--llm-color-base-400'
5026
- ) {
5027
- console.log(k, newValue, v);
5028
- }
5029
- });
5030
- if (Object.keys(mutatedVars).length > 0) {
5031
- setVars(mutatedVars);
5032
- }
5033
- });
5034
- observer.observe(innerRef.current, {
5035
- attributes: true,
5036
- attributeFilter: ['style'],
5037
- });
5038
- return () => observer.disconnect();
5039
- } else {
5040
- return () => { };
5041
- }
5042
- }, []);
5043
- */
5044
5014
  const shouldShowTrigger = !opened && !idle && !embed || (app === null || app === void 0 ? void 0 : app.contents.customIntro) && !introed;
5045
5015
  const classNames = bomCore.getClassNames('llm', {
5046
5016
  '-open': opened,