@websolutespa/bom-llm 0.0.1
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 +7 -0
- package/README.md +113 -0
- package/dist/umd/index.css +2796 -0
- package/dist/umd/index.js +26319 -0
- package/dist/umd/index.js.map +1 -0
- package/package.json +101 -0
- package/src/__tests/example.test.ts +8 -0
- package/src/app.scss +128 -0
- package/src/app.tsx +125 -0
- package/src/error-handler.tsx +20 -0
- package/src/index.ts +1 -0
- package/src/label.json +128 -0
- package/src/main.tsx +28 -0
- package/src/types.ts +13 -0
package/package.json
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@websolutespa/bom-llm",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "LLM module of the BOM Repository",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"bom",
|
|
7
|
+
"llm"
|
|
8
|
+
],
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git://github.com/websolutespa/bom.git"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"lint": "eslint *.ts*",
|
|
16
|
+
"test": "jest",
|
|
17
|
+
"test-watch": "npm test -- --watch",
|
|
18
|
+
"coverage:integration": "npm run test -- --coverage",
|
|
19
|
+
"coverage": "run-s -c --silent coverage:*",
|
|
20
|
+
"compile": "rollup -c ./rollup.config.js --bundleConfigAsCjs",
|
|
21
|
+
"prepack": "bom prepack",
|
|
22
|
+
"postpack": "bom postpack"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@websolutespa/bom-core": "*",
|
|
26
|
+
"@websolutespa/bom-mixer-forms": "*",
|
|
27
|
+
"@websolutespa/bom-mixer-hooks": "*",
|
|
28
|
+
"@websolutespa/bom-mixer-icons": "*",
|
|
29
|
+
"@websolutespa/bom-mixer-llm": "*",
|
|
30
|
+
"framer-motion": "^10.16.12",
|
|
31
|
+
"react-dom": "^18.2.0",
|
|
32
|
+
"react-error-boundary": "^4.0.11",
|
|
33
|
+
"react": "^18.2.0",
|
|
34
|
+
"swiper": "^8.3.2",
|
|
35
|
+
"zustand": "^4.4.0"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@babel/core": "^7.21.0",
|
|
40
|
+
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
41
|
+
"@babel/preset-env": "^7.20.2",
|
|
42
|
+
"@babel/preset-react": "^7.18.6",
|
|
43
|
+
"@babel/preset-typescript": "^7.21.0",
|
|
44
|
+
"@rollup/plugin-babel": "^6.0.3",
|
|
45
|
+
"@rollup/plugin-commonjs": "^24.0.1",
|
|
46
|
+
"@rollup/plugin-json": "^6.0.0",
|
|
47
|
+
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
48
|
+
"@rollup/plugin-replace": "^5.0.5",
|
|
49
|
+
"@rollup/plugin-terser": "^0.4.0",
|
|
50
|
+
"@rollup/plugin-typescript": "^11.0.0",
|
|
51
|
+
"@svgr/rollup": "^6.5.1",
|
|
52
|
+
"@types/cross-spawn": "latest",
|
|
53
|
+
"@types/react-dom": "^18.2.7",
|
|
54
|
+
"@types/react": "^18.2.18",
|
|
55
|
+
"@websolutespa/bom-cli": "*",
|
|
56
|
+
"@websolutespa/test": "*",
|
|
57
|
+
"@websolutespa/tsconfig": "*",
|
|
58
|
+
"babel-loader": "^9.1.2",
|
|
59
|
+
"babel-plugin-styled-components": "^2.0.7",
|
|
60
|
+
"babel-preset-react-app": "^10.0.1",
|
|
61
|
+
"cross-spawn": "latest",
|
|
62
|
+
"eslint-config-websolute": "*",
|
|
63
|
+
"eslint": "^8.46.0",
|
|
64
|
+
"node-sass": "^8.0.0",
|
|
65
|
+
"npm-run-all": "^4.1.5",
|
|
66
|
+
"raw-loader": "^4.0.2",
|
|
67
|
+
"react-dom": "^18.2.0",
|
|
68
|
+
"react-error-boundary": "^4.0.11",
|
|
69
|
+
"react": "^18.2.0",
|
|
70
|
+
"rimraf": "3.0.2",
|
|
71
|
+
"rollup-plugin-copy": "^3.4.0",
|
|
72
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
73
|
+
"rollup-plugin-postcss": "^4.0.2",
|
|
74
|
+
"rollup-plugin-scss": "^4.0.0",
|
|
75
|
+
"rollup-plugin-typescript2": "^0.34.1",
|
|
76
|
+
"rollup": "^3.17.3",
|
|
77
|
+
"sass-loader": "^13.2.0",
|
|
78
|
+
"sass": "^1.66.1",
|
|
79
|
+
"ts-node": "^10.9.1",
|
|
80
|
+
"tsup": "^6.7.0",
|
|
81
|
+
"typescript": "^5.1.6"
|
|
82
|
+
},
|
|
83
|
+
"publishConfig": {
|
|
84
|
+
"access": "public"
|
|
85
|
+
},
|
|
86
|
+
"sideEffects": false,
|
|
87
|
+
"prepack": {
|
|
88
|
+
"types": "./dist/types/index.d.ts",
|
|
89
|
+
"main": "./dist/esm/index.js",
|
|
90
|
+
"module": "./dist/esm/index.js",
|
|
91
|
+
"source": "./src/index.ts"
|
|
92
|
+
},
|
|
93
|
+
"postpack": {
|
|
94
|
+
"types": "./src/index.ts",
|
|
95
|
+
"main": "./src/index.ts"
|
|
96
|
+
},
|
|
97
|
+
"types": "./dist/types/index.d.ts",
|
|
98
|
+
"main": "./dist/esm/index.js",
|
|
99
|
+
"module": "./dist/esm/index.js",
|
|
100
|
+
"source": "./src/index.ts"
|
|
101
|
+
}
|
package/src/app.scss
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
@import '../../../mixer/packages/ui/src/theme/mixins/scrollbar';
|
|
2
|
+
|
|
3
|
+
.llm {
|
|
4
|
+
|
|
5
|
+
html,
|
|
6
|
+
body,
|
|
7
|
+
p,
|
|
8
|
+
ol,
|
|
9
|
+
ul,
|
|
10
|
+
li,
|
|
11
|
+
dl,
|
|
12
|
+
dt,
|
|
13
|
+
dd,
|
|
14
|
+
blockquote,
|
|
15
|
+
figure,
|
|
16
|
+
fieldset,
|
|
17
|
+
legend,
|
|
18
|
+
textarea,
|
|
19
|
+
pre,
|
|
20
|
+
iframe,
|
|
21
|
+
hr,
|
|
22
|
+
h1,
|
|
23
|
+
h2,
|
|
24
|
+
h3,
|
|
25
|
+
h4,
|
|
26
|
+
h5,
|
|
27
|
+
h6 {
|
|
28
|
+
margin: 0;
|
|
29
|
+
padding: 0;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
h1,
|
|
33
|
+
h2,
|
|
34
|
+
h3,
|
|
35
|
+
h4,
|
|
36
|
+
h5,
|
|
37
|
+
h6 {
|
|
38
|
+
font-size: 100%;
|
|
39
|
+
font-weight: normal;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
ul {
|
|
43
|
+
list-style: none;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
button,
|
|
47
|
+
input,
|
|
48
|
+
select {
|
|
49
|
+
margin: 0;
|
|
50
|
+
padding: 0;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
button {
|
|
54
|
+
border: none;
|
|
55
|
+
text-decoration: none;
|
|
56
|
+
background: none;
|
|
57
|
+
appearance: none;
|
|
58
|
+
font-family: inherit;
|
|
59
|
+
font-style: inherit;
|
|
60
|
+
font-variant-ligatures: inherit;
|
|
61
|
+
font-variant-caps: inherit;
|
|
62
|
+
font-variant-numeric: inherit;
|
|
63
|
+
font-variant-east-asian: inherit;
|
|
64
|
+
font-weight: inherit;
|
|
65
|
+
font-stretch: inherit;
|
|
66
|
+
text-rendering: inherit;
|
|
67
|
+
letter-spacing: inherit;
|
|
68
|
+
word-spacing: inherit;
|
|
69
|
+
line-height: inherit;
|
|
70
|
+
text-transform: none;
|
|
71
|
+
text-indent: inherit;
|
|
72
|
+
text-shadow: none;
|
|
73
|
+
text-align: inherit;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
html {
|
|
77
|
+
box-sizing: border-box;
|
|
78
|
+
-webkit-text-size-adjust: none;
|
|
79
|
+
color-scheme: dark light;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
*,
|
|
83
|
+
*::before,
|
|
84
|
+
*::after {
|
|
85
|
+
box-sizing: inherit;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
img,
|
|
89
|
+
video {
|
|
90
|
+
height: auto;
|
|
91
|
+
max-width: 100%;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
iframe {
|
|
95
|
+
border: 0;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
table {
|
|
99
|
+
border-collapse: collapse;
|
|
100
|
+
border-spacing: 0;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
td,
|
|
104
|
+
th {
|
|
105
|
+
padding: 0;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
html,
|
|
109
|
+
body {
|
|
110
|
+
margin: 0;
|
|
111
|
+
padding: 0;
|
|
112
|
+
block-size: 100%;
|
|
113
|
+
block-size: 100dvb;
|
|
114
|
+
font-size: 20px;
|
|
115
|
+
line-height: 1.5;
|
|
116
|
+
font-family: system-ui, sans-serif;
|
|
117
|
+
-webkit-font-smoothing: antialiased;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
a {
|
|
121
|
+
color: inherit;
|
|
122
|
+
text-decoration: none;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
&__scroller {
|
|
126
|
+
@include scrollbar(rgba(255, 255, 255, 0.3));
|
|
127
|
+
}
|
|
128
|
+
}
|
package/src/app.tsx
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// app css
|
|
2
|
+
import './app.scss';
|
|
3
|
+
// llm css
|
|
4
|
+
import '@websolutespa/bom-mixer-llm/src/llm/scss/style.scss';
|
|
5
|
+
// imports
|
|
6
|
+
import { ILayout, IPage, isBrowser, localizeItem } from '@websolutespa/bom-core';
|
|
7
|
+
import { ExtraProvider, LabelProvider, LayoutProvider, PageProvider } from '@websolutespa/bom-mixer-hooks';
|
|
8
|
+
import { LlmComponent, LlmProvider } from '@websolutespa/bom-mixer-llm';
|
|
9
|
+
import { useMemo } from 'react';
|
|
10
|
+
import { ErrorBoundary } from 'react-error-boundary';
|
|
11
|
+
import { ErrorHandler } from './error-handler';
|
|
12
|
+
import label from './label.json';
|
|
13
|
+
import { LlmOptions } from './types';
|
|
14
|
+
|
|
15
|
+
export function App({ locale, market, ...props }: LlmOptions) {
|
|
16
|
+
const data = useMemo<PageData>(() => {
|
|
17
|
+
if (isBrowser) {
|
|
18
|
+
const htmlLang = getHtmlLang();
|
|
19
|
+
const title = document.querySelector('title');
|
|
20
|
+
const description = document.querySelector('meta[name="description"]');
|
|
21
|
+
const canonical = document.querySelector('link[rel="canonical"]');
|
|
22
|
+
return {
|
|
23
|
+
locale: locale || htmlLang?.locale || 'it',
|
|
24
|
+
market: market || htmlLang?.market || 'ww',
|
|
25
|
+
origin: window.origin,
|
|
26
|
+
canonical: canonical?.getAttribute('href') || window.location.href,
|
|
27
|
+
title: title ? title.innerText : 'Untitled',
|
|
28
|
+
description: description?.getAttribute('content') || '',
|
|
29
|
+
slug: window.location.pathname,
|
|
30
|
+
};
|
|
31
|
+
} else {
|
|
32
|
+
return {
|
|
33
|
+
locale: locale || 'it',
|
|
34
|
+
market: market || 'ww',
|
|
35
|
+
origin: '',
|
|
36
|
+
canonical: '',
|
|
37
|
+
title: 'Untitled',
|
|
38
|
+
description: '',
|
|
39
|
+
slug: '',
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}, [locale, market]);
|
|
43
|
+
const endpoint: string =
|
|
44
|
+
props.test ?
|
|
45
|
+
'https://bom-sample-basic-web-git-bom-llm-actarian.vercel.app' :
|
|
46
|
+
'https://ws-ai-ambassador-bowl.azurewebsites.net';
|
|
47
|
+
const layout: ILayout = {
|
|
48
|
+
labels: getLabels(data.locale),
|
|
49
|
+
locale: data.locale,
|
|
50
|
+
locales: [{
|
|
51
|
+
id: data.locale, title: data.locale,
|
|
52
|
+
}],
|
|
53
|
+
market: data.market,
|
|
54
|
+
markets: [{
|
|
55
|
+
id: data.market, title: data.market,
|
|
56
|
+
}],
|
|
57
|
+
menu: {},
|
|
58
|
+
topLevelHrefs: {},
|
|
59
|
+
topLevelRoutes: {},
|
|
60
|
+
};
|
|
61
|
+
const page: IPage = {
|
|
62
|
+
locale: data.locale,
|
|
63
|
+
market: data.market,
|
|
64
|
+
title: data.title,
|
|
65
|
+
abstract: data.description,
|
|
66
|
+
category: 'uncategorized',
|
|
67
|
+
slug: data.slug,
|
|
68
|
+
href: data.canonical,
|
|
69
|
+
id: 1,
|
|
70
|
+
alternates: [],
|
|
71
|
+
breadcrumb: [],
|
|
72
|
+
canonical: data.canonical,
|
|
73
|
+
};
|
|
74
|
+
const extra = {};
|
|
75
|
+
return (
|
|
76
|
+
<ErrorBoundary FallbackComponent={ErrorHandler}>
|
|
77
|
+
<LayoutProvider layout={layout}>
|
|
78
|
+
<LabelProvider>
|
|
79
|
+
<PageProvider page={page}>
|
|
80
|
+
<ExtraProvider extra={extra}>
|
|
81
|
+
<LlmProvider {...props} endpoint={endpoint} >
|
|
82
|
+
<LlmComponent />
|
|
83
|
+
</LlmProvider>
|
|
84
|
+
</ExtraProvider>
|
|
85
|
+
</PageProvider>
|
|
86
|
+
</LabelProvider>
|
|
87
|
+
</LayoutProvider>
|
|
88
|
+
</ErrorBoundary>
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function getLabels(locale: string) {
|
|
93
|
+
return label.map(x => {
|
|
94
|
+
const localizedItem = localizeItem(x, locale, 'en');
|
|
95
|
+
return {
|
|
96
|
+
id: localizedItem.id,
|
|
97
|
+
schema: 'label',
|
|
98
|
+
text: localizedItem.text,
|
|
99
|
+
};
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function getHtmlLang(): { locale: string, market: string } | undefined {
|
|
104
|
+
const html = document.querySelector('html');
|
|
105
|
+
const htmlLang = html?.getAttribute('lang');
|
|
106
|
+
if (htmlLang) {
|
|
107
|
+
const segments = htmlLang.toLowerCase().split('-');
|
|
108
|
+
return {
|
|
109
|
+
locale: segments[0],
|
|
110
|
+
market: segments[1] || 'ww',
|
|
111
|
+
};
|
|
112
|
+
} else {
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
type PageData = {
|
|
118
|
+
locale: string;
|
|
119
|
+
market: string;
|
|
120
|
+
origin: string;
|
|
121
|
+
canonical: string;
|
|
122
|
+
title: string;
|
|
123
|
+
description: string;
|
|
124
|
+
slug: string;
|
|
125
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
export function ErrorHandler({ error, resetErrorBoundary }: { error: any, resetErrorBoundary?: () => void }) {
|
|
3
|
+
console.log('ErrorHandler.error', error);
|
|
4
|
+
return (
|
|
5
|
+
<div style={{ minHeight: '100vh', background: '#101010', color: '#eeeeee' }}>
|
|
6
|
+
<div>
|
|
7
|
+
<div style={{ display: 'flex', gap: '1rem', alignItems: 'flex-start' }}>
|
|
8
|
+
<div>Unhandled Runtime Error</div>
|
|
9
|
+
<div>{error.message}</div>
|
|
10
|
+
{error.stack && (
|
|
11
|
+
<div>{error.stack}</div>
|
|
12
|
+
)}
|
|
13
|
+
{typeof resetErrorBoundary === 'function' && (
|
|
14
|
+
<button onClick={resetErrorBoundary}>Try again?</button>
|
|
15
|
+
)}
|
|
16
|
+
</div>
|
|
17
|
+
</div>
|
|
18
|
+
</div>
|
|
19
|
+
);
|
|
20
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './main';
|
package/src/label.json
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "llm.back",
|
|
4
|
+
"text": {
|
|
5
|
+
"en": "Back to website",
|
|
6
|
+
"it": "Torna al sito"
|
|
7
|
+
}
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"id": "llm.button",
|
|
11
|
+
"text": {
|
|
12
|
+
"en": "Open",
|
|
13
|
+
"it": "Avvia"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"id": "llm.disclaimer",
|
|
18
|
+
"text": {
|
|
19
|
+
"en": "The answers you will receive are created automatically by processing both the information on our site and other information on the web. Always check the correctness of the information provided. <a url=\"#\" target=\"_blank\">Find out how it works</a>",
|
|
20
|
+
"it": "Le risposte che riceverai sono create automaticamente elaborando sia le informazioni presenti sul nostro sito che altre informazioni presenti sul web. Controlla sempre la correttezza delle informazioni fornite. <a url=\"#\" target=\"_blank\">Scopri come funziona</a>"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"id": "llm.eventPretitle",
|
|
25
|
+
"text": {
|
|
26
|
+
"en": "Don't miss this event!",
|
|
27
|
+
"it": "Non perderti questo evento!"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"id": "llm.tellMeMore",
|
|
32
|
+
"text": {
|
|
33
|
+
"en": "Tell me more",
|
|
34
|
+
"it": "Dimmi di più"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"id": "llm.tellMeMoreAbout",
|
|
39
|
+
"text": {
|
|
40
|
+
"en": "Tell me more about",
|
|
41
|
+
"it": "Dimmi di più su"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"id": "llm.goToWebsite",
|
|
46
|
+
"text": {
|
|
47
|
+
"en": "Go to website",
|
|
48
|
+
"it": "Vai al sito"
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"id": "llm.bookNow",
|
|
53
|
+
"text": {
|
|
54
|
+
"en": "Book now",
|
|
55
|
+
"it": "Prenota ora"
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"id": "llm.reviews",
|
|
60
|
+
"text": {
|
|
61
|
+
"en": "reviews",
|
|
62
|
+
"it": "recensioni"
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"id": "llm.formRequestTitle",
|
|
67
|
+
"text": {
|
|
68
|
+
"en": "Do you want me to email you all the information we talked about so you have a reminder?",
|
|
69
|
+
"it": "Vuoi che ti mandi tutte le informazioni di cui abbiamo parlato per email, così avrai un promemoria?"
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"id": "llm.formRequestYes",
|
|
74
|
+
"text": {
|
|
75
|
+
"en": "Yes",
|
|
76
|
+
"it": "Sì"
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"id": "llm.formRequestNo",
|
|
81
|
+
"text": {
|
|
82
|
+
"en": "No",
|
|
83
|
+
"it": "No"
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"id": "llm.formRecapTitle",
|
|
88
|
+
"text": {
|
|
89
|
+
"en": "Please fill the form",
|
|
90
|
+
"it": "Compila le informazioni qui sotto"
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"id": "llm.formRecapFullName",
|
|
95
|
+
"text": {
|
|
96
|
+
"en": "Full name",
|
|
97
|
+
"it": "Nome completo"
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"id": "llm.formRecapEmail",
|
|
102
|
+
"text": {
|
|
103
|
+
"en": "Email",
|
|
104
|
+
"it": "Email"
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"id": "llm.formRecapSend",
|
|
109
|
+
"text": {
|
|
110
|
+
"en": "Send",
|
|
111
|
+
"it": "Invia"
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"id": "llm.formRecapPrivacy",
|
|
116
|
+
"text": {
|
|
117
|
+
"en": "I agree to be contacted for marketing activities",
|
|
118
|
+
"it": "Acconsento a essere ricontattato per attività di marketing"
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"id": "llm.formResponseYes",
|
|
123
|
+
"text": {
|
|
124
|
+
"en": "Excellent, you will find everything in your inbox, for anything else you know where to find me, I will always be happy to talk to you. 👋",
|
|
125
|
+
"it": "Ottimo, troverai tutto nella tua casella di posta, per qualunque altra cosa sai dove potermi trovare, sarò sempre lieto di parlare con te. 👋"
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
]
|
package/src/main.tsx
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ReactDOM from 'react-dom/client';
|
|
3
|
+
import { App } from './app';
|
|
4
|
+
import { LlmOptions } from './types';
|
|
5
|
+
|
|
6
|
+
export function bomLlm(props: LlmOptions): void {
|
|
7
|
+
if (!document) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const body = document.querySelector('body');
|
|
11
|
+
if (!body) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const node = document.createElement('div');
|
|
15
|
+
node.setAttribute('id', 'bom-llm');
|
|
16
|
+
body.appendChild(node);
|
|
17
|
+
ReactDOM.createRoot(node).render(
|
|
18
|
+
<React.StrictMode>
|
|
19
|
+
<App {...props} />
|
|
20
|
+
</React.StrictMode>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (typeof window !== 'undefined') {
|
|
25
|
+
(window as unknown as {
|
|
26
|
+
bomLlm: typeof bomLlm;
|
|
27
|
+
}).bomLlm = bomLlm;
|
|
28
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { LlmItem } from '@websolutespa/bom-mixer-llm';
|
|
2
|
+
|
|
3
|
+
export type LlmDecorateUrl = (item: LlmItem) => string | void;
|
|
4
|
+
|
|
5
|
+
export type LlmOptions = {
|
|
6
|
+
apiKey: string;
|
|
7
|
+
appKey: string;
|
|
8
|
+
decorateUrl?: LlmDecorateUrl;
|
|
9
|
+
locale?: string;
|
|
10
|
+
market?: string;
|
|
11
|
+
test?: boolean;
|
|
12
|
+
threadId?: string;
|
|
13
|
+
};
|