@playcraft/adsdk 1.0.18-beta.4 → 1.0.20
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/LICENSE +21 -21
- package/defines.d.ts +130 -130
- package/dist/esm/index.js +21 -11
- package/dist/iife/index.js +21 -11
- package/dist/index.d.mts +12 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.js +21 -11
- package/package.json +56 -56
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025-present Smoud
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-present Smoud
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/defines.d.ts
CHANGED
|
@@ -1,130 +1,130 @@
|
|
|
1
|
-
declare const mraid: {
|
|
2
|
-
getVersion: () => string; // MRAID 规范必需:返回 MRAID 版本(如 "3.0")
|
|
3
|
-
isReady: () => boolean;
|
|
4
|
-
isViewable: () => boolean;
|
|
5
|
-
getState: () => string;
|
|
6
|
-
addEventListener: (
|
|
7
|
-
event: 'viewableChange' | 'sizeChange' | 'ready' | 'audioVolumeChange' | 'stateChange' | 'error' | 'orientationChange' | 'resize',
|
|
8
|
-
callback: (...args: any[]) => void
|
|
9
|
-
) => void;
|
|
10
|
-
removeEventListener: (
|
|
11
|
-
event: 'viewableChange' | 'sizeChange' | 'ready' | 'audioVolumeChange' | 'stateChange' | 'error' | 'orientationChange' | 'resize',
|
|
12
|
-
callback: (...args: any[]) => void
|
|
13
|
-
) => void;
|
|
14
|
-
getMaxSize: () => { width: number; height: number };
|
|
15
|
-
openStoreUrl: () => void;
|
|
16
|
-
open: (url: string) => void;
|
|
17
|
-
close: () => void; // Unity Ads 必需:关闭广告
|
|
18
|
-
getAudioVolume: () => number;
|
|
19
|
-
fireTrackingEvent?: (event: string) => void; // Unity Ads 可选:跟踪事件
|
|
20
|
-
preloadStore?: () => void;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
declare const dapi: {
|
|
24
|
-
addEventListener: (
|
|
25
|
-
event: 'viewableChange' | 'adResized' | 'ready' | 'audioVolumeChange' | 'error',
|
|
26
|
-
callback: (...args: any[]) => void
|
|
27
|
-
) => void;
|
|
28
|
-
removeEventListener: (
|
|
29
|
-
event: 'viewableChange' | 'adResized' | 'ready' | 'audioVolumeChange' | 'error',
|
|
30
|
-
callback: (...args: any[]) => void
|
|
31
|
-
) => void;
|
|
32
|
-
getScreenSize: () => { width: number; height: number };
|
|
33
|
-
openStoreUrl: () => void;
|
|
34
|
-
getAudioVolume: () => number;
|
|
35
|
-
isViewable: () => boolean;
|
|
36
|
-
isReady: () => boolean;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
declare const NUC: {
|
|
40
|
-
trigger: {
|
|
41
|
-
convert: (destinationUrl: string) => void;
|
|
42
|
-
tryAgain: Function;
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
declare const ScPlayableAd: { onCTAClick: () => void };
|
|
47
|
-
|
|
48
|
-
// Adikteev 占位符变量
|
|
49
|
-
declare const AK_CLICK_DESTINATION_URL: string;
|
|
50
|
-
declare const AK_CLICK_PIXEL_URL: string;
|
|
51
|
-
declare const FbPlayableAd: { onCTAClick: () => void };
|
|
52
|
-
declare const smxTracking: { redirect: () => void };
|
|
53
|
-
declare const ExitApi: { exit: () => void };
|
|
54
|
-
|
|
55
|
-
declare const AD_NETWORK:
|
|
56
|
-
| 'preview'
|
|
57
|
-
| 'applovin'
|
|
58
|
-
| 'unity'
|
|
59
|
-
| 'google'
|
|
60
|
-
| 'ironsource'
|
|
61
|
-
| 'facebook'
|
|
62
|
-
| 'moloco'
|
|
63
|
-
| 'mintegral'
|
|
64
|
-
| 'vungle'
|
|
65
|
-
| 'adcolony'
|
|
66
|
-
| 'tapjoy'
|
|
67
|
-
| 'snapchat'
|
|
68
|
-
| 'tiktok'
|
|
69
|
-
| 'appreciate'
|
|
70
|
-
| 'chartboost'
|
|
71
|
-
| 'pangle'
|
|
72
|
-
| 'mytarget'
|
|
73
|
-
| 'liftoff'
|
|
74
|
-
| 'smadex'
|
|
75
|
-
| 'adikteev'
|
|
76
|
-
| 'bigabid'
|
|
77
|
-
| 'inmobi'
|
|
78
|
-
| 'bigoads';
|
|
79
|
-
|
|
80
|
-
declare const AD_PROTOCOL: 'mraid' | 'dapi' | 'nucleo' | 'none';
|
|
81
|
-
declare const GOOGLE_PLAY_URL: string;
|
|
82
|
-
declare const APP_STORE_URL: string;
|
|
83
|
-
declare const BUILD_HASH: string;
|
|
84
|
-
|
|
85
|
-
interface Window {
|
|
86
|
-
PlayableSDK: any;
|
|
87
|
-
ADS_MRAID_CONFIG: {
|
|
88
|
-
landUrl: string;
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
// AppLovin Playable Analytics
|
|
92
|
-
// 文档: https://support.axon.ai/en/growth/promoting-your-apps/creatives/playable-analytics-integration
|
|
93
|
-
ALPlayableAnalytics?: {
|
|
94
|
-
trackEvent: (event: string) => void;
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
// BigoAds SDK
|
|
98
|
-
// 文档: https://www.bigoads.com/help/detail?id=143&moduleId=7¤tLan=CN
|
|
99
|
-
BGY_MRAID: {
|
|
100
|
-
open: () => void; // 打开应用商店/推广地址
|
|
101
|
-
gameReady: () => void; // 素材准备完毕时调用
|
|
102
|
-
gameEnd: () => void; // 游戏结束时调用
|
|
103
|
-
isViewable: () => boolean;
|
|
104
|
-
addEventListener: (event: string, callback: (...args: any[]) => void) => void;
|
|
105
|
-
removeEventListener: (event: string, callback: (...args: any[]) => void) => void;
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
// Mintegral functions
|
|
109
|
-
gameReady: Function;
|
|
110
|
-
gameEnd: Function;
|
|
111
|
-
gameRetry: Function;
|
|
112
|
-
install: Function;
|
|
113
|
-
mintGameStart: Function;
|
|
114
|
-
mintGameClose: Function;
|
|
115
|
-
|
|
116
|
-
// Tapjoy functions
|
|
117
|
-
TJ_API: {
|
|
118
|
-
objectiveComplete: Function;
|
|
119
|
-
playableFinished: Function;
|
|
120
|
-
gameplayFinished: Function;
|
|
121
|
-
setPlayableBuild: Function;
|
|
122
|
-
setPlayableAPI: Function;
|
|
123
|
-
click: Function;
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
BIGABID_BIDTIMEMACROS?: Record<string, string>
|
|
127
|
-
INMOBI_DSPMACROS?: Record<string, string>
|
|
128
|
-
|
|
129
|
-
openAppStore: Function;
|
|
130
|
-
}
|
|
1
|
+
declare const mraid: {
|
|
2
|
+
getVersion: () => string; // MRAID 规范必需:返回 MRAID 版本(如 "3.0")
|
|
3
|
+
isReady: () => boolean;
|
|
4
|
+
isViewable: () => boolean;
|
|
5
|
+
getState: () => string;
|
|
6
|
+
addEventListener: (
|
|
7
|
+
event: 'viewableChange' | 'sizeChange' | 'ready' | 'audioVolumeChange' | 'stateChange' | 'error' | 'orientationChange' | 'resize',
|
|
8
|
+
callback: (...args: any[]) => void
|
|
9
|
+
) => void;
|
|
10
|
+
removeEventListener: (
|
|
11
|
+
event: 'viewableChange' | 'sizeChange' | 'ready' | 'audioVolumeChange' | 'stateChange' | 'error' | 'orientationChange' | 'resize',
|
|
12
|
+
callback: (...args: any[]) => void
|
|
13
|
+
) => void;
|
|
14
|
+
getMaxSize: () => { width: number; height: number };
|
|
15
|
+
openStoreUrl: () => void;
|
|
16
|
+
open: (url: string) => void;
|
|
17
|
+
close: () => void; // Unity Ads 必需:关闭广告
|
|
18
|
+
getAudioVolume: () => number;
|
|
19
|
+
fireTrackingEvent?: (event: string) => void; // Unity Ads 可选:跟踪事件
|
|
20
|
+
preloadStore?: () => void;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
declare const dapi: {
|
|
24
|
+
addEventListener: (
|
|
25
|
+
event: 'viewableChange' | 'adResized' | 'ready' | 'audioVolumeChange' | 'error',
|
|
26
|
+
callback: (...args: any[]) => void
|
|
27
|
+
) => void;
|
|
28
|
+
removeEventListener: (
|
|
29
|
+
event: 'viewableChange' | 'adResized' | 'ready' | 'audioVolumeChange' | 'error',
|
|
30
|
+
callback: (...args: any[]) => void
|
|
31
|
+
) => void;
|
|
32
|
+
getScreenSize: () => { width: number; height: number };
|
|
33
|
+
openStoreUrl: () => void;
|
|
34
|
+
getAudioVolume: () => number;
|
|
35
|
+
isViewable: () => boolean;
|
|
36
|
+
isReady: () => boolean;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
declare const NUC: {
|
|
40
|
+
trigger: {
|
|
41
|
+
convert: (destinationUrl: string) => void;
|
|
42
|
+
tryAgain: Function;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
declare const ScPlayableAd: { onCTAClick: () => void };
|
|
47
|
+
|
|
48
|
+
// Adikteev 占位符变量
|
|
49
|
+
declare const AK_CLICK_DESTINATION_URL: string;
|
|
50
|
+
declare const AK_CLICK_PIXEL_URL: string;
|
|
51
|
+
declare const FbPlayableAd: { onCTAClick: () => void };
|
|
52
|
+
declare const smxTracking: { redirect: () => void };
|
|
53
|
+
declare const ExitApi: { exit: () => void };
|
|
54
|
+
|
|
55
|
+
declare const AD_NETWORK:
|
|
56
|
+
| 'preview'
|
|
57
|
+
| 'applovin'
|
|
58
|
+
| 'unity'
|
|
59
|
+
| 'google'
|
|
60
|
+
| 'ironsource'
|
|
61
|
+
| 'facebook'
|
|
62
|
+
| 'moloco'
|
|
63
|
+
| 'mintegral'
|
|
64
|
+
| 'vungle'
|
|
65
|
+
| 'adcolony'
|
|
66
|
+
| 'tapjoy'
|
|
67
|
+
| 'snapchat'
|
|
68
|
+
| 'tiktok'
|
|
69
|
+
| 'appreciate'
|
|
70
|
+
| 'chartboost'
|
|
71
|
+
| 'pangle'
|
|
72
|
+
| 'mytarget'
|
|
73
|
+
| 'liftoff'
|
|
74
|
+
| 'smadex'
|
|
75
|
+
| 'adikteev'
|
|
76
|
+
| 'bigabid'
|
|
77
|
+
| 'inmobi'
|
|
78
|
+
| 'bigoads';
|
|
79
|
+
|
|
80
|
+
declare const AD_PROTOCOL: 'mraid' | 'dapi' | 'nucleo' | 'none';
|
|
81
|
+
declare const GOOGLE_PLAY_URL: string;
|
|
82
|
+
declare const APP_STORE_URL: string;
|
|
83
|
+
declare const BUILD_HASH: string;
|
|
84
|
+
|
|
85
|
+
interface Window {
|
|
86
|
+
PlayableSDK: any;
|
|
87
|
+
ADS_MRAID_CONFIG: {
|
|
88
|
+
landUrl: string;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
// AppLovin Playable Analytics
|
|
92
|
+
// 文档: https://support.axon.ai/en/growth/promoting-your-apps/creatives/playable-analytics-integration
|
|
93
|
+
ALPlayableAnalytics?: {
|
|
94
|
+
trackEvent: (event: string) => void;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
// BigoAds SDK
|
|
98
|
+
// 文档: https://www.bigoads.com/help/detail?id=143&moduleId=7¤tLan=CN
|
|
99
|
+
BGY_MRAID: {
|
|
100
|
+
open: () => void; // 打开应用商店/推广地址
|
|
101
|
+
gameReady: () => void; // 素材准备完毕时调用
|
|
102
|
+
gameEnd: () => void; // 游戏结束时调用
|
|
103
|
+
isViewable: () => boolean;
|
|
104
|
+
addEventListener: (event: string, callback: (...args: any[]) => void) => void;
|
|
105
|
+
removeEventListener: (event: string, callback: (...args: any[]) => void) => void;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
// Mintegral functions
|
|
109
|
+
gameReady: Function;
|
|
110
|
+
gameEnd: Function;
|
|
111
|
+
gameRetry: Function;
|
|
112
|
+
install: Function;
|
|
113
|
+
mintGameStart: Function;
|
|
114
|
+
mintGameClose: Function;
|
|
115
|
+
|
|
116
|
+
// Tapjoy functions
|
|
117
|
+
TJ_API: {
|
|
118
|
+
objectiveComplete: Function;
|
|
119
|
+
playableFinished: Function;
|
|
120
|
+
gameplayFinished: Function;
|
|
121
|
+
setPlayableBuild: Function;
|
|
122
|
+
setPlayableAPI: Function;
|
|
123
|
+
click: Function;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
BIGABID_BIDTIMEMACROS?: Record<string, string>
|
|
127
|
+
INMOBI_DSPMACROS?: Record<string, string>
|
|
128
|
+
|
|
129
|
+
openAppStore: Function;
|
|
130
|
+
}
|
package/dist/esm/index.js
CHANGED
|
@@ -614,9 +614,9 @@ function lookupI18nRuntime(runtime, key, langCode) {
|
|
|
614
614
|
const fallbackChain = (_a = LANG_FALLBACK_MAP[langCode]) != null ? _a : [langCode, "en"];
|
|
615
615
|
for (const code of fallbackChain) {
|
|
616
616
|
const val = map[code];
|
|
617
|
-
if (
|
|
617
|
+
if (typeof val === "string") return val;
|
|
618
618
|
}
|
|
619
|
-
return Object.values(map).find((v) => typeof v === "string"
|
|
619
|
+
return Object.values(map).find((v) => typeof v === "string");
|
|
620
620
|
}
|
|
621
621
|
function mergeI18nRuntimes(runtimes) {
|
|
622
622
|
const merged = {};
|
|
@@ -645,7 +645,7 @@ function resolveI18nRefs(config, i18nRecord, langCode) {
|
|
|
645
645
|
if (resolved !== void 0) {
|
|
646
646
|
config[key] = resolved;
|
|
647
647
|
} else {
|
|
648
|
-
console.warn(`[i18n] Missing translation for key "${i18nKey}" (lang: ${langCode}), using key name as fallback
|
|
648
|
+
console.warn(`[i18n] Missing translation for key "${i18nKey}" (lang: ${langCode}), using key name as fallback.`);
|
|
649
649
|
config[key] = i18nKey;
|
|
650
650
|
}
|
|
651
651
|
}
|
|
@@ -733,7 +733,7 @@ function toCursor(src, size) {
|
|
|
733
733
|
});
|
|
734
734
|
}
|
|
735
735
|
function enableCustomCursor(opts = {}) {
|
|
736
|
-
var _a, _b;
|
|
736
|
+
var _a, _b, _c;
|
|
737
737
|
cleanup == null ? void 0 : cleanup();
|
|
738
738
|
cleanup = null;
|
|
739
739
|
if (typeof document === "undefined") return () => {
|
|
@@ -761,10 +761,10 @@ function enableCustomCursor(opts = {}) {
|
|
|
761
761
|
if (cleanup === dispose) cleanup = null;
|
|
762
762
|
};
|
|
763
763
|
cleanup = dispose;
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
764
|
+
const hoverSrc = opts.hoverImage;
|
|
765
|
+
const pressSrc = (_c = opts.pressImage) != null ? _c : opts.hoverImage;
|
|
766
|
+
const cursorPromises = hoverSrc ? [toCursor(hoverSrc, size), pressSrc ? toCursor(pressSrc, size) : toCursor(hoverSrc, size)] : [toCursor(FINGER_HOVERING, size), toCursor(FINGER_PRESSING, size)];
|
|
767
|
+
Promise.all(cursorPromises).then(([hover, press]) => {
|
|
768
768
|
if (disposed) return;
|
|
769
769
|
target.style.cursor = hover;
|
|
770
770
|
down = () => {
|
|
@@ -1051,6 +1051,15 @@ function initSDK() {
|
|
|
1051
1051
|
destinationUrl = /android/i.test(navigator.userAgent) ? GOOGLE_PLAY_URL : APP_STORE_URL;
|
|
1052
1052
|
console.log("[SDK DEBUG] destinationUrl set to:", destinationUrl, "length:", destinationUrl.length);
|
|
1053
1053
|
ensureProtocol();
|
|
1054
|
+
document.addEventListener("visibilitychange", function lockScreenAudioHandler() {
|
|
1055
|
+
if (document.visibilityState === "hidden") {
|
|
1056
|
+
changeVolume(0);
|
|
1057
|
+
} else if (document.visibilityState === "visible") {
|
|
1058
|
+
if (!sdk.isPaused) {
|
|
1059
|
+
changeVolume(actualVolume);
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
});
|
|
1054
1063
|
if ("mraid" === AD_PROTOCOL && typeof mraid === "undefined") {
|
|
1055
1064
|
console.warn("[SDK] MRAID protocol detected but mraid.js not loaded, creating fallback mock (MRAID 2.0)");
|
|
1056
1065
|
window.mraid = {
|
|
@@ -1141,8 +1150,9 @@ var _sdk = class _sdk {
|
|
|
1141
1150
|
initTrackingProtocols();
|
|
1142
1151
|
document.readyState === "loading" ? window.addEventListener("DOMContentLoaded", initSDK) : initSDK();
|
|
1143
1152
|
isSDKInitialized = true;
|
|
1144
|
-
|
|
1145
|
-
|
|
1153
|
+
const customCursor = options == null ? void 0 : options.customCursor;
|
|
1154
|
+
if (customCursor !== false) {
|
|
1155
|
+
enableCustomCursor(typeof customCursor === "object" ? customCursor : void 0);
|
|
1146
1156
|
}
|
|
1147
1157
|
}
|
|
1148
1158
|
/**
|
|
@@ -1576,7 +1586,7 @@ var _sdk = class _sdk {
|
|
|
1576
1586
|
}
|
|
1577
1587
|
};
|
|
1578
1588
|
/** Current version of the SDK */
|
|
1579
|
-
_sdk.version = "1.0.
|
|
1589
|
+
_sdk.version = "1.0.20";
|
|
1580
1590
|
/** Current maximum width of the playable ad container in pixels */
|
|
1581
1591
|
_sdk.maxWidth = Math.floor(window.innerWidth);
|
|
1582
1592
|
/** Current maximum height of the playable ad container in pixels */
|
package/dist/iife/index.js
CHANGED
|
@@ -852,9 +852,9 @@
|
|
|
852
852
|
const fallbackChain = (_a = LANG_FALLBACK_MAP[langCode]) != null ? _a : [langCode, "en"];
|
|
853
853
|
for (const code of fallbackChain) {
|
|
854
854
|
const val = map[code];
|
|
855
|
-
if (
|
|
855
|
+
if (typeof val === "string") return val;
|
|
856
856
|
}
|
|
857
|
-
return Object.values(map).find((v) => typeof v === "string"
|
|
857
|
+
return Object.values(map).find((v) => typeof v === "string");
|
|
858
858
|
}
|
|
859
859
|
function mergeI18nRuntimes(runtimes) {
|
|
860
860
|
const merged = {};
|
|
@@ -883,7 +883,7 @@
|
|
|
883
883
|
if (resolved !== void 0) {
|
|
884
884
|
config[key] = resolved;
|
|
885
885
|
} else {
|
|
886
|
-
console.warn(`[i18n] Missing translation for key "${i18nKey}" (lang: ${langCode}), using key name as fallback
|
|
886
|
+
console.warn(`[i18n] Missing translation for key "${i18nKey}" (lang: ${langCode}), using key name as fallback.`);
|
|
887
887
|
config[key] = i18nKey;
|
|
888
888
|
}
|
|
889
889
|
}
|
|
@@ -971,7 +971,7 @@
|
|
|
971
971
|
});
|
|
972
972
|
}
|
|
973
973
|
function enableCustomCursor(opts = {}) {
|
|
974
|
-
var _a, _b;
|
|
974
|
+
var _a, _b, _c;
|
|
975
975
|
cleanup == null ? void 0 : cleanup();
|
|
976
976
|
cleanup = null;
|
|
977
977
|
if (typeof document === "undefined") return () => {
|
|
@@ -999,10 +999,10 @@
|
|
|
999
999
|
if (cleanup === dispose) cleanup = null;
|
|
1000
1000
|
};
|
|
1001
1001
|
cleanup = dispose;
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1002
|
+
const hoverSrc = opts.hoverImage;
|
|
1003
|
+
const pressSrc = (_c = opts.pressImage) != null ? _c : opts.hoverImage;
|
|
1004
|
+
const cursorPromises = hoverSrc ? [toCursor(hoverSrc, size), pressSrc ? toCursor(pressSrc, size) : toCursor(hoverSrc, size)] : [toCursor(FINGER_HOVERING, size), toCursor(FINGER_PRESSING, size)];
|
|
1005
|
+
Promise.all(cursorPromises).then(([hover, press]) => {
|
|
1006
1006
|
if (disposed) return;
|
|
1007
1007
|
target.style.cursor = hover;
|
|
1008
1008
|
down = () => {
|
|
@@ -1289,6 +1289,15 @@
|
|
|
1289
1289
|
destinationUrl = /android/i.test(navigator.userAgent) ? GOOGLE_PLAY_URL : APP_STORE_URL;
|
|
1290
1290
|
console.log("[SDK DEBUG] destinationUrl set to:", destinationUrl, "length:", destinationUrl.length);
|
|
1291
1291
|
ensureProtocol();
|
|
1292
|
+
document.addEventListener("visibilitychange", function lockScreenAudioHandler() {
|
|
1293
|
+
if (document.visibilityState === "hidden") {
|
|
1294
|
+
changeVolume(0);
|
|
1295
|
+
} else if (document.visibilityState === "visible") {
|
|
1296
|
+
if (!sdk.isPaused) {
|
|
1297
|
+
changeVolume(actualVolume);
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
});
|
|
1292
1301
|
if ("mraid" === AD_PROTOCOL && typeof mraid === "undefined") {
|
|
1293
1302
|
console.warn("[SDK] MRAID protocol detected but mraid.js not loaded, creating fallback mock (MRAID 2.0)");
|
|
1294
1303
|
window.mraid = {
|
|
@@ -1379,8 +1388,9 @@
|
|
|
1379
1388
|
initTrackingProtocols();
|
|
1380
1389
|
document.readyState === "loading" ? window.addEventListener("DOMContentLoaded", initSDK) : initSDK();
|
|
1381
1390
|
isSDKInitialized = true;
|
|
1382
|
-
|
|
1383
|
-
|
|
1391
|
+
const customCursor = options == null ? void 0 : options.customCursor;
|
|
1392
|
+
if (customCursor !== false) {
|
|
1393
|
+
enableCustomCursor(typeof customCursor === "object" ? customCursor : void 0);
|
|
1384
1394
|
}
|
|
1385
1395
|
}
|
|
1386
1396
|
/**
|
|
@@ -1814,7 +1824,7 @@
|
|
|
1814
1824
|
}
|
|
1815
1825
|
};
|
|
1816
1826
|
/** Current version of the SDK */
|
|
1817
|
-
_sdk.version = "1.0.
|
|
1827
|
+
_sdk.version = "1.0.20";
|
|
1818
1828
|
/** Current maximum width of the playable ad container in pixels */
|
|
1819
1829
|
_sdk.maxWidth = Math.floor(window.innerWidth);
|
|
1820
1830
|
/** Current maximum height of the playable ad container in pixels */
|
package/dist/index.d.mts
CHANGED
|
@@ -28,6 +28,17 @@ interface CursorOptions {
|
|
|
28
28
|
target?: HTMLElement;
|
|
29
29
|
/** 光标尺寸(像素),默认 64。热点固定为 size 的 1/8 */
|
|
30
30
|
size?: number;
|
|
31
|
+
/**
|
|
32
|
+
* 自定义鼠标悬浮态图片(URL 或 dataURL)。
|
|
33
|
+
* 传入后覆盖内置的手指图标。
|
|
34
|
+
*/
|
|
35
|
+
hoverImage?: string;
|
|
36
|
+
/**
|
|
37
|
+
* 自定义鼠标按压态图片(URL 或 dataURL)。
|
|
38
|
+
* 仅当同时传了 hoverImage 时生效。
|
|
39
|
+
* 未传时按压态复用 hoverImage,无状态切换效果。
|
|
40
|
+
*/
|
|
41
|
+
pressImage?: string;
|
|
31
42
|
}
|
|
32
43
|
/**
|
|
33
44
|
* 启用自定义鼠标指针。默认挂载到 `document.body`,作用于整个页面。
|
|
@@ -87,7 +98,7 @@ declare class sdk {
|
|
|
87
98
|
* @fires playcraftReady When game instance is created and ready to load resources
|
|
88
99
|
*/
|
|
89
100
|
static playcraftInit(callback?: InitCallbackType, options?: {
|
|
90
|
-
|
|
101
|
+
customCursor?: boolean | CursorOptions;
|
|
91
102
|
}): void;
|
|
92
103
|
/**
|
|
93
104
|
* Starts the playable ad experience.
|
package/dist/index.d.ts
CHANGED
|
@@ -28,6 +28,17 @@ interface CursorOptions {
|
|
|
28
28
|
target?: HTMLElement;
|
|
29
29
|
/** 光标尺寸(像素),默认 64。热点固定为 size 的 1/8 */
|
|
30
30
|
size?: number;
|
|
31
|
+
/**
|
|
32
|
+
* 自定义鼠标悬浮态图片(URL 或 dataURL)。
|
|
33
|
+
* 传入后覆盖内置的手指图标。
|
|
34
|
+
*/
|
|
35
|
+
hoverImage?: string;
|
|
36
|
+
/**
|
|
37
|
+
* 自定义鼠标按压态图片(URL 或 dataURL)。
|
|
38
|
+
* 仅当同时传了 hoverImage 时生效。
|
|
39
|
+
* 未传时按压态复用 hoverImage,无状态切换效果。
|
|
40
|
+
*/
|
|
41
|
+
pressImage?: string;
|
|
31
42
|
}
|
|
32
43
|
/**
|
|
33
44
|
* 启用自定义鼠标指针。默认挂载到 `document.body`,作用于整个页面。
|
|
@@ -87,7 +98,7 @@ declare class sdk {
|
|
|
87
98
|
* @fires playcraftReady When game instance is created and ready to load resources
|
|
88
99
|
*/
|
|
89
100
|
static playcraftInit(callback?: InitCallbackType, options?: {
|
|
90
|
-
|
|
101
|
+
customCursor?: boolean | CursorOptions;
|
|
91
102
|
}): void;
|
|
92
103
|
/**
|
|
93
104
|
* Starts the playable ad experience.
|
package/dist/index.js
CHANGED
|
@@ -644,9 +644,9 @@ function lookupI18nRuntime(runtime, key, langCode) {
|
|
|
644
644
|
const fallbackChain = (_a = LANG_FALLBACK_MAP[langCode]) != null ? _a : [langCode, "en"];
|
|
645
645
|
for (const code of fallbackChain) {
|
|
646
646
|
const val = map[code];
|
|
647
|
-
if (
|
|
647
|
+
if (typeof val === "string") return val;
|
|
648
648
|
}
|
|
649
|
-
return Object.values(map).find((v) => typeof v === "string"
|
|
649
|
+
return Object.values(map).find((v) => typeof v === "string");
|
|
650
650
|
}
|
|
651
651
|
function mergeI18nRuntimes(runtimes) {
|
|
652
652
|
const merged = {};
|
|
@@ -675,7 +675,7 @@ function resolveI18nRefs(config, i18nRecord, langCode) {
|
|
|
675
675
|
if (resolved !== void 0) {
|
|
676
676
|
config[key] = resolved;
|
|
677
677
|
} else {
|
|
678
|
-
console.warn(`[i18n] Missing translation for key "${i18nKey}" (lang: ${langCode}), using key name as fallback
|
|
678
|
+
console.warn(`[i18n] Missing translation for key "${i18nKey}" (lang: ${langCode}), using key name as fallback.`);
|
|
679
679
|
config[key] = i18nKey;
|
|
680
680
|
}
|
|
681
681
|
}
|
|
@@ -763,7 +763,7 @@ function toCursor(src, size) {
|
|
|
763
763
|
});
|
|
764
764
|
}
|
|
765
765
|
function enableCustomCursor(opts = {}) {
|
|
766
|
-
var _a, _b;
|
|
766
|
+
var _a, _b, _c;
|
|
767
767
|
cleanup == null ? void 0 : cleanup();
|
|
768
768
|
cleanup = null;
|
|
769
769
|
if (typeof document === "undefined") return () => {
|
|
@@ -791,10 +791,10 @@ function enableCustomCursor(opts = {}) {
|
|
|
791
791
|
if (cleanup === dispose) cleanup = null;
|
|
792
792
|
};
|
|
793
793
|
cleanup = dispose;
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
794
|
+
const hoverSrc = opts.hoverImage;
|
|
795
|
+
const pressSrc = (_c = opts.pressImage) != null ? _c : opts.hoverImage;
|
|
796
|
+
const cursorPromises = hoverSrc ? [toCursor(hoverSrc, size), pressSrc ? toCursor(pressSrc, size) : toCursor(hoverSrc, size)] : [toCursor(FINGER_HOVERING, size), toCursor(FINGER_PRESSING, size)];
|
|
797
|
+
Promise.all(cursorPromises).then(([hover, press]) => {
|
|
798
798
|
if (disposed) return;
|
|
799
799
|
target.style.cursor = hover;
|
|
800
800
|
down = () => {
|
|
@@ -1081,6 +1081,15 @@ function initSDK() {
|
|
|
1081
1081
|
destinationUrl = /android/i.test(navigator.userAgent) ? GOOGLE_PLAY_URL : APP_STORE_URL;
|
|
1082
1082
|
console.log("[SDK DEBUG] destinationUrl set to:", destinationUrl, "length:", destinationUrl.length);
|
|
1083
1083
|
ensureProtocol();
|
|
1084
|
+
document.addEventListener("visibilitychange", function lockScreenAudioHandler() {
|
|
1085
|
+
if (document.visibilityState === "hidden") {
|
|
1086
|
+
changeVolume(0);
|
|
1087
|
+
} else if (document.visibilityState === "visible") {
|
|
1088
|
+
if (!sdk.isPaused) {
|
|
1089
|
+
changeVolume(actualVolume);
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
});
|
|
1084
1093
|
if ("mraid" === AD_PROTOCOL && typeof mraid === "undefined") {
|
|
1085
1094
|
console.warn("[SDK] MRAID protocol detected but mraid.js not loaded, creating fallback mock (MRAID 2.0)");
|
|
1086
1095
|
window.mraid = {
|
|
@@ -1171,8 +1180,9 @@ var _sdk = class _sdk {
|
|
|
1171
1180
|
initTrackingProtocols();
|
|
1172
1181
|
document.readyState === "loading" ? window.addEventListener("DOMContentLoaded", initSDK) : initSDK();
|
|
1173
1182
|
isSDKInitialized = true;
|
|
1174
|
-
|
|
1175
|
-
|
|
1183
|
+
const customCursor = options == null ? void 0 : options.customCursor;
|
|
1184
|
+
if (customCursor !== false) {
|
|
1185
|
+
enableCustomCursor(typeof customCursor === "object" ? customCursor : void 0);
|
|
1176
1186
|
}
|
|
1177
1187
|
}
|
|
1178
1188
|
/**
|
|
@@ -1606,7 +1616,7 @@ var _sdk = class _sdk {
|
|
|
1606
1616
|
}
|
|
1607
1617
|
};
|
|
1608
1618
|
/** Current version of the SDK */
|
|
1609
|
-
_sdk.version = "1.0.
|
|
1619
|
+
_sdk.version = "1.0.20";
|
|
1610
1620
|
/** Current maximum width of the playable ad container in pixels */
|
|
1611
1621
|
_sdk.maxWidth = Math.floor(window.innerWidth);
|
|
1612
1622
|
/** Current maximum height of the playable ad container in pixels */
|
package/package.json
CHANGED
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@playcraft/adsdk",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "统一的 Playable SDK,支持 MRAID、Google、Facebook、Vungle、BigoAds 等多广告渠道",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"module": "dist/esm/index.js",
|
|
7
|
-
"types": "dist/index.d.ts",
|
|
8
|
-
"repository": {
|
|
9
|
-
"type": "git"
|
|
10
|
-
},
|
|
11
|
-
"files": [
|
|
12
|
-
"dist",
|
|
13
|
-
"LICENSE",
|
|
14
|
-
"defines.d.ts"
|
|
15
|
-
],
|
|
16
|
-
"scripts": {
|
|
17
|
-
"build": "npx tsup",
|
|
18
|
-
"test": "jest",
|
|
19
|
-
"deploy": "npm run build && node scripts/publish.js",
|
|
20
|
-
"deploy:beta": "npm run build && node scripts/publish.js --tag beta"
|
|
21
|
-
},
|
|
22
|
-
"author": "Tencent ADS Team",
|
|
23
|
-
"license": "MIT",
|
|
24
|
-
"devDependencies": {
|
|
25
|
-
"@types/jest": "^29.5.14",
|
|
26
|
-
"jest": "^29.7.0",
|
|
27
|
-
"jest-environment-jsdom": "^29.7.0",
|
|
28
|
-
"ts-jest": "^29.2.5",
|
|
29
|
-
"tsup": "^8.4.0",
|
|
30
|
-
"typescript": "^5.7.2"
|
|
31
|
-
},
|
|
32
|
-
"keywords": [
|
|
33
|
-
"playable",
|
|
34
|
-
"sdk",
|
|
35
|
-
"playable-sdk",
|
|
36
|
-
"PlayableSDK",
|
|
37
|
-
"playable-ads",
|
|
38
|
-
"html5",
|
|
39
|
-
"tencent",
|
|
40
|
-
"bigoads",
|
|
41
|
-
"mraid",
|
|
42
|
-
"google-ads",
|
|
43
|
-
"facebook-playable",
|
|
44
|
-
"unity-ads",
|
|
45
|
-
"vungle",
|
|
46
|
-
"ironsource",
|
|
47
|
-
"javascript-sdk",
|
|
48
|
-
"typescript-sdk"
|
|
49
|
-
],
|
|
50
|
-
"publishConfig": {
|
|
51
|
-
"registry": "https://mirrors.tencent.com/npm/"
|
|
52
|
-
},
|
|
53
|
-
"dependencies": {
|
|
54
|
-
"@playcraft/ads-tracking": "*"
|
|
55
|
-
}
|
|
56
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@playcraft/adsdk",
|
|
3
|
+
"version": "1.0.20",
|
|
4
|
+
"description": "统一的 Playable SDK,支持 MRAID、Google、Facebook、Vungle、BigoAds 等多广告渠道",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/esm/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"LICENSE",
|
|
14
|
+
"defines.d.ts"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "npx tsup",
|
|
18
|
+
"test": "jest",
|
|
19
|
+
"deploy": "npm run build && node scripts/publish.js",
|
|
20
|
+
"deploy:beta": "npm run build && node scripts/publish.js --tag beta"
|
|
21
|
+
},
|
|
22
|
+
"author": "Tencent ADS Team",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@types/jest": "^29.5.14",
|
|
26
|
+
"jest": "^29.7.0",
|
|
27
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
28
|
+
"ts-jest": "^29.2.5",
|
|
29
|
+
"tsup": "^8.4.0",
|
|
30
|
+
"typescript": "^5.7.2"
|
|
31
|
+
},
|
|
32
|
+
"keywords": [
|
|
33
|
+
"playable",
|
|
34
|
+
"sdk",
|
|
35
|
+
"playable-sdk",
|
|
36
|
+
"PlayableSDK",
|
|
37
|
+
"playable-ads",
|
|
38
|
+
"html5",
|
|
39
|
+
"tencent",
|
|
40
|
+
"bigoads",
|
|
41
|
+
"mraid",
|
|
42
|
+
"google-ads",
|
|
43
|
+
"facebook-playable",
|
|
44
|
+
"unity-ads",
|
|
45
|
+
"vungle",
|
|
46
|
+
"ironsource",
|
|
47
|
+
"javascript-sdk",
|
|
48
|
+
"typescript-sdk"
|
|
49
|
+
],
|
|
50
|
+
"publishConfig": {
|
|
51
|
+
"registry": "https://mirrors.tencent.com/npm/"
|
|
52
|
+
},
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"@playcraft/ads-tracking": "*"
|
|
55
|
+
}
|
|
56
|
+
}
|