@tugitark/vue-widget 1.5.4 → 1.5.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.
package/implementation.md CHANGED
@@ -1,13 +1,13 @@
1
1
  Reimplementing The Widget With A Library
2
2
  ==========================================
3
3
 
4
- This library uses [@tugitark/declarative-widget](https://gitlab.com/tugitark/integration/libraries/javascript/declarative-widget) to handle the heavy lifting of detecting property changes, downloading the widget script, and (un)loading the actual widget tags on changes. Basically that library converts the imperative and static Tugi Tark chat widget in to a functional equivalent. All this library does is call that library from inside a component.
4
+ This library uses [@tugi/declarative-widget](https://gitlab.com/tugitark-integration/libraries/javascript/declarative-widget) to handle the heavy lifting of detecting property changes, downloading the widget script, and (un)loading the actual widget tags on changes. Basically that library converts the imperative and static Tugi Tark chat widget in to a functional equivalent. All this library does is call that library from inside a component.
5
5
 
6
6
  The code below, while unoptimised, demonstrates how this compoment wraps that library. See [the source code](index.ts) for more details.
7
7
 
8
8
  ```vue
9
9
  <script setup lang="ts">
10
- import tugiWidget, { type Props } from '@tugitark/declarative-widget';
10
+ import tugiWidget, { type Props } from '@tugi/declarative-widget';
11
11
 
12
12
  import { defineProps } from 'vue';
13
13
 
package/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { PropType } from 'vue';
2
- import type { Props, TugiWidget, WidgetInitializeOptions, WidgetFreeVersionOptions, TugiWidgetEvents, WidgetFreeSection } from '@tugitark/declarative-widget';
3
- export type { Props, TugiWidget, WidgetInitializeOptions, WidgetFreeVersionOptions, TugiWidgetEvents, WidgetFreeSection, };
2
+ import type { Props, TugiWidget as TugiWidgetType, WidgetInitializeOptions, WidgetFreeVersionOptions, TugiWidgetEvents, WidgetFreeSection } from '@tugi/declarative-widget';
3
+ export type { Props, TugiWidgetType as TugiWidget, WidgetInitializeOptions, WidgetFreeVersionOptions, TugiWidgetEvents, WidgetFreeSection, };
4
4
  type Sections = NonNullable<Props['sections']>;
5
5
  type Customise = NonNullable<Props['customize']>;
6
6
  declare const TugiWidget: {
@@ -10,6 +10,7 @@ declare const TugiWidget: {
10
10
  props: {
11
11
  user: StringConstructor;
12
12
  jwtFn: FunctionConstructor;
13
+ baseAddress: StringConstructor;
13
14
  tenantId: StringConstructor;
14
15
  brandId: StringConstructor;
15
16
  brandName: StringConstructor;
@@ -49,6 +50,8 @@ declare const TugiWidget: {
49
50
  immediate: boolean;
50
51
  };
51
52
  };
53
+ mounted: () => void;
54
+ unmounted: () => void;
52
55
  render: () => any;
53
56
  };
54
57
  export default TugiWidget;
package/index.js CHANGED
@@ -1 +1 @@
1
- import a,{isFree as r}from"@tugitark/declarative-widget";var n,t=String,e=Function,o={type:Boolean,default:void 0},s={data:function(){return{firstTime_:!0}},props:{user:t,jwtFn:e,tenantId:t,brandId:t,brandName:t,language:t,customize:Object,httpUrl:t,wsUrl:t,chatDisabledReason:t,title:t,body:t,sections:Array,open:o,visible:o,onNotification:e,onReady:e,onOpened:e,onClosed:e,onError:e,proactiveMessage:t,proactiveContext:t,ticketLanguageCode:t},methods:{onNotification_:function(i){r(this)&&!this.firstTime_||(n=this.onNotification)&&n(i)},onReady_:function(){this.firstTime_&&(this.firstTime_=!1,(n=this.onReady)&&n())}},watch:{$props:{handler:function(i){i=Object.assign({},i,{onNotification:this.onNotification_,onReady:this.onReady_}),a(i)},deep:!0,immediate:!0}},render:function(){return null}};export default s;
1
+ import s,{destroy as d,isFree as u}from"@tugi/declarative-widget";var o,a=0,i=!1;function f(){i=!1}function c(){i||(i=!0,queueMicrotask(function(){i&&(i=!1,a===0&&d())}))}var e=String,t=Function,r={type:Boolean,default:void 0},l={data:function(){return{firstTime_:!0}},props:{user:e,jwtFn:t,baseAddress:e,tenantId:e,brandId:e,brandName:e,language:e,customize:Object,httpUrl:e,wsUrl:e,chatDisabledReason:e,title:e,body:e,sections:Array,open:r,visible:r,onNotification:t,onReady:t,onOpened:t,onClosed:t,onError:t,proactiveMessage:e,proactiveContext:e,ticketLanguageCode:e},methods:{onNotification_:function(n){u(this)&&!this.firstTime_||(o=this.onNotification)&&o(n)},onReady_:function(){this.firstTime_&&(this.firstTime_=!1,(o=this.onReady)&&o())}},watch:{$props:{handler:function(n){n=Object.assign({},n,{onNotification:this.onNotification_,onReady:this.onReady_}),s(n)},deep:!0,immediate:!0}},mounted:function(){f(),a+=1},unmounted:function(){a=Math.max(0,a-1),c()},render:function(){return null}};export default l;
package/index.md CHANGED
@@ -8,11 +8,23 @@ Also see [the original integration guide](https://www.tugitark.com/chat-setup) f
8
8
  Minimal Example
9
9
  -----------------
10
10
 
11
- This is the smallest number of properties that you can pass to `<TugiWidget>` and have it still operate correctly. These properties are given to you on signing up with Tugi Tark and must be entered accurately.
11
+ To use the Tugi Tark widget on your page, simply call the exported default component. With no parameters given the code will try its upmost to determine the current player and brand, falling back to unauthenticated users when it can't (which will require them to verify their e-mail address and will not provide their profile to the AI Agent).
12
12
 
13
13
  ```vue
14
14
  <script setup lang="js">
15
- import TugiWidget from '@tugitark/vue-widget';
15
+ import TugiWidget from '@tugi/vue-widget';
16
+ </script>
17
+
18
+ <template>
19
+ <TugiWidget language="EN" />
20
+ </template>
21
+ ```
22
+
23
+ If your server has the standard `/.tugi` endpoints (as provided by our back-end libraries and documented in our [developer documentation](https://gitlab.com/tugitark-integration/docs)) this is enough to get started with the Tugi Widget. The `/.tugi/jwt/issue` endpoint will be called with no ID given, and if that can return the data for the current player (e.g. from the HTTP session) this is enough. Alternatively you can pass an ID explicitly:
24
+
25
+ ```vue
26
+ <script setup lang="js">
27
+ import TugiWidget from '@tugi/vue-widget';
16
28
 
17
29
  const props = defineProps({
18
30
  userId: {
@@ -28,18 +40,18 @@ const props = defineProps({
28
40
  </template>
29
41
  ```
30
42
 
31
- If your server has the standard `/.tugi` endpoints (as provided by our back-end libraries and documented in our [developer documentation](https://gitlab.com/tugitark/integration/docs)) this is enough to get started with the Tugi Widget. `user` is the ID within your system of the current player. How you determine the current player's unique ID depends entirely on your system and is left as a provided parameter here. This is the ID that the widget will internally pass to the `/.tugi/jwt/issue` endpoint to retrieve the player's profile, and so must in some way identify an end-user on your server. Technically even `user` is optional, and not passing this either will use the unauthenticated flow (in which the AI Agent has no information on which to base responses, and where a player will require e-mail verification first), or try to get the user's ID from the server.
43
+ `user` is the ID within your system of the current player. How you determine the current player's unique ID depends entirely on your system and is left as a provided parameter here. This is the ID that the widget will internally pass to the `/.tugi/jwt/issue` endpoint to retrieve the player's profile, and so must in some way identify an end-user on your server.
32
44
 
33
- Calls to `render` are idempotent, if the parameter objects are equivalent. The library will perform deep value comparisons between the parameters of two calls and only act on those that have changed.
45
+ Calls to `<TugiWidget />` are idempotent, if the parameter objects are equivalent. The library will perform deep value comparisons between the parameters of two calls and only act on those that have changed.
34
46
 
35
47
  Custom Example
36
48
  ----------------
37
49
 
38
- This is a more extensive widget example, with colour-scheme customisation and an explicit JWT lookup function. The HTTP and websocket addresses are also specified, though match the defaults. The `brand-id`, `brand-name`, and `tenant-id` will be provided by us based on details provided by you when signing up with our system. They are not secret, so can safely appear in client-side code, but are case-sensitive so must remain exactly as specified by us. When not specified (as in the previous example) they are retrieved from the `/.tugi/config` endpoint - either a custom version or one served by the `Tugi Players` library.
50
+ This is a more extensive widget example, with colour-scheme customisation and an explicit JWT lookup function. The HTTP and websocket addresses are also specified, though match the defaults. The `brand-id`, `brand-name`, and `tenant-id` will be provided by us based on details provided by you when signing up with our system. They are not secret, so can safely appear in client-side code, but are case-sensitive so must remain exactly as specified by us. When not specified (as in the previous example) they are retrieved from the `/.tugi/config` endpoint - either a custom version or one served by the `Tugi Players` library. `language` will set the language for the ticket. If it is not given the user will have to select one when they open a new conversation.
39
51
 
40
52
  ```vue
41
53
  <script setup lang="ts">
42
- import TugiWidget from '@tugitark/vue-widget';
54
+ import TugiWidget from '@tugi/vue-widget';
43
55
 
44
56
  interface Props {
45
57
  getUserId: () => string;
@@ -74,6 +86,7 @@ async function jwtFn() {
74
86
  homePageBackgroundColor: 'hsla(36, 100%, 37%, 0.2)',
75
87
  homePageTextColor: '#2c3e50',
76
88
  }"
89
+ language="EN"
77
90
  />
78
91
  </template>
79
92
  ```
@@ -99,6 +112,7 @@ The full list of properties that can be passed to the `<TugiWidget>` component a
99
112
  * `on-error` Optional. An event callback triggered when an error occurs. If this is not given all errors are printed to the console.
100
113
  * `open` Optional. When `true` the widget is forced to be open. When `false` it is forced to be closed. When not specified normal user control resumes.
101
114
  * `visible` Optional. When `false` the widget can't be seen.
115
+ * `base-address` Optional. The JWT and widget config are requested by default from `/.tugi/jwt/issue` and '/.tugi/config` respectively. When given, the value of `baseAddress` will be prepended to these addresses to use (when, for example, `baseAddress is `/casino`) :`/casino/.tugi/jwt/issue` and `/casino/.tugi/config`.
102
116
 
103
117
  The following two properties should all be specified together. If either of them is missing then nothing will happen:
104
118
 
@@ -115,7 +129,7 @@ If both `tugi-fn` and `user` are missing from the `<TugiWidget>` properties AND
115
129
 
116
130
  ```vue
117
131
  <script setup lang="js">
118
- import TugiWidget from '@tugitark/vue-widget';
132
+ import TugiWidget from '@tugi/vue-widget';
119
133
  </script>
120
134
 
121
135
  <template>
@@ -191,7 +205,7 @@ While there can be only one widget on the page there can be multiple `<TugiWidge
191
205
  </template>
192
206
  ```
193
207
 
194
- [Click here](implementation.md) to see how this component wraps the underlying [@tugitark/declarative-widget](https://gitlab.com/tugitark/integration/libraries/javascript/declarative-widget) library in a react component.
208
+ [Click here](implementation.md) to see how this component wraps the underlying [@tugi/declarative-widget](https://gitlab.com/tugitark-integration/libraries/javascript/declarative-widget) library in a react component.
195
209
 
196
- [Click here](https://gitlab.com/tugitark/integration/libraries/javascript/declarative-widget/implementation.md) to get a better understanding of everything that that library is doing behind the scenes to inject the main widget script in to a page and initialise it.
210
+ [Click here](https://gitlab.com/tugitark-integration/libraries/javascript/declarative-widget/implementation.md) to get a better understanding of everything that that library is doing behind the scenes to inject the main widget script in to a page and initialise it.
197
211
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tugitark/vue-widget",
3
- "version": "1.5.4",
4
- "description": "Wraps the tugitark widget in a Vue component.",
3
+ "version": "1.5.12",
4
+ "description": "Wraps the Tugi Widget in a Vue component.",
5
5
  "scripts": {
6
6
  "build": "npx esbuild index.ts --target=es6 --outfile=index.js && sed -i 's/\\bconst\\b/var/g' index.js && sed -i 's/\\blet\\b/var/g' index.js && npx esbuild index.js --allow-overwrite --minify --target=es5 --outfile=index.js && npx tsc --noErrorTruncation --declaration --emitDeclarationOnly --target es6 --module nodenext --moduleResolution nodenext --outDir . index.ts"
7
7
  },
@@ -12,7 +12,7 @@
12
12
  "index.md"
13
13
  ],
14
14
  "dependencies": {
15
- "@tugitark/declarative-widget": "^1.3.3"
15
+ "@tugitark/declarative-widget": "^1.3.10"
16
16
  },
17
17
  "peerDependencies": {
18
18
  "vue": ">=0.0.0"
@@ -26,11 +26,16 @@
26
26
  "Typescript",
27
27
  "Vue",
28
28
  "Tugitark",
29
+ "Tugi",
29
30
  "Casino",
30
31
  "Integration",
31
32
  "JWT",
32
33
  "Library"
33
34
  ],
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "git+https://gitlab.com/tugitark-integration/libraries/javascript/vue-widget.git"
38
+ },
34
39
  "author": "alex.cole@tugitark.com",
35
40
  "license": "(c) 2026 Tugi Tark OÜ"
36
- }
41
+ }