@jolibox/implement 1.4.15 → 1.4.16

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.
@@ -1,9 +1,9 @@
1
1
  Invoking: npm run clean && npm run build:esm && tsc
2
2
 
3
- > @jolibox/implement@1.4.15 clean
3
+ > @jolibox/implement@1.4.16 clean
4
4
  > rimraf ./dist
5
5
 
6
6
 
7
- > @jolibox/implement@1.4.15 build:esm
7
+ > @jolibox/implement@1.4.16 build:esm
8
8
  > BUILD_VERSION=$(node -p "require('./package.json').version") node esbuild.config.js --format=esm
9
9
 
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@jolibox/implement",
3
3
  "description": "This project is Jolibox JS-SDk implement for Native && H5",
4
- "version": "1.4.15",
4
+ "version": "1.4.16",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
7
7
  "license": "MIT",
8
8
  "dependencies": {
9
- "@jolibox/common": "1.4.15",
10
- "@jolibox/types": "1.4.15",
11
- "@jolibox/native-bridge": "1.4.15",
12
- "@jolibox/ads": "1.4.15",
9
+ "@jolibox/common": "1.4.16",
10
+ "@jolibox/types": "1.4.16",
11
+ "@jolibox/native-bridge": "1.4.16",
12
+ "@jolibox/ads": "1.4.16",
13
13
  "localforage": "1.10.0",
14
- "@jolibox/ui": "1.4.15",
14
+ "@jolibox/ui": "1.4.16",
15
15
  "web-vitals": "4.2.4"
16
16
  },
17
17
  "devDependencies": {
@@ -34,8 +34,9 @@ export abstract class TaskTracker {
34
34
  private reportCount = 0; // 添加上报次数计数
35
35
 
36
36
  protected notifyIframeGameEvent = (eventName: string, data: any) => {
37
- if (window.parent) {
38
- window.parent.postMessage(
37
+ const parentWindow = window.parent;
38
+ if (parentWindow && parentWindow !== window && typeof parentWindow.postMessage === 'function') {
39
+ parentWindow.postMessage(
39
40
  {
40
41
  type: eventName,
41
42
  data
@@ -69,15 +69,18 @@ interface JoliboxCustomEvent {
69
69
 
70
70
  const notifyCustomEvent = <T extends keyof JoliboxCustomEvent>(eventName: T, data: JoliboxCustomEvent[T]) => {
71
71
  window.dispatchEvent(new CustomEvent(eventName, { detail: data }));
72
- window.parent?.postMessage(
73
- {
74
- type: eventName,
75
- data: {
76
- detail: data
77
- }
78
- },
79
- '*'
80
- );
72
+ const parentWindow = window.parent;
73
+ if (parentWindow && parentWindow !== window && typeof parentWindow.postMessage === 'function') {
74
+ parentWindow.postMessage(
75
+ {
76
+ type: eventName,
77
+ data: {
78
+ detail: data
79
+ }
80
+ },
81
+ '*'
82
+ );
83
+ }
81
84
  };
82
85
 
83
86
  /**
@@ -11,8 +11,9 @@ enum ECrossFrameEvent {
11
11
  }
12
12
 
13
13
  const notifyIframeGameTaskEvent = (eventName: string, data: any) => {
14
- if (window.parent) {
15
- window.parent.postMessage(
14
+ const parentWindow = window.parent;
15
+ if (parentWindow && parentWindow !== window && typeof parentWindow.postMessage === 'function') {
16
+ parentWindow.postMessage(
16
17
  {
17
18
  type: eventName,
18
19
  data