@tellyouai/plugin 0.1.0
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/README.md +125 -0
- package/dist/package/index.d.ts +3 -0
- package/dist/package/index.js +85504 -0
- package/dist/package/public.d.ts +156 -0
- package/package.json +66 -0
package/README.md
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# Tellyou AI Plugin
|
|
2
|
+
|
|
3
|
+
The plugin is available as a self-contained browser SDK and as the existing
|
|
4
|
+
Cloudflare-hosted script. The npm package bundles its runtime dependencies, so
|
|
5
|
+
it can be used from React, Vue, Svelte, or a plain browser application.
|
|
6
|
+
|
|
7
|
+
## npm
|
|
8
|
+
|
|
9
|
+
Pin an exact release when application behavior must remain stable:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm install --save-exact @tellyouai/plugin@0.1.0
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Initialize the plugin after the page has loaded:
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { initialize } from "@tellyouai/plugin";
|
|
19
|
+
|
|
20
|
+
const plugin = await initialize({
|
|
21
|
+
entityId: "YOUR_ENTITY_ID",
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
plugin.toggle({ open: true });
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
For an inline or otherwise custom target, create the element before
|
|
28
|
+
initializing:
|
|
29
|
+
|
|
30
|
+
```html
|
|
31
|
+
<div id="support"></div>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import { initialize, type InstanceConfig } from "@tellyouai/plugin";
|
|
36
|
+
|
|
37
|
+
const config: InstanceConfig = {
|
|
38
|
+
entityId: "YOUR_ENTITY_ID",
|
|
39
|
+
target: "support",
|
|
40
|
+
displayMode: "inline",
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const plugin = await initialize(config);
|
|
44
|
+
plugin.update({ options: { theme: "dark" } });
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Pass an array to initialize multiple instances. The returned controller also
|
|
48
|
+
provides `load`, `goTo`, `setConsent`, and `update` methods. Importing the
|
|
49
|
+
package is safe in server-side builds, but `initialize` must run in a browser.
|
|
50
|
+
|
|
51
|
+
## CDN script
|
|
52
|
+
|
|
53
|
+
Existing script integrations remain supported:
|
|
54
|
+
|
|
55
|
+
```html
|
|
56
|
+
<script
|
|
57
|
+
type="module"
|
|
58
|
+
src="https://app.tellyou.ai/tellyouai-plugin.js?entityId=YOUR_ENTITY_ID"
|
|
59
|
+
></script>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Query-string configuration belongs to the CDN entry. npm consumers pass all
|
|
63
|
+
configuration to `initialize` directly.
|
|
64
|
+
|
|
65
|
+
## Consent and storage
|
|
66
|
+
|
|
67
|
+
The plugin automatically reads IAB TCF v2, Cookiebot, OneTrust, and Didomi
|
|
68
|
+
consent when those APIs are available on the host page. Automatic mode grants
|
|
69
|
+
functional storage and analytics by default, including when no CMP is present,
|
|
70
|
+
and responds when a CMP later reports that consent was revoked.
|
|
71
|
+
|
|
72
|
+
The host can provide or override consent explicitly:
|
|
73
|
+
|
|
74
|
+
```js
|
|
75
|
+
window.tellyouai.setConsent({ functional: true, analytics: false });
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
The equivalent event is `tellyouai-consent-change`, with the same values in
|
|
79
|
+
`event.detail`. This is also the integration point for Google Consent Mode,
|
|
80
|
+
whose current state cannot be reliably read from `gtag`.
|
|
81
|
+
|
|
82
|
+
Optional per-instance policy:
|
|
83
|
+
|
|
84
|
+
````js
|
|
85
|
+
window.tellyouai = {
|
|
86
|
+
entityId: "...",
|
|
87
|
+
consent: {
|
|
88
|
+
mode: "auto", // "auto" (default), "required", or "disabled"
|
|
89
|
+
## Development and release
|
|
90
|
+
|
|
91
|
+
Build the Cloudflare script and npm package separately:
|
|
92
|
+
|
|
93
|
+
```sh
|
|
94
|
+
npm run build
|
|
95
|
+
npm run build:package
|
|
96
|
+
npm run test:package
|
|
97
|
+
npm run pack:check
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Before a release, update `version` with npm's version command and test the
|
|
101
|
+
generated tarball in a consuming application. Publishing the scoped package
|
|
102
|
+
requires access to the `tellyouai` npm organization:
|
|
103
|
+
|
|
104
|
+
```sh
|
|
105
|
+
npm publish --access public
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Do not commit npm access tokens. Package and CDN releases should use the same
|
|
109
|
+
source revision and semantic version.
|
|
110
|
+
|
|
111
|
+
export default tseslint.config({
|
|
112
|
+
// Set the react version
|
|
113
|
+
settings: { react: { version: "18.3" } },
|
|
114
|
+
plugins: {
|
|
115
|
+
// Add the react plugin
|
|
116
|
+
react,
|
|
117
|
+
},
|
|
118
|
+
rules: {
|
|
119
|
+
// other rules...
|
|
120
|
+
// Enable its recommended rules
|
|
121
|
+
...react.configs.recommended.rules,
|
|
122
|
+
...react.configs["jsx-runtime"].rules,
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
````
|