yelda-webchat 1.1.22 → 1.1.24

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yelda-webchat",
3
- "version": "1.1.22",
3
+ "version": "1.1.24",
4
4
  "description": "Website Chat Plugin",
5
5
  "main": "./dist/js/yeldaWebchatInjector.min.js",
6
6
  "license": "MIT",
@@ -15,12 +15,16 @@
15
15
  "type": "git",
16
16
  "url": "https://github.com/Yeldaai/chat-plugin.git"
17
17
  },
18
+ "engines": {
19
+ "node": ">=18"
20
+ },
18
21
  "scripts": {
19
22
  "build": "rimraf dist && webpack -p",
20
- "prepack": "npm run build && npm run test",
23
+ "prepack": "npm test",
24
+ "pretest": "npm run build",
21
25
  "lint:check": "eslint --ext .js src",
22
26
  "lint:fix": "eslint --fix --ext .js src",
23
- "test": "mocha --require esm ./test/*.js",
27
+ "test": "mocha ./test/*.js",
24
28
  "uploadBuildToS3": "npm run prepack && node uploadBuildToS3 build -s $npm_config_semver -d $npm_config_destinationPath -o $otp"
25
29
  },
26
30
  "devDependencies": {
@@ -40,8 +44,6 @@
40
44
  "css-loader": "^1.0.0",
41
45
  "dotenv": "^8.2.0",
42
46
  "eslint": "^5.16.0",
43
- "esm": "^3.2.25",
44
- "extract-text-webpack-plugin": "^3.0.2",
45
47
  "file-loader": "^1.1.11",
46
48
  "inject-loader": "^4.0.1",
47
49
  "jsdom": "^16.5.0",
@@ -58,7 +60,7 @@
58
60
  "style-loader": "^0.22.1",
59
61
  "uglifyjs-webpack-plugin": "^2.2.0",
60
62
  "url-loader": "^1.1.1",
61
- "webpack": "^4.41.5",
63
+ "webpack": "^4.47.0",
62
64
  "webpack-cli": "^3.3.10",
63
65
  "xhr-mock": "^2.5.1",
64
66
  "yargs": "^15.4.1"
@@ -10,13 +10,14 @@ module.exports = {
10
10
  },
11
11
  HOST: {
12
12
  PRODUCTION: 'app.yelda.ai',
13
- STAGING: 'staging.yelda.ai',
13
+ STAGING: 'staging.yelda.ai'
14
14
  },
15
15
  FRAME_EVENT_TYPES: {
16
16
  SENT: {
17
17
  OPEN_CHAT: 'openChat',
18
18
  LEAVE_VIEWPORT: 'leaveViewPort',
19
19
  SEND_USER_MESSAGE: 'sendUserMessage',
20
+ UPDATE_SLOT: 'updateSlot',
20
21
  URL_UPDATE: 'urlUpdate'
21
22
  },
22
23
  RECEIVED: {
@@ -334,28 +334,9 @@ class YeldaChat {
334
334
  return
335
335
  }
336
336
 
337
- const isVoiceFirstUI = this.webchatSettings.hasOwnProperty('isVoiceFirstUI')
338
- ? this.webchatSettings.isVoiceFirstUI
339
- : false
340
337
  const customImage = this.webchatSettings.image && this.webchatSettings.image.url
341
338
  const hasCustomStyle = this.webchatSettings.hasOwnProperty('isDefaultStyle') && !this.webchatSettings.isDefaultStyle
342
339
 
343
- /**
344
- * in isVoiceFirstUI mode
345
- * - the assistant should be opened directly and will never be closed
346
- * => we call directly openChat and do not add the assistant image
347
- * - we don't want the box-shadow css style
348
- * => we add voiceFirstUI to iframeContainer
349
- * - /chat vue render the voice first UI
350
- * => nothing more to do here
351
- */
352
- if (isVoiceFirstUI) {
353
- this.iframeContainer.classList.add('voiceFirstUI')
354
- this.openChat()
355
- this.assistantImage = null
356
- return
357
- }
358
-
359
340
  if (!hasCustomStyle || !customImage) {
360
341
  this.addAssistantImageToWebChatContainer()
361
342
  return
@@ -1396,6 +1377,18 @@ class YeldaChat {
1396
1377
  event: config.FRAME_EVENT_TYPES.SENT.LEAVE_VIEWPORT
1397
1378
  }, '*')
1398
1379
  }
1380
+
1381
+ /**
1382
+ * Send an updateSlot postMessage to the webchat iframe
1383
+ * @param {Object} slotObject {slotSlug: slotValue}
1384
+ */
1385
+ updateSlot(slotObject) {
1386
+ const webchatFrame = document.getElementById('web_chat_frame')
1387
+ if (webchatFrame) {
1388
+ webchatFrame.contentWindow.postMessage(slotObject, '*')
1389
+ webchatFrame.contentWindow.postMessage({ event: config.FRAME_EVENT_TYPES.SENT.UPDATE_SLOT, data: slotObject }, '*')
1390
+ }
1391
+ }
1399
1392
  }
1400
1393
 
1401
1394
  let yeldaChat = new YeldaChat()