@subiz/widget-v4 4.0.55 → 4.0.56

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 (34) hide show
  1. package/compiled_src/notif/notif.js +1 -1
  2. package/dist/{17d7ef81b7a.178.js → 17d7f3360b5.178.js} +0 -0
  3. package/dist/{17d7ef81b7a.213.js → 17d7f3360b5.213.js} +0 -0
  4. package/dist/{17d7ef81b7a.362.js → 17d7f3360b5.362.js} +0 -0
  5. package/dist/{17d7ef81b7a.441.js → 17d7f3360b5.441.js} +0 -0
  6. package/dist/17d7f3360b5.605.js +1 -0
  7. package/dist/{17d7ef81b7a.619.js → 17d7f3360b5.619.js} +0 -0
  8. package/dist/{17d7ef81b7a.678.js → 17d7f3360b5.678.js} +0 -0
  9. package/dist/{17d7ef81b7a.74.js → 17d7f3360b5.74.js} +0 -0
  10. package/dist/{17d7ef81b7a.782.js → 17d7f3360b5.782.js} +0 -0
  11. package/dist/{17d7ef81b7a.app.js → 17d7f3360b5.app.js} +1 -1
  12. package/dist/{17d7ef81b7a.index.html → 17d7f3360b5.index.html} +1 -1
  13. package/dist/{17d7ef81b7a.library.html → 17d7f3360b5.library.html} +1 -1
  14. package/dist/{17d7ef81b7a.library.js → 17d7f3360b5.library.js} +1 -1
  15. package/dist/{17d7ef81b7a.preview.html → 17d7f3360b5.preview.html} +1 -1
  16. package/dist/{17d7ef81b7a.preview.js → 17d7f3360b5.preview.js} +1 -1
  17. package/dist/{17d7ef81b7a.screenshoot.js → 17d7f3360b5.screenshoot.js} +1 -1
  18. package/dist/{17d7ef84382.178.js → 17d7f338b23.178.js} +0 -0
  19. package/dist/{17d7ef84382.213.js → 17d7f338b23.213.js} +0 -0
  20. package/dist/{17d7ef84382.362.js → 17d7f338b23.362.js} +0 -0
  21. package/dist/{17d7ef84382.441.js → 17d7f338b23.441.js} +0 -0
  22. package/dist/{17d7ef84382.605.js → 17d7f338b23.605.js} +1 -1
  23. package/dist/{17d7ef84382.619.js → 17d7f338b23.619.js} +0 -0
  24. package/dist/{17d7ef84382.678.js → 17d7f338b23.678.js} +0 -0
  25. package/dist/{17d7ef84382.74.js → 17d7f338b23.74.js} +0 -0
  26. package/dist/{17d7ef84382.782.js → 17d7f338b23.782.js} +0 -0
  27. package/dist/{17d7ef84382.screenshoot.js → 17d7f338b23.screenshoot.js} +29 -1
  28. package/dist/HASH +1 -1
  29. package/dist/screenshoot.html +1 -1
  30. package/package.json +1 -1
  31. package/screenshoot.js +31 -0
  32. package/src/notif/notif.js +1 -1
  33. package/src/plugin.js +11 -4
  34. package/dist/17d7ef81b7a.605.js +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@subiz/widget-v4",
3
- "version": "4.0.55",
3
+ "version": "4.0.56",
4
4
  "main": "./compiled_src/lib.js",
5
5
  "scripts": {
6
6
  "dev": "npx webpack serve --config webpack.dev.js",
package/screenshoot.js CHANGED
@@ -13,11 +13,42 @@ function main() {
13
13
  var $div = document.createElement('div')
14
14
  document.body.appendChild($div)
15
15
  let hash = document.location.hash.substr(1)
16
+
16
17
  let plugin = JSON.parse(decodeURIComponent(atob(hash)))
17
18
  plugin.triggers = [{type: 'after_pageview', after_pageview_sec: 0, enabled: true}]
18
19
  if (plugin.popup) plugin.popup.overlay = false
19
20
  plugin._dont_close = true
20
21
  plugin._page_index = 0
22
+ plugin.conditions = []
23
+
24
+ if (plugin.type === 'notification') {
25
+ if (!plugin.notification) return console.log('EMPTY PLUGIN')
26
+
27
+ if (!plugin.notification.profiles || plugin.notification.profiles.length == 0) {
28
+ plugin.notification.profiles = [
29
+ {
30
+ address: 'Hàng Da, Hoàn Kiếm, Hà Nội',
31
+ age: 26,
32
+ avatar_url: 'https://vcdn.subiz-cdn.com/file/firegedmbhqftirxacho-avatar3.jpeg',
33
+ country: 'VN',
34
+ email: 'linhxx@gmail.com',
35
+ gender: 'Female',
36
+ fullname: 'Nguyễn Linh',
37
+ phone: '0823588xxx',
38
+ },
39
+ {
40
+ address: 'Lũng Cú, Đồng Văn, Hà Giang',
41
+ age: 23,
42
+ avatar_url: 'https://vcdn.subiz-cdn.com/file/fiqvzdstytzxlbsguaci-ellipse_2319.png',
43
+ country: 'VN',
44
+ email: 'lannhoanggxx@gmail.com',
45
+ gender: 'Female',
46
+ name: 'Nguyễn Hoàng Lan',
47
+ phone: '0326789xxx',
48
+ },
49
+ ]
50
+ }
51
+ }
21
52
 
22
53
  plugin.account_id = accid
23
54
  widget._overridePlugin([plugin])
@@ -100,7 +100,7 @@ export default class Notif extends Com {
100
100
  this.setState({closeAnimation: false})
101
101
  let timestamp = this.randomTimestampt()
102
102
  let profiles = sb.get(this.props, 'plugin.notification.profiles', [])
103
- let user = profiles[Math.floor(Math.random() * sb.size(profiles))]
103
+ let user = profiles[Math.floor(Math.random() * sb.size(profiles))] || {}
104
104
  // make sure image loaded
105
105
  if (user.avatar_url && user.avatar_url.startsWith('http')) {
106
106
  await sb.preloadImg(user.avatar_url)
package/src/plugin.js CHANGED
@@ -29,10 +29,9 @@ function Plugin(plugin, store, $container, lib) {
29
29
 
30
30
  this.getState = () => state
31
31
 
32
- var run = async function () {
32
+ var run = async function() {
33
33
  if (_destroy) return
34
34
  if (state !== 'hold') return
35
-
36
35
  // dont run converted plugin twice
37
36
  if (plugin.type === 'popup' && store.isConverted(plugin.id)) return
38
37
 
@@ -375,8 +374,16 @@ const getLocale = (plugin, loc) => {
375
374
  if (found) return found
376
375
 
377
376
  found = sb.find(plugin.locales, (l) => {
378
- l = l.replace('-', '_').split('_')[0].trim().toLowerCase()
379
- let compareloc = loc.replace('-', '_').split('_')[0].trim().toLowerCase()
377
+ l = l
378
+ .replace('-', '_')
379
+ .split('_')[0]
380
+ .trim()
381
+ .toLowerCase()
382
+ let compareloc = loc
383
+ .replace('-', '_')
384
+ .split('_')[0]
385
+ .trim()
386
+ .toLowerCase()
380
387
  return l == compareloc
381
388
  })
382
389
  if (found) return found
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunk_subiz_widget_v4=self.webpackChunk_subiz_widget_v4||[]).push([[605],{2493:(t,e,s)=>{s.d(e,{M:()=>o,u:()=>n});var i=s(6400);s(819);class o extends i.wA{constructor(t){super(t),this._isMounted=!0,setTimeout((()=>{if(this.componentWillUnmount){let t=this.componentWillUnmount.bind(this);this.componentWillUnmount=()=>{t(),this._isMounted=!1}}}),10)}}class n extends o{constructor(t){super(t),this.setWrapperRef=this.setWrapperRef.bind(this),this.onClick=this.onClick.bind(this)}componentDidMount(){document.addEventListener("mousedown",this.onClick)}componentWillUnmount(){document.removeEventListener("mousedown",this.onClick)}setWrapperRef(t){this.wrapperRef=t}onClick(t){this.wrapperRef&&!this.wrapperRef.contains(t.target)&&this.props.onClickaway&&this.props.onClickaway()}render(){return(0,i.h)("div",{ref:this.setWrapperRef},this.props.children)}}},9605:(t,e,s)=>{s.r(e),s.d(e,{default:()=>r});var i=s(819),o=s(6400),n=s(2493);let a=s.e(362).then(s.bind(s,362));class r extends n.M{constructor(t){var e,s;super(t),s={close:!0,cssready:!1,closeAnimation:!0,imageReady:!1,user:{},timestamp:"",message:"",title:"",last_show:0},(e="state")in this?Object.defineProperty(this,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):this[e]=s,setTimeout((async()=>{let{body:t}=await this.props.store.sendImpression(this.props.plugin.id);this.impressionToken=i.Z.get(t,"impression_token")||"";let e=i.Z.get(this.props,"plugin.notification.background_url");i.Z.preloadImg(e,(()=>this.setState({imageReady:!0})))}))}setOver(t){this.mouse_leave=t?0:i.Z.Date.now()}randomTimestampt(){let t=Math.floor(5*Math.random());return 0==t?this.props.t("just_now"):1==t?"1 "+this.props.t("minute_ago"):2==t?"2 "+this.props.t("minutes_ago"):3==t?"3 "+this.props.t("minutes_ago"):"4 "+this.props.t("minutes_ago")}onClick(t){if(t.stopPropagation(),this.props.plugin._dont_follow)return;this.props.store.sendConversion(this.props.plugin.id,null,this.impressionToken);let e=i.Z.get(this.props,"plugin.notification.url");return e?(e.startsWith("http://")||e.startsWith("https://")||(e="//"+e),i.Z.get(this.props,"plugin.notification.new_tab",!1)?window.open(e):void(window.location.href=e)):void 0}onCloseButtonClick(t){t.preventDefault(),t.stopPropagation(),this.setClose(!0)}renderCloseButton(){return(0,o.h)("div",{class:"btn_close",onClick:t=>this.onCloseButtonClick(t)},(0,o.h)("svg",{class:"btn_close__icon",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24","stroke-linecap":"round","stroke-linejoin":"round"},(0,o.h)("line",{x1:"18",y1:"6",x2:"6",y2:"18",style:"stroke-width: 3 !important;"}),(0,o.h)("line",{x1:"6",y1:"6",x2:"18",y2:"18",style:"stroke-width: 3 !important;"})))}async waitForT(){if(!this.props.t)return await i.Z.sleep(100),this.waitForT()}async setClose(t){if(await this.waitForT(),this.props.t){if(!t){clearTimeout(this.lastCloseTimeout),this.setState({closeAnimation:!1});let t=this.randomTimestampt(),e=i.Z.get(this.props,"plugin.notification.profiles",[]),s=e[Math.floor(Math.random()*i.Z.size(e))];s.avatar_url&&s.avatar_url.startsWith("http")&&await i.Z.preloadImg(s.avatar_url),i.Z.map(i.Z.get(this.props.plugin,"notification.custom_avatar_urls"),(t=>{e.push({type:"person",fullname:l(),avatar_url:t,email:l().split(" ").join(".").toLowerCase()+"@gmail.com",address:h(),phone:"+84"+Math.floor(10*Math.random())+Math.floor(10*Math.random())+Math.floor(10*Math.random())+Math.floor(10*Math.random())+Math.floor(10*Math.random())+Math.floor(10*Math.random())+"xxxx",age:15+Math.floor(20*Math.random())})}));let o=i.Z.get(this.props,"plugin.notification.i18n_message_quill_deltas",[]),n=o[Math.floor(Math.random()*i.Z.size(o))],a=i.Z.get(this.props,"plugin.notification.message_quill_deltas",[]),r=a[Math.floor(Math.random()*i.Z.size(a))],p=i.Z.get(this.props,"plugin.notification.i18n_title_quill_delta");return this.setState({close:!1,last_show:i.Z.Date.now(),timestamp:t,user:s,title:this.props.t.i18n(p)||i.Z.get(this.props,"plugin.notification.title_quill_delta"),message:this.props.t.i18n(n)||r})}this.setState({closeAnimation:!0}),this.mouse_leave=i.Z.Date.now(),this.lastCloseTimeout=setTimeout((()=>this.setState({close:!0,closeAnimation:!1})),150),this.props.plugin._dont_close&&setTimeout((()=>this.setState({closeAnimation:!1,close:!1})),1e3)}}async refreshCSS(){let t=this.props.store.matchPlugin();if(!i.Z.find(t,(t=>t.id===this.props.plugin.id)))return;let e=(await a).default.default.toString();i.Z.setCss(this.props.plugin.id,this.$cssStyleDiv,e),this.setClose(this.state.close)}componentWillUnmount(){clearInterval(this.interval),i.Z.setCss(this.props.plugin.id,this.$cssStyleDiv,"")}async componentDidMount(){this.setState({last_show:i.Z.Date.now()}),this.$cssStyleDiv=document.getElementById("subiz-style-for-"+this.props.plugin.id),this.$cssStyleDiv||(this.$cssStyleDiv=document.createElement("style"),document.head.appendChild(this.$cssStyleDiv),this.$cssStyleDiv.type="text/css",this.$cssStyleDiv.id="subiz-style-for-"+this.props.plugin.id),this.props.store.onResetCSS(this,(()=>this.refreshCSS())),await this.refreshCSS(),this.interval=setInterval((()=>{if(this.props._destroy)return this.componentWillUnmount();let t=this.mouse_leave;return 0===t&&(t=i.Z.Date.now()),i.Z.Date.now()-t<1e3?void 0:this.state.close||this.props.plugin._dont_close?i.Z.Date.now()-this.state.last_show>this.props.plugin.notification.interval_sec?this.setClose(!1):void 0:i.Z.Date.now()-this.state.last_show>8e3?this.setClose(!0):void 0}),1e3),setTimeout((()=>{this.setState({cssready:!0}),this.setClose(!1)}),50)}renderTextFromQuillDelta(t,e){let s=i.Z.parseJSON(t);return s&&s.ops?i.Z.map(s.ops,(t=>{let s=null;if(!t.insert)return null;if("string"==typeof t.insert&&(s=t.insert),i.Z.get(t,"insert.dynamicField")){let o=i.Z.get(t,"insert.dynamicField.key");"user.fullname"===o&&(s=e.fullname),"user.email"===o&&(s=e.email),"user.address"===o&&(s=e.address),"user.phone"===o&&(s=e.phone)}return i.Z.get(t,"attributes.bold")&&(s=(0,o.h)("b",null,s)),i.Z.get(t,"attributes.italic")&&(s=(0,o.h)("b",null,s)),s})):null}render(){if(!this.props.t)return null;if(!this.state.cssready)return null;if(!this.state.imageReady)return null;if(this.state.close)return null;if(!this.state.message)return null;let t=i.Z.get(this.props.plugin,"notification",{});if(!t)return null;let e="",s=i.Z.get(t,"position","bottom-left");this.props.mobile&&(s=i.Z.get(t,"mobile_position",s)),"top-left"===s||"top-right"===s?e="fadeInDown":"top-center"===s?e="fadeInDownCenter":"bottom-center"===s?e="fadeInUpCenter":("bottom-right"===s||(s="bottom-left"),e="fadeInUpBig");let n=this.state.user||{},a=t.subtext_style||{};void 0===a.color&&(a.color=i.Z.get(t,"message_style.color","black"));let r="position: fixed !important; z-index: 1000000000 !important";return this.props.plugin._preview&&(r="position: absolute !important;"),this.state.closeAnimation&&(e="fadeOut"),(0,o.h)("div",{class:e+" notif notif__"+s,onClick:t=>this.onClick(t),onmouseover:t=>this.setOver(!0),style:r,onmouseleave:t=>this.setOver(!1)},(0,o.h)("div",{style:"position: relative !important; display: flex !important; align-items: center !important;"},(0,o.h)("img",{alt:"notification background",class:"notif_bg",src:t.background_url,style:i.Z.js2css(t.background_style)}),this.renderCloseButton(),(0,o.h)("div",{class:"notif_avatar",style:i.Z.js2css(t.avatar_style)},(0,o.h)("img",{alt:"notification avatar",class:"notif_avatar__img",src:n.avatar_url})),(0,o.h)("div",{class:"notif_body"},(0,o.h)("div",{class:"notif_title",style:i.Z.js2css(t.title_style)},this.renderTextFromQuillDelta(this.state.title,n)),(0,o.h)("div",{class:"notif_message",style:i.Z.js2css(t.message_style)},this.renderTextFromQuillDelta(this.state.message,n)),(0,o.h)("div",{class:"notif_time",style:i.Z.js2css(t.subtext_style)},this.state.timestamp))))}}function l(){let t=["Kiều Thanh","Phương Anh","Lê Thùy Linh","Trang Nguyễn","Thanh Hoa","Hoài Đức","Huơng Giang"];return t[Math.floor(Math.random()*t.length)]}function h(){let t=["Dịch Vọng Hậu, Cầu Giấy","Quận 1, TP Hồ Chí Minh","Ngõ 34 Tôn Thất Thuyết","87 Phạm Hùng","Đống Đa, Hà Nội"];return t[Math.floor(Math.random()*t.length)]}}}]);