@websolutespa/bom-llm 0.0.16 → 0.0.18

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,17 @@
1
1
  # @websolutespa/bom-llm
2
2
 
3
+ ## 0.0.18
4
+
5
+ ### Patch Changes
6
+
7
+ - Added: flags preview, dismissable, opened, skipCustomIntro
8
+
9
+ ## 0.0.17
10
+
11
+ ### Patch Changes
12
+
13
+ - Modified: theme & cards
14
+
3
15
  ## 0.0.16
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1,5 +1,3 @@
1
- import { LlmInstance } from '@websolutespa/bom-mixer-llm';
2
-
3
1
  type DeepPartial<T> = T extends object ? {
4
2
  [P in keyof T]?: DeepPartial<T[P]>;
5
3
  } : T;
@@ -63,17 +61,25 @@ type LlmMock = {
63
61
  };
64
62
  type LlmTest = undefined | boolean | DeepPartial<LlmMock>;
65
63
  type LlmDecorateUrl = (item: LlmItem) => (string | void) | Promise<string | void>;
64
+ type LlmViewOptions = {
65
+ threadId?: string;
66
+ preview?: boolean;
67
+ opened?: boolean;
68
+ dismissable?: boolean;
69
+ skipCustomIntro?: boolean;
70
+ embedded?: boolean;
71
+ };
66
72
  type LlmOptions = {
67
73
  apiKey: string;
68
74
  appKey: string;
69
75
  decorateUrl?: LlmDecorateUrl;
70
76
  test?: LlmTest;
71
- threadId?: string;
72
77
  customTheme?: Partial<LlmTheme>;
73
- opened?: boolean;
74
- embedded?: boolean;
75
78
  locale?: string;
76
79
  market?: string;
80
+ } & LlmViewOptions;
81
+ type LlmInstance = {
82
+ open: () => void;
77
83
  };
78
84
 
79
85
  declare function bomLlm(props: LlmOptions): LlmInstance | undefined;
@@ -1022,8 +1022,7 @@ llm-embed {
1022
1022
  position: absolute;
1023
1023
  padding: clamp(16px, 16px + (100vw - 375px) / 1545 * (8), 24px);
1024
1024
  width: calc(100vw - 40px);
1025
- min-width: 240px;
1026
- max-width: 460px;
1025
+ max-width: var(--llm-popup-max-width);
1027
1026
  left: 50%;
1028
1027
  bottom: calc(100% + 12px);
1029
1028
  translate: -50% 0%;
@@ -1041,8 +1040,7 @@ llm-embed {
1041
1040
  }
1042
1041
  .llm .llm__trigger-welcome > div + div {
1043
1042
  width: calc(100vw - 40px);
1044
- min-width: 240px;
1045
- max-width: 460px;
1043
+ max-width: var(--llm-popup-max-width);
1046
1044
  translate: -50% 10%;
1047
1045
  opacity: 0;
1048
1046
  }
@@ -1905,7 +1903,7 @@ llm-embed {
1905
1903
  display: flex;
1906
1904
  justify-content: center;
1907
1905
  align-items: center;
1908
- aspect-ratio: 240/165;
1906
+ aspect-ratio: var(--llm-card-aspect-ratio);
1909
1907
  border-radius: 24px;
1910
1908
  overflow: hidden;
1911
1909
  background: var(--llm-color-neutral-200);
@@ -1930,7 +1928,7 @@ llm-embed {
1930
1928
  }
1931
1929
  .llm .llm__card--video .llm__card-asset {
1932
1930
  border-radius: 0;
1933
- aspect-ratio: 16/9;
1931
+ aspect-ratio: var(--llm-card-video-aspect-ratio);
1934
1932
  }
1935
1933
  .llm .llm__card--full .llm__card-media {
1936
1934
  position: absolute;
@@ -2148,33 +2146,33 @@ llm-embed {
2148
2146
  cursor: pointer;
2149
2147
  }
2150
2148
 
2151
- .llm .llm__thron-player .th-video .th-video-player .th-video-poster {
2149
+ .llm__thron-player .th-video .th-video-player .th-video-poster {
2152
2150
  background-size: cover;
2153
2151
  }
2154
- .llm .llm__thron-player .th-player-external-element.th-std-bars,
2155
- .llm .llm__thron-player .th-player.th-std-bars {
2152
+ .llm__thron-player .th-player-external-element.th-std-bars,
2153
+ .llm__thron-player .th-player.th-std-bars {
2156
2154
  width: 100%;
2157
2155
  height: 100%;
2158
2156
  border-radius: 0;
2159
2157
  margin: 0;
2160
2158
  }
2161
- .llm .llm__thron-player .th-video .th-video-player .th-display-icon-wrapper {
2159
+ .llm__thron-player .th-video .th-video-player .th-display-icon-wrapper {
2162
2160
  display: none;
2163
2161
  }
2164
- .llm .llm__thron-player:not(.-enlarged) .th-control-bar.th-horizontal.th-top {
2162
+ .llm__thron-player:not(.-enlarged) .th-control-bar.th-horizontal.th-top {
2165
2163
  display: none;
2166
2164
  }
2167
- .llm .llm__thron-player:not(.-enlarged) .th-time-info {
2165
+ .llm__thron-player:not(.-enlarged) .th-time-info {
2168
2166
  display: none;
2169
2167
  }
2170
- .llm .llm__thron-player:not(.-enlarged) .th-control-bar.th-horizontal .th-group .th-button,
2171
- .llm .llm__thron-player:not(.-enlarged) .th-control-bar.th-horizontal .th-group .th-toggle-button:not(.th-fullscreen-button) {
2168
+ .llm__thron-player:not(.-enlarged) .th-control-bar.th-horizontal .th-group .th-button,
2169
+ .llm__thron-player:not(.-enlarged) .th-control-bar.th-horizontal .th-group .th-toggle-button:not(.th-fullscreen-button) {
2172
2170
  display: none;
2173
2171
  }
2174
- .llm .llm__thron-player:not(.-enlarged) .th-time-rail {
2172
+ .llm__thron-player:not(.-enlarged) .th-time-rail {
2175
2173
  display: none;
2176
2174
  }
2177
- .llm .llm__thron-player.-enlarged {
2175
+ .llm__thron-player.-enlarged {
2178
2176
  position: fixed;
2179
2177
  width: calc(100vw - 40px);
2180
2178
  height: calc((100vw - 40px) / 16 * 9);
package/dist/umd/index.js CHANGED
@@ -23083,6 +23083,9 @@
23083
23083
  foreground: 'var(--llm-color-base-100)',
23084
23084
  boxShadow: '0 0 30px rgba(0, 0, 0, 0.3)'
23085
23085
  },
23086
+ popup: {
23087
+ maxWidth: '210px'
23088
+ },
23086
23089
  hint: {
23087
23090
  fontFamily: 'var(--llm-font-primary)',
23088
23091
  background: 'linear-gradient(rgba(154, 154, 154, 0.2) 10%, rgba(221, 221, 221, 0.1) 80%)',
@@ -23108,7 +23111,11 @@
23108
23111
  },
23109
23112
  card: {
23110
23113
  background: 'var(--llm-color-neutral-100)',
23111
- foreground: 'var(--llm-color-neutral-900)'
23114
+ foreground: 'var(--llm-color-neutral-900)',
23115
+ aspectRatio: '240 / 165'
23116
+ },
23117
+ cardVideo: {
23118
+ aspectRatio: '16 / 9'
23112
23119
  },
23113
23120
  markdown: {
23114
23121
  marginTop: '0.5rem',
@@ -24048,7 +24055,7 @@ ${Object.entries(vars).map(_ref2 => {
24048
24055
  message: 'Bad Request: html is missing'
24049
24056
  };
24050
24057
  }
24051
- console.log('/llm/summary', payload);
24058
+ // console.log('/llm/summary', payload);
24052
24059
  return {
24053
24060
  code: 'SENT'
24054
24061
  };
@@ -24946,15 +24953,19 @@ ${Object.entries(vars).map(_ref2 => {
24946
24953
  const createLlmViewStore = _ref => {
24947
24954
  let {
24948
24955
  threadId,
24956
+ dismissable = true,
24957
+ skipCustomIntro = false,
24949
24958
  opened,
24950
24959
  embedded,
24951
24960
  send,
24952
24961
  setEmbed
24953
24962
  } = _ref;
24954
24963
  const props = {
24955
- opened: opened != null || embedded != null ? Boolean(opened || embedded) : threadId != null ? true : false,
24964
+ opened: opened != null ? opened : embedded != null || threadId != null ? true : false,
24965
+ dismissable: embedded ? false : dismissable,
24966
+ skipCustomIntro: skipCustomIntro,
24956
24967
  embedded: embedded || false,
24957
- introed: false,
24968
+ introed: skipCustomIntro ? true : false,
24958
24969
  hidden: false,
24959
24970
  fixed: false,
24960
24971
  idle: true,
@@ -25157,11 +25168,12 @@ ${Object.entries(vars).map(_ref2 => {
25157
25168
  appKey,
25158
25169
  apiKey,
25159
25170
  threadId,
25160
- customTheme,
25161
25171
  decorateUrl,
25162
25172
  endpoint,
25163
- test,
25164
25173
  storage,
25174
+ test,
25175
+ preview,
25176
+ customTheme,
25165
25177
  label
25166
25178
  } = _ref;
25167
25179
  const theme = getTheme(customTheme);
@@ -25193,7 +25205,8 @@ ${Object.entries(vars).map(_ref2 => {
25193
25205
  threadId,
25194
25206
  endpoint,
25195
25207
  locale,
25196
- test
25208
+ test,
25209
+ preview
25197
25210
  });
25198
25211
  return apiService;
25199
25212
  },
@@ -25204,7 +25217,8 @@ ${Object.entries(vars).map(_ref2 => {
25204
25217
  threadId,
25205
25218
  endpoint,
25206
25219
  locale,
25207
- test
25220
+ test,
25221
+ preview
25208
25222
  });
25209
25223
  const app = await apiService.getInfo();
25210
25224
  if (!app) {
@@ -25481,6 +25495,15 @@ ${Object.entries(vars).map(_ref2 => {
25481
25495
  ...props
25482
25496
  } = _ref3;
25483
25497
  const label = useLabel();
25498
+ if (props.embedded) {
25499
+ props.dismissable = false;
25500
+ props.opened = true;
25501
+ }
25502
+ if (props.preview) {
25503
+ props.dismissable = false;
25504
+ props.opened = true;
25505
+ props.skipCustomIntro = true;
25506
+ }
25484
25507
  const storeRef = reactExports.useRef();
25485
25508
  if (!storeRef.current) {
25486
25509
  storeRef.current = createSharedLlmStore({
@@ -26597,6 +26620,7 @@ void main(void) {
26597
26620
  } = useLlmView(state => state.actions);
26598
26621
  const hidden = useLlmView(state => state.hidden);
26599
26622
  const fixed = useLlmView(state => state.fixed);
26623
+ const dismissable = useLlmView(state => state.dismissable);
26600
26624
  const label = useLabel();
26601
26625
  const logo = app?.contents.logo;
26602
26626
  const logoMini = app?.contents?.logoMini;
@@ -26623,7 +26647,7 @@ void main(void) {
26623
26647
  alt: logoMini.alt
26624
26648
  })
26625
26649
  })]
26626
- }), /*#__PURE__*/jsxRuntimeExports.jsxs("button", {
26650
+ }), dismissable && /*#__PURE__*/jsxRuntimeExports.jsxs("button", {
26627
26651
  className: "llm__header-back -llm-t-cta-3",
26628
26652
  onClick: () => open(),
26629
26653
  children: [label('llm.back'), /*#__PURE__*/jsxRuntimeExports.jsx(IconLlmArrowCornerRightUp, {})]
@@ -26830,13 +26854,11 @@ void main(void) {
26830
26854
  const Intro = () => {
26831
26855
  const iframeRef = reactExports.useRef(null);
26832
26856
  const app = useLlm(state => state.app);
26833
- // const introed = useLlmView(state => state.introed);
26834
- const {
26835
- send
26836
- } = useLlmView(state => state.actions);
26837
26857
  const {
26858
+ send,
26838
26859
  setIntroed
26839
26860
  } = useLlmView(state => state.actions);
26861
+ const skipCustomIntro = useLlmView(state => state.skipCustomIntro);
26840
26862
  const motionItem = {
26841
26863
  hidden: {
26842
26864
  y: '40px'
@@ -26906,27 +26928,6 @@ void main(void) {
26906
26928
  }
26907
26929
  return () => {};
26908
26930
  }, [setIntroed]);
26909
-
26910
- /*
26911
- const onIntroed = (newIntroed: boolean) => {
26912
- console.log('onIntroed', 'introed', introed, 'newIntroed', newIntroed);
26913
- if (newIntroed !== introed) {
26914
- setIntroed(newIntroed);
26915
- }
26916
- };
26917
- useEffect(() => {
26918
- const onScroll = () => {
26919
- if (iframeRef.current) {
26920
- const rect = iframeRef.current.getBoundingClientRect();
26921
- console.log('onScroll', rect.bottom < window.innerHeight);
26922
- onIntroed(rect.bottom < window.innerHeight);
26923
- }
26924
- }
26925
- window.addEventListener('scroll', onScroll);
26926
- return () => window.removeEventListener('scroll', onScroll);
26927
- }, [setIntroed]);
26928
- */
26929
-
26930
26931
  reactExports.useEffect(() => {
26931
26932
  const onLenisScroll = () => {
26932
26933
  if (iframeRef.current) {
@@ -26944,7 +26945,7 @@ void main(void) {
26944
26945
  if (!app) {
26945
26946
  return;
26946
26947
  }
26947
- return app.contents.customIntro ? /*#__PURE__*/jsxRuntimeExports.jsx("div", {
26948
+ return app.contents.customIntro ? skipCustomIntro ? null : /*#__PURE__*/jsxRuntimeExports.jsx("div", {
26948
26949
  className: "llm__customIntro",
26949
26950
  children: /*#__PURE__*/jsxRuntimeExports.jsx("iframe", {
26950
26951
  ref: iframeRef,
@@ -27313,6 +27314,40 @@ void main(void) {
27313
27314
  }) : /*#__PURE__*/jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {}), portal);
27314
27315
  };
27315
27316
 
27317
+ const StaticNode = _ref => {
27318
+ let {
27319
+ outerRef,
27320
+ playing,
27321
+ ...props
27322
+ } = _ref;
27323
+ const innerRef = reactExports.useRef(null);
27324
+ reactExports.useEffect(() => {
27325
+ if (innerRef.current && outerRef.current) {
27326
+ outerRef.current.removeAttribute('style');
27327
+ innerRef.current.appendChild(outerRef.current);
27328
+ }
27329
+ }, [innerRef, outerRef]);
27330
+ const onClose = () => {
27331
+ if (typeof props.onClose === 'function') {
27332
+ props.onClose();
27333
+ }
27334
+ };
27335
+ const classNames = getClassNames('llm__thron-player', 'llm__video', '-enlarged', {
27336
+ '-playing': playing
27337
+ });
27338
+ return /*#__PURE__*/jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, {
27339
+ children: [/*#__PURE__*/jsxRuntimeExports.jsx("div", {
27340
+ ref: innerRef,
27341
+ className: classNames
27342
+ }), /*#__PURE__*/jsxRuntimeExports.jsx("button", {
27343
+ type: "button",
27344
+ className: "llm__video-reduce",
27345
+ onClick: () => onClose(),
27346
+ "aria-label": "Reduce",
27347
+ children: /*#__PURE__*/jsxRuntimeExports.jsx(IconLlmMinimize, {})
27348
+ })]
27349
+ });
27350
+ };
27316
27351
  const ThronPlayer = props => {
27317
27352
  const id = reactExports.useMemo(() => {
27318
27353
  return `video-${props.media.xcontentId}-${Math.round(Math.random() * 10000)}`;
@@ -27439,40 +27474,6 @@ void main(void) {
27439
27474
  })]
27440
27475
  });
27441
27476
  };
27442
- const StaticNode = _ref => {
27443
- let {
27444
- outerRef,
27445
- playing,
27446
- ...props
27447
- } = _ref;
27448
- const innerRef = reactExports.useRef(null);
27449
- reactExports.useEffect(() => {
27450
- if (innerRef.current && outerRef.current) {
27451
- outerRef.current.removeAttribute('style');
27452
- innerRef.current.appendChild(outerRef.current);
27453
- }
27454
- }, [innerRef, outerRef]);
27455
- const onClose = () => {
27456
- if (typeof props.onClose === 'function') {
27457
- props.onClose();
27458
- }
27459
- };
27460
- const classNames = getClassNames('llm__thron-player', 'llm__video', '-enlarged', {
27461
- '-playing': playing
27462
- });
27463
- return /*#__PURE__*/jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, {
27464
- children: [/*#__PURE__*/jsxRuntimeExports.jsx("div", {
27465
- ref: innerRef,
27466
- className: classNames
27467
- }), /*#__PURE__*/jsxRuntimeExports.jsx("button", {
27468
- type: "button",
27469
- className: "llm__video-reduce",
27470
- onClick: () => onClose(),
27471
- "aria-label": "Reduce",
27472
- children: /*#__PURE__*/jsxRuntimeExports.jsx(IconLlmMinimize, {})
27473
- })]
27474
- });
27475
- };
27476
27477
 
27477
27478
  const VideoPlayer = props => {
27478
27479
  const id = reactExports.useId();
@@ -27607,7 +27608,7 @@ void main(void) {
27607
27608
  dangerouslySetInnerHTML: {
27608
27609
  __html: props.abstract
27609
27610
  }
27610
- }), props.cardType !== 'full' && props.cta.url && /*#__PURE__*/jsxRuntimeExports.jsxs("a", {
27611
+ }), props.cta && props.cta.url && /*#__PURE__*/jsxRuntimeExports.jsxs("a", {
27611
27612
  className: "llm__card-cta",
27612
27613
  href: props.cta.url,
27613
27614
  target: "_blank",
@@ -30876,6 +30877,7 @@ void main(void) {
30876
30877
  animate: "show",
30877
30878
  exit: "exit",
30878
30879
  className: classNames,
30880
+ "data-lenis-prevent": true,
30879
30881
  children: [visible && /*#__PURE__*/jsxRuntimeExports.jsx(Canvas, {}), !embedded && /*#__PURE__*/jsxRuntimeExports.jsx(motion.div, {
30880
30882
  className: "llm__top",
30881
30883
  variants: slideIn(-1),
@@ -30998,42 +31000,6 @@ void main(void) {
30998
31000
  document.documentElement.style.overflow = opened ? 'hidden' : 'auto';
30999
31001
  }
31000
31002
  }, [opened, embedded]);
31001
-
31002
- /*
31003
- useEffect(() => {
31004
- if (innerRef.current) {
31005
- const observer = new MutationObserver((mutations) => {
31006
- const target = mutations[0].target as HTMLDivElement;
31007
- const mutatedVars: Partial<LlmVars> = {};
31008
- Object.entries(vars).forEach(([k, v]) => {
31009
- const newValue = target.style.getPropertyValue(k);
31010
- if (v !== newValue) {
31011
- mutatedVars[k] = newValue;
31012
- }
31013
- if (
31014
- k === '--llm-color-base-100' ||
31015
- k === '--llm-color-base-200' ||
31016
- k === '--llm-color-base-300' ||
31017
- k === '--llm-color-base-400'
31018
- ) {
31019
- console.log(k, newValue, v);
31020
- }
31021
- });
31022
- if (Object.keys(mutatedVars).length > 0) {
31023
- setVars(mutatedVars);
31024
- }
31025
- });
31026
- observer.observe(innerRef.current, {
31027
- attributes: true,
31028
- attributeFilter: ['style'],
31029
- });
31030
- return () => observer.disconnect();
31031
- } else {
31032
- return () => { };
31033
- }
31034
- }, []);
31035
- */
31036
-
31037
31003
  const shouldShowTrigger = !opened && !idle && !embed || app?.contents.customIntro && !introed;
31038
31004
  const classNames = getClassNames('llm', {
31039
31005
  '-open': opened,
@@ -31352,7 +31318,7 @@ void main(void) {
31352
31318
  };
31353
31319
  }
31354
31320
  }, [locale, market]);
31355
- const endpoint = props.test === true ? 'https://bom-sample-basic-web-git-bom-llm-actarian.vercel.app' : 'https://platform.websolute.ai';
31321
+ const endpoint = typeof props.test !== 'undefined' ? 'https://bom-sample-basic-web-git-bom-llm-actarian.vercel.app' : 'https://platform.websolute.ai';
31356
31322
  const layout = {
31357
31323
  labels: getLabels(data.locale),
31358
31324
  locale: data.locale,