@tugitark/vue-widget 1.5.5 → 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 +2 -2
- package/index.d.ts +5 -2
- package/index.js +1 -1
- package/index.md +11 -9
- package/package.json +9 -4
package/implementation.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Reimplementing The Widget With A Library
|
|
2
2
|
==========================================
|
|
3
3
|
|
|
4
|
-
This library uses [@
|
|
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 '@
|
|
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 '@
|
|
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
|
|
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
|
@@ -12,19 +12,19 @@ To use the Tugi Tark widget on your page, simply call the exported default compo
|
|
|
12
12
|
|
|
13
13
|
```vue
|
|
14
14
|
<script setup lang="js">
|
|
15
|
-
import TugiWidget from '@
|
|
15
|
+
import TugiWidget from '@tugi/vue-widget';
|
|
16
16
|
</script>
|
|
17
17
|
|
|
18
18
|
<template>
|
|
19
|
-
<TugiWidget />
|
|
19
|
+
<TugiWidget language="EN" />
|
|
20
20
|
</template>
|
|
21
21
|
```
|
|
22
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
|
|
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
24
|
|
|
25
25
|
```vue
|
|
26
26
|
<script setup lang="js">
|
|
27
|
-
import TugiWidget from '@
|
|
27
|
+
import TugiWidget from '@tugi/vue-widget';
|
|
28
28
|
|
|
29
29
|
const props = defineProps({
|
|
30
30
|
userId: {
|
|
@@ -47,11 +47,11 @@ Calls to `<TugiWidget />` are idempotent, if the parameter objects are equivalen
|
|
|
47
47
|
Custom Example
|
|
48
48
|
----------------
|
|
49
49
|
|
|
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.
|
|
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.
|
|
51
51
|
|
|
52
52
|
```vue
|
|
53
53
|
<script setup lang="ts">
|
|
54
|
-
import TugiWidget from '@
|
|
54
|
+
import TugiWidget from '@tugi/vue-widget';
|
|
55
55
|
|
|
56
56
|
interface Props {
|
|
57
57
|
getUserId: () => string;
|
|
@@ -86,6 +86,7 @@ async function jwtFn() {
|
|
|
86
86
|
homePageBackgroundColor: 'hsla(36, 100%, 37%, 0.2)',
|
|
87
87
|
homePageTextColor: '#2c3e50',
|
|
88
88
|
}"
|
|
89
|
+
language="EN"
|
|
89
90
|
/>
|
|
90
91
|
</template>
|
|
91
92
|
```
|
|
@@ -111,6 +112,7 @@ The full list of properties that can be passed to the `<TugiWidget>` component a
|
|
|
111
112
|
* `on-error` Optional. An event callback triggered when an error occurs. If this is not given all errors are printed to the console.
|
|
112
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.
|
|
113
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`.
|
|
114
116
|
|
|
115
117
|
The following two properties should all be specified together. If either of them is missing then nothing will happen:
|
|
116
118
|
|
|
@@ -127,7 +129,7 @@ If both `tugi-fn` and `user` are missing from the `<TugiWidget>` properties AND
|
|
|
127
129
|
|
|
128
130
|
```vue
|
|
129
131
|
<script setup lang="js">
|
|
130
|
-
import TugiWidget from '@
|
|
132
|
+
import TugiWidget from '@tugi/vue-widget';
|
|
131
133
|
</script>
|
|
132
134
|
|
|
133
135
|
<template>
|
|
@@ -203,7 +205,7 @@ While there can be only one widget on the page there can be multiple `<TugiWidge
|
|
|
203
205
|
</template>
|
|
204
206
|
```
|
|
205
207
|
|
|
206
|
-
[Click here](implementation.md) to see how this component wraps the underlying [@
|
|
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.
|
|
207
209
|
|
|
208
|
-
[Click here](https://gitlab.com/tugitark
|
|
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.
|
|
209
211
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tugitark/vue-widget",
|
|
3
|
-
"version": "1.5.
|
|
4
|
-
"description": "Wraps the
|
|
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.
|
|
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
|
+
}
|