@textback/notification-widget 2.0.1-84986 → 2.0.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 (85) hide show
  1. package/.eslintrc.js +291 -291
  2. package/.idea/inspectionProfiles/Project_Default.xml +6 -0
  3. package/.idea/misc.xml +6 -0
  4. package/.idea/modules.xml +8 -0
  5. package/.idea/notificationwidget.iml +9 -0
  6. package/.idea/vcs.xml +6 -0
  7. package/build/index.js +3 -3
  8. package/build/sdk.js +2 -2
  9. package/package.json +70 -70
  10. package/promote_tag.sh +1 -1
  11. package/readme.md +569 -569
  12. package/server.js +1 -1
  13. package/src/libraries/ai.1.0.11.js +4088 -4088
  14. package/src/libraries/localization/locales/index.js +8 -8
  15. package/src/libraries/localization/text.js +9 -9
  16. package/src/libraries/t.js +82 -82
  17. package/src/sdk/channels/channel.js +30 -30
  18. package/src/sdk/channels/facebook.js +13 -13
  19. package/src/sdk/channels/skype.js +12 -12
  20. package/src/sdk/channels/telegram.js +18 -18
  21. package/src/sdk/channels/viber.js +12 -12
  22. package/src/sdk/channels/vk-modal/vk-modal.html +17 -17
  23. package/src/sdk/channels/vk-modal/vk-modal.js +25 -25
  24. package/src/sdk/channels/vk-modal/vk-modal.scss +116 -116
  25. package/src/sdk/channels/vk.js +195 -195
  26. package/src/sdk/events/observer.js +46 -46
  27. package/src/sdk/index.js +5 -5
  28. package/src/sdk/sdk.js +67 -67
  29. package/src/sdk/utils/apiErrorHandler.js +11 -11
  30. package/src/sdk/utils/appInsights.js +88 -88
  31. package/src/sdk/utils/browserInfo.js +8 -8
  32. package/src/sdk/utils/constants.js +17 -17
  33. package/src/sdk/utils/cookies.js +67 -67
  34. package/src/sdk/utils/find.js +7 -7
  35. package/src/sdk/utils/loadConfig.js +20 -20
  36. package/src/sdk/utils/loadDeepLink.js +48 -48
  37. package/src/sdk/utils/loadScript.js +25 -25
  38. package/src/sdk/utils/loadSubscriptions.js +6 -6
  39. package/src/sdk/utils/parseQueryString.js +33 -33
  40. package/src/sdk/utils/windowHelper.js +25 -25
  41. package/src/sdk/widget/widget.js +192 -192
  42. package/src/widget/components/tb-notification-button/index.js +34 -34
  43. package/src/widget/components/tb-notification-button/styles.scss +657 -657
  44. package/src/widget/components/tb-notification-widget/normalize.scss +395 -395
  45. package/src/widget/components/tb-nw-wahunter/styles.scss +471 -471
  46. package/src/widget/config.js +5 -5
  47. package/src/widget/icons/icon_chat_window.svg +1 -1
  48. package/src/widget/icons/icon_close.svg +1 -1
  49. package/src/widget/icons/icon_facebook.svg +7 -7
  50. package/src/widget/icons/icon_facebook_circle.svg +7 -7
  51. package/src/widget/icons/icon_instagram_circle.svg +95 -95
  52. package/src/widget/icons/icon_skype.svg +44 -44
  53. package/src/widget/icons/icon_skype_circle.svg +46 -46
  54. package/src/widget/icons/icon_skype_new.svg +113 -113
  55. package/src/widget/icons/icon_tg.svg +25 -25
  56. package/src/widget/icons/icon_tg_circle.svg +17 -17
  57. package/src/widget/icons/icon_viber.svg +75 -75
  58. package/src/widget/icons/icon_viber_circle.svg +67 -67
  59. package/src/widget/icons/icon_viber_new.svg +102 -102
  60. package/src/widget/icons/icon_vk.svg +14 -14
  61. package/src/widget/icons/icon_vk_circle.svg +16 -16
  62. package/src/widget/icons/icon_whatsapp.svg +147 -147
  63. package/src/widget/icons/icon_whatsapp_circle.svg +3 -3
  64. package/src/widget/icons/icon_whatsapp_new.svg +127 -127
  65. package/src/widget/icons/icon_whatsappb.svg +147 -147
  66. package/src/widget/icons/icon_whatsappb_circle.svg +3 -3
  67. package/src/widget/icons/icon_whatsappb_new.svg +127 -127
  68. package/src/widget/icons/paper-plane-arrow.svg +3 -3
  69. package/src/widget/icons/tb-logo.svg +21 -21
  70. package/src/widget/index.js +28 -28
  71. package/src/widget/locales/cs.js +42 -42
  72. package/src/widget/locales/en.js +42 -42
  73. package/src/widget/locales/ro.js +41 -41
  74. package/src/widget/utils/cookiesEx.js +41 -41
  75. package/src/widget/utils/stringifyAttributes.js +19 -19
  76. package/src/widget/utils/widgetsStorage.js +28 -28
  77. package/src/widget/widget.entry.js +3 -3
  78. package/tests/gf.html +35 -35
  79. package/tests/gf.js +21 -21
  80. package/tests/index.js +61 -61
  81. package/views/examples.ejs +3 -3
  82. package/views/sdk.html +274 -274
  83. package/webpack.common.js +72 -72
  84. package/webpack.dev.js +15 -15
  85. package/webpack.prod.js +10 -10
@@ -1,9 +1,9 @@
1
- module.exports = {
2
- main: require('./en'),
3
- ru: require('./ru'),
4
- pl: require('./pl'),
5
- ro: require('./ro'),
6
- uk: require('./uk'),
7
- cz: require('./cs'),
8
- 'cs-CZ': require('./cs'),
1
+ module.exports = {
2
+ main: require('./en'),
3
+ ru: require('./ru'),
4
+ pl: require('./pl'),
5
+ ro: require('./ro'),
6
+ uk: require('./uk'),
7
+ cz: require('./cs'),
8
+ 'cs-CZ': require('./cs'),
9
9
  };
@@ -1,9 +1,9 @@
1
- const locales = require('./locales');
2
-
3
- function text(string, locale) {
4
- const dictionary = locales[locale] || locales[locale.split('-')[0]] || locales[locale.split('_')[0]] || locales.main;
5
-
6
- return dictionary[string] || locales.main[string] || string;
7
- }
8
-
9
- export default text;
1
+ const locales = require('./locales');
2
+
3
+ function text(string, locale) {
4
+ const dictionary = locales[locale] || locales[locale.split('-')[0]] || locales[locale.split('_')[0]] || locales.main;
5
+
6
+ return dictionary[string] || locales.main[string] || string;
7
+ }
8
+
9
+ export default text;
@@ -1,82 +1,82 @@
1
- // local-scoped modification of https://github.com/jasonmoo/t.js
2
- var blockregex = /\{\{(([@!]?)(.+?))\}\}(([\s\S]+?)(\{\{:\1\}\}([\s\S]+?))?)\{\{\/\1\}\}/g,
3
- valregex = /\{\{([=%])(.+?)\}\}/g;
4
-
5
- function t(template) {
6
- this.t = template;
7
- }
8
-
9
- function scrub(val) {
10
- return new Option(val).innerHTML.replace(/"/g,""");
11
- }
12
-
13
- function get_value(vars, key) {
14
- var parts = key.split('.');
15
- while (parts.length) {
16
- if (!(parts[0] in vars)) {
17
- return false;
18
- }
19
- vars = vars[parts.shift()];
20
- }
21
- return vars;
22
- }
23
-
24
- function render(fragment, vars) {
25
- return fragment
26
- .replace(blockregex, function(_, __, meta, key, inner, if_true, has_else, if_false) {
27
-
28
- var val = get_value(vars,key), temp = "", i;
29
-
30
- if (!val) {
31
-
32
- // handle if not
33
- if (meta == '!') {
34
- return render(inner, vars);
35
- }
36
- // check for else
37
- if (has_else) {
38
- return render(if_false, vars);
39
- }
40
-
41
- return "";
42
- }
43
-
44
- // regular if
45
- if (!meta) {
46
- return render(if_true, vars);
47
- }
48
-
49
- // process array/obj iteration
50
- if (meta == '@') {
51
- // store any previous vars
52
- // reuse existing vars
53
- _ = vars._key;
54
- __ = vars._val;
55
- for (i in val) {
56
- if (val.hasOwnProperty(i)) {
57
- vars._key = i;
58
- vars._val = val[i];
59
- temp += render(inner, vars);
60
- }
61
- }
62
- vars._key = _;
63
- vars._val = __;
64
- return temp;
65
- }
66
-
67
- })
68
- .replace(valregex, function(_, meta, key) {
69
- var val = get_value(vars,key);
70
-
71
- if (val || val === 0) {
72
- return meta == '%' ? scrub(val) : val;
73
- }
74
- return "";
75
- });
76
- }
77
-
78
- t.prototype.render = function (vars) {
79
- return render(this.t, vars);
80
- };
81
-
82
- export default t;
1
+ // local-scoped modification of https://github.com/jasonmoo/t.js
2
+ var blockregex = /\{\{(([@!]?)(.+?))\}\}(([\s\S]+?)(\{\{:\1\}\}([\s\S]+?))?)\{\{\/\1\}\}/g,
3
+ valregex = /\{\{([=%])(.+?)\}\}/g;
4
+
5
+ function t(template) {
6
+ this.t = template;
7
+ }
8
+
9
+ function scrub(val) {
10
+ return new Option(val).innerHTML.replace(/"/g,""");
11
+ }
12
+
13
+ function get_value(vars, key) {
14
+ var parts = key.split('.');
15
+ while (parts.length) {
16
+ if (!(parts[0] in vars)) {
17
+ return false;
18
+ }
19
+ vars = vars[parts.shift()];
20
+ }
21
+ return vars;
22
+ }
23
+
24
+ function render(fragment, vars) {
25
+ return fragment
26
+ .replace(blockregex, function(_, __, meta, key, inner, if_true, has_else, if_false) {
27
+
28
+ var val = get_value(vars,key), temp = "", i;
29
+
30
+ if (!val) {
31
+
32
+ // handle if not
33
+ if (meta == '!') {
34
+ return render(inner, vars);
35
+ }
36
+ // check for else
37
+ if (has_else) {
38
+ return render(if_false, vars);
39
+ }
40
+
41
+ return "";
42
+ }
43
+
44
+ // regular if
45
+ if (!meta) {
46
+ return render(if_true, vars);
47
+ }
48
+
49
+ // process array/obj iteration
50
+ if (meta == '@') {
51
+ // store any previous vars
52
+ // reuse existing vars
53
+ _ = vars._key;
54
+ __ = vars._val;
55
+ for (i in val) {
56
+ if (val.hasOwnProperty(i)) {
57
+ vars._key = i;
58
+ vars._val = val[i];
59
+ temp += render(inner, vars);
60
+ }
61
+ }
62
+ vars._key = _;
63
+ vars._val = __;
64
+ return temp;
65
+ }
66
+
67
+ })
68
+ .replace(valregex, function(_, meta, key) {
69
+ var val = get_value(vars,key);
70
+
71
+ if (val || val === 0) {
72
+ return meta == '%' ? scrub(val) : val;
73
+ }
74
+ return "";
75
+ });
76
+ }
77
+
78
+ t.prototype.render = function (vars) {
79
+ return render(this.t, vars);
80
+ };
81
+
82
+ export default t;
@@ -1,31 +1,31 @@
1
- import { Observer, EVENTS } from '../events/observer.js';
2
-
3
- export default class Channel {
4
- constructor(channelData = {}, deeplink, widget) {
5
- this.config = channelData;
6
-
7
- this.channel = channelData.channel;
8
- this.channelId = channelData.channelId;
9
- this.enabled = channelData.enabled;
10
- this.id = channelData.id;
11
- this.slug = channelData.slug;
12
-
13
- this.deeplink = deeplink;
14
- this.widget = widget;
15
-
16
- this.initPromise = null;
17
- this.hasError = false;
18
- }
19
-
20
- subscribe() {
21
- Observer.trigger(EVENTS.SUBSCRIBE_START, {
22
- widgetId: this.widget.id,
23
- channel: this,
24
- });
25
- }
26
-
27
- reportError(...args) {
28
- console.error(...args);
29
- this.hasError = true;
30
- }
1
+ import { Observer, EVENTS } from '../events/observer.js';
2
+
3
+ export default class Channel {
4
+ constructor(channelData = {}, deeplink, widget) {
5
+ this.config = channelData;
6
+
7
+ this.channel = channelData.channel;
8
+ this.channelId = channelData.channelId;
9
+ this.enabled = channelData.enabled;
10
+ this.id = channelData.id;
11
+ this.slug = channelData.slug;
12
+
13
+ this.deeplink = deeplink;
14
+ this.widget = widget;
15
+
16
+ this.initPromise = null;
17
+ this.hasError = false;
18
+ }
19
+
20
+ subscribe() {
21
+ Observer.trigger(EVENTS.SUBSCRIBE_START, {
22
+ widgetId: this.widget.id,
23
+ channel: this,
24
+ });
25
+ }
26
+
27
+ reportError(...args) {
28
+ console.error(...args);
29
+ this.hasError = true;
30
+ }
31
31
  }
@@ -1,13 +1,13 @@
1
- import Channel from './channel.js';
2
- import windowHelper from '../utils/windowHelper.js';
3
-
4
- export default class FacebookChannel extends Channel {
5
- constructor(channelData = {}, deeplink, widget) {
6
- super(channelData, deeplink, widget);
7
- }
8
-
9
- subscribe() {
10
- super.subscribe();
11
- window.open(`https://m.me/${this.id}?ref=${this.deeplink}`, 'tb_facebook');
12
- }
13
- }
1
+ import Channel from './channel.js';
2
+ import windowHelper from '../utils/windowHelper.js';
3
+
4
+ export default class FacebookChannel extends Channel {
5
+ constructor(channelData = {}, deeplink, widget) {
6
+ super(channelData, deeplink, widget);
7
+ }
8
+
9
+ subscribe() {
10
+ super.subscribe();
11
+ window.open(`https://m.me/${this.id}?ref=${this.deeplink}`, 'tb_facebook');
12
+ }
13
+ }
@@ -1,13 +1,13 @@
1
- import Channel from './channel.js';
2
- import constants from '../utils/constants.js';
3
-
4
- export default class SkypeChannel extends Channel {
5
- constructor(channelData = {}, deeplink, widget) {
6
- super(channelData, deeplink, widget);
7
- }
8
-
9
- subscribe() {
10
- super.subscribe();
11
- window.open(`https://join.skype.com/bot/${this.id}?add`, 'tb_skype');
12
- }
1
+ import Channel from './channel.js';
2
+ import constants from '../utils/constants.js';
3
+
4
+ export default class SkypeChannel extends Channel {
5
+ constructor(channelData = {}, deeplink, widget) {
6
+ super(channelData, deeplink, widget);
7
+ }
8
+
9
+ subscribe() {
10
+ super.subscribe();
11
+ window.open(`https://join.skype.com/bot/${this.id}?add`, 'tb_skype');
12
+ }
13
13
  }
@@ -1,18 +1,18 @@
1
- import Channel from './channel.js';
2
- import constants from '../utils/constants.js';
3
-
4
- export default class TelegramChannel extends Channel {
5
- constructor(channelData = {}, deeplink, widget) {
6
- super(channelData, deeplink, widget);
7
- }
8
-
9
- subscribe() {
10
- super.subscribe();
11
-
12
- if (this.widget.config.tgRedirector) {
13
- return window.open(`${this.widget.config.tgRedirector}${this.id}?start=${this.deeplink}`, 'tb_tg');
14
- }
15
-
16
- return window.open(`https://telegram.me/${this.id}?start=${this.deeplink}`, 'tb_tg');
17
- }
18
- }
1
+ import Channel from './channel.js';
2
+ import constants from '../utils/constants.js';
3
+
4
+ export default class TelegramChannel extends Channel {
5
+ constructor(channelData = {}, deeplink, widget) {
6
+ super(channelData, deeplink, widget);
7
+ }
8
+
9
+ subscribe() {
10
+ super.subscribe();
11
+
12
+ if (this.widget.config.tgRedirector) {
13
+ return window.open(`${this.widget.config.tgRedirector}${this.id}?start=${this.deeplink}`, 'tb_tg');
14
+ }
15
+
16
+ return window.open(`https://telegram.me/${this.id}?start=${this.deeplink}`, 'tb_tg');
17
+ }
18
+ }
@@ -1,13 +1,13 @@
1
- import Channel from './channel.js';
2
- import constants from '../utils/constants.js';
3
-
4
- export default class ViberChannel extends Channel {
5
- constructor(channelData = {}, deeplink, widget) {
6
- super(channelData, deeplink, widget);
7
- }
8
-
9
- subscribe() {
10
- super.subscribe();
11
- window.open(`viber://pa?chatURI=${this.id}&context=${this.deeplink}`, 'viber');
12
- }
1
+ import Channel from './channel.js';
2
+ import constants from '../utils/constants.js';
3
+
4
+ export default class ViberChannel extends Channel {
5
+ constructor(channelData = {}, deeplink, widget) {
6
+ super(channelData, deeplink, widget);
7
+ }
8
+
9
+ subscribe() {
10
+ super.subscribe();
11
+ window.open(`viber://pa?chatURI=${this.id}&context=${this.deeplink}`, 'viber');
12
+ }
13
13
  }
@@ -1,17 +1,17 @@
1
- <div class="tb-modal">
2
- <div class="tb-modal-dialog">
3
- <div class="tb-modal-content">
4
- <button class="tb-close" type="button">&times;</button>
5
- <div class="tb-modal-content_text">
6
- <p>
7
- Разрешите сообществу присылать сообщения. <br>
8
- Вы в любой момент сможете отписаться.
9
- </p>
10
- </div>
11
- <div class="tb-vk-button">
12
- <div class="tb-vk-icon">{{=vkIcon}}</div>
13
- <div id="{{=vkPluginContainerId}}"></div>
14
- </div>
15
- </div>
16
- </div>
17
- </div>
1
+ <div class="tb-modal">
2
+ <div class="tb-modal-dialog">
3
+ <div class="tb-modal-content">
4
+ <button class="tb-close" type="button">&times;</button>
5
+ <div class="tb-modal-content_text">
6
+ <p>
7
+ Разрешите сообществу присылать сообщения. <br>
8
+ Вы в любой момент сможете отписаться.
9
+ </p>
10
+ </div>
11
+ <div class="tb-vk-button">
12
+ <div class="tb-vk-icon">{{=vkIcon}}</div>
13
+ <div id="{{=vkPluginContainerId}}"></div>
14
+ </div>
15
+ </div>
16
+ </div>
17
+ </div>
@@ -1,25 +1,25 @@
1
- import t from '../../../libraries/t.js';
2
-
3
- import './vk-modal.scss';
4
- import vkTemplate from './vk-modal.html';
5
- import vkIcon from '../../../widget/icons/icon_vk.svg';
6
-
7
- export default class VKModal {
8
- constructor(vkPluginContainerId) {
9
- const modalContainer = document.createElement('div');
10
-
11
- modalContainer.innerHTML = new t(vkTemplate).render({ vkPluginContainerId, vkIcon });
12
-
13
- this.element = document.body.appendChild(modalContainer.firstChild);
14
- this.element.querySelector('.tb-close').addEventListener('click', event => {
15
- document.body.classList.remove('tb-modal-open');
16
- document.body.removeChild(this.element);
17
-
18
- if (this.onClose) {
19
- this.onClose();
20
- }
21
- });
22
-
23
- document.body.classList.add('tb-modal-open');
24
- }
25
- }
1
+ import t from '../../../libraries/t.js';
2
+
3
+ import './vk-modal.scss';
4
+ import vkTemplate from './vk-modal.html';
5
+ import vkIcon from '../../../widget/icons/icon_vk.svg';
6
+
7
+ export default class VKModal {
8
+ constructor(vkPluginContainerId) {
9
+ const modalContainer = document.createElement('div');
10
+
11
+ modalContainer.innerHTML = new t(vkTemplate).render({ vkPluginContainerId, vkIcon });
12
+
13
+ this.element = document.body.appendChild(modalContainer.firstChild);
14
+ this.element.querySelector('.tb-close').addEventListener('click', event => {
15
+ document.body.classList.remove('tb-modal-open');
16
+ document.body.removeChild(this.element);
17
+
18
+ if (this.onClose) {
19
+ this.onClose();
20
+ }
21
+ });
22
+
23
+ document.body.classList.add('tb-modal-open');
24
+ }
25
+ }