@dpgradio/creative 7.2.1 → 7.2.3

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": "@dpgradio/creative",
3
- "version": "7.2.1",
3
+ "version": "7.2.3",
4
4
  "description": "Support package for standalone Javascript applications",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -10,7 +10,7 @@
10
10
  },
11
11
  "repository": {
12
12
  "type": "git",
13
- "url": "https://github.com/dpgradio/creative.git"
13
+ "url": "git+https://github.com/dpgradio/creative.git"
14
14
  },
15
15
  "keywords": [
16
16
  "qmusic"
@@ -5,6 +5,10 @@ import loadScript from '../utils/loadScript.js'
5
5
 
6
6
  class DataLayer {
7
7
  constructor() {
8
+ if (typeof window === 'undefined') {
9
+ return
10
+ }
11
+
8
12
  window.dataLayer = window.dataLayer || []
9
13
  this.campaignDetails = {}
10
14
  this.userInformation = {}
package/src/app/hybrid.js CHANGED
@@ -17,6 +17,10 @@ class Hybrid {
17
17
  }
18
18
 
19
19
  constructor() {
20
+ if (typeof window === 'undefined') {
21
+ return
22
+ }
23
+
20
24
  // Hook this on window so it can be required in multiple packs
21
25
  window._hybridEventSubscriptions = window._hybridEventSubscriptions || {}
22
26
 
@@ -3,6 +3,10 @@ import loadScript from '../utils/loadScript.js'
3
3
 
4
4
  class Privacy {
5
5
  constructor() {
6
+ if (typeof window === 'undefined') {
7
+ return
8
+ }
9
+
6
10
  window._privacy = window._privacy || []
7
11
 
8
12
  this.consent = undefined
@@ -1,4 +1,4 @@
1
- import openLink from '../utils/openLink.js'
1
+ import openExternalUrl from '../utils/openExternalUrl.js'
2
2
 
3
3
  export default class ShareResult {
4
4
  constructor(shareable, { url, image }) {
@@ -20,14 +20,14 @@ export default class ShareResult {
20
20
  }
21
21
 
22
22
  openFacebookUrl() {
23
- openLink(this.facebookUrl())
23
+ openExternalUrl(this.facebookUrl())
24
24
  }
25
25
 
26
26
  openWhatsappUrl() {
27
- openLink(this.whatsappUrl())
27
+ openExternalUrl(this.whatsappUrl())
28
28
  }
29
29
 
30
30
  openInstagramUrl() {
31
- openLink(this.instagramUrl())
31
+ openExternalUrl(this.instagramUrl())
32
32
  }
33
33
  }
@@ -1,5 +1,3 @@
1
- // eslint-disable-next-line import/no-unresolved -- TODO: Needs a rewrite to fetch
2
- import axios from 'axios'
3
1
  import ShareResult from './ShareResult.js'
4
2
 
5
3
  export default class Shareable {
@@ -36,21 +34,21 @@ export default class Shareable {
36
34
  return this
37
35
  }
38
36
 
39
- generateUsingImage(imageGeneratorProperties) {
40
- return new Promise((resolve, reject) => {
41
- axios({
42
- url: 'https://dba1du5ckc.execute-api.eu-west-3.amazonaws.com/prod/',
43
- method: 'post',
44
- data: {
45
- title: this.title,
46
- description: this.description,
47
- image_generator: imageGeneratorProperties.toJson(),
48
- redirect_url: this.redirectUrl,
49
- domain: this.domain,
50
- },
51
- })
52
- .then((response) => resolve(new ShareResult(this, response.data)))
53
- .catch(reject)
37
+ async generateUsingImage(imageGeneratorProperties) {
38
+ const response = await fetch('https://dba1du5ckc.execute-api.eu-west-3.amazonaws.com/prod/', {
39
+ method: 'POST',
40
+ headers: {
41
+ 'Content-Type': 'application/json',
42
+ },
43
+ body: JSON.stringify({
44
+ title: this.title,
45
+ description: this.description,
46
+ image_generator: imageGeneratorProperties.toJson(),
47
+ redirect_url: this.redirectUrl,
48
+ domain: this.domain,
49
+ }),
54
50
  })
51
+ const data = await response.json()
52
+ return new ShareResult(this, data)
55
53
  }
56
54
  }