@tugitark/vue-widget 1.0.5 → 1.1.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.
Files changed (4) hide show
  1. package/index.js +89 -3
  2. package/index.md +44 -7
  3. package/package.json +5 -7
  4. package/Widget.vue +0 -39
package/index.js CHANGED
@@ -1,7 +1,93 @@
1
1
  // Copyright (c) 2026, TugiTark. All rights reserved.
2
2
 
3
- /// <reference types="Widget" />
3
+ import render from '@tugitark/declarative-widget';
4
4
 
5
- import Widget from './Widget.vue';
6
- export default Widget;
5
+ // Weirdly, this way of declaring a `vue` component has absolutly no dependencies on `vue`...
6
+ export default {
7
+ data() {
8
+ return {
9
+ firstTime_: true,
10
+ props_: {},
11
+ props_: {},
12
+ };
13
+ },
14
+ props: {
15
+ // Full props.
16
+ user: [String, null],
17
+ jwtFn: Function,
18
+ tenantId: String,
19
+ brandId: String,
20
+ brandName: String,
21
+ language: String,
22
+ customize: Object,
23
+ httpUrl: String,
24
+ wsUrl: String,
25
+ // Free props.
26
+ chatDisabledReason: String,
27
+ title: String,
28
+ body: String,
29
+ sections: Array,
30
+ // Display props.
31
+ open: {
32
+ type: Boolean,
33
+ default: undefined,
34
+ },
35
+ visible: {
36
+ type: Boolean,
37
+ default: undefined,
38
+ },
39
+ onNotification: Function,
40
+ onReady: Function,
41
+ onOpened: Function,
42
+ onClosed: Function,
43
+ onError: Function,
44
+ // Two of these are required to open a message.
45
+ proactiveMessage: String,
46
+ proactiveContext: String,
47
+ ticketLanguageCode: String,
48
+ },
49
+ methods: {
50
+ onNotification_(hasNotification) {
51
+ if (this.jwtFn == null && this.user == null) {
52
+ if (this.firstTime_) {
53
+ // Replicate FAQ internal behaviour at a per-component level.
54
+ this.onNotification?.(hasNotification);
55
+ }
56
+ } else {
57
+ this.onNotification?.(hasNotification);
58
+ }
59
+ },
60
+ onReady_() {
61
+ if (this.firstTime_) {
62
+ this.firstTime_ = false;
63
+ this.onReady?.();
64
+ }
65
+ },
66
+ onOpened_() { return this.onOpened?.(); },
67
+ onClosed_() { return this.onClosed?.(); },
68
+ onError_(e) { return this.onError?.(e); },
69
+ },
70
+ watc() {
71
+ return render(this.props_);
72
+ },
73
+ watch: {
74
+ $props: {
75
+ handler(props) {
76
+ render({
77
+ ...props,
78
+ onNotification: this.onNotification_,
79
+ onReady: this.onReady_,
80
+ onOpened: this.onOpened_,
81
+ onClosed: this.onClosed_,
82
+ onError: this.onError_,
83
+ });
84
+ },
85
+ deep: true,
86
+ immediate: true,
87
+ },
88
+ },
89
+ render() {
90
+ return null;
91
+ },
92
+ };
7
93
 
package/index.md CHANGED
@@ -24,14 +24,14 @@ const props = defineProps({
24
24
  <template>
25
25
  <TugiWidget
26
26
  :user="props.userId"
27
- brand_id="a040050697fc4b2db16acfbbad1d0da4"
28
- brand_name="Super Casino"
29
- tenant_id="gb-casinos-ltd"
27
+ brand-id="a040050697fc4b2db16acfbbad1d0da4"
28
+ brand-name="Super Casino"
29
+ tenant-id="gb-casinos-ltd"
30
30
  />
31
31
  </template>
32
32
  ```
33
33
 
34
- 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 `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.
34
+ 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 `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.
35
35
 
36
36
  `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.
37
37
 
@@ -63,9 +63,9 @@ async function jwtFn() {
63
63
  <template>
64
64
  <TugiWidget
65
65
  :jwt-fn="jwtFn"
66
- brand_id="a040050697fc4b2db16acfbbad1d0da4"
67
- brand_name="Super Casino"
68
- tenant_id="gb-casinos-ltd"
66
+ brand-id="a040050697fc4b2db16acfbbad1d0da4"
67
+ brand-name="Super Casino"
68
+ tenant-id="gb-casinos-ltd"
69
69
  http-url="https://app.tugi.ai/tugi.widget"
70
70
  ws-url="wss://ws.tugi.ai"
71
71
  :customize="{
@@ -155,4 +155,41 @@ The following optional properties are shared with the full version:
155
155
  * `open`
156
156
  * `visible`
157
157
 
158
+ Notes
159
+ -------
160
+
161
+ While there can be only one widget on the page there can be multiple `<TugiWidget>` components at once. Which one will be used is non-deterministic - even if you have one `<TugiWidget>` with `visible={true}` and another one with `visible={false}` this will not guarantee that the visible one is the one that gets shown, the invisible one may be "shown", resulting in neither being seen. The one selected is based on internal render and update orders. Further, having two at once may result in the widget being constantly unloaded and reloaded even when nothing has changed as the underlying code flips repeatedly between them. If you have two versions of the widget shown in different circumstances then make sure that the whole component is conditional:
162
+
163
+
164
+ ```javascript
165
+ <template>
166
+ <TugiWidget v-if="disabled"
167
+ chat-disabled-reason="You are not signed in."
168
+ title="FAQ"
169
+ body="Let us help you get started."
170
+ :sections="[
171
+ { title: 'Who are we?', content: 'We are Tugi Tark.' },
172
+ { title: 'What do we do?', content: 'Make awesome customer support solutions.' },
173
+ { title: 'How?', content: 'Smart AI agents who know all about your customers and services.' },
174
+ { title: 'How do I join?', content: 'Click the sign-up botton at the top-right of the page.' },
175
+ ]"
176
+ />
177
+ <TugiWidget v-else
178
+ :jwt-fn="jwtFn"
179
+ brand-id="a040050697fc4b2db16acfbbad1d0da4"
180
+ brand-name="Super Casino"
181
+ tenant-id="gb-casinos-ltd"
182
+ http-url="https://app.tugi.ai/tugi.widget"
183
+ ws-url="wss://ws.tugi.ai"
184
+ :customize="{
185
+ title: 'Tugi Casino Help',
186
+ showTitle: true,
187
+ fontColor: '#2c3e50',
188
+ primaryColor: '#2c3e50',
189
+ secondaryColor: 'hsla(36, 100%, 50%, 1)',
190
+ homePageBackgroundColor: 'hsla(36, 100%, 37%, 0.2)',
191
+ homePageTextColor: '#2c3e50',
192
+ }"
193
+ /></template>
194
+ ```
158
195
 
package/package.json CHANGED
@@ -1,18 +1,16 @@
1
1
  {
2
2
  "name": "@tugitark/vue-widget",
3
- "version": "1.0.5",
3
+ "version": "1.1.1",
4
4
  "description": "Wraps the tugitark widget in a Vue component.",
5
- "scripts": {
6
- "release": "npm publish --access public"
7
- },
8
5
  "files": [
9
- "Widget.vue",
10
6
  "index.js",
11
7
  "index.md"
12
8
  ],
13
9
  "dependencies": {
14
- "@tugitark/declarative-widget": "^1.0.0",
15
- "vue": "^3.3.0"
10
+ "@tugitark/declarative-widget": "^1.0.1"
11
+ },
12
+ "peerDependencies": {
13
+ "vue": ">=0.0.0"
16
14
  },
17
15
  "keywords": [
18
16
  "Typescript",
package/Widget.vue DELETED
@@ -1,39 +0,0 @@
1
- // Copyright (c) 2026, TugiTark. All rights reserved.
2
-
3
- <script setup lang="ts">
4
- import { watch, ref } from 'vue';
5
- import render, { Props } from '@tugitark/declarative-widget';
6
-
7
- // Weird vue behaviour with optional boolean props. Ensure they don't default to `false`.
8
- const props = withDefaults(defineProps<Props>(), {
9
- open: void 0,
10
- visible: void 0,
11
- });
12
-
13
- // Is this the first time this component has been rendered ever?
14
- const firstTime = ref(true);
15
-
16
- function onNotification(hasNotification: boolean) {
17
- if (props.jwtFn == null && props.user == null) {
18
- if (firstTime.value) {
19
- // Replicate FAQ internal behaviour at a per-component level.
20
- props.onNotification?.(hasNotification);
21
- }
22
- } else {
23
- props.onNotification?.(hasNotification);
24
- }
25
- }
26
-
27
- function onReady() {
28
- if (firstTime.value) {
29
- firstTime.value = false;
30
- props.onReady?.();
31
- }
32
- }
33
-
34
- watch(props, (p) => render({ ...p, onReady, onNotification }), { deep: true, immediate: true });
35
- </script>
36
-
37
- <template>
38
- </template>
39
-